diff --git a/TestBenchFramework/BenchControl/DataEntry/Standard/CycleBeginningForm.cs b/TestBenchFramework/BenchControl/DataEntry/Standard/CycleBeginningForm.cs index 9795573c2..48078545f 100644 --- a/TestBenchFramework/BenchControl/DataEntry/Standard/CycleBeginningForm.cs +++ b/TestBenchFramework/BenchControl/DataEntry/Standard/CycleBeginningForm.cs @@ -90,7 +90,12 @@ namespace TBF.BenchControl.DataEntry.Standard private void okButton_Click(object sender, EventArgs e) { PurchaseOrder = orderComboBox.Text; - Program.LocalSettings.UpdatePurchaseOrderHistory(orderComboBox.Text); + Program.LocalSettings.UpdateHistory(orderComboBox.Text, + ref Program.LocalSettings.PurchaseOrderHistory +#if FUZHOU150 || FUZHOU300 + , 20 +#endif + ); if (WaterMetersCount >= 1) { SNText[0] = textBox1.Text; Disabled[0] = !checkBox1.Checked; } if (WaterMetersCount >= 2) { SNText[1] = textBox2.Text; Disabled[1] = !checkBox2.Checked; } diff --git a/TestBenchFramework/Forms/PrintOrderForm.Designer.cs b/TestBenchFramework/Forms/PrintOrderForm.Designer.cs index 5f8e9d578..ce9990f8d 100644 --- a/TestBenchFramework/Forms/PrintOrderForm.Designer.cs +++ b/TestBenchFramework/Forms/PrintOrderForm.Designer.cs @@ -32,13 +32,16 @@ this.purchaseOrderGroupBox = new System.Windows.Forms.GroupBox(); this.printButton = new System.Windows.Forms.Button(); this.cancelButton = new System.Windows.Forms.Button(); + this.testerGroupBox = new System.Windows.Forms.GroupBox(); + this.testerComboBox = new System.Windows.Forms.ComboBox(); this.purchaseOrderGroupBox.SuspendLayout(); + this.testerGroupBox.SuspendLayout(); this.SuspendLayout(); // // purchaseOrderComboBox // this.purchaseOrderComboBox.FormattingEnabled = true; - this.purchaseOrderComboBox.Location = new System.Drawing.Point(47, 47); + this.purchaseOrderComboBox.Location = new System.Drawing.Point(47, 41); this.purchaseOrderComboBox.Name = "purchaseOrderComboBox"; this.purchaseOrderComboBox.Size = new System.Drawing.Size(380, 31); this.purchaseOrderComboBox.TabIndex = 0; @@ -48,14 +51,14 @@ this.purchaseOrderGroupBox.Controls.Add(this.purchaseOrderComboBox); this.purchaseOrderGroupBox.Location = new System.Drawing.Point(59, 38); this.purchaseOrderGroupBox.Name = "purchaseOrderGroupBox"; - this.purchaseOrderGroupBox.Size = new System.Drawing.Size(481, 114); + this.purchaseOrderGroupBox.Size = new System.Drawing.Size(481, 96); this.purchaseOrderGroupBox.TabIndex = 1; this.purchaseOrderGroupBox.TabStop = false; this.purchaseOrderGroupBox.Text = "Purchase order"; // // printButton // - this.printButton.Location = new System.Drawing.Point(106, 204); + this.printButton.Location = new System.Drawing.Point(106, 269); this.printButton.Name = "printButton"; this.printButton.Size = new System.Drawing.Size(144, 64); this.printButton.TabIndex = 2; @@ -65,7 +68,7 @@ // // cancelButton // - this.cancelButton.Location = new System.Drawing.Point(342, 204); + this.cancelButton.Location = new System.Drawing.Point(342, 269); this.cancelButton.Name = "cancelButton"; this.cancelButton.Size = new System.Drawing.Size(144, 64); this.cancelButton.TabIndex = 3; @@ -73,11 +76,30 @@ this.cancelButton.UseVisualStyleBackColor = true; this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); // + // testerGroupBox + // + this.testerGroupBox.Controls.Add(this.testerComboBox); + this.testerGroupBox.Location = new System.Drawing.Point(58, 142); + this.testerGroupBox.Name = "testerGroupBox"; + this.testerGroupBox.Size = new System.Drawing.Size(481, 96); + this.testerGroupBox.TabIndex = 4; + this.testerGroupBox.TabStop = false; + this.testerGroupBox.Text = "Tester"; + // + // testerComboBox + // + this.testerComboBox.FormattingEnabled = true; + this.testerComboBox.Location = new System.Drawing.Point(47, 41); + this.testerComboBox.Name = "testerComboBox"; + this.testerComboBox.Size = new System.Drawing.Size(380, 31); + this.testerComboBox.TabIndex = 0; + // // PrintOrderForm // this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 23F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(597, 323); + this.ClientSize = new System.Drawing.Size(597, 380); + this.Controls.Add(this.testerGroupBox); this.Controls.Add(this.cancelButton); this.Controls.Add(this.printButton); this.Controls.Add(this.purchaseOrderGroupBox); @@ -91,6 +113,7 @@ this.Text = "Print watermeter results"; this.Load += new System.EventHandler(this.PrintOrderForm_Load); this.purchaseOrderGroupBox.ResumeLayout(false); + this.testerGroupBox.ResumeLayout(false); this.ResumeLayout(false); } @@ -101,5 +124,7 @@ private System.Windows.Forms.GroupBox purchaseOrderGroupBox; private System.Windows.Forms.Button printButton; private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.GroupBox testerGroupBox; + private System.Windows.Forms.ComboBox testerComboBox; } } \ No newline at end of file diff --git a/TestBenchFramework/Forms/PrintOrderForm.cs b/TestBenchFramework/Forms/PrintOrderForm.cs index 483a892b3..44a48a2e0 100644 --- a/TestBenchFramework/Forms/PrintOrderForm.cs +++ b/TestBenchFramework/Forms/PrintOrderForm.cs @@ -12,6 +12,7 @@ namespace TBF.Forms public partial class PrintOrderForm : Form { public string PurchaseOrder; + public string Tester; public PrintOrderForm() { @@ -25,6 +26,7 @@ namespace TBF.Forms Top = (ls.PrintOrderTop != 0) ? ls.PrintOrderTop : 100; PrepareOrderCombo(purchaseOrderComboBox); + PrepareTesterCombo(testerComboBox); } /// @@ -37,20 +39,44 @@ namespace TBF.Forms { orderComboBox.Items.Add(Program.LocalSettings.PurchaseOrderHistory[i]); } - if (orderComboBox.Items.Count > 0) { orderComboBox.Text = orderComboBox.Items[0].ToString(); } } + /// + /// Load Purchase order combo box items from the LocalSettings PurchaseOrderHistory array + /// + /// Puchase order ComboBox + void PrepareTesterCombo(ComboBox testerComboBox) + { + for (int i = 0; i < Program.LocalSettings.TesterHistoryCount; i++) + { + testerComboBox.Items.Add(Program.LocalSettings.TesterHistory[i]); + } + if (testerComboBox.Items.Count > 0) + { + testerComboBox.Text = testerComboBox.Items[0].ToString(); + } + } + private void printButton_Click(object sender, EventArgs e) { PurchaseOrder = purchaseOrderComboBox.Text; + Tester = testerComboBox.Text; Program.LocalSettings.PrintOrderLeft = Location.X; Program.LocalSettings.PrintOrderTop = Location.Y; - if (!Program.LocalSettings.UpdatePurchaseOrderHistory(purchaseOrderComboBox.Text)) + bool b1 = Program.LocalSettings.UpdateHistory(testerComboBox.Text, + ref Program.LocalSettings.TesterHistory); + bool b2 = Program.LocalSettings.UpdateHistory(purchaseOrderComboBox.Text, + ref Program.LocalSettings.PurchaseOrderHistory +#if FUZHOU150 || FUZHOU300 + , 20 +#endif + ); + if (!b1 && !b2) { Program.LocalSettings.Save(); } @@ -62,6 +88,7 @@ namespace TBF.Forms private void cancelButton_Click(object sender, EventArgs e) { PurchaseOrder = string.Empty; + Tester = string.Empty; DialogResult = DialogResult.Cancel; Close(); } diff --git a/TestBenchFramework/LocalSettings.cs b/TestBenchFramework/LocalSettings.cs index ae34193fb..87707b0b7 100644 --- a/TestBenchFramework/LocalSettings.cs +++ b/TestBenchFramework/LocalSettings.cs @@ -144,6 +144,11 @@ namespace TBF [XmlIgnore] public int PurchaseOrderHistoryCount { get { return (PurchaseOrderHistory != null) ? PurchaseOrderHistory.Length : 0; } } + /// Tester history + public string[] TesterHistory; + [XmlIgnore] + public int TesterHistoryCount { get { return (TesterHistory != null) ? TesterHistory.Length : 0; } } + /// Configuration of results public Forms.ResultsConfig.Meters ResultsConfigMeters; public Forms.ResultsConfig.TestsAre ResultsConfigTests; @@ -218,47 +223,47 @@ namespace TBF } /// - /// Updates purchase order history + /// Updates history stored in a string array by a new latest string. /// - /// + /// Lste entered string /// true = updated and saved - public bool UpdatePurchaseOrderHistory(string lastPurchaseOrder) + public bool UpdateHistory(string lastStrValue, ref string[] history, int maxHistoryLen = 10) { - const int HistoryLen = 10; + if (string.IsNullOrEmpty(lastStrValue)) return false; - if (string.IsNullOrEmpty(lastPurchaseOrder)) return false; + int currentHistoryCount = (history != null) ? history.Length : 0; int match = -1; - for (int i = 0; i < PurchaseOrderHistoryCount; i++) + for (int i = 0; i < currentHistoryCount; i++) { - if (PurchaseOrderHistory[i] == lastPurchaseOrder) + if (history[i] == lastStrValue) { match = i; break; } } - if (match >= 0 || PurchaseOrderHistoryCount >= HistoryLen) + if (match >= 0 || currentHistoryCount >= maxHistoryLen) { /// History does not have to be (because of a match) or should not be extended (because of the lenght) if (match < 0) match = PurchaseOrderHistoryCount - 1; for (int j = match; j > 0; j--) { - PurchaseOrderHistory[j] = PurchaseOrderHistory[j - 1]; + history[j] = history[j - 1]; } - Program.LocalSettings.PurchaseOrderHistory[0] = lastPurchaseOrder; + history[0] = lastStrValue; } else { /// History wiil be extended, new item inserted at the beginning - string[] newHistory = new string[Program.LocalSettings.PurchaseOrderHistoryCount + 1]; - newHistory[0] = lastPurchaseOrder; - for (int j = 1; j <= PurchaseOrderHistoryCount; j++) + string[] newHistory = new string[currentHistoryCount + 1]; + newHistory[0] = lastStrValue; + for (int j = 1; j <= currentHistoryCount; j++) { - newHistory[j] = PurchaseOrderHistory[j - 1]; + newHistory[j] = history[j - 1]; } - PurchaseOrderHistory = newHistory; + history = newHistory; } Save(); return true; diff --git a/TestBenchFramework/MainWnd.cs b/TestBenchFramework/MainWnd.cs index 711e85ba3..cc459c0f8 100644 --- a/TestBenchFramework/MainWnd.cs +++ b/TestBenchFramework/MainWnd.cs @@ -457,6 +457,7 @@ namespace TBF if (dlg.ShowDialog() == DialogResult.OK) { string purchaseOrder = dlg.PurchaseOrder; + string tester = dlg.Tester; NHibernate.ISession session = FluentCommon.CreateSession(Database.Procedures); @@ -485,7 +486,7 @@ namespace TBF if ((testResults != null) && (testResults.Count != 0) && (testResults[0].MetersKind == Entities.MetersKind.Single)) { - new PrintOrderDocument(procedure[0], testResults).Print(); + new PrintOrderDocument(procedure[0], testResults, tester).Print(); } else if((testResults != null) && (testResults.Count != 0) && (testResults[0].MetersKind == Entities.MetersKind.Combined)) { diff --git a/TestBenchFramework/PrintOrderDocument.cs b/TestBenchFramework/PrintOrderDocument.cs index da5542641..d325fe5dd 100644 --- a/TestBenchFramework/PrintOrderDocument.cs +++ b/TestBenchFramework/PrintOrderDocument.cs @@ -12,13 +12,15 @@ namespace TBF const string FontFamilyName = "Arial"; //"Times New Roman"; const int SpacingOne = 18; - const int SpacingOneAndHalf = (3 * SpacingOne) / 2; - const int TitleX = 100; - const int TitleY = 180; /// Depends on the size of the header - const int HdrTop = 240; /// Depends on the size of the header - const int TableTopFirstPage = 390; - const int TableTopNextPage = 180; const int Padding = 10; + const int TitleX = 100; + const int TitleY = 160; /// Depends on the size of the header + int HdrTop = 220; /// Depends on the size of the header + int TableTopFirstPage = 390; + int TableTopNextPage = TitleY; + + + const int SpacingOneAndHalf = (3 * SpacingOne) / 2; /// @@ -33,6 +35,7 @@ namespace TBF /// readonly Entities.Procedure procedure; readonly IList allResults; + readonly string tester; readonly DateTime dateTime; readonly int batchMin; readonly int batchMax; @@ -69,10 +72,11 @@ namespace TBF /// /// Procedure belonging to the results /// Results to be printed (multiple batches) - public PrintOrderDocument(Entities.Procedure procedure, IList allResults) + public PrintOrderDocument(Entities.Procedure procedure, IList allResults, string tester) { this.procedure = procedure; this.allResults = allResults; + this.tester = tester; dateTime = DateTime.Now; @@ -195,18 +199,27 @@ namespace TBF ///--------------- if (pageNr == 1) { - RectangleF printArea = new RectangleF(TitleX, TitleY, 667, 40); - e.Graphics.DrawString(allResults[0].ProtocolTitle, titleFont, Brushes.Black, printArea); - + if (!string.IsNullOrEmpty(allResults[0].ProtocolTitle)) + { + RectangleF printArea = new RectangleF(TitleX, TitleY, 667, 40); + e.Graphics.DrawString(allResults[0].ProtocolTitle, titleFont, Brushes.Black, printArea); + } + else + { + TableTopFirstPage -= (HdrTop - TitleY); + HdrTop = TitleY; + } + string[] leftColumn = new string[] { - "Purchase order: ", - "Date and time: ", - "Procedure:", - Strings.User_, - "Ambient temperature: ", - "Ambient pressure: ", - "Ambient humidity: ", + Strings.Purchase_order_, + Strings.Date_and_time_, + Strings.Procedure_, + Strings.Tester_, + Strings.Approval_, + Strings.Ambient_temperature_, + Strings.Ambient_pressure_, + Strings.Ambient_humidity_, }; string[] rightColumn = new string[] @@ -219,7 +232,8 @@ namespace TBF dateTime.Hour.ToString("D2"), dateTime.Minute.ToString("D2")), procedure.Name, - Entities.User.CurrentUser.Name, + tester, + string.Empty, allResults[0].AmbientTempAve.ToString("F1") + " °C", allResults[0].AmbientPressAve.ToString("F0") + " mbar", allResults[0].AmbientHumiAve.ToString("F0") + " %", diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index ae80a3444..489954858 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -123,6 +123,42 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Ambient humidity: . + /// + internal static string Ambient_humidity_ { + get { + return ResourceManager.GetString("Ambient_humidity_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Ambient pressure: . + /// + internal static string Ambient_pressure_ { + get { + return ResourceManager.GetString("Ambient_pressure_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Ambient temperature: . + /// + internal static string Ambient_temperature_ { + get { + return ResourceManager.GetString("Ambient_temperature_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Approval: . + /// + internal static string Approval_ { + get { + return ResourceManager.GetString("Approval_", resourceCulture); + } + } + /// /// Looks up a localized string similar to Approval info.. /// @@ -474,6 +510,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Date and time: . + /// + internal static string Date_and_time_ { + get { + return ResourceManager.GetString("Date_and_time_", resourceCulture); + } + } + /// /// Looks up a localized string similar to The database was successfully created!. /// @@ -1545,6 +1590,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Procedure: . + /// + internal static string Procedure_ { + get { + return ResourceManager.GetString("Procedure_", resourceCulture); + } + } + /// /// Looks up a localized string similar to Procedures. /// @@ -1635,6 +1689,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Purchase order: . + /// + internal static string Purchase_order_ { + get { + return ResourceManager.GetString("Purchase_order_", resourceCulture); + } + } + /// /// Looks up a localized string similar to Fill the test bench with water?. /// @@ -2355,6 +2418,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Tester: . + /// + internal static string Tester_ { + get { + return ResourceManager.GetString("Tester_", resourceCulture); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index b262ab136..085b626e6 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -997,4 +997,28 @@ Purchase Order + + Ambient humidity: + + + Ambient pressure: + + + Ambient temperature: + + + Approval: + + + Date and time: + + + Procedure: + + + Purchase order: + + + Tester: + \ No newline at end of file