diff --git a/BO/Utils/BillRpc/WeightBillRpc.cs b/BO/Utils/BillRpc/WeightBillRpc.cs index 0d5fa25..626f38e 100644 --- a/BO/Utils/BillRpc/WeightBillRpc.cs +++ b/BO/Utils/BillRpc/WeightBillRpc.cs @@ -141,10 +141,10 @@ namespace BO.Utils.BillRpc return RpcFacade.Call(method, id); } - public static List GetWeightBillList() + public static List GetWeightBillList(long? carID, long? supplierID) { const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/GetWeightBillList"; - var list = RpcFacade.Call>(method, DateTime.Today); + var list = RpcFacade.Call>(method, DateTime.Today, carID, supplierID); var result = new List(); foreach (var obj in list) { diff --git a/ButcherManageClient/Program.cs b/ButcherManageClient/Program.cs index d342bd3..306f178 100644 --- a/ButcherManageClient/Program.cs +++ b/ButcherManageClient/Program.cs @@ -40,7 +40,12 @@ namespace ButcherManageClient catch (Exception e) { // LogUtil.WriteError(e); +#if debug MessageBox.Show("错误:" + e.Message + " \n详细信息:" + e.StackTrace); +#endif +#if !debug + MessageBox.Show("错误:" + e.Message ); +#endif } } @@ -58,8 +63,12 @@ namespace ButcherManageClient //LogUtil.WriteError(ex); err = ex.Message; } + #if debug MessageBox.Show("错误:" + ex.Message + " \n详细信息:" + ex.StackTrace); - // MessageBox.Show("错误:" + err); +#endif + #if !debug + MessageBox.Show("错误:" + err); +#endif } private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) @@ -71,9 +80,12 @@ namespace ButcherManageClient //LogUtil.WriteError(ex); err = ex.Message; } - +#if debug MessageBox.Show("错误:" + ex.Message + " \n详细信息:" + ex.StackTrace); - //MessageBox.Show("错误:" + err); +#endif +#if !debug + MessageBox.Show("错误:" + err); +#endif } } } diff --git a/ButcherWeight/WeightContext.cs b/ButcherWeight/WeightContext.cs index 71758d7..b8eb3de 100644 --- a/ButcherWeight/WeightContext.cs +++ b/ButcherWeight/WeightContext.cs @@ -15,7 +15,7 @@ namespace ButcherWeight private static string loginConfigPath = @"C:\B3Service\src\B3ButcherManageClient\ButcherManageClient\bin\Debug\WeightSetting.xml"; //#endif //#if !debug - // private static string loginConfigPath = Application.StartupPath + "\\WeightSetting.xml"; + // private static string loginConfigPath = Application.StartupPath + "\\WeightSetting.xml"; //#endif private static WeightSetting _config; public static WeightSetting Config diff --git a/ButcherWeight/WeightForm.Designer.cs b/ButcherWeight/WeightForm.Designer.cs index 98ca4ea..f772d2a 100644 --- a/ButcherWeight/WeightForm.Designer.cs +++ b/ButcherWeight/WeightForm.Designer.cs @@ -128,8 +128,20 @@ this.S_AbnormalItem_Name = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.S_Number = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.billGrid = new System.Windows.Forms.DataGridView(); + this.label15 = new System.Windows.Forms.Label(); + this.label16 = new System.Windows.Forms.Label(); + this.label17 = new System.Windows.Forms.Label(); + this.panel5 = new System.Windows.Forms.Panel(); + this.weightLabel = new System.Windows.Forms.Label(); + this.weightSerialPort = new System.IO.Ports.SerialPort(this.components); + this.qCarSelect = new BWP.WinFormControl.UComboBox(); + this.label4 = new System.Windows.Forms.Label(); + this.qSupplierSelect = new BWP.WinFormControl.UComboBox(); + this.label5 = new System.Windows.Forms.Label(); + this.queryBtn = new System.Windows.Forms.Button(); this.M_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.M_B3ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.M_Car_Name = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.M_Supplier_Name = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.M_Zone_Name = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.M_FarmerNames = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -138,12 +150,6 @@ this.M_Weight = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.M_HouseNames = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.M_SanctionNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.label15 = new System.Windows.Forms.Label(); - this.label16 = new System.Windows.Forms.Label(); - this.label17 = new System.Windows.Forms.Label(); - this.panel5 = new System.Windows.Forms.Panel(); - this.weightLabel = new System.Windows.Forms.Label(); - this.weightSerialPort = new System.IO.Ports.SerialPort(this.components); this.panel1.SuspendLayout(); this.panel2.SuspendLayout(); this.panel3.SuspendLayout(); @@ -1116,6 +1122,7 @@ this.billGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.M_ID, this.M_B3ID, + this.M_Car_Name, this.M_Supplier_Name, this.M_Zone_Name, this.M_FarmerNames, @@ -1124,7 +1131,7 @@ this.M_Weight, this.M_HouseNames, this.M_SanctionNumber}); - this.billGrid.Location = new System.Drawing.Point(12, 580); + this.billGrid.Location = new System.Drawing.Point(12, 595); this.billGrid.MultiSelect = false; this.billGrid.Name = "billGrid"; this.billGrid.ReadOnly = true; @@ -1133,10 +1140,120 @@ this.billGrid.RowsDefaultCellStyle = dataGridViewCellStyle15; this.billGrid.RowTemplate.Height = 23; this.billGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.billGrid.Size = new System.Drawing.Size(1250, 239); + this.billGrid.Size = new System.Drawing.Size(1250, 230); this.billGrid.TabIndex = 0; this.billGrid.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.billGrid_CellDoubleClick); // + // label15 + // + this.label15.AutoSize = true; + this.label15.Font = new System.Drawing.Font("宋体", 15F); + this.label15.ForeColor = System.Drawing.Color.Red; + this.label15.Location = new System.Drawing.Point(9, 297); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(89, 20); + this.label15.TabIndex = 6; + this.label15.Text = "过磅记录"; + // + // label16 + // + this.label16.AutoSize = true; + this.label16.Font = new System.Drawing.Font("宋体", 15F); + this.label16.ForeColor = System.Drawing.Color.Red; + this.label16.Location = new System.Drawing.Point(434, 297); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(89, 20); + this.label16.TabIndex = 7; + this.label16.Text = "入圈信息"; + // + // label17 + // + this.label17.AutoSize = true; + this.label17.Font = new System.Drawing.Font("宋体", 15F); + this.label17.ForeColor = System.Drawing.Color.Red; + this.label17.Location = new System.Drawing.Point(858, 297); + this.label17.Name = "label17"; + this.label17.Size = new System.Drawing.Size(89, 20); + this.label17.TabIndex = 8; + this.label17.Text = "异常明细"; + // + // panel5 + // + this.panel5.BackColor = System.Drawing.Color.Black; + this.panel5.Controls.Add(this.weightLabel); + this.panel5.Location = new System.Drawing.Point(13, 13); + this.panel5.Name = "panel5"; + this.panel5.Size = new System.Drawing.Size(156, 59); + this.panel5.TabIndex = 11; + // + // weightLabel + // + this.weightLabel.AutoSize = true; + this.weightLabel.Font = new System.Drawing.Font("宋体", 22F, System.Drawing.FontStyle.Bold); + this.weightLabel.ForeColor = System.Drawing.Color.Red; + this.weightLabel.Location = new System.Drawing.Point(3, 15); + this.weightLabel.Name = "weightLabel"; + this.weightLabel.Size = new System.Drawing.Size(29, 30); + this.weightLabel.TabIndex = 12; + this.weightLabel.Text = "0"; + // + // qCarSelect + // + this.qCarSelect.CodeArgs = null; + this.qCarSelect.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; + this.qCarSelect.EnableTopItem = true; + this.qCarSelect.Font = new System.Drawing.Font("宋体", 12F); + this.qCarSelect.FormattingEnabled = true; + this.qCarSelect.Location = new System.Drawing.Point(64, 562); + this.qCarSelect.Name = "qCarSelect"; + this.qCarSelect.Range = 10; + this.qCarSelect.Size = new System.Drawing.Size(135, 27); + this.qCarSelect.TabIndex = 40; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("宋体", 15F); + this.label4.Location = new System.Drawing.Point(9, 566); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(69, 20); + this.label4.TabIndex = 39; + this.label4.Text = "车辆:"; + // + // qSupplierSelect + // + this.qSupplierSelect.CodeArgs = null; + this.qSupplierSelect.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; + this.qSupplierSelect.EnableTopItem = true; + this.qSupplierSelect.Font = new System.Drawing.Font("宋体", 12F); + this.qSupplierSelect.FormattingEnabled = true; + this.qSupplierSelect.Location = new System.Drawing.Point(279, 562); + this.qSupplierSelect.Name = "qSupplierSelect"; + this.qSupplierSelect.Range = 10; + this.qSupplierSelect.Size = new System.Drawing.Size(135, 27); + this.qSupplierSelect.TabIndex = 42; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("宋体", 15F); + this.label5.Location = new System.Drawing.Point(204, 566); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(89, 20); + this.label5.TabIndex = 41; + this.label5.Text = "供应商:"; + // + // queryBtn + // + this.queryBtn.Font = new System.Drawing.Font("宋体", 13F); + this.queryBtn.Location = new System.Drawing.Point(437, 557); + this.queryBtn.Name = "queryBtn"; + this.queryBtn.Size = new System.Drawing.Size(80, 35); + this.queryBtn.TabIndex = 43; + this.queryBtn.Text = "查询"; + this.queryBtn.UseVisualStyleBackColor = true; + this.queryBtn.Click += new System.EventHandler(this.queryBtn_Click); + // // M_ID // this.M_ID.DataPropertyName = "ID"; @@ -1151,7 +1268,14 @@ this.M_B3ID.HeaderText = "过磅单号"; this.M_B3ID.Name = "M_B3ID"; this.M_B3ID.ReadOnly = true; - this.M_B3ID.Width = 110; + // + // M_Car_Name + // + this.M_Car_Name.DataPropertyName = "Car_Name"; + this.M_Car_Name.HeaderText = "车辆"; + this.M_Car_Name.Name = "M_Car_Name"; + this.M_Car_Name.ReadOnly = true; + this.M_Car_Name.Width = 120; // // M_Supplier_Name // @@ -1159,7 +1283,7 @@ this.M_Supplier_Name.HeaderText = "供应商"; this.M_Supplier_Name.Name = "M_Supplier_Name"; this.M_Supplier_Name.ReadOnly = true; - this.M_Supplier_Name.Width = 150; + this.M_Supplier_Name.Width = 120; // // M_Zone_Name // @@ -1167,7 +1291,7 @@ this.M_Zone_Name.HeaderText = "来源地"; this.M_Zone_Name.Name = "M_Zone_Name"; this.M_Zone_Name.ReadOnly = true; - this.M_Zone_Name.Width = 130; + this.M_Zone_Name.Width = 120; // // M_FarmerNames // @@ -1175,7 +1299,7 @@ this.M_FarmerNames.HeaderText = "养殖户"; this.M_FarmerNames.Name = "M_FarmerNames"; this.M_FarmerNames.ReadOnly = true; - this.M_FarmerNames.Width = 130; + this.M_FarmerNames.Width = 120; // // M_PurchaseType_Name // @@ -1183,7 +1307,7 @@ this.M_PurchaseType_Name.HeaderText = "收购类型"; this.M_PurchaseType_Name.Name = "M_PurchaseType_Name"; this.M_PurchaseType_Name.ReadOnly = true; - this.M_PurchaseType_Name.Width = 130; + this.M_PurchaseType_Name.Width = 120; // // M_Number // @@ -1191,7 +1315,7 @@ this.M_Number.HeaderText = "收购头数"; this.M_Number.Name = "M_Number"; this.M_Number.ReadOnly = true; - this.M_Number.Width = 130; + this.M_Number.Width = 120; // // M_Weight // @@ -1199,7 +1323,7 @@ this.M_Weight.HeaderText = "收购重量"; this.M_Weight.Name = "M_Weight"; this.M_Weight.ReadOnly = true; - this.M_Weight.Width = 130; + this.M_Weight.Width = 120; // // M_HouseNames // @@ -1207,7 +1331,7 @@ this.M_HouseNames.HeaderText = "圈舍"; this.M_HouseNames.Name = "M_HouseNames"; this.M_HouseNames.ReadOnly = true; - this.M_HouseNames.Width = 200; + this.M_HouseNames.Width = 180; // // M_SanctionNumber // @@ -1215,66 +1339,17 @@ this.M_SanctionNumber.HeaderText = "异常明细"; this.M_SanctionNumber.Name = "M_SanctionNumber"; this.M_SanctionNumber.ReadOnly = true; - this.M_SanctionNumber.Width = 130; - // - // label15 - // - this.label15.AutoSize = true; - this.label15.Font = new System.Drawing.Font("宋体", 15F); - this.label15.ForeColor = System.Drawing.Color.Red; - this.label15.Location = new System.Drawing.Point(9, 297); - this.label15.Name = "label15"; - this.label15.Size = new System.Drawing.Size(89, 20); - this.label15.TabIndex = 6; - this.label15.Text = "过磅记录"; - // - // label16 - // - this.label16.AutoSize = true; - this.label16.Font = new System.Drawing.Font("宋体", 15F); - this.label16.ForeColor = System.Drawing.Color.Red; - this.label16.Location = new System.Drawing.Point(434, 297); - this.label16.Name = "label16"; - this.label16.Size = new System.Drawing.Size(89, 20); - this.label16.TabIndex = 7; - this.label16.Text = "入圈信息"; - // - // label17 - // - this.label17.AutoSize = true; - this.label17.Font = new System.Drawing.Font("宋体", 15F); - this.label17.ForeColor = System.Drawing.Color.Red; - this.label17.Location = new System.Drawing.Point(858, 297); - this.label17.Name = "label17"; - this.label17.Size = new System.Drawing.Size(89, 20); - this.label17.TabIndex = 8; - this.label17.Text = "异常明细"; - // - // panel5 - // - this.panel5.BackColor = System.Drawing.Color.Black; - this.panel5.Controls.Add(this.weightLabel); - this.panel5.Location = new System.Drawing.Point(13, 13); - this.panel5.Name = "panel5"; - this.panel5.Size = new System.Drawing.Size(156, 59); - this.panel5.TabIndex = 11; - // - // weightLabel - // - this.weightLabel.AutoSize = true; - this.weightLabel.Font = new System.Drawing.Font("宋体", 22F, System.Drawing.FontStyle.Bold); - this.weightLabel.ForeColor = System.Drawing.Color.Red; - this.weightLabel.Location = new System.Drawing.Point(3, 15); - this.weightLabel.Name = "weightLabel"; - this.weightLabel.Size = new System.Drawing.Size(29, 30); - this.weightLabel.TabIndex = 12; - this.weightLabel.Text = "0"; // // WeightForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1276, 831); + this.Controls.Add(this.queryBtn); + this.Controls.Add(this.qSupplierSelect); + this.Controls.Add(this.label5); + this.Controls.Add(this.qCarSelect); + this.Controls.Add(this.label4); this.Controls.Add(this.panel5); this.Controls.Add(this.abnormalGrid); this.Controls.Add(this.billGrid); @@ -1376,16 +1451,6 @@ private System.Windows.Forms.DataGridViewTextBoxColumn D_MaoWeight; private System.Windows.Forms.DataGridViewTextBoxColumn D_PiWeight; private System.Windows.Forms.DataGridViewTextBoxColumn D_Weight; - private System.Windows.Forms.DataGridViewTextBoxColumn M_ID; - private System.Windows.Forms.DataGridViewTextBoxColumn M_B3ID; - private System.Windows.Forms.DataGridViewTextBoxColumn M_Supplier_Name; - private System.Windows.Forms.DataGridViewTextBoxColumn M_Zone_Name; - private System.Windows.Forms.DataGridViewTextBoxColumn M_FarmerNames; - private System.Windows.Forms.DataGridViewTextBoxColumn M_PurchaseType_Name; - private System.Windows.Forms.DataGridViewTextBoxColumn M_Number; - private System.Windows.Forms.DataGridViewTextBoxColumn M_Weight; - private System.Windows.Forms.DataGridViewTextBoxColumn M_HouseNames; - private System.Windows.Forms.DataGridViewTextBoxColumn M_SanctionNumber; private System.Windows.Forms.DataGridViewTextBoxColumn H_ID; private System.Windows.Forms.DataGridViewTextBoxColumn H_B3ID; private System.Windows.Forms.DataGridViewTextBoxColumn H_WeightBill_ID; @@ -1410,5 +1475,21 @@ private System.Windows.Forms.Panel panel5; private System.Windows.Forms.Label weightLabel; private System.IO.Ports.SerialPort weightSerialPort; + private BWP.WinFormControl.UComboBox qCarSelect; + private System.Windows.Forms.Label label4; + private BWP.WinFormControl.UComboBox qSupplierSelect; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Button queryBtn; + private System.Windows.Forms.DataGridViewTextBoxColumn M_ID; + private System.Windows.Forms.DataGridViewTextBoxColumn M_B3ID; + private System.Windows.Forms.DataGridViewTextBoxColumn M_Car_Name; + private System.Windows.Forms.DataGridViewTextBoxColumn M_Supplier_Name; + private System.Windows.Forms.DataGridViewTextBoxColumn M_Zone_Name; + private System.Windows.Forms.DataGridViewTextBoxColumn M_FarmerNames; + private System.Windows.Forms.DataGridViewTextBoxColumn M_PurchaseType_Name; + private System.Windows.Forms.DataGridViewTextBoxColumn M_Number; + private System.Windows.Forms.DataGridViewTextBoxColumn M_Weight; + private System.Windows.Forms.DataGridViewTextBoxColumn M_HouseNames; + private System.Windows.Forms.DataGridViewTextBoxColumn M_SanctionNumber; } } \ No newline at end of file diff --git a/ButcherWeight/WeightForm.cs b/ButcherWeight/WeightForm.cs index b91e721..aac9277 100644 --- a/ButcherWeight/WeightForm.cs +++ b/ButcherWeight/WeightForm.cs @@ -43,10 +43,13 @@ namespace ButcherWeight hogGradeSelect.Init("BaseInfoRpc/GetHogGradeList"); zoneSelect.Init("BaseInfoRpc/GetZoneList"); farmerSelect.Init("BaseInfoRpc/GetFarmerList"); + + qCarSelect.Init("BaseInfoRpc/GetCarList"); + qSupplierSelect.Init("BaseInfoRpc/GetSupplierList"); farmerSelect.EnableTopItem = false; weightTimeSelect.Date = DateTime.Now; testTimeInput.Date = null; - dmoList = WeightBillRpc.GetWeightBillList(); + dmoList = WeightBillRpc.GetWeightBillList(null, null); billGrid.AutoGenerateColumns = false; farmerGrid.AutoGenerateColumns = false; weightGrid.AutoGenerateColumns = false; @@ -226,9 +229,7 @@ namespace ButcherWeight else d = weightGrid.CurrentRow.DataBoundItem as WeightBill_Detail; d.MaoWeight = WeightValue; - d.Weight = (d.PiWeight ?? 0) - (d.MaoWeight ?? 0); - weightGrid.DataSource = null; - weightGrid.DataSource = _details; + d.Weight = (d.MaoWeight ?? 0) - (d.PiWeight ?? 0); weightGrid.Refresh(); WeightValue = null; } @@ -449,10 +450,19 @@ namespace ButcherWeight { if (Dmo.ID != 0) WeightBillRpc.Delete(Dmo.ID); - dmoList.Remove(Dmo); - BindWeightBill(); + if (dmoList.Any(x => x.ID == Dmo.ID)) + { + dmoList.Remove(Dmo); + BindWeightBill(); + } createBtn_Click(sender, e); MessageBox.Show("删除成功!"); } + + private void queryBtn_Click(object sender, EventArgs e) + { + dmoList = WeightBillRpc.GetWeightBillList(qCarSelect.LongValue, qSupplierSelect.LongValue); + BindWeightBill(); + } } } \ No newline at end of file diff --git a/ButcherWeight/WeightForm.resx b/ButcherWeight/WeightForm.resx index 843173d..46615f3 100644 --- a/ButcherWeight/WeightForm.resx +++ b/ButcherWeight/WeightForm.resx @@ -372,6 +372,9 @@ True + + True + True @@ -414,6 +417,21 @@ 17, 17 + + True + + + True + + + True + + + True + + + True + True diff --git a/ButcherWeight/WeightFormWeightPart.cs b/ButcherWeight/WeightFormWeightPart.cs index 1bd8ba4..4b400a0 100644 --- a/ButcherWeight/WeightFormWeightPart.cs +++ b/ButcherWeight/WeightFormWeightPart.cs @@ -1,6 +1,7 @@ using BWP.WinFormControl; using BWP.WinFormControl.WeightDataFormat; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Text; @@ -13,10 +14,28 @@ namespace ButcherWeight partial class WeightForm { private IDataFormat _dataFormat; - private Thread _inQueryThread; + private Thread _inQueryThread, _outQueryThread; + private bool _mainProcessIsRun; readonly StringBuilder _dataStrBuilder = new StringBuilder(); + readonly ConcurrentQueue _dataQueue = new ConcurrentQueue(); - void InitWeightControl() + private const int WmUpdDisplayMessage = 0x0500 + 2; + private string _displayValue; + private int _mainHandle; + + int MainHandle + { + get + { + if (_mainHandle == 0) + { + _mainHandle = WinApiSendMessage.FindWindow(null, this.Text); + } + return _mainHandle; + } + } + + void OpenSerialPort() { if (enableCheckBox.Checked) return; @@ -45,13 +64,6 @@ namespace ButcherWeight _dataFormat = new Xk3190D10DataFormat(); break; } - } - - private void OpenSerialPort() - { - - Thread.Sleep(10); - // 打开串口 if (!weightSerialPort.IsOpen) { try @@ -71,15 +83,18 @@ namespace ButcherWeight void ReadData() { - _inQueryThread = new Thread(InQuery) { IsBackground = true }; + _inQueryThread = new Thread(InQuery); _inQueryThread.Start(); + + _outQueryThread = new Thread(OutQuery); + _outQueryThread.Start(); } string format = "{0:0.00}"; private void InQuery() { - while (enableCheckBox.CheckState == CheckState.Checked) + while (_mainProcessIsRun) { int availableCount = weightSerialPort.BytesToRead; if (availableCount == 0) @@ -102,15 +117,7 @@ namespace ButcherWeight else if (c == _dataFormat.Endchar || _dataStrBuilder.Length > _dataFormat.Bufsize) { _dataStrBuilder.Append(c); - bool isStatic; - string str; - if (_dataFormat.ParseAscii(_dataStrBuilder.ToString(), out str, out isStatic)) - { - if (string.IsNullOrEmpty(str)) - str = "0"; - WeightValue = decimal.Parse(str); - break; - } + _dataQueue.Enqueue(_dataStrBuilder.ToString()); _dataStrBuilder.Clear(); } else @@ -121,8 +128,43 @@ namespace ButcherWeight } } + private void OutQuery() + { + while (_mainProcessIsRun) + { + try + { + bool isStatic; + string str; + + string subStr; + + if (!_dataQueue.TryDequeue(out subStr)) + { + Thread.Sleep(1); + continue; + } + // 解析接受的端口数据 + if (_dataFormat.ParseAscii(subStr, out str, out isStatic)) + { + if (string.IsNullOrEmpty(str)) + str = "0"; + _displayValue = string.Format(format, decimal.Parse(str)); + WinApiSendMessage.SendMessage(MainHandle, WmUpdDisplayMessage, 0, 0); + } + } + catch (Exception) + { + Thread.Sleep(1000); + continue; + } + Thread.Sleep(1); + } + } + void DisableWeight() { + _mainProcessIsRun = false; WeightValue = 0; format = "{0:0.00}"; Thread.Sleep(10); @@ -130,6 +172,10 @@ namespace ButcherWeight { _inQueryThread.Abort(); } + if (_outQueryThread.IsAlive) + { + _outQueryThread.Abort(); + } if (weightSerialPort.IsOpen) weightSerialPort.Close(); } @@ -138,8 +184,8 @@ namespace ButcherWeight { if (!enableCheckBox.Checked) { - InitWeightControl(); OpenSerialPort(); + _mainProcessIsRun = true; ReadData(); } else @@ -158,5 +204,19 @@ namespace ButcherWeight } set { weightLabel.Text = string.Format(format, value); } } + + protected override void DefWndProc(ref Message m) + { + switch (m.Msg) + { + case WmUpdDisplayMessage: + weightLabel.Text = string.Format(format, decimal.Parse(_displayValue)); + break; + + default: + base.DefWndProc(ref m); + break; + } + } } } diff --git a/QualityAndOrder/QualityOrderForm.Designer.cs b/QualityAndOrder/QualityOrderForm.Designer.cs index cc8ca58..adf0b57 100644 --- a/QualityAndOrder/QualityOrderForm.Designer.cs +++ b/QualityAndOrder/QualityOrderForm.Designer.cs @@ -28,18 +28,18 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle19 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle20 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle21 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle22 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle23 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle24 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle16 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); this.uTabControl1 = new BWP.WinFormControl.UTabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.panel1 = new System.Windows.Forms.Panel(); @@ -147,7 +147,7 @@ this.tabPage1.Location = new System.Drawing.Point(4, 54); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(1268, 815); + this.tabPage1.Size = new System.Drawing.Size(1268, 773); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "验质分圈"; this.tabPage1.UseVisualStyleBackColor = true; @@ -192,17 +192,17 @@ this.sanctionGrid.AllowUserToDeleteRows = false; this.sanctionGrid.AllowUserToResizeColumns = false; this.sanctionGrid.AllowUserToResizeRows = false; - dataGridViewCellStyle19.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.sanctionGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle19; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.sanctionGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.sanctionGrid.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle20.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle20.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle20.Font = new System.Drawing.Font("宋体", 12F); - dataGridViewCellStyle20.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle20.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle20.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle20.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.sanctionGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle20; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 12F); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.sanctionGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; this.sanctionGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.sanctionGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.S_AbnormalItem_Name1, @@ -223,8 +223,8 @@ this.sanctionGrid.Name = "sanctionGrid"; this.sanctionGrid.ReadOnly = true; this.sanctionGrid.RowHeadersVisible = false; - dataGridViewCellStyle21.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.sanctionGrid.RowsDefaultCellStyle = dataGridViewCellStyle21; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.sanctionGrid.RowsDefaultCellStyle = dataGridViewCellStyle3; this.sanctionGrid.RowTemplate.DefaultCellStyle.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.sanctionGrid.RowTemplate.Height = 50; this.sanctionGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; @@ -433,17 +433,17 @@ this.weightBillGrid.AllowUserToDeleteRows = false; this.weightBillGrid.AllowUserToResizeColumns = false; this.weightBillGrid.AllowUserToResizeRows = false; - dataGridViewCellStyle22.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.weightBillGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle22; + dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.weightBillGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle4; this.weightBillGrid.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle23.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle23.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle23.Font = new System.Drawing.Font("宋体", 12F); - dataGridViewCellStyle23.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle23.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle23.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle23.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.weightBillGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle23; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 12F); + dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.weightBillGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle5; this.weightBillGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.weightBillGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.W_ID, @@ -457,8 +457,8 @@ this.weightBillGrid.Name = "weightBillGrid"; this.weightBillGrid.ReadOnly = true; this.weightBillGrid.RowHeadersVisible = false; - dataGridViewCellStyle24.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.weightBillGrid.RowsDefaultCellStyle = dataGridViewCellStyle24; + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.weightBillGrid.RowsDefaultCellStyle = dataGridViewCellStyle6; this.weightBillGrid.RowTemplate.Height = 40; this.weightBillGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.weightBillGrid.Size = new System.Drawing.Size(452, 401); @@ -613,17 +613,17 @@ this.preOrderGrid.AllowUserToDeleteRows = false; this.preOrderGrid.AllowUserToResizeColumns = false; this.preOrderGrid.AllowUserToResizeRows = false; - dataGridViewCellStyle13.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.preOrderGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle13; + dataGridViewCellStyle7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.preOrderGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle7; this.preOrderGrid.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle14.Font = new System.Drawing.Font("宋体", 12F); - dataGridViewCellStyle14.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle14.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle14.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.preOrderGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle14; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle8.Font = new System.Drawing.Font("宋体", 12F); + dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.preOrderGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle8; this.preOrderGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.preOrderGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.P_ID, @@ -639,8 +639,8 @@ this.preOrderGrid.Name = "preOrderGrid"; this.preOrderGrid.ReadOnly = true; this.preOrderGrid.RowHeadersVisible = false; - dataGridViewCellStyle15.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.preOrderGrid.RowsDefaultCellStyle = dataGridViewCellStyle15; + dataGridViewCellStyle9.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.preOrderGrid.RowsDefaultCellStyle = dataGridViewCellStyle9; this.preOrderGrid.RowTemplate.Height = 23; this.preOrderGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.preOrderGrid.Size = new System.Drawing.Size(714, 663); @@ -710,17 +710,17 @@ this.orderGrid.AllowUserToDeleteRows = false; this.orderGrid.AllowUserToResizeColumns = false; this.orderGrid.AllowUserToResizeRows = false; - dataGridViewCellStyle16.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.orderGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle16; + dataGridViewCellStyle10.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.orderGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle10; this.orderGrid.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle17.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle17.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle17.Font = new System.Drawing.Font("宋体", 12F); - dataGridViewCellStyle17.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle17.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle17.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle17.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.orderGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle17; + dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle11.Font = new System.Drawing.Font("宋体", 12F); + dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.orderGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; this.orderGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.orderGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.O_ID, @@ -733,8 +733,8 @@ this.orderGrid.MultiSelect = false; this.orderGrid.Name = "orderGrid"; this.orderGrid.RowHeadersVisible = false; - dataGridViewCellStyle18.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.orderGrid.RowsDefaultCellStyle = dataGridViewCellStyle18; + dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.orderGrid.RowsDefaultCellStyle = dataGridViewCellStyle12; this.orderGrid.RowTemplate.Height = 23; this.orderGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.orderGrid.Size = new System.Drawing.Size(454, 387); diff --git a/QualityAndOrder/QualityOrderForm.resx b/QualityAndOrder/QualityOrderForm.resx index e6455bc..24b4399 100644 --- a/QualityAndOrder/QualityOrderForm.resx +++ b/QualityAndOrder/QualityOrderForm.resx @@ -126,235 +126,181 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True - + True diff --git a/Setup/Release/Setup.msi b/Setup/Release/Setup.msi index f6f8d68..4b3ffae 100644 Binary files a/Setup/Release/Setup.msi and b/Setup/Release/Setup.msi differ