From 3ae820f0b8cf589c9167bdd60599504ad62ab093 Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Fri, 15 Sep 2017 20:07:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BO/BO.csproj | 5 + BO/BO/Bill/OrderDetail/NeedOrderEntity.cs | 27 +++ BO/BO/Bill/OrderDetail/OrderDetail.cs | 31 +++ BO/CTuple.cs | 42 ++++ BO/Utils/BillRpc/OrderDetailRpc.cs | 68 ++++++ ButcherManageClient/Program.cs | 19 +- ButcherWeight/WeightForm.cs | 3 +- QualityAndOrder/QualityOrderForm.Designer.cs | 213 +++++++++++++------ QualityAndOrder/QualityOrderForm.cs | 11 +- QualityAndOrder/QualityOrderForm.resx | 103 +-------- QualityAndOrder/QualityOrderFormForTab2.cs | 209 +++++++++++++++++- 11 files changed, 544 insertions(+), 187 deletions(-) create mode 100644 BO/BO/Bill/OrderDetail/NeedOrderEntity.cs create mode 100644 BO/BO/Bill/OrderDetail/OrderDetail.cs create mode 100644 BO/CTuple.cs create mode 100644 BO/Utils/BillRpc/OrderDetailRpc.cs diff --git a/BO/BO.csproj b/BO/BO.csproj index d67d0cc..f20a704 100644 --- a/BO/BO.csproj +++ b/BO/BO.csproj @@ -44,6 +44,7 @@ + @@ -52,7 +53,11 @@ + + + + diff --git a/BO/BO/Bill/OrderDetail/NeedOrderEntity.cs b/BO/BO/Bill/OrderDetail/NeedOrderEntity.cs new file mode 100644 index 0000000..8c9b155 --- /dev/null +++ b/BO/BO/Bill/OrderDetail/NeedOrderEntity.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BO.BO.Bill +{ + public class NeedOrderEntity + { + public long? B3ID { get; set; } + + public long WeightBill_ID { get; set; } + + public string Supplier_Name { get; set; } + + public string HouseNames { get; set; } + + public int Number { get; set; } + + public int AlreadyNumber { get; set; } + + public int LastNumber { get { return Number - AlreadyNumber; } } + + public DateTime WeighTime { get; set; } + } +} diff --git a/BO/BO/Bill/OrderDetail/OrderDetail.cs b/BO/BO/Bill/OrderDetail/OrderDetail.cs new file mode 100644 index 0000000..ffc7a34 --- /dev/null +++ b/BO/BO/Bill/OrderDetail/OrderDetail.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BO.BO.Bill +{ + public class OrderDetail + { + public long ID { get; set; } + + public string Creator { get; set; } + + public long? AccountingUnit_ID { get; set; } + + public DateTime? Date { get; set; } + + public long WeightBill_ID { get; set; } + + public long? B3WeighBill_ID { get; set; } + + public int Order { get; set; } + + public int PlanNumber { get; set; } + + public string LiveColonyHouse_Name { get; set; } + + public bool IsHurryButcher { get; set; } + } +} diff --git a/BO/CTuple.cs b/BO/CTuple.cs new file mode 100644 index 0000000..15306f5 --- /dev/null +++ b/BO/CTuple.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BO +{ + public class CTuple + { + public T1 Item1 { get; set; } + + public T2 Item2 { get; set; } + + public CTuple() + { } + + public CTuple(T1 t1, T2 t2) + { + Item1 = t1; + Item2 = t2; + } + } + + public class CTuple + { + public T1 Item1 { get; set; } + + public T2 Item2 { get; set; } + + public T3 Item3 { get; set; } + public CTuple() + { } + + public CTuple(T1 t1, T2 t2, T3 t3) + { + Item1 = t1; + Item2 = t2; + Item3 = t3; + } + } +} diff --git a/BO/Utils/BillRpc/OrderDetailRpc.cs b/BO/Utils/BillRpc/OrderDetailRpc.cs new file mode 100644 index 0000000..01aa591 --- /dev/null +++ b/BO/Utils/BillRpc/OrderDetailRpc.cs @@ -0,0 +1,68 @@ +using BO.BO.Bill; +using Forks.JsonRpc.Client; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Web.Script.Serialization; + +namespace BO.Utils.BillRpc +{ + public static class OrderDetailRpc + { + static JavaScriptSerializer serializer = new JavaScriptSerializer(); + public static List GetNeedOrderWeightBill(DateTime date) + { + const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/OrderDetailRpc/GetNeedOrderWeightBill"; + var result = RpcFacade.Call(method, date); + return serializer.Deserialize>(result); + } + + public static NeedOrderEntity GetBackWeightBillInfo(long weightId, long orerID) + { + const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/OrderDetailRpc/GetBackWeightBillInfo"; + var result = RpcFacade.Call(method, weightId, orerID); + return serializer.Deserialize(result); + } + + public static int GetMaxOrder(DateTime date) + { + const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/OrderDetailRpc/GetMaxOrder"; + return RpcFacade.Call(method, date); + } + + public static List GetOrderDetail(DateTime date) + { + const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/OrderDetailRpc/GetOrderDetail"; + var result = RpcFacade.Call(method, date); + return serializer.Deserialize>(result); + } + + public static void Insert(List> update, OrderDetail insert) + { + insert.AccountingUnit_ID = ButcherAppContext.Context.UserConfig.AccountingUnit_ID; + insert.Creator = ButcherAppContext.Context.UserConfig.UserName; + const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/OrderDetailRpc/Insert"; + insert.ID = RpcFacade.Call(method, serializer.Serialize(update), serializer.Serialize(insert)); + } + + public static void UpdateNumber(long id, int number) + { + const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/OrderDetailRpc/UpdateOrderProperty"; + RpcFacade.Call(method, id, "PlanNumber", number); + } + + public static void UpdateHurryFlag(long id, bool flag) + { + const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/OrderDetailRpc/UpdateOrderProperty"; + RpcFacade.Call(method, id, "IsHurryButcher", flag); + } + + public static void Delete(List> update, long id) + { + const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/OrderDetailRpc/Delete"; + RpcFacade.Call(method, serializer.Serialize(update), id); + } + } +} diff --git a/ButcherManageClient/Program.cs b/ButcherManageClient/Program.cs index 306f178..f2421d2 100644 --- a/ButcherManageClient/Program.cs +++ b/ButcherManageClient/Program.cs @@ -40,12 +40,9 @@ 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 + //MessageBox.Show("错误:" + e.Message ); } } @@ -63,12 +60,8 @@ namespace ButcherManageClient //LogUtil.WriteError(ex); err = ex.Message; } - #if debug MessageBox.Show("错误:" + ex.Message + " \n详细信息:" + ex.StackTrace); -#endif - #if !debug - MessageBox.Show("错误:" + err); -#endif + // MessageBox.Show("错误:" + err); } private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) @@ -80,12 +73,8 @@ namespace ButcherManageClient //LogUtil.WriteError(ex); err = ex.Message; } -#if debug MessageBox.Show("错误:" + ex.Message + " \n详细信息:" + ex.StackTrace); -#endif -#if !debug - MessageBox.Show("错误:" + err); -#endif + //MessageBox.Show("错误:" + err); } } } diff --git a/ButcherWeight/WeightForm.cs b/ButcherWeight/WeightForm.cs index aac9277..8af14b6 100644 --- a/ButcherWeight/WeightForm.cs +++ b/ButcherWeight/WeightForm.cs @@ -94,7 +94,7 @@ namespace ButcherWeight { this.Invoke(new InvokeHandler(delegate() { - BindWeightBill(); + billGrid.Refresh(); })); } var details = new List(); @@ -230,6 +230,7 @@ namespace ButcherWeight d = weightGrid.CurrentRow.DataBoundItem as WeightBill_Detail; d.MaoWeight = WeightValue; d.Weight = (d.MaoWeight ?? 0) - (d.PiWeight ?? 0); + weightGrid.DataSource = _details; weightGrid.Refresh(); WeightValue = null; } diff --git a/QualityAndOrder/QualityOrderForm.Designer.cs b/QualityAndOrder/QualityOrderForm.Designer.cs index adf0b57..534c571 100644 --- a/QualityAndOrder/QualityOrderForm.Designer.cs +++ b/QualityAndOrder/QualityOrderForm.Designer.cs @@ -79,24 +79,29 @@ this.testTimeInput = new BWP.WinFormControl.UDatePicker(); this.label20 = new System.Windows.Forms.Label(); this.tabPage2 = new System.Windows.Forms.TabPage(); + this.panel2 = new System.Windows.Forms.Panel(); this.tab2KeyPanel = new System.Windows.Forms.FlowLayoutPanel(); this.closeBtn2 = new System.Windows.Forms.Button(); this.label6 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.preOrderGrid = new BWP.WinFormControl.UDataGridView(); - this.P_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.P_WeightBill_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.P_B3ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.P_Supplier_Name = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.P_HouseNames = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.P_Number = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.P_AlreadyNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.P_LastNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.P_WeightTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.R_OKBtn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.P_WeighTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.R_OKBtn = new System.Windows.Forms.DataGridViewButtonColumn(); this.orderGrid = new BWP.WinFormControl.UDataGridView(); this.O_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.O_IsHurryButcher = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.O_WeightBill_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.O_Order = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.O_Number = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.O_HouseNames = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.O_B3WeighBill_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.O_PlanNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.O_LiveColonyHouse_Name = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.O_OKBtn = new System.Windows.Forms.DataGridViewButtonColumn(); this.O_HurryBtn = new System.Windows.Forms.DataGridViewButtonColumn(); this.tab2SyncBtn = new System.Windows.Forms.Button(); @@ -111,6 +116,7 @@ this.tabPage4.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.weightBillGrid)).BeginInit(); this.tabPage2.SuspendLayout(); + this.panel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.preOrderGrid)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.orderGrid)).BeginInit(); this.SuspendLayout(); @@ -125,7 +131,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, 831); + this.uTabControl1.Size = new System.Drawing.Size(1294, 831); this.uTabControl1.SizeMode = System.Windows.Forms.TabSizeMode.Fixed; this.uTabControl1.TabIndex = 0; // @@ -147,7 +153,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, 773); + this.tabPage1.Size = new System.Drawing.Size(1286, 773); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "验质分圈"; this.tabPage1.UseVisualStyleBackColor = true; @@ -548,7 +554,7 @@ // // tabPage2 // - this.tabPage2.Controls.Add(this.tab2KeyPanel); + this.tabPage2.Controls.Add(this.panel2); this.tabPage2.Controls.Add(this.closeBtn2); this.tabPage2.Controls.Add(this.label6); this.tabPage2.Controls.Add(this.label5); @@ -560,15 +566,23 @@ 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, 773); + this.tabPage2.Size = new System.Drawing.Size(1286, 773); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "排宰顺序"; this.tabPage2.UseVisualStyleBackColor = true; // + // panel2 + // + this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel2.Controls.Add(this.tab2KeyPanel); + this.panel2.Location = new System.Drawing.Point(25, 515); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(538, 241); + this.panel2.TabIndex = 44; + // // tab2KeyPanel // - this.tab2KeyPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tab2KeyPanel.Location = new System.Drawing.Point(25, 515); + this.tab2KeyPanel.Location = new System.Drawing.Point(38, 0); this.tab2KeyPanel.Name = "tab2KeyPanel"; this.tab2KeyPanel.Padding = new System.Windows.Forms.Padding(25, 0, 0, 0); this.tab2KeyPanel.Size = new System.Drawing.Size(452, 241); @@ -590,7 +604,7 @@ this.label6.AutoSize = true; this.label6.Font = new System.Drawing.Font("宋体", 15F); this.label6.ForeColor = System.Drawing.Color.Red; - this.label6.Location = new System.Drawing.Point(529, 61); + this.label6.Location = new System.Drawing.Point(587, 61); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(89, 20); this.label6.TabIndex = 39; @@ -626,33 +640,43 @@ this.preOrderGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle8; this.preOrderGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.preOrderGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.P_ID, + this.P_WeightBill_ID, + this.P_B3ID, this.P_Supplier_Name, this.P_HouseNames, this.P_Number, this.P_AlreadyNumber, this.P_LastNumber, - this.P_WeightTime, + this.P_WeighTime, this.R_OKBtn}); - this.preOrderGrid.Location = new System.Drawing.Point(533, 93); + this.preOrderGrid.Location = new System.Drawing.Point(591, 93); this.preOrderGrid.MultiSelect = false; 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; - this.preOrderGrid.RowTemplate.Height = 23; + this.preOrderGrid.RowTemplate.Height = 40; this.preOrderGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.preOrderGrid.Size = new System.Drawing.Size(714, 663); + this.preOrderGrid.Size = new System.Drawing.Size(683, 663); this.preOrderGrid.TabIndex = 38; + this.preOrderGrid.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.preOrderGrid_CellClick); + // + // P_WeightBill_ID + // + this.P_WeightBill_ID.DataPropertyName = "WeightBill_ID"; + this.P_WeightBill_ID.HeaderText = "WeightBill_ID"; + this.P_WeightBill_ID.Name = "P_WeightBill_ID"; + this.P_WeightBill_ID.ReadOnly = true; + this.P_WeightBill_ID.Visible = false; // - // P_ID + // P_B3ID // - this.P_ID.DataPropertyName = "ID"; - this.P_ID.HeaderText = "ID"; - this.P_ID.Name = "P_ID"; - this.P_ID.ReadOnly = true; - this.P_ID.Visible = false; + this.P_B3ID.DataPropertyName = "B3ID"; + this.P_B3ID.HeaderText = "磅单号"; + this.P_B3ID.Name = "P_B3ID"; + this.P_B3ID.ReadOnly = true; + this.P_B3ID.Width = 80; // // P_Supplier_Name // @@ -660,6 +684,7 @@ this.P_Supplier_Name.HeaderText = "供应商"; this.P_Supplier_Name.Name = "P_Supplier_Name"; this.P_Supplier_Name.ReadOnly = true; + this.P_Supplier_Name.Width = 80; // // P_HouseNames // @@ -667,42 +692,50 @@ this.P_HouseNames.HeaderText = "圈舍"; this.P_HouseNames.Name = "P_HouseNames"; this.P_HouseNames.ReadOnly = true; + this.P_HouseNames.Width = 95; // // P_Number // this.P_Number.DataPropertyName = "Number"; - this.P_Number.HeaderText = "过磅头数"; + this.P_Number.HeaderText = "总头数"; this.P_Number.Name = "P_Number"; this.P_Number.ReadOnly = true; - this.P_Number.Width = 95; + this.P_Number.Width = 80; // // P_AlreadyNumber // - this.P_AlreadyNumber.HeaderText = "已排头数"; + this.P_AlreadyNumber.DataPropertyName = "AlreadyNumber"; + this.P_AlreadyNumber.HeaderText = "已排"; this.P_AlreadyNumber.Name = "P_AlreadyNumber"; this.P_AlreadyNumber.ReadOnly = true; - this.P_AlreadyNumber.Width = 95; + this.P_AlreadyNumber.Width = 65; // // P_LastNumber // - this.P_LastNumber.HeaderText = "剩余头数"; + this.P_LastNumber.DataPropertyName = "LastNumber"; + this.P_LastNumber.HeaderText = "剩余"; this.P_LastNumber.Name = "P_LastNumber"; this.P_LastNumber.ReadOnly = true; - this.P_LastNumber.Width = 95; + this.P_LastNumber.Width = 65; // - // P_WeightTime + // P_WeighTime // - this.P_WeightTime.HeaderText = "过磅时间"; - this.P_WeightTime.Name = "P_WeightTime"; - this.P_WeightTime.ReadOnly = true; - this.P_WeightTime.Width = 130; + this.P_WeighTime.DataPropertyName = "WeighTime"; + this.P_WeighTime.HeaderText = "过磅时间"; + this.P_WeighTime.Name = "P_WeighTime"; + this.P_WeighTime.ReadOnly = true; + this.P_WeighTime.Width = 105; // // R_OKBtn // this.R_OKBtn.HeaderText = "排宰"; this.R_OKBtn.Name = "R_OKBtn"; this.R_OKBtn.ReadOnly = true; - this.R_OKBtn.Width = 90; + this.R_OKBtn.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.R_OKBtn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + this.R_OKBtn.Text = "排宰"; + this.R_OKBtn.UseColumnTextForButtonValue = true; + this.R_OKBtn.Width = 85; // // orderGrid // @@ -724,62 +757,99 @@ this.orderGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.orderGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.O_ID, + this.O_IsHurryButcher, + this.O_WeightBill_ID, this.O_Order, - this.O_Number, - this.O_HouseNames, + this.O_B3WeighBill_ID, + this.O_PlanNumber, + this.O_LiveColonyHouse_Name, this.O_OKBtn, this.O_HurryBtn}); this.orderGrid.Location = new System.Drawing.Point(25, 93); this.orderGrid.MultiSelect = false; this.orderGrid.Name = "orderGrid"; + this.orderGrid.ReadOnly = true; this.orderGrid.RowHeadersVisible = false; 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.RowTemplate.Height = 40; this.orderGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.orderGrid.Size = new System.Drawing.Size(454, 387); + this.orderGrid.Size = new System.Drawing.Size(540, 397); this.orderGrid.TabIndex = 38; + this.orderGrid.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.orderGrid_CellClick); // // O_ID // this.O_ID.DataPropertyName = "ID"; this.O_ID.HeaderText = "ID"; this.O_ID.Name = "O_ID"; + this.O_ID.ReadOnly = true; this.O_ID.Visible = false; // + // O_IsHurryButcher + // + this.O_IsHurryButcher.DataPropertyName = "IsHurryButcher"; + this.O_IsHurryButcher.HeaderText = "IsHurryButcher"; + this.O_IsHurryButcher.Name = "O_IsHurryButcher"; + this.O_IsHurryButcher.ReadOnly = true; + this.O_IsHurryButcher.Visible = false; + // + // O_WeightBill_ID + // + this.O_WeightBill_ID.DataPropertyName = "WeightBill_ID"; + this.O_WeightBill_ID.HeaderText = "WeightBill_ID"; + this.O_WeightBill_ID.Name = "O_WeightBill_ID"; + this.O_WeightBill_ID.ReadOnly = true; + this.O_WeightBill_ID.Visible = false; + // // O_Order // this.O_Order.DataPropertyName = "Order"; - this.O_Order.HeaderText = "屠宰顺序"; + this.O_Order.HeaderText = "序号"; this.O_Order.Name = "O_Order"; this.O_Order.ReadOnly = true; - this.O_Order.Width = 95; + this.O_Order.Width = 70; + // + // O_B3WeighBill_ID // - // O_Number + this.O_B3WeighBill_ID.DataPropertyName = "B3WeighBill_ID"; + this.O_B3WeighBill_ID.HeaderText = "磅单号"; + this.O_B3WeighBill_ID.Name = "O_B3WeighBill_ID"; + this.O_B3WeighBill_ID.ReadOnly = true; + this.O_B3WeighBill_ID.Width = 80; // - this.O_Number.DataPropertyName = "Number"; - this.O_Number.HeaderText = "头数"; - this.O_Number.Name = "O_Number"; - this.O_Number.Width = 70; + // O_PlanNumber // - // O_HouseNames + this.O_PlanNumber.DataPropertyName = "PlanNumber"; + this.O_PlanNumber.HeaderText = "头数"; + this.O_PlanNumber.Name = "O_PlanNumber"; + this.O_PlanNumber.ReadOnly = true; + this.O_PlanNumber.Width = 70; // - this.O_HouseNames.DataPropertyName = "HouseNames"; - this.O_HouseNames.HeaderText = "圈舍"; - this.O_HouseNames.Name = "O_HouseNames"; - this.O_HouseNames.ReadOnly = true; + // O_LiveColonyHouse_Name + // + this.O_LiveColonyHouse_Name.DataPropertyName = "LiveColonyHouse_Name"; + this.O_LiveColonyHouse_Name.HeaderText = "圈舍"; + this.O_LiveColonyHouse_Name.Name = "O_LiveColonyHouse_Name"; + this.O_LiveColonyHouse_Name.ReadOnly = true; // // O_OKBtn // this.O_OKBtn.HeaderText = "确定"; this.O_OKBtn.Name = "O_OKBtn"; - this.O_OKBtn.Width = 90; + this.O_OKBtn.ReadOnly = true; + this.O_OKBtn.Text = "确定"; + this.O_OKBtn.UseColumnTextForButtonValue = true; + this.O_OKBtn.Width = 95; // // O_HurryBtn // this.O_HurryBtn.HeaderText = "急宰"; this.O_HurryBtn.Name = "O_HurryBtn"; - this.O_HurryBtn.Width = 90; + this.O_HurryBtn.ReadOnly = true; + this.O_HurryBtn.Text = "急宰"; + this.O_HurryBtn.UseColumnTextForButtonValue = true; + this.O_HurryBtn.Width = 95; // // tab2SyncBtn // @@ -790,6 +860,7 @@ this.tab2SyncBtn.TabIndex = 37; this.tab2SyncBtn.Text = "同步"; this.tab2SyncBtn.UseVisualStyleBackColor = true; + this.tab2SyncBtn.Click += new System.EventHandler(this.tab2SyncBtn_Click); // // tab2DateSelect // @@ -819,7 +890,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1276, 831); + this.ClientSize = new System.Drawing.Size(1294, 831); this.Controls.Add(this.uTabControl1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.MaximizeBox = false; @@ -837,6 +908,7 @@ ((System.ComponentModel.ISupportInitialize)(this.weightBillGrid)).EndInit(); this.tabPage2.ResumeLayout(false); this.tabPage2.PerformLayout(); + this.panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.preOrderGrid)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.orderGrid)).EndInit(); this.ResumeLayout(false); @@ -870,20 +942,6 @@ private BWP.WinFormControl.UDataGridView preOrderGrid; private System.Windows.Forms.FlowLayoutPanel tab2KeyPanel; private System.Windows.Forms.Button closeBtn2; - private System.Windows.Forms.DataGridViewTextBoxColumn P_ID; - private System.Windows.Forms.DataGridViewTextBoxColumn P_Supplier_Name; - private System.Windows.Forms.DataGridViewTextBoxColumn P_HouseNames; - private System.Windows.Forms.DataGridViewTextBoxColumn P_Number; - private System.Windows.Forms.DataGridViewTextBoxColumn P_AlreadyNumber; - private System.Windows.Forms.DataGridViewTextBoxColumn P_LastNumber; - private System.Windows.Forms.DataGridViewTextBoxColumn P_WeightTime; - private System.Windows.Forms.DataGridViewTextBoxColumn R_OKBtn; - private System.Windows.Forms.DataGridViewTextBoxColumn O_ID; - private System.Windows.Forms.DataGridViewTextBoxColumn O_Order; - private System.Windows.Forms.DataGridViewTextBoxColumn O_Number; - private System.Windows.Forms.DataGridViewTextBoxColumn O_HouseNames; - private System.Windows.Forms.DataGridViewButtonColumn O_OKBtn; - private System.Windows.Forms.DataGridViewButtonColumn O_HurryBtn; private System.Windows.Forms.Panel panel1; private BWP.WinFormControl.UTabControl uTabControl2; private System.Windows.Forms.TabPage tabPage3; @@ -907,6 +965,25 @@ private System.Windows.Forms.DataGridViewTextBoxColumn W_Supplier_Name; private System.Windows.Forms.DataGridViewTextBoxColumn W_FirstWeightNumber; private System.Windows.Forms.DataGridViewTextBoxColumn W_HouseNames; + private System.Windows.Forms.DataGridViewTextBoxColumn O_ID; + private System.Windows.Forms.DataGridViewTextBoxColumn O_IsHurryButcher; + private System.Windows.Forms.DataGridViewTextBoxColumn O_WeightBill_ID; + private System.Windows.Forms.DataGridViewTextBoxColumn O_Order; + private System.Windows.Forms.DataGridViewTextBoxColumn O_B3WeighBill_ID; + private System.Windows.Forms.DataGridViewTextBoxColumn O_PlanNumber; + private System.Windows.Forms.DataGridViewTextBoxColumn O_LiveColonyHouse_Name; + private System.Windows.Forms.DataGridViewButtonColumn O_OKBtn; + private System.Windows.Forms.DataGridViewButtonColumn O_HurryBtn; + private System.Windows.Forms.DataGridViewTextBoxColumn P_WeightBill_ID; + private System.Windows.Forms.DataGridViewTextBoxColumn P_B3ID; + private System.Windows.Forms.DataGridViewTextBoxColumn P_Supplier_Name; + private System.Windows.Forms.DataGridViewTextBoxColumn P_HouseNames; + private System.Windows.Forms.DataGridViewTextBoxColumn P_Number; + private System.Windows.Forms.DataGridViewTextBoxColumn P_AlreadyNumber; + private System.Windows.Forms.DataGridViewTextBoxColumn P_LastNumber; + private System.Windows.Forms.DataGridViewTextBoxColumn P_WeighTime; + private System.Windows.Forms.DataGridViewButtonColumn R_OKBtn; + private System.Windows.Forms.Panel panel2; diff --git a/QualityAndOrder/QualityOrderForm.cs b/QualityAndOrder/QualityOrderForm.cs index 9d936ad..0c85772 100644 --- a/QualityAndOrder/QualityOrderForm.cs +++ b/QualityAndOrder/QualityOrderForm.cs @@ -45,7 +45,7 @@ namespace QualityAndOrder { InitializeComponent(); Control.CheckForIllegalCrossThreadCalls = false; - testTimeInput.Date = tab2DateSelect.Date = DateTime.Today; + testTimeInput.Date = DateTime.Today; syncBtn.Focus(); this.uTabControl1.Selected += (sender, e) => { @@ -63,16 +63,19 @@ namespace QualityAndOrder AddHouseBtn(); - AddKeyPadForTab2(); - numberBox.LostFocus += (sender, e) => { flag = 1; }; sanctionGrid.GotFocus += (sender, e) => { flag = 2; }; syncThread = new Thread(SyncTask) { IsBackground = true }; - this.FormClosing += delegate { + this.FormClosing += delegate + { if (syncThread.IsAlive) syncThread.Abort(); + if (tb2SyncThread != null && tb2SyncThread.IsAlive) + tb2SyncThread.Abort(); }; syncThread.Start(); + + Tab2Init(); } private void SyncTask() diff --git a/QualityAndOrder/QualityOrderForm.resx b/QualityAndOrder/QualityOrderForm.resx index 24b4399..2f3175a 100644 --- a/QualityAndOrder/QualityOrderForm.resx +++ b/QualityAndOrder/QualityOrderForm.resx @@ -117,24 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - True - - - True - - - True - - - True - - - True - - - True - True @@ -171,39 +153,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True @@ -222,34 +171,10 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - + True - + True @@ -267,43 +192,37 @@ True - + True True - - True - True - + True - + True - + True - + True - + True - + True - - True - - + True - + True \ No newline at end of file diff --git a/QualityAndOrder/QualityOrderFormForTab2.cs b/QualityAndOrder/QualityOrderFormForTab2.cs index d500e9a..4d65c49 100644 --- a/QualityAndOrder/QualityOrderFormForTab2.cs +++ b/QualityAndOrder/QualityOrderFormForTab2.cs @@ -1,8 +1,12 @@ -using System; +using BO; +using BO.BO.Bill; +using BO.Utils.BillRpc; +using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; @@ -10,6 +14,21 @@ namespace QualityAndOrder { partial class QualityOrderForm { + List needOrderList; + List orderList; + Thread tb2SyncThread; + + void Tab2Init() + { + tab2DateSelect.Date = DateTime.Today; + + orderGrid.AutoGenerateColumns = false; + preOrderGrid.AutoGenerateColumns = false; + orderGrid.DataSource = null; + preOrderGrid.DataSource = null; + + AddKeyPadForTab2(); + } private void AddKeyPadForTab2() { @@ -18,32 +37,208 @@ namespace QualityAndOrder var btn = new Button() { Name = "_2" + i, Text = i.ToString(), Size = new Size(80, 60), TextAlign = ContentAlignment.MiddleCenter, Margin = new Padding { All = 10 }, Font = new Font("宋体", 15) }; btn.Click += (sender, e) => { - //numberBox.Text += btn.Text; + InputPlanNumber(btn.Text); }; tab2KeyPanel.Controls.Add(btn); } var zero = new Button() { Name = "_20", Text = "0", Size = new Size(80, 60), TextAlign = ContentAlignment.MiddleCenter, Margin = new Padding { All = 10 }, Font = new Font("宋体", 15) }; zero.Click += (sender, e) => { - //if (!string.IsNullOrEmpty(numberBox.Text)) - // numberBox.Text += "0"; + InputPlanNumber(zero.Text); }; tab2KeyPanel.Controls.Add(zero); var back = new Button() { Name = "_2back", Text = "←", Size = new Size(80, 60), TextAlign = ContentAlignment.MiddleCenter, Margin = new Padding { All = 10 }, Font = new Font("宋体", 15) }; back.Click += (sender, e) => { - //if (!string.IsNullOrEmpty(numberBox.Text)) - // numberBox.Text = numberBox.Text.Substring(0, numberBox.Text.Length - 1); + InputPlanNumber(back.Text); }; tab2KeyPanel.Controls.Add(back); var clear = new Button() { Name = "_2clear", Text = "清空", Size = new Size(80, 60), TextAlign = ContentAlignment.MiddleCenter, Margin = new Padding { All = 10 }, Font = new Font("宋体", 15) }; clear.Click += (sender, e) => { - //numberBox.Text = null; + InputPlanNumber(clear.Text); }; tab2KeyPanel.Controls.Add(clear); } + + void InputPlanNumber(string input) + { + if (orderGrid.CurrentCell == null) + throw new Exception("请选择一条排宰明细"); + var tag = orderGrid.CurrentRow.DataBoundItem as OrderDetail; + tag.PlanNumber = GetAfterNumber(tag.PlanNumber, input) ?? 0; + orderGrid.Refresh(); + } + + private void tab2SyncBtn_Click(object sender, EventArgs e) + { + needOrderList = OrderDetailRpc.GetNeedOrderWeightBill(tab2DateSelect.Date.Value); + BindPreOrderGrid(); + orderList = OrderDetailRpc.GetOrderDetail(tab2DateSelect.Date.Value); + BindOrderGrid(); + if (tb2SyncThread == null) + { + tb2SyncThread = new Thread(Tab2SyncB3ID) { IsBackground = true }; + tb2SyncThread.Start(); + } + } + + private void Tab2SyncB3ID() + { + while (true) + { + bool orderChange = false; + bool needListChange = false; + var ids = orderList.Where(x => x.B3WeighBill_ID == null).Select(x => (long?)x.WeightBill_ID).Distinct().ToList(); + var needOrderIds = needOrderList.Where(x => x.B3ID == null).Select(x => (long?)x.WeightBill_ID); + ids.AddRange(needOrderIds.Except(ids)); + if (ids.Any()) + { + var result = WeightBillRpc.SyncBillB3Ids(ids); + foreach (var item in result) + { + var left = orderList.Where(x => x.WeightBill_ID == item.Item1); + foreach (var lEntity in left) + { + lEntity.B3WeighBill_ID = item.Item2; + if (!orderChange) + orderChange = true; + } + + var rFirst = needOrderList.FirstOrDefault(x => x.WeightBill_ID == item.Item1); + if (rFirst != null) + { + rFirst.B3ID = item.Item2; + if (!needListChange) + needListChange = true; + } + } + } + if (orderChange) + { + this.Invoke(new InvokeHandler(delegate() + { + orderGrid.Refresh(); + })); + } + if (needListChange) + { + this.Invoke(new InvokeHandler(delegate() + { + preOrderGrid.Refresh(); + })); + } + Thread.Sleep(2000); + } + } + + void BindPreOrderGrid() + { + preOrderGrid.DataSource = needOrderList.OrderBy(x => x.WeighTime).ToList(); + preOrderGrid.Refresh(); + } + + void BindOrderGrid() + { + orderGrid.DataSource = orderList.OrderByDescending(x => x.Order).ToList(); + foreach (DataGridViewRow row in orderGrid.Rows) + { + if ((bool)row.Cells["O_IsHurryButcher"].Value) + row.DefaultCellStyle.BackColor = Color.YellowGreen; + } + orderGrid.Refresh(); + } + + private void preOrderGrid_CellClick(object sender, DataGridViewCellEventArgs e) + { + if (e.RowIndex == -1) + return; + if (e.ColumnIndex != preOrderGrid.ColumnCount - 1) + return; + var currentOrder = 0; + if (orderGrid.CurrentRow != null) + currentOrder = (int)orderGrid.CurrentRow.Cells["O_Order"].Value + 1; + else + currentOrder = OrderDetailRpc.GetMaxOrder(tab2DateSelect.Date.Value); + var entity = preOrderGrid.CurrentRow.DataBoundItem as NeedOrderEntity; + var order = new OrderDetail(); + order.Order = currentOrder; + order.LiveColonyHouse_Name = entity.HouseNames; + order.PlanNumber = entity.LastNumber; + order.WeightBill_ID = entity.WeightBill_ID; + order.B3WeighBill_ID = entity.B3ID; + var needUpdate = ReOrder(order, true); + orderList.Add(order); + order.Date = entity.WeighTime.Date; + OrderDetailRpc.Insert(needUpdate, order); + BindOrderGrid(); + needOrderList.Remove(entity); + BindPreOrderGrid(); + } + + private void orderGrid_CellClick(object sender, DataGridViewCellEventArgs e) + { + if (e.RowIndex == -1) + return; + if (e.ColumnIndex < orderGrid.ColumnCount - 2) + return; + var entity = orderGrid.CurrentRow.DataBoundItem as OrderDetail; + if (e.ColumnIndex == orderGrid.ColumnCount - 2)//确定 + { + if (entity.PlanNumber < 0) + throw new Exception("排宰头数不能小于0"); + var backInfo = OrderDetailRpc.GetBackWeightBillInfo(entity.WeightBill_ID, entity.ID); + + if (entity.PlanNumber > backInfo.LastNumber) + throw new Exception("排宰总头数多余过磅头数"); + var item = needOrderList.FirstOrDefault(x => x.WeightBill_ID == backInfo.WeightBill_ID); + if (entity.PlanNumber == backInfo.LastNumber) + return; + if (item == null) + { + item = new NeedOrderEntity(); + needOrderList.Add(item); + item.WeightBill_ID = backInfo.WeightBill_ID; + item.Supplier_Name = backInfo.Supplier_Name; + item.HouseNames = backInfo.HouseNames; + item.Number = backInfo.Number; + item.AlreadyNumber = backInfo.AlreadyNumber; + item.WeighTime = backInfo.WeighTime; + item.B3ID = entity.B3WeighBill_ID; + } + if (entity.PlanNumber == 0) + { + orderList.Remove(entity); + var list = ReOrder(entity, false); + OrderDetailRpc.Delete(list, entity.ID); + } + else + OrderDetailRpc.UpdateNumber(entity.ID, entity.PlanNumber); + item.AlreadyNumber = backInfo.AlreadyNumber + entity.PlanNumber; + BindOrderGrid(); + BindPreOrderGrid(); + } + else if ((e.ColumnIndex == orderGrid.ColumnCount - 1))//急宰 + { + entity.IsHurryButcher = !entity.IsHurryButcher; + OrderDetailRpc.UpdateHurryFlag(entity.ID, entity.IsHurryButcher); + BindOrderGrid(); + } + } + + List> ReOrder(OrderDetail dealDetail, bool isAdd) + { + var result = new List>(); + foreach (var item in orderList.OrderByDescending(x => x.Order)) + { + if (item.Order < dealDetail.Order) + break; + item.Order += isAdd ? 1 : -1; + result.Add(new CTuple(item.ID, item.Order)); + } + return result; + } } }