From 7ff2a98ccfefaa78eb36f220092e9d8b61efdd05 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Tue, 21 Apr 2015 07:34:41 +0200 Subject: [PATCH] PrintOrder: Print only the last results, version = 1.3.18 --- .../Forms/PrintOrderForm.Designer.cs | 20 +++++++++-- TestBenchFramework/Forms/PrintOrderForm.cs | 5 +++ TestBenchFramework/LocalSettings.cs | 2 ++ TestBenchFramework/MainWnd.cs | 35 +++++++++++++++++++ TestBenchFramework/Properties/AssemblyInfo.cs | 4 +-- 5 files changed, 61 insertions(+), 5 deletions(-) diff --git a/TestBenchFramework/Forms/PrintOrderForm.Designer.cs b/TestBenchFramework/Forms/PrintOrderForm.Designer.cs index cf6e9518e..3cd83c374 100644 --- a/TestBenchFramework/Forms/PrintOrderForm.Designer.cs +++ b/TestBenchFramework/Forms/PrintOrderForm.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/TestBenchFramework/Forms/PrintOrderForm.cs b/TestBenchFramework/Forms/PrintOrderForm.cs index cb3bdc7e1..4581fb4c6 100644 --- a/TestBenchFramework/Forms/PrintOrderForm.cs +++ b/TestBenchFramework/Forms/PrintOrderForm.cs @@ -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, diff --git a/TestBenchFramework/LocalSettings.cs b/TestBenchFramework/LocalSettings.cs index d12010e1d..bcabcb373 100644 --- a/TestBenchFramework/LocalSettings.cs +++ b/TestBenchFramework/LocalSettings.cs @@ -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; diff --git a/TestBenchFramework/MainWnd.cs b/TestBenchFramework/MainWnd.cs index 2806754a3..ecf65330a 100644 --- a/TestBenchFramework/MainWnd.cs +++ b/TestBenchFramework/MainWnd.cs @@ -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 = session .CreateQuery("FROM Procedure WHERE Name = :procedureName") .SetParameter("procedureName", testResults[0].ProcedureName) diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 736fdf7b9..ea9860510 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -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")]