PrintOrder: Print only the last results, version = 1.3.18

This commit is contained in:
Milan Hanajik 2015-04-21 07:34:41 +02:00
parent d1987d968e
commit 7ff2a98ccf
5 changed files with 61 additions and 5 deletions

View File

@ -37,6 +37,7 @@ namespace TBF.Forms
this.cancelButton = new System.Windows.Forms.Button();
this.testerGroupBox = new System.Windows.Forms.GroupBox();
this.testerComboBox = new System.Windows.Forms.ComboBox();
this.printLastCheckBox = new System.Windows.Forms.CheckBox();
this.purchaseOrderGroupBox.SuspendLayout();
this.testerGroupBox.SuspendLayout();
this.SuspendLayout();
@ -61,7 +62,7 @@ namespace TBF.Forms
//
// printButton
//
this.printButton.Location = new System.Drawing.Point(106, 269);
this.printButton.Location = new System.Drawing.Point(106, 332);
this.printButton.Name = "printButton";
this.printButton.Size = new System.Drawing.Size(144, 64);
this.printButton.TabIndex = 2;
@ -71,7 +72,7 @@ namespace TBF.Forms
//
// cancelButton
//
this.cancelButton.Location = new System.Drawing.Point(342, 269);
this.cancelButton.Location = new System.Drawing.Point(342, 332);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(144, 64);
this.cancelButton.TabIndex = 3;
@ -97,11 +98,22 @@ namespace TBF.Forms
this.testerComboBox.Size = new System.Drawing.Size(380, 31);
this.testerComboBox.TabIndex = 0;
//
// printLastCheckBox
//
this.printLastCheckBox.AutoSize = true;
this.printLastCheckBox.Location = new System.Drawing.Point(105, 264);
this.printLastCheckBox.Name = "printLastCheckBox";
this.printLastCheckBox.Size = new System.Drawing.Size(335, 27);
this.printLastCheckBox.TabIndex = 5;
this.printLastCheckBox.Text = "Print only the last measurement";
this.printLastCheckBox.UseVisualStyleBackColor = true;
//
// PrintOrderForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 23F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(597, 380);
this.ClientSize = new System.Drawing.Size(597, 435);
this.Controls.Add(this.printLastCheckBox);
this.Controls.Add(this.testerGroupBox);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.printButton);
@ -118,6 +130,7 @@ namespace TBF.Forms
this.purchaseOrderGroupBox.ResumeLayout(false);
this.testerGroupBox.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
@ -129,5 +142,6 @@ namespace TBF.Forms
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.GroupBox testerGroupBox;
private System.Windows.Forms.ComboBox testerComboBox;
private System.Windows.Forms.CheckBox printLastCheckBox;
}
}

View File

@ -16,6 +16,7 @@ namespace TBF.Forms
{
public string PurchaseOrder;
public string Tester;
public bool PrintOnlyLastResult;
public PrintOrderForm()
{
@ -28,6 +29,8 @@ namespace TBF.Forms
Left = (ls.PrintOrderLeft != 0) ? ls.PrintOrderLeft : 200;
Top = (ls.PrintOrderTop != 0) ? ls.PrintOrderTop : 100;
printLastCheckBox.Checked = PrintOnlyLastResult = Program.LocalSettings.PrintOrderOnlyLastResult;
PrepareOrderCombo(purchaseOrderComboBox);
PrepareTesterCombo(testerComboBox);
}
@ -69,6 +72,8 @@ namespace TBF.Forms
PurchaseOrder = purchaseOrderComboBox.Text;
Tester = testerComboBox.Text;
Program.LocalSettings.PrintOrderOnlyLastResult = PrintOnlyLastResult = printLastCheckBox.Checked;
Program.LocalSettings.PrintOrderLeft = Location.X;
Program.LocalSettings.PrintOrderTop = Location.Y;
bool b1 = Program.LocalSettings.UpdateHistory(testerComboBox.Text,

View File

@ -152,6 +152,8 @@ namespace TBF
[XmlIgnore]
public int TesterHistoryCount { get { return (TesterHistory != null) ? TesterHistory.Length : 0; } }
public bool PrintOrderOnlyLastResult;
/// Configuration of results
public Forms.ResultsConfig.Meters ResultsConfigMeters;
public Forms.ResultsConfig.TestsAre ResultsConfigTests;

View File

@ -475,6 +475,41 @@ namespace TBF
return;
}
if (dlg.PrintOnlyLastResult)
{
/// Remove test results if there exist a later test results for the same sn
/// Proceed from the end of the list so that items can be removed by index
for (int i = testResults.Count - 1; i >= 0; i--)
{
string name = testResults[i].Name;
int batchNr = testResults[i].BatchNr;
foreach (var tr in testResults)
{
if (tr.Name == name && tr.BatchNr > batchNr)
{
bool allWMsAreTheSame = true;
int cnt = Math.Min(testResults[i].Meters.Count, tr.Meters.Count);
for (int j = 0; j < cnt; j++)
{
if (testResults[i].Meters[j].SerialNr != tr.Meters[j].SerialNr)
{
allWMsAreTheSame = false;
break;
}
}
if (allWMsAreTheSame)
{
/// Remove as there exists a more recent measurement with the same meters
testResults.RemoveAt(i);
break;
}
}
}
}
}
IList<Procedure> procedure = session
.CreateQuery("FROM Procedure WHERE Name = :procedureName")
.SetParameter("procedureName", testResults[0].ProcedureName)

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.3.17.1")]
[assembly: AssemblyFileVersion("1.3.17.1")]
[assembly: AssemblyVersion("1.3.18.1")]
[assembly: AssemblyFileVersion("1.3.18.1")]