From 2a0fbca1e00cbbe3c426cb13c0fb5515184ee4d1 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Fri, 11 Sep 2015 08:23:13 +0200 Subject: [PATCH] Baujahr written into Oracle database --- .../BenchControl/DB/SensusOracle/Database.cs | 13 ++++-- .../DB/SensusOracle/DatabaseCfg.cs | 5 ++- .../DB/SensusOracle/DatabaseCfgCtrl.cs | 29 ++++++++++--- .../SensusOracle/DatabaseCfgCtrl.designer.cs | 41 +++++++++++++++---- 4 files changed, 69 insertions(+), 19 deletions(-) diff --git a/TestBenchFramework/BenchControl/DB/SensusOracle/Database.cs b/TestBenchFramework/BenchControl/DB/SensusOracle/Database.cs index 0f83e7016..286db2814 100644 --- a/TestBenchFramework/BenchControl/DB/SensusOracle/Database.cs +++ b/TestBenchFramework/BenchControl/DB/SensusOracle/Database.cs @@ -1,6 +1,5 @@ /// /// Copyright (c) 2015 Sensus Metering Systems -/// Author: Milan Hanajík /// using System; using System.Collections.Generic; @@ -393,13 +392,17 @@ namespace TBF.BenchControl.DB.SensusOracle OracleParameter parm9 = new OracleParameter(); parm9.OracleDbType = OracleDbType.Int32; - parm9.Value = 4; /// = ANBID Stara Tura + parm9.Value = 4; /// = ANBID Stara Tura + + OracleParameter parm10 = new OracleParameter(); + parm9.OracleDbType = OracleDbType.Int32; + parm9.Value = dbCfg.Baujahr; if (MAX_Pruefindex % 100 == 1) { OracleCommand cmd = new OracleCommand(); cmd.Connection = conn; - cmd.CommandText = "INSERT INTO VT_ZAEHLER_PD(Auftragsnummer, VT_Identnummer, VT_Fernum, Max_Pruefindex, Zaehlernummer, Sekundaere_Adr, Hydr_Pruefung, ID_Benutzer, ANBID) VALUES (:1, :2, :3, :4, :5, :6, :7, :8, :9)"; + cmd.CommandText = "INSERT INTO VT_ZAEHLER_PD(Auftragsnummer, VT_Identnummer, VT_Fernum, Max_Pruefindex, Zaehlernummer, Sekundaere_Adr, Hydr_Pruefung, ID_Benutzer, ANBID, Baujahr) VALUES (:1, :2, :3, :4, :5, :6, :7, :8, :9, :10)"; cmd.Parameters.Add(parm1); cmd.Parameters.Add(parm2); cmd.Parameters.Add(parm3); @@ -409,6 +412,7 @@ namespace TBF.BenchControl.DB.SensusOracle cmd.Parameters.Add(parm7); cmd.Parameters.Add(parm8); cmd.Parameters.Add(parm9); + cmd.Parameters.Add(parm10); int rowsUpdated = cmd.ExecuteNonQuery(); } else @@ -432,7 +436,7 @@ namespace TBF.BenchControl.DB.SensusOracle { OracleCommand cmd = new OracleCommand(); cmd.Connection = conn; - cmd.CommandText = "UPDATE VT_ZAEHLER_PD SET Auftragsnummer = :1, VT_Identnummer = :2, Max_Pruefindex = :4, Zaehlernummer = :5, Sekundaere_Adr= :6, Hydr_Pruefung= :7, ID_Benutzer= :8 WHERE VT_Fernum = :3 and ANBID = :9"; + cmd.CommandText = "UPDATE VT_ZAEHLER_PD SET Auftragsnummer = :1, VT_Identnummer = :2, Max_Pruefindex = :4, Zaehlernummer = :5, Sekundaere_Adr= :6, Hydr_Pruefung= :7, ID_Benutzer= :8, Baujahr= :10 WHERE VT_Fernum = :3 and ANBID = :9"; cmd.Parameters.Add(parm1); cmd.Parameters.Add(parm2); cmd.Parameters.Add(parm3); @@ -442,6 +446,7 @@ namespace TBF.BenchControl.DB.SensusOracle cmd.Parameters.Add(parm7); cmd.Parameters.Add(parm8); cmd.Parameters.Add(parm9); + cmd.Parameters.Add(parm10); int rowsUpdated = cmd.ExecuteNonQuery(); diff --git a/TestBenchFramework/BenchControl/DB/SensusOracle/DatabaseCfg.cs b/TestBenchFramework/BenchControl/DB/SensusOracle/DatabaseCfg.cs index 597a87b3a..266e1c878 100644 --- a/TestBenchFramework/BenchControl/DB/SensusOracle/DatabaseCfg.cs +++ b/TestBenchFramework/BenchControl/DB/SensusOracle/DatabaseCfg.cs @@ -36,6 +36,7 @@ namespace TBF.BenchControl.DB.SensusOracle public int TestBenchId; public DBUsed DBUsed; + public int Baujahr; /// Written to the database public string DestinationPath; /// Directory path into which the results will be saved public bool YearFolders; public bool MonthFolders; @@ -51,6 +52,7 @@ namespace TBF.BenchControl.DB.SensusOracle ParentName = string.Empty; TestBenchId = 1; DBUsed = DBUsed.Test; + Baujahr = 2015; DestinationPath = Program.HomeDir + "Results\\"; YearFolders = true; MonthFolders = true; @@ -67,10 +69,11 @@ namespace TBF.BenchControl.DB.SensusOracle public string ToString(int i) { - return string.Format("Name={0}, BenchId={1}, DBUsed={2}, Path={3}, Y={4}, M={5}, D={6}, Elim.Spaces={7}, Separator={8}", + return string.Format("Name={0}, BenchId={1}, DBUsed={2}, Baujahr={3}, Path={4}, Y={5}, M={6}, D={7}, Elim.Spaces={8}, Separator={9}", Name, TestBenchId, DBUsed, + Baujahr, DestinationPath, YearFolders, MonthFolders, diff --git a/TestBenchFramework/BenchControl/DB/SensusOracle/DatabaseCfgCtrl.cs b/TestBenchFramework/BenchControl/DB/SensusOracle/DatabaseCfgCtrl.cs index 299bf1994..e8fa98453 100644 --- a/TestBenchFramework/BenchControl/DB/SensusOracle/DatabaseCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/DB/SensusOracle/DatabaseCfgCtrl.cs @@ -55,6 +55,7 @@ namespace TBF.BenchControl.DB.SensusOracle nameTextBox.Text = config.Name; benchIdTextBox.Text = config.TestBenchId.ToString(); dbUsedComboBox.Text = config.DBUsed.ToString(); + baujahrTextBox.Text = config.Baujahr.ToString(); destinationTextBox.Text = config.DestinationPath; yearFoldersCheckBox.Checked = config.YearFolders; monthFoldersCheckBox.Checked = config.MonthFolders; @@ -68,6 +69,7 @@ namespace TBF.BenchControl.DB.SensusOracle nameTextBox.Enabled = true; benchIdTextBox.Enabled = true; dbUsedComboBox.Enabled = true; + baujahrTextBox.Enabled = true; destinationTextBox.Enabled = true; destinationButton.Enabled = true; yearFoldersCheckBox.Enabled = true; @@ -81,13 +83,19 @@ namespace TBF.BenchControl.DB.SensusOracle { CfgUpdateFlags flags = CfgUpdateFlags.None; - int benchId; - if (!int.TryParse(benchIdTextBox.Text, out benchId) || benchId <= 0) + int tmp; + if (!int.TryParse(benchIdTextBox.Text, out tmp) || tmp <= 0) { flags |= CfgUpdateFlags.Error; message += Environment.NewLine + "Invalid 'Test bench ID'"; } + if (!int.TryParse(baujahrTextBox.Text, out tmp) || tmp < 2015 || tmp > 2099) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "Invalid 'Bujahr'"; + } + if (!dbUsedComboBox.Items.Contains(dbUsedComboBox.Text)) { flags |= CfgUpdateFlags.Error; @@ -108,15 +116,26 @@ namespace TBF.BenchControl.DB.SensusOracle if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed - if (config.Name != nameTextBox.Text) { config.Name = nameTextBox.Text; flags = CfgUpdateFlags.RestartRqrd; } + if (config.Name != nameTextBox.Text) + { + config.Name = nameTextBox.Text; + flags = CfgUpdateFlags.RestartRqrd; + } - int benchId; - if (int.TryParse(benchIdTextBox.Text, out benchId) && (benchId > 0) && (config.TestBenchId != benchId)) + int benchId = int.Parse(benchIdTextBox.Text); + if (config.TestBenchId != benchId) { config.TestBenchId = benchId; flags = CfgUpdateFlags.RestartRqrd; } + int baujahr = int.Parse(baujahrTextBox.Text); + if (config.Baujahr != baujahr) + { + config.Baujahr = baujahr; + flags = CfgUpdateFlags.RestartRqrd; + } + for (int i = 0; i < (int)DBUsed.Count; i++) { if (((DBUsed)i).ToString().Equals(dbUsedComboBox.Text) && (config.DBUsed != (DBUsed)i)) diff --git a/TestBenchFramework/BenchControl/DB/SensusOracle/DatabaseCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/DB/SensusOracle/DatabaseCfgCtrl.designer.cs index d081012ee..cec851ae6 100644 --- a/TestBenchFramework/BenchControl/DB/SensusOracle/DatabaseCfgCtrl.designer.cs +++ b/TestBenchFramework/BenchControl/DB/SensusOracle/DatabaseCfgCtrl.designer.cs @@ -48,6 +48,8 @@ namespace TBF.BenchControl.DB.SensusOracle this.benchIdLabel = new System.Windows.Forms.Label(); this.dbUsedComboBox = new System.Windows.Forms.ComboBox(); this.dbUsedLabel = new System.Windows.Forms.Label(); + this.baujahrTextBox = new System.Windows.Forms.TextBox(); + this.baujahrLabel = new System.Windows.Forms.Label(); this.SuspendLayout(); // // nameTextBox @@ -82,7 +84,7 @@ namespace TBF.BenchControl.DB.SensusOracle this.destinationTextBox.Location = new System.Drawing.Point(110, 131); this.destinationTextBox.Name = "destinationTextBox"; this.destinationTextBox.Size = new System.Drawing.Size(145, 20); - this.destinationTextBox.TabIndex = 8; + this.destinationTextBox.TabIndex = 10; // // destinationLabel // @@ -90,7 +92,7 @@ namespace TBF.BenchControl.DB.SensusOracle this.destinationLabel.Location = new System.Drawing.Point(19, 134); this.destinationLabel.Name = "destinationLabel"; this.destinationLabel.Size = new System.Drawing.Size(60, 13); - this.destinationLabel.TabIndex = 7; + this.destinationLabel.TabIndex = 9; this.destinationLabel.Text = "Destination"; // // dayFoldersCheckBox @@ -100,7 +102,7 @@ namespace TBF.BenchControl.DB.SensusOracle this.dayFoldersCheckBox.Location = new System.Drawing.Point(207, 157); this.dayFoldersCheckBox.Name = "dayFoldersCheckBox"; this.dayFoldersCheckBox.Size = new System.Drawing.Size(79, 17); - this.dayFoldersCheckBox.TabIndex = 12; + this.dayFoldersCheckBox.TabIndex = 14; this.dayFoldersCheckBox.Text = "Day folders"; this.dayFoldersCheckBox.UseVisualStyleBackColor = true; // @@ -110,7 +112,7 @@ namespace TBF.BenchControl.DB.SensusOracle this.destinationButton.Location = new System.Drawing.Point(261, 131); this.destinationButton.Name = "destinationButton"; this.destinationButton.Size = new System.Drawing.Size(30, 20); - this.destinationButton.TabIndex = 9; + this.destinationButton.TabIndex = 11; this.destinationButton.Text = "..."; this.destinationButton.UseVisualStyleBackColor = true; // @@ -121,7 +123,7 @@ namespace TBF.BenchControl.DB.SensusOracle this.yearFoldersCheckBox.Location = new System.Drawing.Point(23, 157); this.yearFoldersCheckBox.Name = "yearFoldersCheckBox"; this.yearFoldersCheckBox.Size = new System.Drawing.Size(82, 17); - this.yearFoldersCheckBox.TabIndex = 10; + this.yearFoldersCheckBox.TabIndex = 12; this.yearFoldersCheckBox.Text = "Year folders"; this.yearFoldersCheckBox.UseVisualStyleBackColor = true; // @@ -132,7 +134,7 @@ namespace TBF.BenchControl.DB.SensusOracle this.monthFoldersCheckBox.Location = new System.Drawing.Point(111, 157); this.monthFoldersCheckBox.Name = "monthFoldersCheckBox"; this.monthFoldersCheckBox.Size = new System.Drawing.Size(90, 17); - this.monthFoldersCheckBox.TabIndex = 11; + this.monthFoldersCheckBox.TabIndex = 13; this.monthFoldersCheckBox.Text = "Month folders"; this.monthFoldersCheckBox.UseVisualStyleBackColor = true; // @@ -143,7 +145,7 @@ namespace TBF.BenchControl.DB.SensusOracle this.eliminateSpacesCheckBox.Location = new System.Drawing.Point(111, 205); this.eliminateSpacesCheckBox.Name = "eliminateSpacesCheckBox"; this.eliminateSpacesCheckBox.Size = new System.Drawing.Size(165, 17); - this.eliminateSpacesCheckBox.TabIndex = 15; + this.eliminateSpacesCheckBox.TabIndex = 17; this.eliminateSpacesCheckBox.Text = "Eliminate spaces in each field"; this.eliminateSpacesCheckBox.UseVisualStyleBackColor = true; // @@ -153,7 +155,7 @@ namespace TBF.BenchControl.DB.SensusOracle this.separatorLabel.Location = new System.Drawing.Point(19, 182); this.separatorLabel.Name = "separatorLabel"; this.separatorLabel.Size = new System.Drawing.Size(53, 13); - this.separatorLabel.TabIndex = 13; + this.separatorLabel.TabIndex = 15; this.separatorLabel.Text = "Separator"; // // separatorComboBox @@ -163,7 +165,7 @@ namespace TBF.BenchControl.DB.SensusOracle this.separatorComboBox.Location = new System.Drawing.Point(110, 179); this.separatorComboBox.Name = "separatorComboBox"; this.separatorComboBox.Size = new System.Drawing.Size(146, 21); - this.separatorComboBox.TabIndex = 14; + this.separatorComboBox.TabIndex = 16; // // benchIdTextBox // @@ -200,10 +202,29 @@ namespace TBF.BenchControl.DB.SensusOracle this.dbUsedLabel.TabIndex = 5; this.dbUsedLabel.Text = "Database used"; // + // baujahrTextBox + // + this.baujahrTextBox.Enabled = false; + this.baujahrTextBox.Location = new System.Drawing.Point(110, 106); + this.baujahrTextBox.Name = "baujahrTextBox"; + this.baujahrTextBox.Size = new System.Drawing.Size(57, 20); + this.baujahrTextBox.TabIndex = 8; + // + // baujahrLabel + // + this.baujahrLabel.AutoSize = true; + this.baujahrLabel.Location = new System.Drawing.Point(19, 109); + this.baujahrLabel.Name = "baujahrLabel"; + this.baujahrLabel.Size = new System.Drawing.Size(43, 13); + this.baujahrLabel.TabIndex = 7; + this.baujahrLabel.Text = "Baujahr"; + // // DatabaseCfgCtrl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.baujahrTextBox); + this.Controls.Add(this.baujahrLabel); this.Controls.Add(this.dbUsedComboBox); this.Controls.Add(this.dbUsedLabel); this.Controls.Add(this.benchIdTextBox); @@ -246,5 +267,7 @@ namespace TBF.BenchControl.DB.SensusOracle private System.Windows.Forms.Label benchIdLabel; private System.Windows.Forms.ComboBox dbUsedComboBox; private System.Windows.Forms.Label dbUsedLabel; + private System.Windows.Forms.TextBox baujahrTextBox; + private System.Windows.Forms.Label baujahrLabel; } }