diff --git a/BO/BO/Bill/WeightBill/WeightBill.cs b/BO/BO/Bill/WeightBill/WeightBill.cs index 41a81ef..3f2ce87 100644 --- a/BO/BO/Bill/WeightBill/WeightBill.cs +++ b/BO/BO/Bill/WeightBill/WeightBill.cs @@ -111,5 +111,7 @@ namespace BO.BO public List SanctionDetails { get { return _sanctionDetails; } } public int SanctionNumber { get { return _sanctionDetails.Sum(x => (x.Number ?? 0)); } } + + public int? FirstWeightNumber { get; set; } } } diff --git a/BO/Utils/AfterLoginUtil.cs b/BO/Utils/AfterLoginUtil.cs index ac7a1ad..3ac68e7 100644 --- a/BO/Utils/AfterLoginUtil.cs +++ b/BO/Utils/AfterLoginUtil.cs @@ -19,14 +19,14 @@ namespace BO.Utils public static class AfterLoginUtil { //#if debug - static List> roleToAssemblies= new List>(){new Tuple("排宰员",@"C:\B3Service\src\B3ButcherManageClient\ButcherOrder\bin\Debug\ButcherOrder"), + static List> roleToAssemblies = new List>(){new Tuple("排宰员",@"C:\B3Service\src\B3ButcherManageClient\ButcherOrder\bin\Debug\ButcherOrder"), new Tuple("过磅员",@"C:\B3Service\src\B3ButcherManageClient\ButcherWeight\bin\Debug\ButcherWeight"), new Tuple("验质员",@"C:\B3Service\src\B3ButcherManageClient\QualityAndOrder\bin\Debug\QualityAndOrder")}; //#endif -//#if relase - // static List> roleToAssemblies = new List>(){new Tuple("排宰员",@"ButcherOrder"), - // new Tuple("过磅员",@"ButcherWeight"), - // new Tuple("验质员",@"QualityAndOrder")}; +//#if !debug + // static List> roleToAssemblies = new List>(){new Tuple("排宰员",@"ButcherOrder"), + //new Tuple("过磅员",@"ButcherWeight"), + // new Tuple("验质员",@"QualityAndOrder")}; //#endif @@ -38,8 +38,8 @@ namespace BO.Utils //#if debug var filePath = string.Format("{0}.dll", first.Item2); //#endif -//#if relase - // var filePath = Path.Combine(Application.StartupPath, string.Format("{0}.dll", first.Item2)); +//#if !debug + // var filePath = Path.Combine(Application.StartupPath, string.Format("{0}.dll", first.Item2)); //#endif if (!File.Exists(filePath)) throw new Exception("相关模块不存在"); diff --git a/BO/Utils/BillRpc/WeightBillRpc.cs b/BO/Utils/BillRpc/WeightBillRpc.cs index 5b41af2..0d5fa25 100644 --- a/BO/Utils/BillRpc/WeightBillRpc.cs +++ b/BO/Utils/BillRpc/WeightBillRpc.cs @@ -17,26 +17,19 @@ namespace BO.Utils.BillRpc var obj = new RpcObject("/MainSystem/B3ClientService/BO/WeightBill"); if (bo.ID == 0) { - obj.Set("Creator", ButcherAppContext.Context.UserConfig.UserName); - obj.Set("AccountingUnit_ID", ButcherAppContext.Context.UserConfig.AccountingUnit_ID); - obj.Set("Department_ID", ButcherAppContext.Context.UserConfig.Department_ID); - } - else - { - obj.Set("Creator", bo.Creator); - obj.Set("AccountingUnit_ID", bo.AccountingUnit_ID); - obj.Set("Department_ID", bo.Department_ID); + bo.Creator = ButcherAppContext.Context.UserConfig.UserName; + bo.AccountingUnit_ID = ButcherAppContext.Context.UserConfig.AccountingUnit_ID; + bo.Department_ID = ButcherAppContext.Context.UserConfig.Department_ID; } + obj.Set("Creator", bo.Creator); + obj.Set("AccountingUnit_ID", bo.AccountingUnit_ID); + obj.Set("Department_ID", bo.Department_ID); //base obj.Set("ID", bo.ID); - obj.Set("B3ID", bo.B3ID); - obj.Set("DeleteState", bo.DeleteState); //bill obj.Set("FinishCreate", bo.FinishCreate); - obj.Set("Sync", false); obj.Set("ModifyTime", DateTime.Now); - //bill obj.Set("Employee_ID", bo.Employee_ID); obj.Set("Employee_Name", bo.Employee_Name); @@ -59,8 +52,8 @@ namespace BO.Utils.BillRpc obj.Set("AnimalTestDate", bo.AnimalTestDate); obj.Set("AnimalTestMan", bo.AnimalTestMan); obj.Set("Remark", bo.Remark); - obj.Set("Inspector_ID", bo.Inspector_ID); - obj.Set("Inspector_Name", bo.Inspector_Name); + //obj.Set("Inspector_ID", bo.Inspector_ID); + //obj.Set("Inspector_Name", bo.Inspector_Name); const string detailErtPath = "/MainSystem/B3ClientService/BO/WeightBill_Detail"; @@ -239,26 +232,28 @@ namespace BO.Utils.BillRpc entity.B3ID = bill.Get("B3ID"); entity.Supplier_Name = bill.Get("Supplier_Name"); entity.AlreadyHouse = bill.Get("AlreadyHouse"); + entity.FirstWeightNumber = bill.Get("FirstWeightNumber"); var details = obj.Get>("Detail"); + //明细接收的数据不全,所以不能全量保存. foreach (var detail in details) { var d = new WeightBill_HouseDetail(); entity.HouseDetails.Add(d); d.LiveColonyHouse_Name = detail.Get("LiveColonyHouse_Name"); - d.Number = detail.Get("Number"); } } return result; } - public static int InsertHouseAndSanctionInfo(WeightBill bo) + public static int UpdateInsertHouseAndSanctionInfo(WeightBill bo) { - const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/InsertWeightBillHouseDetail"; + const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/UpdateInsertWeightBillHouseDetail"; var obj = new RpcObject("/MainSystem/B3ClientService/BO/WeightBill"); obj.Set("ID", bo.ID); obj.Set("HogGrade_ID", bo.HogGrade_ID); obj.Set("HogGrade_Name", bo.HogGrade_Name); obj.Set("AlreadyHouse", bo.AlreadyHouse); + obj.Set("FirstWeightNumber", bo.FirstWeightNumber); obj.Set("Inspector_ID", ButcherAppContext.Context.UserConfig.Employee_ID); obj.Set("Inspector_Name", ButcherAppContext.Context.UserConfig.Employee_Name); @@ -297,9 +292,9 @@ namespace BO.Utils.BillRpc return RpcFacade.Call(method, obj); } - public static int GetHouseDetailTotalNumber(DateTime date) + public static int GetDetailTotalNumber(DateTime date) { - const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/GetHouseDetailTotalNumber"; + const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/GetDetailTotalNumber"; return RpcFacade.Call(method, date); } @@ -320,5 +315,41 @@ namespace BO.Utils.BillRpc const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/SyncFarmerDetailB3Ids"; return RpcFacade.Call>>(method, ids); } + + public static List> SyncWeightDetailFirstNumber(List ids) + { + const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/SyncWeightDetailFirstNumber"; + return RpcFacade.Call>>(method, ids); + } + + public static WeightBill GetWeightBillOnHousePage(long id) + { + const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/GetWeightBillOnHousePage"; + var obj = RpcFacade.Call(method, id); + var entity = new WeightBill(); + var bill = obj.Get("Bill"); + entity.FirstWeightNumber = bill.Get("FirstWeightNumber"); + entity.HogGrade_ID = bill.Get("HogGrade_ID"); + var details = obj.Get>("Detail"); + //明细接收的数据不全,所以不能全量保存. + foreach (var detail in details) + { + var d = new WeightBill_HouseDetail(); + entity.HouseDetails.Add(d); + d.ID = detail.Get("ID"); + d.LiveColonyHouse_ID = detail.Get("LiveColonyHouse_ID"); + } + var sanctionDetail = obj.Get>("SanctionDetail"); + //明细接收的数据不全,所以不能全量保存. + foreach (var detail in sanctionDetail) + { + var d = new WeightBill_SanctionDetail(); + entity.SanctionDetails.Add(d); + d.ID = detail.Get("ID"); + d.AbnormalItem_ID = detail.Get("AbnormalItem_ID"); + d.Number = detail.Get("Number"); + } + return entity; + } } } diff --git a/BWP.WinFormControl/WeightControl.Designer.cs b/BWP.WinFormControl/WeightControl.Designer.cs index d7d4ebb..171bdb0 100644 --- a/BWP.WinFormControl/WeightControl.Designer.cs +++ b/BWP.WinFormControl/WeightControl.Designer.cs @@ -75,7 +75,6 @@ namespace BWP.WinFormControl this.enableWeightBox.TabIndex = 1; this.enableWeightBox.Text = "启用称重"; this.enableWeightBox.UseVisualStyleBackColor = true; - this.enableWeightBox.Click += new System.EventHandler(this.enableWeightBox_Click); // // WeightControl // diff --git a/BWP.WinFormControl/WeightControl.cs b/BWP.WinFormControl/WeightControl.cs index 6cbe6dd..4d6005f 100644 --- a/BWP.WinFormControl/WeightControl.cs +++ b/BWP.WinFormControl/WeightControl.cs @@ -160,7 +160,6 @@ namespace BWP.WinFormControl Value = decimal.Parse(str); break; } - // _dataQueue.Enqueue(_dataStrBuilder.ToString()); _dataStrBuilder.Clear(); } else @@ -171,37 +170,6 @@ namespace BWP.WinFormControl } } - //private void OutQuery() - //{ - // while (enableWeightBox.CheckState == CheckState.Checked) - // { - // try - // { - // bool isStatic; - // string str; - - // string subStr; - - // if (!_dataQueue.TryDequeue(out subStr)) - // { - // Thread.Sleep(1); - // continue; - // } - // // 解析接受的端口数据 - // if (_dataFormat.ParseAscii(subStr, out str, out isStatic)) - // { - // Value = decimal.Parse(str); - // } - // } - // catch (Exception) - // { - // Thread.Sleep(1000); - // continue; - // } - // Thread.Sleep(1); - // } - //} - void InitWeightType() { switch (_weightType) @@ -231,10 +199,6 @@ namespace BWP.WinFormControl { _inQueryThread.Abort(); } - //if (_outQueryThread.IsAlive) - //{ - // _outQueryThread.Abort(); - //} weightSerialPort.Close(); Value = 0; } @@ -246,7 +210,7 @@ namespace BWP.WinFormControl DisableWeight(); } - private void enableWeightBox_Click(object sender, EventArgs e) + public void enableWeightBox_Click(object sender, EventArgs e) { if (InitWeightInfo == null) throw new Exception("InitWeightInfo是用来实例化称参数的,请给此委托赋值并在其中实例化称参数"); diff --git a/BWP.WinFormControl/WeightDataFormat/DataFormatBase.cs b/BWP.WinFormControl/WeightDataFormat/DataFormatBase.cs index 3d41d52..041e4fb 100644 --- a/BWP.WinFormControl/WeightDataFormat/DataFormatBase.cs +++ b/BWP.WinFormControl/WeightDataFormat/DataFormatBase.cs @@ -1,6 +1,6 @@ namespace BWP.WinFormControl.WeightDataFormat { - interface IDataFormat { + public interface IDataFormat { char Beginchar { get; } char Endchar { get; } short Bufsize { get; } diff --git a/ButcherWeight/ButcherWeight.csproj b/ButcherWeight/ButcherWeight.csproj index f935354..474a2af 100644 --- a/ButcherWeight/ButcherWeight.csproj +++ b/ButcherWeight/ButcherWeight.csproj @@ -71,6 +71,9 @@ WeightForm.cs + + Form + diff --git a/ButcherWeight/WeightContext.cs b/ButcherWeight/WeightContext.cs index c7edcc8..71758d7 100644 --- a/ButcherWeight/WeightContext.cs +++ b/ButcherWeight/WeightContext.cs @@ -11,11 +11,11 @@ namespace ButcherWeight { public static class WeightContext { -//#if relase - // private static string loginConfigPath = Application.StartupPath + "\\WeightSetting.xml"; -//#endif //#if debug - private static string loginConfigPath = @"C:\B3Service\src\B3ButcherManageClient\ButcherManageClient\bin\Debug\WeightSetting.xml"; + private static string loginConfigPath = @"C:\B3Service\src\B3ButcherManageClient\ButcherManageClient\bin\Debug\WeightSetting.xml"; +//#endif +//#if !debug + // private static string loginConfigPath = Application.StartupPath + "\\WeightSetting.xml"; //#endif private static WeightSetting _config; public static WeightSetting Config @@ -45,8 +45,8 @@ namespace ButcherWeight throw new Exception("请选择称型号"); if (string.IsNullOrEmpty(_config.ComSet)) throw new Exception("请选择Com口"); - if (_config.RateSet==null) - throw new Exception("请选择波特率"); + if (_config.RateSet == null) + throw new Exception("请选择波特率"); if (_config.BitSet == null) throw new Exception("请选择数据位"); if (string.IsNullOrEmpty(_config.Format)) @@ -65,14 +65,14 @@ namespace ButcherWeight public class WeightSetting { - public string WeightSet{get;set;} + public string WeightSet { get; set; } - public string ComSet{get;set;} + public string ComSet { get; set; } - public int? RateSet{get;set;} + public int? RateSet { get; set; } - public int? BitSet{get;set;} + public int? BitSet { get; set; } - public string Format{get;set;} + public string Format { get; set; } } } diff --git a/ButcherWeight/WeightForm.Designer.cs b/ButcherWeight/WeightForm.Designer.cs index 4fb9c31..98ca4ea 100644 --- a/ButcherWeight/WeightForm.Designer.cs +++ b/ButcherWeight/WeightForm.Designer.cs @@ -29,24 +29,25 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle31 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle32 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle33 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle34 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle35 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle36 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle37 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle38 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle39 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle40 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle41 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle42 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle43 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle44 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle45 = new System.Windows.Forms.DataGridViewCellStyle(); + this.components = new System.ComponentModel.Container(); + 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(); + 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(); this.panel1 = new System.Windows.Forms.Panel(); + this.enableCheckBox = new System.Windows.Forms.CheckBox(); this.weightSet = new System.Windows.Forms.Button(); - this.weightControl = new BWP.WinFormControl.WeightControl(); this.exitBtn = new System.Windows.Forms.Button(); this.deleteBtn = new System.Windows.Forms.Button(); this.printBtn = new System.Windows.Forms.Button(); @@ -140,6 +141,9 @@ 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(); @@ -149,13 +153,14 @@ ((System.ComponentModel.ISupportInitialize)(this.houseGird)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.abnormalGrid)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.billGrid)).BeginInit(); + this.panel5.SuspendLayout(); this.SuspendLayout(); // // panel1 // this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel1.Controls.Add(this.enableCheckBox); this.panel1.Controls.Add(this.weightSet); - this.panel1.Controls.Add(this.weightControl); this.panel1.Controls.Add(this.exitBtn); this.panel1.Controls.Add(this.deleteBtn); this.panel1.Controls.Add(this.printBtn); @@ -168,6 +173,19 @@ this.panel1.Size = new System.Drawing.Size(1252, 95); this.panel1.TabIndex = 1; // + // enableCheckBox + // + this.enableCheckBox.AutoCheck = false; + this.enableCheckBox.AutoSize = true; + this.enableCheckBox.Font = new System.Drawing.Font("宋体", 19F); + this.enableCheckBox.Location = new System.Drawing.Point(8, 60); + this.enableCheckBox.Name = "enableCheckBox"; + this.enableCheckBox.Size = new System.Drawing.Size(135, 30); + this.enableCheckBox.TabIndex = 11; + this.enableCheckBox.Text = "启用称重"; + this.enableCheckBox.UseVisualStyleBackColor = true; + this.enableCheckBox.Click += new System.EventHandler(this.enableCheckBox_Click); + // // weightSet // this.weightSet.Font = new System.Drawing.Font("宋体", 15F); @@ -179,15 +197,6 @@ this.weightSet.UseVisualStyleBackColor = true; this.weightSet.Click += new System.EventHandler(this.weightSet_Click); // - // weightControl - // - this.weightControl.Location = new System.Drawing.Point(0, 0); - this.weightControl.Name = "weightControl"; - this.weightControl.Size = new System.Drawing.Size(156, 92); - this.weightControl.TabIndex = 9; - this.weightControl.TypeOfWeight = BWP.WinFormControl.WeightType.Xk3190A9; - this.weightControl.ValueFormat = "0.00"; - // // exitBtn // this.exitBtn.Font = new System.Drawing.Font("宋体", 15F); @@ -461,7 +470,7 @@ this.label19.Name = "label19"; this.label19.Size = new System.Drawing.Size(66, 19); this.label19.TabIndex = 24; - this.label19.Text = "经办人"; + this.label19.Text = "业务员"; // // label20 // @@ -689,17 +698,17 @@ this.farmerGrid.AllowUserToAddRows = false; this.farmerGrid.AllowUserToResizeColumns = false; this.farmerGrid.AllowUserToResizeRows = false; - dataGridViewCellStyle31.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.farmerGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle31; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.farmerGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.farmerGrid.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle32.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle32.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle32.Font = new System.Drawing.Font("宋体", 12F); - dataGridViewCellStyle32.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle32.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle32.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle32.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.farmerGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle32; + 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.farmerGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; this.farmerGrid.ColumnHeadersHeight = 24; this.farmerGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.farmerGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { @@ -714,8 +723,8 @@ this.farmerGrid.MultiSelect = false; this.farmerGrid.Name = "farmerGrid"; this.farmerGrid.RowHeadersVisible = false; - dataGridViewCellStyle33.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.farmerGrid.RowsDefaultCellStyle = dataGridViewCellStyle33; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.farmerGrid.RowsDefaultCellStyle = dataGridViewCellStyle3; this.farmerGrid.RowTemplate.Height = 23; this.farmerGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.farmerGrid.Size = new System.Drawing.Size(400, 112); @@ -798,17 +807,17 @@ this.weightGrid.AllowUserToAddRows = false; this.weightGrid.AllowUserToResizeColumns = false; this.weightGrid.AllowUserToResizeRows = false; - dataGridViewCellStyle34.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.weightGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle34; + dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.weightGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle4; this.weightGrid.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle35.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle35.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle35.Font = new System.Drawing.Font("宋体", 12F); - dataGridViewCellStyle35.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle35.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle35.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle35.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.weightGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle35; + 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.weightGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle5; this.weightGrid.ColumnHeadersHeight = 24; this.weightGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.weightGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { @@ -824,8 +833,8 @@ this.weightGrid.MultiSelect = false; this.weightGrid.Name = "weightGrid"; this.weightGrid.RowHeadersVisible = false; - dataGridViewCellStyle36.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.weightGrid.RowsDefaultCellStyle = dataGridViewCellStyle36; + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.weightGrid.RowsDefaultCellStyle = dataGridViewCellStyle6; this.weightGrid.RowTemplate.Height = 23; this.weightGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.weightGrid.Size = new System.Drawing.Size(400, 90); @@ -906,17 +915,17 @@ this.houseGird.AllowUserToDeleteRows = false; this.houseGird.AllowUserToResizeColumns = false; this.houseGird.AllowUserToResizeRows = false; - dataGridViewCellStyle37.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.houseGird.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle37; + dataGridViewCellStyle7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.houseGird.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle7; this.houseGird.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle38.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle38.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle38.Font = new System.Drawing.Font("宋体", 12F); - dataGridViewCellStyle38.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle38.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle38.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle38.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.houseGird.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle38; + 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.houseGird.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle8; this.houseGird.ColumnHeadersHeight = 24; this.houseGird.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.houseGird.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { @@ -931,8 +940,8 @@ this.houseGird.MultiSelect = false; this.houseGird.Name = "houseGird"; this.houseGird.RowHeadersVisible = false; - dataGridViewCellStyle39.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.houseGird.RowsDefaultCellStyle = dataGridViewCellStyle39; + dataGridViewCellStyle9.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.houseGird.RowsDefaultCellStyle = dataGridViewCellStyle9; this.houseGird.RowTemplate.Height = 23; this.houseGird.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.houseGird.Size = new System.Drawing.Size(400, 90); @@ -995,17 +1004,17 @@ this.abnormalGrid.AllowUserToDeleteRows = false; this.abnormalGrid.AllowUserToResizeColumns = false; this.abnormalGrid.AllowUserToResizeRows = false; - dataGridViewCellStyle40.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.abnormalGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle40; + dataGridViewCellStyle10.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.abnormalGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle10; this.abnormalGrid.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle41.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle41.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle41.Font = new System.Drawing.Font("宋体", 12F); - dataGridViewCellStyle41.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle41.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle41.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle41.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.abnormalGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle41; + 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.abnormalGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; this.abnormalGrid.ColumnHeadersHeight = 24; this.abnormalGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.abnormalGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { @@ -1021,8 +1030,8 @@ this.abnormalGrid.MultiSelect = false; this.abnormalGrid.Name = "abnormalGrid"; this.abnormalGrid.RowHeadersVisible = false; - dataGridViewCellStyle42.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.abnormalGrid.RowsDefaultCellStyle = dataGridViewCellStyle42; + dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.abnormalGrid.RowsDefaultCellStyle = dataGridViewCellStyle12; this.abnormalGrid.RowTemplate.Height = 23; this.abnormalGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.abnormalGrid.Size = new System.Drawing.Size(400, 237); @@ -1091,17 +1100,17 @@ this.billGrid.AllowUserToDeleteRows = false; this.billGrid.AllowUserToResizeColumns = false; this.billGrid.AllowUserToResizeRows = false; - dataGridViewCellStyle43.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.billGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle43; + dataGridViewCellStyle13.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.billGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle13; this.billGrid.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle44.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle44.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle44.Font = new System.Drawing.Font("宋体", 12F); - dataGridViewCellStyle44.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle44.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle44.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle44.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.billGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle44; + 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.billGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle14; this.billGrid.ColumnHeadersHeight = 24; this.billGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.billGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { @@ -1120,11 +1129,11 @@ this.billGrid.Name = "billGrid"; this.billGrid.ReadOnly = true; this.billGrid.RowHeadersVisible = false; - dataGridViewCellStyle45.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.billGrid.RowsDefaultCellStyle = dataGridViewCellStyle45; + dataGridViewCellStyle15.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + 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, 281); + this.billGrid.Size = new System.Drawing.Size(1250, 239); this.billGrid.TabIndex = 0; this.billGrid.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.billGrid_CellDoubleClick); // @@ -1241,11 +1250,32 @@ 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, 873); + this.ClientSize = new System.Drawing.Size(1276, 831); + this.Controls.Add(this.panel5); this.Controls.Add(this.abnormalGrid); this.Controls.Add(this.billGrid); this.Controls.Add(this.label17); @@ -1261,6 +1291,7 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "毛猪过磅"; this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); this.panel2.ResumeLayout(false); this.panel2.PerformLayout(); this.panel3.ResumeLayout(false); @@ -1271,6 +1302,8 @@ ((System.ComponentModel.ISupportInitialize)(this.houseGird)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.abnormalGrid)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.billGrid)).EndInit(); + this.panel5.ResumeLayout(false); + this.panel5.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -1372,7 +1405,10 @@ private System.Windows.Forms.Button exitBtn; private System.Windows.Forms.Button deleteBtn; private System.Windows.Forms.Button printBtn; - private BWP.WinFormControl.WeightControl weightControl; private System.Windows.Forms.Button weightSet; + private System.Windows.Forms.CheckBox enableCheckBox; + private System.Windows.Forms.Panel panel5; + private System.Windows.Forms.Label weightLabel; + private System.IO.Ports.SerialPort weightSerialPort; } } \ No newline at end of file diff --git a/ButcherWeight/WeightForm.cs b/ButcherWeight/WeightForm.cs index 6ae54af..b91e721 100644 --- a/ButcherWeight/WeightForm.cs +++ b/ButcherWeight/WeightForm.cs @@ -29,12 +29,12 @@ namespace ButcherWeight } #endregion - private const int WmUpdDisplayMessage = 0x0500 + 2; - + private delegate void InvokeHandler(); bool mainIsRun = false; public WeightForm() { InitializeComponent(); + Control.CheckForIllegalCrossThreadCalls = false; supplierSelect.Init("BaseInfoRpc/GetSupplierList"); purchaseTypeSelect.Init("BaseInfoRpc/GetPurchaseTypeList"); carSelect.Init("BaseInfoRpc/GetCarList"); @@ -52,21 +52,24 @@ namespace ButcherWeight weightGrid.AutoGenerateColumns = false; houseGird.AutoGenerateColumns = false; abnormalGrid.AutoGenerateColumns = false; - weightControl.InitWeightInfo += WeightControlInitWeightInfo; - weightControl.EnableCheckBox.CheckStateChanged += delegate - { - readMaoBtn.Enabled = readPiBtn.Enabled = weightControl.EnableCheckBox.Checked; - }; BindWeightBill(); mainIsRun = true; var syncThread = new Thread(SyncTask) { IsBackground = true }; syncThread.Start(); + this.FormClosing += delegate + { + if (syncThread.IsAlive) + syncThread.Abort(); + if (_inQueryThread != null && _inQueryThread.IsAlive) + DisableWeight(); + }; } private void SyncTask() { while (mainIsRun) { + Thread.Sleep(2000); bool changed = false; var ids = dmoList.Where(x => x.B3ID == null).Select(x => (long?)x.ID).ToList(); if (ids.Any()) @@ -82,10 +85,14 @@ namespace ButcherWeight changed = true; } } - if (changed) + } + var detailChange = SyncWeightDetailFirstNumber(); + if (changed || detailChange) + { + this.Invoke(new InvokeHandler(delegate() { BindWeightBill(); - } + })); } var details = new List(); var farms = new List(); @@ -124,31 +131,41 @@ namespace ButcherWeight } } - void WeightControlInitWeightInfo(object sender, EventArgs e) + bool SyncWeightDetailFirstNumber() { - if (weightControl.EnableCheckBox.Checked) - return; - if (WeightContext.Config.RateSet == null) - throw new Exception("请先配置称相关信息"); - weightControl.InitSerialPort(WeightContext.Config.ComSet, WeightContext.Config.RateSet.Value, WeightContext.Config.BitSet.Value); - switch (WeightContext.Config.WeightSet) + var details = new List(); + foreach (var item in dmoList) + { + if (item.Details.Any()) + details.Add(item.Details.First()); + + } + if (details.Any()) { - case "IND560": - weightControl.TypeOfWeight = WeightType.IND560; - break; - case "Xk3124": - weightControl.TypeOfWeight = WeightType.Xk3124; - break; - case "Xk3190A9": - weightControl.TypeOfWeight = WeightType.Xk3190A9; - break; - default: - weightControl.TypeOfWeight = WeightType.Xk3190D10; - break; + var result = WeightBillRpc.SyncWeightDetailFirstNumber(details.Select(x => (long?)x.ID).ToList()); + bool change = false; + foreach (var item in result) + { + var first = details.First(x => x.ID == item.Item2); + if (first.Number != item.Item3) + { + first.Number = item.Item3; + if (!change) + change = true; + if (first.WeightBill_ID == Dmo.ID) + { + _details.First(x => x.ID == first.ID).Number = first.Number; + weightGrid.DataSource = _details; + weightGrid.Refresh(); + } + } + } + return change; } - //weightControl.InitWeightInfo -= WeightControlInitWeightInfo; + return false; } + void BindWeightBill() { billGrid.DataSource = dmoList.OrderByDescending(x => x.ID).ToList(); @@ -163,8 +180,8 @@ namespace ButcherWeight private void exitBtn_Click(object sender, EventArgs e) { - if (weightControl.EnableCheckBox.Checked) - weightControl.EnableCheckBox.Checked = false; + if (enableCheckBox.Checked) + enableCheckBox.Checked = false; this.Close(); } @@ -172,8 +189,8 @@ namespace ButcherWeight { if (!_details.Any()) throw new Exception("没有称重记录"); - if (!_farmerDetails.Any()) - throw new Exception("没有养殖户信息"); + //if (!_farmerDetails.Any()) + //throw new Exception("没有养殖户信息"); GetFromUI(); Dmo.Details.Clear(); Dmo.Details.AddRange(_details.ToList()); @@ -200,15 +217,20 @@ namespace ButcherWeight private void readMaoBtn_Click(object sender, EventArgs e) { var d = new WeightBill_Detail(); - _details.Add(d); - d.Index = _details.Max(x => x.Index) + 1; - d.WeightBill_ID = Dmo.ID; - d.MaoWeight = weightControl.Value; - d.Weight = d.MaoWeight; + if (weightGrid.CurrentRow == null) + { + _details.Add(d); + d.Index = _details.Max(x => x.Index) + 1; + d.WeightBill_ID = Dmo.ID; + } + 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; weightGrid.Refresh(); - weightControl.Clear(); + WeightValue = null; } private void readPiBtn_Click(object sender, EventArgs e) @@ -219,10 +241,11 @@ namespace ButcherWeight return; } var target = weightGrid.CurrentRow.DataBoundItem as WeightBill_Detail; - target.PiWeight = weightControl.Value; + target.PiWeight = WeightValue; target.Weight = target.MaoWeight - target.PiWeight; weightGrid.Refresh(); - weightControl.Clear(); + WeightValue = null; + } private void farmerSelect_SelectedIndexChanged(object sender, EventArgs e) diff --git a/ButcherWeight/WeightForm.resx b/ButcherWeight/WeightForm.resx index c8f2207..843173d 100644 --- a/ButcherWeight/WeightForm.resx +++ b/ButcherWeight/WeightForm.resx @@ -117,6 +117,144 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 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 @@ -138,6 +276,15 @@ True + + True + + + True + + + True + True @@ -162,6 +309,12 @@ True + + True + + + True + True @@ -183,6 +336,9 @@ True + + True + True @@ -207,6 +363,9 @@ True + + True + True @@ -237,4 +396,28 @@ True + + True + + + True + + + True + + + True + + + True + + + 17, 17 + + + True + + + 26 + \ No newline at end of file diff --git a/ButcherWeight/WeightFormWeightPart.cs b/ButcherWeight/WeightFormWeightPart.cs new file mode 100644 index 0000000..1bd8ba4 --- /dev/null +++ b/ButcherWeight/WeightFormWeightPart.cs @@ -0,0 +1,162 @@ +using BWP.WinFormControl; +using BWP.WinFormControl.WeightDataFormat; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ButcherWeight +{ + partial class WeightForm + { + private IDataFormat _dataFormat; + private Thread _inQueryThread; + readonly StringBuilder _dataStrBuilder = new StringBuilder(); + + void InitWeightControl() + { + if (enableCheckBox.Checked) + return; + if (WeightContext.Config.RateSet == null) + throw new Exception("请先配置称相关信息"); + + weightSerialPort.PortName = WeightContext.Config.ComSet; + weightSerialPort.BaudRate = WeightContext.Config.RateSet.Value; + weightSerialPort.DataBits = WeightContext.Config.BitSet.Value; + weightSerialPort.ReadBufferSize = 4096 * 100; + if (!string.IsNullOrEmpty(WeightContext.Config.Format)) + format = "{0:{format}}".Replace("{format}", WeightContext.Config.Format); + + switch (WeightContext.Config.WeightSet) + { + case "IND560": + _dataFormat = new IND560DataFormat(); + break; + case "Xk3124": + _dataFormat = new Xk3124DataFormat(); + break; + case "Xk3190A9": + _dataFormat = new Xk3190A9DataFormat(); + break; + default: + _dataFormat = new Xk3190D10DataFormat(); + break; + } + } + + private void OpenSerialPort() + { + + Thread.Sleep(10); + // 打开串口 + if (!weightSerialPort.IsOpen) + { + try + { + weightSerialPort.Open(); + } + catch (InvalidOperationException) + { + MessageBox.Show(@"指定的端口已打开"); + } + catch (UnauthorizedAccessException) + { + MessageBox.Show(@"对端口的访问被拒绝"); + } + } + } + + void ReadData() + { + _inQueryThread = new Thread(InQuery) { IsBackground = true }; + _inQueryThread.Start(); + } + + string format = "{0:0.00}"; + + private void InQuery() + { + while (enableCheckBox.CheckState == CheckState.Checked) + { + int availableCount = weightSerialPort.BytesToRead; + if (availableCount == 0) + { + Thread.Sleep(1); + } + char[] buffer = new char[availableCount]; + if (!weightSerialPort.IsOpen) + { + continue; + } + weightSerialPort.Read(buffer, 0, availableCount); + foreach (var c in buffer) + { + if (c == _dataFormat.Beginchar) + { + _dataStrBuilder.Clear(); + _dataStrBuilder.Append(c); + } + 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; + } + _dataStrBuilder.Clear(); + } + else + { + _dataStrBuilder.Append(c); + } + } + } + } + + void DisableWeight() + { + WeightValue = 0; + format = "{0:0.00}"; + Thread.Sleep(10); + if (_inQueryThread.IsAlive) + { + _inQueryThread.Abort(); + } + if (weightSerialPort.IsOpen) + weightSerialPort.Close(); + } + + public void enableCheckBox_Click(object sender, EventArgs e) + { + if (!enableCheckBox.Checked) + { + InitWeightControl(); + OpenSerialPort(); + ReadData(); + } + else + DisableWeight(); + enableCheckBox.CheckState = enableCheckBox.Checked ? CheckState.Unchecked : CheckState.Checked; + readMaoBtn.Enabled = readPiBtn.Enabled = enableCheckBox.Checked; + } + + decimal? WeightValue + { + get + { + if (!string.IsNullOrEmpty(weightLabel.Text)) + return decimal.Parse(weightLabel.Text); + return null; + } + set { weightLabel.Text = string.Format(format, value); } + } + } +} diff --git a/QualityAndOrder/QualityOrderForm.Designer.cs b/QualityAndOrder/QualityOrderForm.Designer.cs index 79e3106..cc8ca58 100644 --- a/QualityAndOrder/QualityOrderForm.Designer.cs +++ b/QualityAndOrder/QualityOrderForm.Designer.cs @@ -28,18 +28,18 @@ /// private void InitializeComponent() { - 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(); + 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(); this.uTabControl1 = new BWP.WinFormControl.UTabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.panel1 = new System.Windows.Forms.Panel(); @@ -73,7 +73,7 @@ this.W_AlreadyHouse = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.W_B3ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.W_Supplier_Name = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.W_HouseNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.W_FirstWeightNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.W_HouseNames = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.syncBtn = new System.Windows.Forms.Button(); this.testTimeInput = new BWP.WinFormControl.UDatePicker(); @@ -125,7 +125,7 @@ this.uTabControl1.Location = new System.Drawing.Point(0, 0); this.uTabControl1.Name = "uTabControl1"; this.uTabControl1.SelectedIndex = 0; - this.uTabControl1.Size = new System.Drawing.Size(1276, 873); + this.uTabControl1.Size = new System.Drawing.Size(1276, 831); this.uTabControl1.SizeMode = System.Windows.Forms.TabSizeMode.Fixed; this.uTabControl1.TabIndex = 0; // @@ -192,17 +192,17 @@ this.sanctionGrid.AllowUserToDeleteRows = false; this.sanctionGrid.AllowUserToResizeColumns = false; this.sanctionGrid.AllowUserToResizeRows = false; - dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.sanctionGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + dataGridViewCellStyle19.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.sanctionGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle19; this.sanctionGrid.BackgroundColor = System.Drawing.Color.White; - 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; + 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; 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; - dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.sanctionGrid.RowsDefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle21.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.sanctionGrid.RowsDefaultCellStyle = dataGridViewCellStyle21; 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,36 +433,37 @@ this.weightBillGrid.AllowUserToDeleteRows = false; this.weightBillGrid.AllowUserToResizeColumns = false; this.weightBillGrid.AllowUserToResizeRows = false; - dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.weightBillGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle22.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.weightBillGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle22; this.weightBillGrid.BackgroundColor = System.Drawing.Color.White; - 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; + 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; this.weightBillGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.weightBillGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.W_ID, this.W_AlreadyHouse, this.W_B3ID, this.W_Supplier_Name, - this.W_HouseNumber, + this.W_FirstWeightNumber, this.W_HouseNames}); this.weightBillGrid.Location = new System.Drawing.Point(25, 77); this.weightBillGrid.MultiSelect = false; this.weightBillGrid.Name = "weightBillGrid"; this.weightBillGrid.ReadOnly = true; this.weightBillGrid.RowHeadersVisible = false; - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.weightBillGrid.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle24.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.weightBillGrid.RowsDefaultCellStyle = dataGridViewCellStyle24; this.weightBillGrid.RowTemplate.Height = 40; this.weightBillGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.weightBillGrid.Size = new System.Drawing.Size(452, 401); this.weightBillGrid.TabIndex = 34; + this.weightBillGrid.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.weightBillGrid_CellClick); // // W_ID // @@ -495,12 +496,12 @@ this.W_Supplier_Name.ReadOnly = true; this.W_Supplier_Name.Width = 120; // - // W_HouseNumber + // W_FirstWeightNumber // - this.W_HouseNumber.DataPropertyName = "HouseNumber"; - this.W_HouseNumber.HeaderText = "头数"; - this.W_HouseNumber.Name = "W_HouseNumber"; - this.W_HouseNumber.ReadOnly = true; + this.W_FirstWeightNumber.DataPropertyName = "FirstWeightNumber"; + this.W_FirstWeightNumber.HeaderText = "头数"; + this.W_FirstWeightNumber.Name = "W_FirstWeightNumber"; + this.W_FirstWeightNumber.ReadOnly = true; // // W_HouseNames // @@ -559,7 +560,7 @@ this.tabPage2.Location = new System.Drawing.Point(4, 54); this.tabPage2.Name = "tabPage2"; this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(1268, 683); + this.tabPage2.Size = new System.Drawing.Size(1268, 773); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "排宰顺序"; this.tabPage2.UseVisualStyleBackColor = true; @@ -612,17 +613,17 @@ this.preOrderGrid.AllowUserToDeleteRows = false; this.preOrderGrid.AllowUserToResizeColumns = false; this.preOrderGrid.AllowUserToResizeRows = false; - dataGridViewCellStyle7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.preOrderGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle7; + dataGridViewCellStyle13.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.preOrderGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle13; this.preOrderGrid.BackgroundColor = System.Drawing.Color.White; - 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; + 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; this.preOrderGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.preOrderGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.P_ID, @@ -638,8 +639,8 @@ this.preOrderGrid.Name = "preOrderGrid"; this.preOrderGrid.ReadOnly = true; this.preOrderGrid.RowHeadersVisible = false; - dataGridViewCellStyle9.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.preOrderGrid.RowsDefaultCellStyle = dataGridViewCellStyle9; + dataGridViewCellStyle15.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.preOrderGrid.RowsDefaultCellStyle = dataGridViewCellStyle15; this.preOrderGrid.RowTemplate.Height = 23; this.preOrderGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.preOrderGrid.Size = new System.Drawing.Size(714, 663); @@ -709,17 +710,17 @@ this.orderGrid.AllowUserToDeleteRows = false; this.orderGrid.AllowUserToResizeColumns = false; this.orderGrid.AllowUserToResizeRows = false; - dataGridViewCellStyle10.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.orderGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle10; + dataGridViewCellStyle16.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.orderGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle16; this.orderGrid.BackgroundColor = System.Drawing.Color.White; - 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; + 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; this.orderGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.orderGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.O_ID, @@ -732,8 +733,8 @@ this.orderGrid.MultiSelect = false; this.orderGrid.Name = "orderGrid"; this.orderGrid.RowHeadersVisible = false; - dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.orderGrid.RowsDefaultCellStyle = dataGridViewCellStyle12; + dataGridViewCellStyle18.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.orderGrid.RowsDefaultCellStyle = dataGridViewCellStyle18; this.orderGrid.RowTemplate.Height = 23; this.orderGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.orderGrid.Size = new System.Drawing.Size(454, 387); @@ -818,7 +819,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1276, 873); + this.ClientSize = new System.Drawing.Size(1276, 831); this.Controls.Add(this.uTabControl1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.MaximizeBox = false; @@ -904,7 +905,7 @@ private System.Windows.Forms.DataGridViewTextBoxColumn W_AlreadyHouse; private System.Windows.Forms.DataGridViewTextBoxColumn W_B3ID; private System.Windows.Forms.DataGridViewTextBoxColumn W_Supplier_Name; - private System.Windows.Forms.DataGridViewTextBoxColumn W_HouseNumber; + private System.Windows.Forms.DataGridViewTextBoxColumn W_FirstWeightNumber; private System.Windows.Forms.DataGridViewTextBoxColumn W_HouseNames; diff --git a/QualityAndOrder/QualityOrderForm.cs b/QualityAndOrder/QualityOrderForm.cs index 85a8bb0..9d936ad 100644 --- a/QualityAndOrder/QualityOrderForm.cs +++ b/QualityAndOrder/QualityOrderForm.cs @@ -29,27 +29,22 @@ namespace QualityAndOrder #endregion + private delegate void InvokeHandler(); + List> hogGradeList; List houseList; List sanctionList; List weightBills; - private Thread tab1SyncThread; - bool mainIsRun = false; - + Thread syncThread; readonly Color btnSelectForeColor = Color.FromArgb(255, 255, 255); readonly Color btnSelectBackColor = Color.FromArgb(66, 163, 218); Color btnUnSelectForeColor = SystemColors.ControlText; Color btnUnSelectBackColor = Color.FromArgb(225, 225, 225); + public QualityOrderForm() { InitializeComponent(); - this.FormClosing += delegate - { - if (tab1SyncThread != null && tab1SyncThread.IsAlive) - { - tab1SyncThread.Abort(); - } - }; + Control.CheckForIllegalCrossThreadCalls = false; testTimeInput.Date = tab2DateSelect.Date = DateTime.Today; syncBtn.Focus(); this.uTabControl1.Selected += (sender, e) => @@ -58,6 +53,7 @@ namespace QualityAndOrder }; sanctionGrid.AutoGenerateColumns = false; weightBillGrid.AutoGenerateColumns = false; + weightBillGrid.DataSource = null; hogGradeList = BaseInfoRpcUtil.GetBaseInfoEntity("GetHogGradeList"); houseList = HouseSplitEntity.Init(BaseInfoRpcUtil.GetBaseInfoEntity("GetLiveColonyHouseList")); sanctionList = SanctionSplit3Part.Init(BaseInfoRpcUtil.GetSanctionList()); @@ -71,14 +67,30 @@ namespace QualityAndOrder numberBox.LostFocus += (sender, e) => { flag = 1; }; sanctionGrid.GotFocus += (sender, e) => { flag = 2; }; - mainIsRun = true; + syncThread = new Thread(SyncTask) { IsBackground = true }; + this.FormClosing += delegate { + if (syncThread.IsAlive) + syncThread.Abort(); + }; + syncThread.Start(); + } + + private void SyncTask() + { + while (true) + { + BindNumberLabel(); + Thread.Sleep(2000); + } } - int flag = 0; + int flag = 1; + + List