diff --git a/全自动水压检测仪/App.config b/全自动水压检测仪/App.config index 418f172..dfd15c7 100644 --- a/全自动水压检测仪/App.config +++ b/全自动水压检测仪/App.config @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/全自动水压检测仪/NormalTemperatureMode.cs b/全自动水压检测仪/NormalTemperatureMode.cs index 8b10544..6e82680 100644 --- a/全自动水压检测仪/NormalTemperatureMode.cs +++ b/全自动水压检测仪/NormalTemperatureMode.cs @@ -1095,6 +1095,84 @@ namespace 全自动水压检测仪 //_readTimerTwo?.Start(); } + //void BoolSignal1_OnRisingEdge() + //{ + // if (isAddTag) return; + + // // 使用SafeInvoke确保UI读取操作在UI线程执行 + // SafeInvoke(() => + // { + // uiTextBox3.Text = uiLabel14.Text;//初始压力 + // uiTextBox8.Text = uiTextBox5.Text;//保压时间 + // uiTextBox6.Text = uiLabel22.Text;//压差 + // uiTextBox7.Text = uiLabel19.Text;//结束压力 + + // // 获取联络单号和件号 + // string contactNumber = uiTextBox2.Text.Trim(); + // string itemNumber = uiTextBox10.Text.Trim(); + // // 组合条码用于兼容性 + // string barcode = $"{contactNumber}-{itemNumber}"; + + // CurrentReport.Add(new ConductivityTestData + // { + // barcode = barcode, + // //ContactNumber = contactNumber, + // //ItemNumber = itemNumber, + // CreateTime = DateTime.Now, + // diffpressure = uiTextBox6.Text.ToDouble(), + // dwelltime = uiTextBox8.Text.ToDouble(), + // temperature = uiTextBox4.Text.ToDouble(), + // endpressure = uiTextBox7.Text.ToDouble(), + // startpressure = uiTextBox3.Text.ToDouble(), + // Type = uiLight1.State == UILightState.On ? 1 : 0, + // //新增 + // kzh = kzh, + // jh = uiTextBox10.Text, + // endtime = DateTime.Now, + // quantity = quantity, + // lldh = uiTextBox2.Text, + // standarderror = standarderror, + // starttime = starttime, + // testresult = (isValid ?? false) ? "合格" : "不合格" + // }); + + // _repository.InsertReportItems(new ConductivityTestData + // { + // barcode = barcode, + + // CreateTime = DateTime.Now, + // diffpressure = uiTextBox6.Text.ToDouble(), + // dwelltime = uiTextBox8.Text.ToDouble(), + // temperature = uiTextBox4.Text.ToDouble(), + // endpressure = uiTextBox7.Text.ToDouble(), + // startpressure = uiTextBox3.Text.ToDouble(), + // Type = uiLight1.State == UILightState.On ? 1 : 0, + + + + // //新增 + // kzh = kzh, + // jh = uiTextBox10.Text, + // endtime = DateTime.Now, + // quantity = quantity, + // lldh = uiTextBox2.Text, + // standarderror = standarderror, + // starttime = starttime, + // testresult = (isValid ?? false) ? "合格" : "不合格" + + + + // }); + + // //uiTextBox2.Text = string.Empty; + // //uiTextBox10.Text = string.Empty; + // }); + + // isAddTag = true; + // _readTimetCompareResult?.Stop(); + //} + + void BoolSignal1_OnRisingEdge() { if (isAddTag) return; @@ -1113,59 +1191,61 @@ namespace 全自动水压检测仪 // 组合条码用于兼容性 string barcode = $"{contactNumber}-{itemNumber}"; - CurrentReport.Add(new ConductivityTestData + // 修复点:如果 starttime 未被正确初始化(默认值),在这里回退为当前时间 + if (starttime == default(DateTime)) + { + starttime = DateTime.Now; + Debug.WriteLine("[Warn] starttime 未初始化,已回退为当前时间:" + starttime.ToString("o")); + } + + // 统一使用局部变量,避免并发/多次调用导致不同时间写入 + DateTime recordStartTime = starttime; + DateTime recordEndTime = DateTime.Now; + DateTime recordCreateTime = DateTime.Now; + + var newItem = new ConductivityTestData { barcode = barcode, - //ContactNumber = contactNumber, - //ItemNumber = itemNumber, - CreateTime = DateTime.Now, + CreateTime = recordCreateTime, diffpressure = uiTextBox6.Text.ToDouble(), dwelltime = uiTextBox8.Text.ToDouble(), temperature = uiTextBox4.Text.ToDouble(), endpressure = uiTextBox7.Text.ToDouble(), startpressure = uiTextBox3.Text.ToDouble(), Type = uiLight1.State == UILightState.On ? 1 : 0, - //新增 + // 新增字段 kzh = kzh, jh = uiTextBox10.Text, - endtime = DateTime.Now, + endtime = recordEndTime, quantity = quantity, lldh = uiTextBox2.Text, standarderror = standarderror, - starttime = starttime, + starttime = recordStartTime, testresult = (isValid ?? false) ? "合格" : "不合格" - }); + }; + + CurrentReport.Add(newItem); _repository.InsertReportItems(new ConductivityTestData { - barcode = barcode, - - CreateTime = DateTime.Now, - diffpressure = uiTextBox6.Text.ToDouble(), - dwelltime = uiTextBox8.Text.ToDouble(), - temperature = uiTextBox4.Text.ToDouble(), - endpressure = uiTextBox7.Text.ToDouble(), - startpressure = uiTextBox3.Text.ToDouble(), - Type = uiLight1.State == UILightState.On ? 1 : 0, - - - - //新增 - kzh = kzh, - jh = uiTextBox10.Text, - endtime = DateTime.Now, - quantity = quantity, - lldh = uiTextBox2.Text, - standarderror = standarderror, - starttime = starttime, - testresult = (isValid ?? false) ? "合格" : "不合格" - - - + barcode = newItem.barcode, + CreateTime = newItem.CreateTime, + diffpressure = newItem.diffpressure, + dwelltime = newItem.dwelltime, + temperature = newItem.temperature, + endpressure = newItem.endpressure, + startpressure = newItem.startpressure, + Type = newItem.Type, + // 新增 + kzh = newItem.kzh, + jh = newItem.jh, + endtime = newItem.endtime, + quantity = newItem.quantity, + lldh = newItem.lldh, + standarderror = newItem.standarderror, + starttime = newItem.starttime, + testresult = newItem.testresult }); - - //uiTextBox2.Text = string.Empty; - //uiTextBox10.Text = string.Empty; }); isAddTag = true; diff --git a/全自动水压检测仪/ScanImport.Designer.cs b/全自动水压检测仪/ScanImport.Designer.cs index aebec5f..43de1f1 100644 --- a/全自动水压检测仪/ScanImport.Designer.cs +++ b/全自动水压检测仪/ScanImport.Designer.cs @@ -35,20 +35,6 @@ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.save = new Sunny.UI.UIButton(); this.uiDataGridView1 = new Sunny.UI.UIDataGridView(); - this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.SerialNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ColumnContactNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ColumnItemNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ColumnEngravingNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ColumnQuantity = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ColumnPressureDiff = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ColumnStandardError = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.uiTextBox2 = new Sunny.UI.UITextBox(); this.uiTextBox11 = new Sunny.UI.UITextBox(); this.uiTextBoxEngravingNumber = new Sunny.UI.UITextBox(); @@ -79,6 +65,20 @@ this.uiPanel2 = new Sunny.UI.UIPanel(); this.uiPanel1 = new Sunny.UI.UIPanel(); this.uiPanelTop = new Sunny.UI.UIPanel(); + this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SerialNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnContactNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnItemNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnEngravingNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnQuantity = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnPressureDiff = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnStandardError = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.uiDataGridView1)).BeginInit(); this.uiTableLayoutPanel1.SuspendLayout(); this.uiPanel3.SuspendLayout(); @@ -181,132 +181,6 @@ this.uiDataGridView1.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(this.uiDataGridView1_RowsAdded); this.uiDataGridView1.RowsRemoved += new System.Windows.Forms.DataGridViewRowsRemovedEventHandler(this.uiDataGridView1_RowsRemoved); // - // Column1 - // - this.Column1.DataPropertyName = "Id"; - this.Column1.HeaderText = "编号"; - this.Column1.MinimumWidth = 6; - this.Column1.Name = "Column1"; - this.Column1.ReadOnly = true; - this.Column1.Width = 75; - // - // SerialNumber - // - this.SerialNumber.HeaderText = "序号"; - this.SerialNumber.MinimumWidth = 8; - this.SerialNumber.Name = "SerialNumber"; - this.SerialNumber.ReadOnly = true; - this.SerialNumber.Width = 75; - // - // ColumnContactNumber - // - this.ColumnContactNumber.DataPropertyName = "lldh"; - this.ColumnContactNumber.HeaderText = "联络单号"; - this.ColumnContactNumber.MinimumWidth = 6; - this.ColumnContactNumber.Name = "ColumnContactNumber"; - this.ColumnContactNumber.ReadOnly = true; - this.ColumnContactNumber.Visible = false; - this.ColumnContactNumber.Width = 150; - // - // ColumnItemNumber - // - this.ColumnItemNumber.DataPropertyName = "jh"; - this.ColumnItemNumber.HeaderText = "件号"; - this.ColumnItemNumber.MinimumWidth = 6; - this.ColumnItemNumber.Name = "ColumnItemNumber"; - this.ColumnItemNumber.ReadOnly = true; - this.ColumnItemNumber.Width = 150; - // - // ColumnEngravingNumber - // - this.ColumnEngravingNumber.DataPropertyName = "kzh"; - this.ColumnEngravingNumber.HeaderText = "刻字号"; - this.ColumnEngravingNumber.MinimumWidth = 6; - this.ColumnEngravingNumber.Name = "ColumnEngravingNumber"; - this.ColumnEngravingNumber.ReadOnly = true; - this.ColumnEngravingNumber.Width = 120; - // - // ColumnQuantity - // - this.ColumnQuantity.DataPropertyName = "Quantity"; - this.ColumnQuantity.HeaderText = "数量"; - this.ColumnQuantity.MinimumWidth = 6; - this.ColumnQuantity.Name = "ColumnQuantity"; - this.ColumnQuantity.ReadOnly = true; - this.ColumnQuantity.Width = 80; - // - // Column3 - // - this.Column3.DataPropertyName = "diffpressure"; - this.Column3.HeaderText = "压力设置(PSI)"; - this.Column3.MinimumWidth = 6; - this.Column3.Name = "Column3"; - this.Column3.ReadOnly = true; - this.Column3.Width = 150; - // - // Column4 - // - this.Column4.DataPropertyName = "exit_temperature"; - this.Column4.HeaderText = "出口温度(℃)"; - this.Column4.MinimumWidth = 6; - this.Column4.Name = "Column4"; - this.Column4.ReadOnly = true; - this.Column4.Width = 110; - // - // Column7 - // - this.Column7.DataPropertyName = "temperature"; - this.Column7.HeaderText = "温度(℃)"; - this.Column7.MinimumWidth = 6; - this.Column7.Name = "Column7"; - this.Column7.ReadOnly = true; - this.Column7.Width = 150; - // - // Column5 - // - this.Column5.DataPropertyName = "dwelltime"; - this.Column5.HeaderText = "保压时间(h)"; - this.Column5.MinimumWidth = 6; - this.Column5.Name = "Column5"; - this.Column5.ReadOnly = true; - this.Column5.Width = 110; - // - // ColumnPressureDiff - // - this.ColumnPressureDiff.DataPropertyName = "pressuresetting"; - this.ColumnPressureDiff.HeaderText = "压差设置"; - this.ColumnPressureDiff.MinimumWidth = 6; - this.ColumnPressureDiff.Name = "ColumnPressureDiff"; - this.ColumnPressureDiff.ReadOnly = true; - this.ColumnPressureDiff.Width = 125; - // - // ColumnStandardError - // - this.ColumnStandardError.DataPropertyName = "standarderror"; - this.ColumnStandardError.HeaderText = "标准误差"; - this.ColumnStandardError.MinimumWidth = 6; - this.ColumnStandardError.Name = "ColumnStandardError"; - this.ColumnStandardError.ReadOnly = true; - this.ColumnStandardError.Width = 125; - // - // Column8 - // - this.Column8.DataPropertyName = "TemperatureMode"; - this.Column8.HeaderText = "温度模式"; - this.Column8.MinimumWidth = 8; - this.Column8.Name = "Column8"; - this.Column8.ReadOnly = true; - this.Column8.Width = 110; - // - // Column6 - // - this.Column6.DataPropertyName = "CreateTime"; - this.Column6.HeaderText = "录入时间"; - this.Column6.MinimumWidth = 6; - this.Column6.Name = "Column6"; - this.Column6.ReadOnly = true; - this.Column6.Width = 150; - // // uiTextBox2 // this.uiTextBox2.Cursor = System.Windows.Forms.Cursors.IBeam; @@ -779,6 +653,132 @@ this.uiPanelTop.Text = null; this.uiPanelTop.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; // + // Column1 + // + this.Column1.DataPropertyName = "Id"; + this.Column1.HeaderText = "编号"; + this.Column1.MinimumWidth = 6; + this.Column1.Name = "Column1"; + this.Column1.ReadOnly = true; + this.Column1.Width = 75; + // + // SerialNumber + // + this.SerialNumber.HeaderText = "序号"; + this.SerialNumber.MinimumWidth = 8; + this.SerialNumber.Name = "SerialNumber"; + this.SerialNumber.ReadOnly = true; + this.SerialNumber.Width = 75; + // + // ColumnContactNumber + // + this.ColumnContactNumber.DataPropertyName = "lldh"; + this.ColumnContactNumber.HeaderText = "联络单号"; + this.ColumnContactNumber.MinimumWidth = 6; + this.ColumnContactNumber.Name = "ColumnContactNumber"; + this.ColumnContactNumber.ReadOnly = true; + this.ColumnContactNumber.Visible = false; + this.ColumnContactNumber.Width = 150; + // + // ColumnItemNumber + // + this.ColumnItemNumber.DataPropertyName = "jh"; + this.ColumnItemNumber.HeaderText = "件号"; + this.ColumnItemNumber.MinimumWidth = 6; + this.ColumnItemNumber.Name = "ColumnItemNumber"; + this.ColumnItemNumber.ReadOnly = true; + this.ColumnItemNumber.Width = 150; + // + // ColumnEngravingNumber + // + this.ColumnEngravingNumber.DataPropertyName = "kzh"; + this.ColumnEngravingNumber.HeaderText = "刻字号"; + this.ColumnEngravingNumber.MinimumWidth = 6; + this.ColumnEngravingNumber.Name = "ColumnEngravingNumber"; + this.ColumnEngravingNumber.ReadOnly = true; + this.ColumnEngravingNumber.Width = 120; + // + // ColumnQuantity + // + this.ColumnQuantity.DataPropertyName = "Quantity"; + this.ColumnQuantity.HeaderText = "数量"; + this.ColumnQuantity.MinimumWidth = 6; + this.ColumnQuantity.Name = "ColumnQuantity"; + this.ColumnQuantity.ReadOnly = true; + this.ColumnQuantity.Width = 80; + // + // Column3 + // + this.Column3.DataPropertyName = "diffpressure"; + this.Column3.HeaderText = "压力设置(PSI)"; + this.Column3.MinimumWidth = 6; + this.Column3.Name = "Column3"; + this.Column3.ReadOnly = true; + this.Column3.Width = 150; + // + // Column4 + // + this.Column4.DataPropertyName = "exit_temperature"; + this.Column4.HeaderText = "出口温度(℃)"; + this.Column4.MinimumWidth = 6; + this.Column4.Name = "Column4"; + this.Column4.ReadOnly = true; + this.Column4.Width = 110; + // + // Column7 + // + this.Column7.DataPropertyName = "temperature"; + this.Column7.HeaderText = "温度(℃)"; + this.Column7.MinimumWidth = 6; + this.Column7.Name = "Column7"; + this.Column7.ReadOnly = true; + this.Column7.Width = 150; + // + // Column5 + // + this.Column5.DataPropertyName = "dwelltime"; + this.Column5.HeaderText = "保压时间(min)"; + this.Column5.MinimumWidth = 6; + this.Column5.Name = "Column5"; + this.Column5.ReadOnly = true; + this.Column5.Width = 110; + // + // ColumnPressureDiff + // + this.ColumnPressureDiff.DataPropertyName = "pressuresetting"; + this.ColumnPressureDiff.HeaderText = "压差设置"; + this.ColumnPressureDiff.MinimumWidth = 6; + this.ColumnPressureDiff.Name = "ColumnPressureDiff"; + this.ColumnPressureDiff.ReadOnly = true; + this.ColumnPressureDiff.Width = 125; + // + // ColumnStandardError + // + this.ColumnStandardError.DataPropertyName = "standarderror"; + this.ColumnStandardError.HeaderText = "标准误差"; + this.ColumnStandardError.MinimumWidth = 6; + this.ColumnStandardError.Name = "ColumnStandardError"; + this.ColumnStandardError.ReadOnly = true; + this.ColumnStandardError.Width = 125; + // + // Column8 + // + this.Column8.DataPropertyName = "TemperatureMode"; + this.Column8.HeaderText = "温度模式"; + this.Column8.MinimumWidth = 8; + this.Column8.Name = "Column8"; + this.Column8.ReadOnly = true; + this.Column8.Width = 110; + // + // Column6 + // + this.Column6.DataPropertyName = "CreateTime"; + this.Column6.HeaderText = "录入时间"; + this.Column6.MinimumWidth = 6; + this.Column6.Name = "Column6"; + this.Column6.ReadOnly = true; + this.Column6.Width = 150; + // // ScanImport // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;