diff --git a/BO/BO.csproj b/BO/BO.csproj index d0750cf..4ccb602 100644 --- a/BO/BO.csproj +++ b/BO/BO.csproj @@ -17,7 +17,7 @@ full false bin\Debug\ - DEBUG;TRACE + TRACE prompt 4 diff --git a/BO/BO/Bill/SecondOrder/SecondOrder.cs b/BO/BO/Bill/SecondOrder/SecondOrder.cs index 8306637..1381db1 100644 --- a/BO/BO/Bill/SecondOrder/SecondOrder.cs +++ b/BO/BO/Bill/SecondOrder/SecondOrder.cs @@ -18,5 +18,7 @@ namespace BO.BO.Bill public int HotFadeNumber { get; set; } public bool IsOk { get; set; } + + public bool Finish { get; set; } } } diff --git a/BO/Utils/AfterLoginUtil.cs b/BO/Utils/AfterLoginUtil.cs index f513b47..962db47 100644 --- a/BO/Utils/AfterLoginUtil.cs +++ b/BO/Utils/AfterLoginUtil.cs @@ -18,16 +18,14 @@ namespace BO.Utils public static class AfterLoginUtil { -//#if debug + // static List> roleToAssemblies = new List>(){new Tuple("排宰员",@"C:\BwpB3Project\src\B3ButcherManageClient\ButcherOrder\bin\Debug\ButcherOrder"), //new Tuple("过磅员",@"C:\BwpB3Project\src\B3ButcherManageClient\ButcherWeight\bin\Debug\ButcherWeight"), // new Tuple("验质员",@"C:\BwpB3Project\src\B3ButcherManageClient\QualityAndOrder\bin\Debug\QualityAndOrder"),new Tuple("定级员",@"C:\BwpB3Project\src\B3ButcherManageClient\WeighAndGrading\bin\Debug\WeighAndGrading")}; -//#endif -//#if !debug + static List> roleToAssemblies = new List>(){new Tuple("排宰员",@"ButcherOrder"), new Tuple("过磅员",@"ButcherWeight"), new Tuple("验质员",@"QualityAndOrder"),new Tuple("定级员",@"WeighAndGrading")}; -//#endif public static Form CreateForm(string role) diff --git a/BO/Utils/BillRpc/SecondOrderRpc.cs b/BO/Utils/BillRpc/SecondOrderRpc.cs index 97cd00a..78a19c9 100644 --- a/BO/Utils/BillRpc/SecondOrderRpc.cs +++ b/BO/Utils/BillRpc/SecondOrderRpc.cs @@ -35,9 +35,9 @@ namespace BO.Utils.BillRpc RpcFacade.Call(method, detail.ID, detail.SecondOrder_ID, detail.Number); } - public static void SetOk(long id, SecondOrder order) + public static void SetFinish(long id, SecondOrder order) { - const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/SecondOrderRpc/SetOk"; + const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/SecondOrderRpc/SetFinish"; string mJson = string.Empty; if (id == 0) mJson = serializer.Serialize(order); diff --git a/ButcherManageClient/Login.cs b/ButcherManageClient/Login.cs index ed50240..47a1fe3 100644 --- a/ButcherManageClient/Login.cs +++ b/ButcherManageClient/Login.cs @@ -122,7 +122,9 @@ namespace ButcherManageClient private void Login_Load(object sender, EventArgs e) { - AutoUpdate(); +//# if relase +// // AutoUpdate(); +//#endif } } } diff --git a/ButcherOrder/ButcherOrderForm.Designer.cs b/ButcherOrder/ButcherOrderForm.Designer.cs index 8481133..897b342 100644 --- a/ButcherOrder/ButcherOrderForm.Designer.cs +++ b/ButcherOrder/ButcherOrderForm.Designer.cs @@ -48,6 +48,7 @@ this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.OrderDetail_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.IsOk = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Finish = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Order = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.PlanNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.HotFadeNumber = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -175,6 +176,7 @@ this.ID, this.OrderDetail_ID, this.IsOk, + this.Finish, this.Order, this.PlanNumber, this.HotFadeNumber, @@ -186,7 +188,9 @@ this.secondOrderGridView.ReadOnly = true; this.secondOrderGridView.RowHeadersVisible = false; dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle5.ForeColor = System.Drawing.Color.Black; dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.Black; this.secondOrderGridView.RowsDefaultCellStyle = dataGridViewCellStyle5; this.secondOrderGridView.RowTemplate.Height = 60; this.secondOrderGridView.ScrollBars = System.Windows.Forms.ScrollBars.None; @@ -234,6 +238,14 @@ this.IsOk.ReadOnly = true; this.IsOk.Visible = false; // + // Finish + // + this.Finish.DataPropertyName = "Finish"; + this.Finish.HeaderText = "Finish"; + this.Finish.Name = "Finish"; + this.Finish.ReadOnly = true; + this.Finish.Visible = false; + // // Order // this.Order.DataPropertyName = "Order"; @@ -261,10 +273,10 @@ dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle3.Padding = new System.Windows.Forms.Padding(5, 10, 5, 10); this.updateBtn.DefaultCellStyle = dataGridViewCellStyle3; - this.updateBtn.HeaderText = "更新"; + this.updateBtn.HeaderText = "完毕"; this.updateBtn.Name = "updateBtn"; this.updateBtn.ReadOnly = true; - this.updateBtn.Text = "更新"; + this.updateBtn.Text = "完毕"; this.updateBtn.UseColumnTextForButtonValue = true; // // viewBtn @@ -323,6 +335,7 @@ private System.Windows.Forms.DataGridViewTextBoxColumn ID; private System.Windows.Forms.DataGridViewTextBoxColumn OrderDetail_ID; private System.Windows.Forms.DataGridViewTextBoxColumn IsOk; + private System.Windows.Forms.DataGridViewTextBoxColumn Finish; private System.Windows.Forms.DataGridViewTextBoxColumn Order; private System.Windows.Forms.DataGridViewTextBoxColumn PlanNumber; private System.Windows.Forms.DataGridViewTextBoxColumn HotFadeNumber; diff --git a/ButcherOrder/ButcherOrderForm.cs b/ButcherOrder/ButcherOrderForm.cs index f2bf0db..38af514 100644 --- a/ButcherOrder/ButcherOrderForm.cs +++ b/ButcherOrder/ButcherOrderForm.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using System.Linq; +using System.Threading; namespace ButcherOrder { @@ -26,8 +27,9 @@ namespace ButcherOrder } # endregion + private delegate void InvokeHandler(); List orderList; - + Thread syncWork; public ButcherOrderForm() { InitializeComponent(); @@ -35,6 +37,11 @@ namespace ButcherOrder secondOrderGridView.AutoGenerateColumns = false; secondOrderGridView.DataSource = null; AddKeyPad(); + this.FormClosing += delegate + { + if (syncWork != null && syncWork.IsAlive) + syncWork.Abort(); + }; } private void AddKeyPad() @@ -78,72 +85,101 @@ namespace ButcherOrder private void syncBtn_Click(object sender, EventArgs e) { - orderList = SecondOrderRpc.GetSecondOrderList(this.uDatePicker1.Date.Value); - BindGrid(); + if (syncWork == null || !syncWork.IsAlive) + { + syncWork = new Thread(Sync); + syncWork.Start(); + syncBtn.BackColor = Color.FromArgb(15, 215, 107); + syncBtn.ForeColor = Color.White; + } + else + { + syncWork.Abort(); + syncBtn.BackColor = Color.FromKnownColor(KnownColor.Control); + syncBtn.ForeColor = Color.FromKnownColor(KnownColor.ControlText); + } + } + + void Sync() + { + while (true) + { + this.Invoke(new InvokeHandler(delegate() + { + orderList = SecondOrderRpc.GetSecondOrderList(this.uDatePicker1.Date.Value); + BindGrid(); + })); + Thread.Sleep(5000); + } } - int? lastSelectOrder = null; + SecondOrder last; void BindGrid() { - secondOrderGridView.DataSource = orderList.OrderBy(x => x.Order).OrderBy(x => x.IsOk).ToList(); - foreach (DataGridViewRow row in secondOrderGridView.Rows) + secondOrderGridView.DataSource = orderList.OrderBy(x => x.Order).OrderBy(x => x.Finish).ToList(); + if (last == null && secondOrderGridView.CurrentRow != null) { - if ((bool)row.Cells["IsOk"].Value) - row.DefaultCellStyle.BackColor = Color.YellowGreen; - if (lastSelectOrder.HasValue && lastSelectOrder == (int?)row.Cells["Order"].Value) + last = secondOrderGridView.CurrentRow.DataBoundItem as SecondOrder; + if (last.Finish) { - row.Selected = true; + last = null; + secondOrderGridView.CurrentRow.DefaultCellStyle.BackColor = Color.YellowGreen; } } - if (secondOrderGridView.CurrentRow != null) + foreach (DataGridViewRow row in secondOrderGridView.Rows) { - var entity = secondOrderGridView.CurrentRow.DataBoundItem as SecondOrder; - if (!entity.IsOk) - orderLabel.Text = entity.Order.ToString(); - BindSelectColor(entity); + if ((bool)row.Cells["Finish"].Value) + row.DefaultCellStyle.BackColor = Color.YellowGreen; + if (last != null && last.Order == (int)row.Cells["Order"].Value) + { + last = row.DataBoundItem as SecondOrder; + if (last.Finish) + row.DefaultCellStyle.BackColor = Color.Yellow; + else + row.DefaultCellStyle.BackColor = secondOrderGridView.RowsDefaultCellStyle.SelectionBackColor; + } } + if (last != null && !last.Finish) + orderLabel.Text = last.Order.ToString(); else orderLabel.Text = "0"; InitScrollBar1(); - secondOrderGridView.Refresh(); - if (roll != -1) + secondOrderGridView.ClearSelection(); + try + { + if (roll != -1) + secondOrderGridView.FirstDisplayedScrollingRowIndex = roll; + } + catch { - secondOrderGridView.FirstDisplayedScrollingRowIndex = roll;// secondOrderGridView.Rows[roll].Index; + roll = -1; } + secondOrderGridView.Refresh(); } private void okBtn_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(numberInput.Text)) return; - if (secondOrderGridView.CurrentRow == null) + if (last == null) throw new Exception("请先同步数据"); - var entity = secondOrderGridView.CurrentRow.DataBoundItem as SecondOrder; - if (entity.IsOk) + if (last.Finish) { var result = MessageBox.Show("当前行已更新\n确定要继续修改吗?", "确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result != DialogResult.OK) return; } var number = int.Parse(numberInput.Text); - if (entity.HotFadeNumber + number > entity.PlanNumber) + if (last.HotFadeNumber + number > last.PlanNumber) throw new Exception("烫褪头数多余总头数,请确认!"); - var detail = new SecondOrder_Detail() { Number = number, SecondOrder_ID = entity.ID, Time = DateTime.Now }; - entity.HotFadeNumber += detail.Number; - SecondOrderRpc.Insert(detail, entity); + var detail = new SecondOrder_Detail() { Number = number, SecondOrder_ID = last.ID, Time = DateTime.Now }; + last.HotFadeNumber += detail.Number; + SecondOrderRpc.Insert(detail, last); secondOrderGridView.Refresh(); numberInput.Text = string.Empty; } - void BindSelectColor(SecondOrder entity) - { - if (entity.IsOk) - secondOrderGridView.RowsDefaultCellStyle.SelectionBackColor = Color.FromArgb(204, 51, 51); - else - secondOrderGridView.RowsDefaultCellStyle.SelectionBackColor = Color.FromArgb(66, 163, 218); - } - private void secondOrderGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) @@ -154,13 +190,13 @@ namespace ButcherOrder return; if (e.ColumnIndex == secondOrderGridView.ColumnCount - 2)//更新 { - if (entity.IsOk) + if (entity.Finish) return; - entity.IsOk = true; - SecondOrderRpc.SetOk(entity.ID, entity); + entity.Finish = true; + SecondOrderRpc.SetFinish(entity.ID, entity); BindGrid(); } - else if ((e.ColumnIndex == secondOrderGridView.ColumnCount - 1))//查看 + else//查看 { var view = new ViewDetail(entity); if (view.ShowDialog() == DialogResult.OK) @@ -189,8 +225,28 @@ namespace ButcherOrder if (e.RowIndex == -1) return; var entity = secondOrderGridView.CurrentRow.DataBoundItem as SecondOrder; - lastSelectOrder = entity.Order; - BindSelectColor(entity); + if (e.ColumnIndex != secondOrderGridView.Columns.Count - 2)//非更新列 + { + if (last != null) + { + foreach (DataGridViewRow row in secondOrderGridView.Rows) + { + if (last.Order == (int)row.Cells["Order"].Value) + { + row.DefaultCellStyle.BackColor = last.Finish ? Color.YellowGreen : secondOrderGridView.RowsDefaultCellStyle.BackColor; + break; + } + } + } + last = entity; + secondOrderGridView.CurrentRow.DefaultCellStyle.SelectionBackColor = last.Finish ? Color.Yellow : secondOrderGridView.RowsDefaultCellStyle.SelectionBackColor; + } + else//更新列 + { + secondOrderGridView.CurrentRow.DefaultCellStyle.SelectionBackColor = last.Finish ? Color.YellowGreen : secondOrderGridView.RowsDefaultCellStyle.BackColor; + last = null; + } + secondOrderGridView.Refresh(); } } } diff --git a/ButcherOrder/ButcherOrderForm.resx b/ButcherOrder/ButcherOrderForm.resx index 15107e7..59976d9 100644 --- a/ButcherOrder/ButcherOrderForm.resx +++ b/ButcherOrder/ButcherOrderForm.resx @@ -126,6 +126,9 @@ True + + True + True diff --git a/ButcherWeight/WeightContext.cs b/ButcherWeight/WeightContext.cs index 9632092..f183274 100644 --- a/ButcherWeight/WeightContext.cs +++ b/ButcherWeight/WeightContext.cs @@ -12,10 +12,10 @@ namespace ButcherWeight public static class WeightContext { //#if debug - private static string loginConfigPath = @"C:\BwpB3Project\src\B3ButcherManageClient\ButcherManageClient\bin\Debug\WeightSetting.xml"; + // private static string loginConfigPath = @"C:\BwpB3Project\src\B3ButcherManageClient\ButcherManageClient\bin\Debug\WeightSetting.xml"; //#endif //#if !debug - //private static string loginConfigPath = Application.StartupPath + "\\WeightSetting.xml"; + private static string loginConfigPath = Application.StartupPath + "\\WeightSetting.xml"; //#endif private static WeightSetting _config; public static WeightSetting Config diff --git a/ButcherWeight/WeightForm.Designer.cs b/ButcherWeight/WeightForm.Designer.cs index 0101dc2..8b457d8 100644 --- a/ButcherWeight/WeightForm.Designer.cs +++ b/ButcherWeight/WeightForm.Designer.cs @@ -33,6 +33,7 @@ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = 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 dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); @@ -49,7 +50,6 @@ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle20 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle19 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = 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(); @@ -100,6 +100,13 @@ this.panel3 = new System.Windows.Forms.Panel(); this.farmerSelect = new BWP.WinFormControl.UComboBox(); this.farmerGrid = new System.Windows.Forms.DataGridView(); + this.F_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.F_WeightBill_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.F_Farmer_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.F_Index = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.F_Farmer_Name = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.F_Number = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.F_Weight = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.label3 = new System.Windows.Forms.Label(); this.label18 = new System.Windows.Forms.Label(); this.weightGrid = new System.Windows.Forms.DataGridView(); @@ -153,13 +160,6 @@ this.farmerMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.farmerDelete = new System.Windows.Forms.ToolStripMenuItem(); this.viewDetailBtn = new System.Windows.Forms.Button(); - this.F_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.F_WeightBill_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.F_Farmer_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.F_Index = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.F_Farmer_Name = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.F_Number = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.F_Weight = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.panel1.SuspendLayout(); this.panel2.SuspendLayout(); this.panel3.SuspendLayout(); @@ -793,6 +793,58 @@ this.farmerGrid.TabIndex = 8; this.farmerGrid.CellMouseDown += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.farmerGrid_CellMouseDown); // + // F_ID + // + this.F_ID.DataPropertyName = "ID"; + this.F_ID.HeaderText = "ID"; + this.F_ID.Name = "F_ID"; + this.F_ID.Visible = false; + // + // F_WeightBill_ID + // + this.F_WeightBill_ID.DataPropertyName = "WeightBill_ID"; + this.F_WeightBill_ID.HeaderText = "WeightBill_ID"; + this.F_WeightBill_ID.Name = "F_WeightBill_ID"; + this.F_WeightBill_ID.Visible = false; + // + // F_Farmer_ID + // + this.F_Farmer_ID.DataPropertyName = "Farmer_ID"; + this.F_Farmer_ID.HeaderText = "Farmer_ID"; + this.F_Farmer_ID.Name = "F_Farmer_ID"; + this.F_Farmer_ID.Visible = false; + // + // F_Index + // + this.F_Index.DataPropertyName = "Index"; + this.F_Index.HeaderText = "序号"; + this.F_Index.Name = "F_Index"; + this.F_Index.ReadOnly = true; + this.F_Index.Width = 80; + // + // F_Farmer_Name + // + this.F_Farmer_Name.DataPropertyName = "Farmer_Name"; + this.F_Farmer_Name.HeaderText = "养殖户"; + this.F_Farmer_Name.Name = "F_Farmer_Name"; + this.F_Farmer_Name.ReadOnly = true; + this.F_Farmer_Name.Width = 120; + // + // F_Number + // + this.F_Number.DataPropertyName = "Number"; + this.F_Number.HeaderText = "头数"; + this.F_Number.Name = "F_Number"; + this.F_Number.Width = 80; + // + // F_Weight + // + this.F_Weight.DataPropertyName = "Weight"; + dataGridViewCellStyle3.Format = "#0.######"; + this.F_Weight.DefaultCellStyle = dataGridViewCellStyle3; + this.F_Weight.HeaderText = "重量"; + this.F_Weight.Name = "F_Weight"; + // // label3 // this.label3.AutoSize = true; @@ -1369,58 +1421,6 @@ this.viewDetailBtn.UseVisualStyleBackColor = true; this.viewDetailBtn.Click += new System.EventHandler(this.viewDetailBtn_Click); // - // F_ID - // - this.F_ID.DataPropertyName = "ID"; - this.F_ID.HeaderText = "ID"; - this.F_ID.Name = "F_ID"; - this.F_ID.Visible = false; - // - // F_WeightBill_ID - // - this.F_WeightBill_ID.DataPropertyName = "WeightBill_ID"; - this.F_WeightBill_ID.HeaderText = "WeightBill_ID"; - this.F_WeightBill_ID.Name = "F_WeightBill_ID"; - this.F_WeightBill_ID.Visible = false; - // - // F_Farmer_ID - // - this.F_Farmer_ID.DataPropertyName = "Farmer_ID"; - this.F_Farmer_ID.HeaderText = "Farmer_ID"; - this.F_Farmer_ID.Name = "F_Farmer_ID"; - this.F_Farmer_ID.Visible = false; - // - // F_Index - // - this.F_Index.DataPropertyName = "Index"; - this.F_Index.HeaderText = "序号"; - this.F_Index.Name = "F_Index"; - this.F_Index.ReadOnly = true; - this.F_Index.Width = 80; - // - // F_Farmer_Name - // - this.F_Farmer_Name.DataPropertyName = "Farmer_Name"; - this.F_Farmer_Name.HeaderText = "养殖户"; - this.F_Farmer_Name.Name = "F_Farmer_Name"; - this.F_Farmer_Name.ReadOnly = true; - this.F_Farmer_Name.Width = 120; - // - // F_Number - // - this.F_Number.DataPropertyName = "Number"; - this.F_Number.HeaderText = "头数"; - this.F_Number.Name = "F_Number"; - this.F_Number.Width = 80; - // - // F_Weight - // - this.F_Weight.DataPropertyName = "Weight"; - dataGridViewCellStyle3.Format = "#0.######"; - this.F_Weight.DefaultCellStyle = dataGridViewCellStyle3; - this.F_Weight.HeaderText = "重量"; - this.F_Weight.Name = "F_Weight"; - // // WeightForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -1447,6 +1447,7 @@ this.Name = "WeightForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "毛猪过磅"; + this.Load += new System.EventHandler(this.WeightForm_Load); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); this.panel2.ResumeLayout(false); diff --git a/ButcherWeight/WeightForm.cs b/ButcherWeight/WeightForm.cs index bd37f14..f001d15 100644 --- a/ButcherWeight/WeightForm.cs +++ b/ButcherWeight/WeightForm.cs @@ -74,20 +74,16 @@ namespace ButcherWeight }; } + private void WeightForm_Load(object sender, EventArgs e) + { + BindWeightBill(); + } + private void SyncTask() { - bool commingRefreshed = false; while (mainIsRun) { - Thread.Sleep(2000); - if (!commingRefreshed) - { - this.Invoke(new InvokeHandler(delegate() - { - BindWeightBill(); - })); - commingRefreshed = true; - } + Thread.Sleep(5000); bool changed = false; var ids = dmoList.Where(x => x.B3ID == null).Select(x => (long?)x.ID).ToList(); if (ids.Any()) diff --git a/QualityAndOrder/QualityOrderForm.Designer.cs b/QualityAndOrder/QualityOrderForm.Designer.cs index 6b5c64d..df45fe7 100644 --- a/QualityAndOrder/QualityOrderForm.Designer.cs +++ b/QualityAndOrder/QualityOrderForm.Designer.cs @@ -37,14 +37,14 @@ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = 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 dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = 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 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(); this.uTabControl1 = new BWP.WinFormControl.UTabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.vScrollBar1 = new System.Windows.Forms.VScrollBar(); @@ -98,19 +98,6 @@ this.label6 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.preOrderGrid = new BWP.WinFormControl.UDataGridView(); - this.orderGrid = new BWP.WinFormControl.UDataGridView(); - this.tab2SyncBtn = new System.Windows.Forms.Button(); - this.tab2DateSelect = new BWP.WinFormControl.UDatePicker(); - this.label4 = new System.Windows.Forms.Label(); - 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_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.P_WeightBill_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.P_Show = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.P_B3ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -122,6 +109,19 @@ this.P_WeighTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.P_OKBtn = new System.Windows.Forms.DataGridViewButtonColumn(); this.P_Hidden = 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_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(); + this.tab2DateSelect = new BWP.WinFormControl.UDatePicker(); + this.label4 = new System.Windows.Forms.Label(); this.uTabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.panel1.SuspendLayout(); @@ -490,7 +490,9 @@ this.weightBillGrid.ReadOnly = true; this.weightBillGrid.RowHeadersVisible = false; dataGridViewCellStyle6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle6.ForeColor = System.Drawing.Color.Black; dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.Black; this.weightBillGrid.RowsDefaultCellStyle = dataGridViewCellStyle6; this.weightBillGrid.RowTemplate.Height = 40; this.weightBillGrid.ScrollBars = System.Windows.Forms.ScrollBars.None; @@ -759,15 +761,118 @@ this.preOrderGrid.ReadOnly = true; this.preOrderGrid.RowHeadersVisible = false; dataGridViewCellStyle12.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle12.ForeColor = System.Drawing.Color.Black; dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + dataGridViewCellStyle12.SelectionForeColor = System.Drawing.Color.Black; this.preOrderGrid.RowsDefaultCellStyle = dataGridViewCellStyle12; this.preOrderGrid.RowTemplate.Height = 60; this.preOrderGrid.ScrollBars = System.Windows.Forms.ScrollBars.None; this.preOrderGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.preOrderGrid.Size = new System.Drawing.Size(743, 663); this.preOrderGrid.TabIndex = 38; + this.preOrderGrid.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.preOrderGrid_CellClick); this.preOrderGrid.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.preOrderGrid_CellContentClick); // + // 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_Show + // + this.P_Show.DataPropertyName = "Show"; + this.P_Show.HeaderText = "Show"; + this.P_Show.Name = "P_Show"; + this.P_Show.ReadOnly = true; + this.P_Show.Visible = false; + // + // P_B3ID + // + 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 + // + this.P_Supplier_Name.DataPropertyName = "Supplier_Name"; + 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 + // + this.P_HouseNames.DataPropertyName = "HouseNames"; + 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.Name = "P_Number"; + this.P_Number.ReadOnly = true; + this.P_Number.Width = 80; + // + // P_AlreadyNumber + // + this.P_AlreadyNumber.DataPropertyName = "AlreadyNumber"; + this.P_AlreadyNumber.HeaderText = "已排"; + this.P_AlreadyNumber.Name = "P_AlreadyNumber"; + this.P_AlreadyNumber.ReadOnly = true; + this.P_AlreadyNumber.Width = 65; + // + // P_LastNumber + // + this.P_LastNumber.DataPropertyName = "LastNumber"; + this.P_LastNumber.HeaderText = "剩余"; + this.P_LastNumber.Name = "P_LastNumber"; + this.P_LastNumber.ReadOnly = true; + this.P_LastNumber.Width = 65; + // + // P_WeighTime + // + this.P_WeighTime.DataPropertyName = "WeighTime"; + dataGridViewCellStyle9.Format = "MM/dd HH:mm"; + dataGridViewCellStyle9.NullValue = null; + this.P_WeighTime.DefaultCellStyle = dataGridViewCellStyle9; + this.P_WeighTime.HeaderText = "过磅时间"; + this.P_WeighTime.Name = "P_WeighTime"; + this.P_WeighTime.ReadOnly = true; + this.P_WeighTime.Width = 105; + // + // P_OKBtn + // + dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle10.Padding = new System.Windows.Forms.Padding(7, 10, 7, 10); + this.P_OKBtn.DefaultCellStyle = dataGridViewCellStyle10; + this.P_OKBtn.HeaderText = "排宰"; + this.P_OKBtn.Name = "P_OKBtn"; + this.P_OKBtn.ReadOnly = true; + this.P_OKBtn.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.P_OKBtn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + this.P_OKBtn.Text = "排宰"; + this.P_OKBtn.UseColumnTextForButtonValue = true; + this.P_OKBtn.Width = 85; + // + // P_Hidden + // + dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle11.Padding = new System.Windows.Forms.Padding(7, 10, 7, 10); + this.P_Hidden.DefaultCellStyle = dataGridViewCellStyle11; + this.P_Hidden.HeaderText = "隐藏"; + this.P_Hidden.Name = "P_Hidden"; + this.P_Hidden.ReadOnly = true; + this.P_Hidden.Text = "隐藏"; + this.P_Hidden.Width = 85; + // // orderGrid // this.orderGrid.AllowUserToAddRows = false; @@ -802,50 +907,18 @@ this.orderGrid.ReadOnly = true; this.orderGrid.RowHeadersVisible = false; dataGridViewCellStyle17.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle17.ForeColor = System.Drawing.Color.Black; dataGridViewCellStyle17.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + dataGridViewCellStyle17.SelectionForeColor = System.Drawing.Color.Black; this.orderGrid.RowsDefaultCellStyle = dataGridViewCellStyle17; this.orderGrid.RowTemplate.Height = 60; this.orderGrid.ScrollBars = System.Windows.Forms.ScrollBars.None; this.orderGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.orderGrid.Size = new System.Drawing.Size(513, 388); this.orderGrid.TabIndex = 38; + this.orderGrid.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.orderGrid_CellClick); this.orderGrid.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.orderGrid_CellContentClick); // - // tab2SyncBtn - // - this.tab2SyncBtn.Font = new System.Drawing.Font("宋体", 15F); - this.tab2SyncBtn.Location = new System.Drawing.Point(277, 9); - this.tab2SyncBtn.Name = "tab2SyncBtn"; - this.tab2SyncBtn.Size = new System.Drawing.Size(94, 56); - this.tab2SyncBtn.TabIndex = 37; - this.tab2SyncBtn.Text = "同步"; - this.tab2SyncBtn.UseVisualStyleBackColor = true; - this.tab2SyncBtn.Click += new System.EventHandler(this.tab2SyncBtn_Click); - // - // tab2DateSelect - // - this.tab2DateSelect.BackColor = System.Drawing.Color.White; - this.tab2DateSelect.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tab2DateSelect.Date = new System.DateTime(2017, 9, 8, 0, 0, 0, 0); - this.tab2DateSelect.Font = new System.Drawing.Font("宋体", 15F); - this.tab2DateSelect.Location = new System.Drawing.Point(124, 19); - this.tab2DateSelect.Name = "tab2DateSelect"; - this.tab2DateSelect.Size = new System.Drawing.Size(135, 30); - this.tab2DateSelect.TabIndex = 36; - this.tab2DateSelect.Text = "2017/09/08"; - this.tab2DateSelect.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.tab2DateSelect.Type = BWP.WinFormControl.DateTimeType.Date; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Font = new System.Drawing.Font("宋体", 14F); - this.label4.Location = new System.Drawing.Point(23, 25); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(104, 19); - this.label4.TabIndex = 35; - this.label4.Text = "过磅日期:"; - // // O_ID // this.O_ID.DataPropertyName = "ID"; @@ -925,105 +998,40 @@ this.O_HurryBtn.UseColumnTextForButtonValue = true; this.O_HurryBtn.Width = 95; // - // 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_Show - // - this.P_Show.DataPropertyName = "Show"; - this.P_Show.HeaderText = "Show"; - this.P_Show.Name = "P_Show"; - this.P_Show.ReadOnly = true; - this.P_Show.Visible = false; - // - // P_B3ID - // - 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 - // - this.P_Supplier_Name.DataPropertyName = "Supplier_Name"; - 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 - // - this.P_HouseNames.DataPropertyName = "HouseNames"; - 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.Name = "P_Number"; - this.P_Number.ReadOnly = true; - this.P_Number.Width = 80; - // - // P_AlreadyNumber - // - this.P_AlreadyNumber.DataPropertyName = "AlreadyNumber"; - this.P_AlreadyNumber.HeaderText = "已排"; - this.P_AlreadyNumber.Name = "P_AlreadyNumber"; - this.P_AlreadyNumber.ReadOnly = true; - this.P_AlreadyNumber.Width = 65; - // - // P_LastNumber - // - this.P_LastNumber.DataPropertyName = "LastNumber"; - this.P_LastNumber.HeaderText = "剩余"; - this.P_LastNumber.Name = "P_LastNumber"; - this.P_LastNumber.ReadOnly = true; - this.P_LastNumber.Width = 65; - // - // P_WeighTime + // tab2SyncBtn // - this.P_WeighTime.DataPropertyName = "WeighTime"; - dataGridViewCellStyle9.Format = "MM/dd HH:mm"; - dataGridViewCellStyle9.NullValue = null; - this.P_WeighTime.DefaultCellStyle = dataGridViewCellStyle9; - this.P_WeighTime.HeaderText = "过磅时间"; - this.P_WeighTime.Name = "P_WeighTime"; - this.P_WeighTime.ReadOnly = true; - this.P_WeighTime.Width = 105; + this.tab2SyncBtn.Font = new System.Drawing.Font("宋体", 15F); + this.tab2SyncBtn.Location = new System.Drawing.Point(277, 9); + this.tab2SyncBtn.Name = "tab2SyncBtn"; + this.tab2SyncBtn.Size = new System.Drawing.Size(94, 56); + this.tab2SyncBtn.TabIndex = 37; + this.tab2SyncBtn.Text = "同步"; + this.tab2SyncBtn.UseVisualStyleBackColor = true; + this.tab2SyncBtn.Click += new System.EventHandler(this.tab2SyncBtn_Click); // - // P_OKBtn + // tab2DateSelect // - dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle10.Padding = new System.Windows.Forms.Padding(7, 10, 7, 10); - this.P_OKBtn.DefaultCellStyle = dataGridViewCellStyle10; - this.P_OKBtn.HeaderText = "排宰"; - this.P_OKBtn.Name = "P_OKBtn"; - this.P_OKBtn.ReadOnly = true; - this.P_OKBtn.Resizable = System.Windows.Forms.DataGridViewTriState.True; - this.P_OKBtn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; - this.P_OKBtn.Text = "排宰"; - this.P_OKBtn.UseColumnTextForButtonValue = true; - this.P_OKBtn.Width = 85; + this.tab2DateSelect.BackColor = System.Drawing.Color.White; + this.tab2DateSelect.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.tab2DateSelect.Date = new System.DateTime(2017, 9, 8, 0, 0, 0, 0); + this.tab2DateSelect.Font = new System.Drawing.Font("宋体", 15F); + this.tab2DateSelect.Location = new System.Drawing.Point(124, 19); + this.tab2DateSelect.Name = "tab2DateSelect"; + this.tab2DateSelect.Size = new System.Drawing.Size(135, 30); + this.tab2DateSelect.TabIndex = 36; + this.tab2DateSelect.Text = "2017/09/08"; + this.tab2DateSelect.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.tab2DateSelect.Type = BWP.WinFormControl.DateTimeType.Date; // - // P_Hidden + // label4 // - dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle11.Padding = new System.Windows.Forms.Padding(7, 10, 7, 10); - this.P_Hidden.DefaultCellStyle = dataGridViewCellStyle11; - this.P_Hidden.HeaderText = "隐藏"; - this.P_Hidden.Name = "P_Hidden"; - this.P_Hidden.ReadOnly = true; - this.P_Hidden.Text = "隐藏"; - this.P_Hidden.Width = 85; + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("宋体", 14F); + this.label4.Location = new System.Drawing.Point(23, 25); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(104, 19); + this.label4.TabIndex = 35; + this.label4.Text = "过磅日期:"; // // QualityOrderForm // diff --git a/QualityAndOrder/QualityOrderForm.cs b/QualityAndOrder/QualityOrderForm.cs index f748b62..de98259 100644 --- a/QualityAndOrder/QualityOrderForm.cs +++ b/QualityAndOrder/QualityOrderForm.cs @@ -65,28 +65,31 @@ namespace QualityAndOrder numberBox.LostFocus += (sender, e) => { flag = 1; }; sanctionGrid.GotFocus += (sender, e) => { flag = 2; }; - syncThread = new Thread(SyncTask); - syncThread.Start(); this.FormClosing += delegate { - if (syncThread.IsAlive) + if (syncThread != null && syncThread.IsAlive) syncThread.Abort(); - if (tb2SyncThread != null && tb2SyncThread.IsAlive) - tb2SyncThread.Abort(); + if (tb2SyncB3IDThread != null && tb2SyncB3IDThread.IsAlive) + tb2SyncB3IDThread.Abort(); + if (bt2SyncTask != null && bt2SyncTask.IsAlive) + bt2SyncTask.Abort(); }; Tab2Init(); } + HouseAndSanctionList lastFirstSelect; private void SyncTask() { while (true) { - Thread.Sleep(2000); this.Invoke(new InvokeHandler(delegate() { + weightBills = HouseAndSanctionRpc.GetHouseAndSanctionList(testTimeInput.Date.Value); + BindWeightBillGrid(); BindNumberLabel(); })); + Thread.Sleep(5000); } } @@ -98,12 +101,39 @@ namespace QualityAndOrder private void BindWeightBillGrid() { weightBillGrid.DataSource = weightBills.OrderBy(x => x.ID).OrderBy(x => x.AlreadyHouse).ToList(); + if (lastFirstSelect == null && weightBillGrid.CurrentRow != null) + { + lastFirstSelect = weightBillGrid.CurrentRow.DataBoundItem as HouseAndSanctionList; + if (lastFirstSelect.AlreadyHouse) + { + lastFirstSelect = null; + weightBillGrid.CurrentRow.DefaultCellStyle.BackColor = Color.YellowGreen; + } + } foreach (DataGridViewRow row in weightBillGrid.Rows) { if ((bool)row.Cells["W_AlreadyHouse"].Value) row.DefaultCellStyle.BackColor = Color.YellowGreen; + if (lastFirstSelect != null && lastFirstSelect.ID == (long)row.Cells["W_ID"].Value) + { + lastFirstSelect = row.DataBoundItem as HouseAndSanctionList; + if (lastFirstSelect.AlreadyHouse) + row.DefaultCellStyle.BackColor = Color.Yellow; + else + row.DefaultCellStyle.BackColor = weightBillGrid.RowsDefaultCellStyle.SelectionBackColor; + } } InitScrollBar(); + weightBillGrid.ClearSelection(); + try + { + if (firstRoll != -1) + weightBillGrid.FirstDisplayedScrollingRowIndex = firstRoll; + } + catch + { + firstRoll = -1; + } weightBillGrid.Refresh(); } @@ -350,8 +380,20 @@ namespace QualityAndOrder private void syncBtn_Click(object sender, EventArgs e) { - weightBills = HouseAndSanctionRpc.GetHouseAndSanctionList(testTimeInput.Date.Value); - BindWeightBillGrid(); + if (syncThread == null || !syncThread.IsAlive) + { + syncThread = new Thread(SyncTask); + syncThread.Start(); + syncBtn.BackColor = Color.FromArgb(15, 215, 107); + syncBtn.ForeColor = Color.White; + } + else + { + syncThread.Abort(); + syncBtn.BackColor = Color.FromKnownColor(KnownColor.Control); + syncBtn.ForeColor = Color.FromKnownColor(KnownColor.ControlText); + } + //BindNumberLabel(); //tab1SyncThread = new Thread(StartQuery) { IsBackground = true }; //tab1SyncThread.Start(); @@ -383,10 +425,10 @@ namespace QualityAndOrder { if (Dmo == null) { - if (weightBillGrid.CurrentRow == null) + if (lastFirstSelect == null) throw new Exception("请选择需要处理的记录"); Dmo = new HouseAndSanctionEdit(); - Dmo.ID = (long)weightBillGrid.CurrentRow.Cells["W_ID"].Value; + Dmo.ID = lastFirstSelect.ID; } else { @@ -469,14 +511,29 @@ namespace QualityAndOrder { if (e.RowIndex < 0) return; + + if (lastFirstSelect != null) + { + foreach (DataGridViewRow row in weightBillGrid.Rows) + { + if (lastFirstSelect.ID == (long)row.Cells["W_ID"].Value) + { + row.DefaultCellStyle.BackColor = lastFirstSelect.AlreadyHouse ? Color.YellowGreen : weightBillGrid.RowsDefaultCellStyle.BackColor; + break; + } + } + } + lastFirstSelect = weightBillGrid.CurrentRow.DataBoundItem as HouseAndSanctionList; + weightBillGrid.CurrentRow.DefaultCellStyle.SelectionBackColor = lastFirstSelect.AlreadyHouse ? Color.Yellow : weightBillGrid.RowsDefaultCellStyle.SelectionBackColor; + weightBillGrid.Refresh(); + ResetTab1Controls(); Tab1AppToUI(); } void Tab1AppToUI() { - var id = Convert.ToInt64(weightBillGrid.CurrentRow.Cells["W_ID"].Value); - Dmo = HouseAndSanctionRpc.GetHouseAndSanctionDetail(id); + Dmo = HouseAndSanctionRpc.GetHouseAndSanctionDetail(lastFirstSelect.ID); numberBox.Text = string.Empty; if (Dmo.HogGrade_ID.HasValue) { @@ -533,6 +590,7 @@ namespace QualityAndOrder btn.ForeColor = btnUnSelectForeColor; } + int firstRoll = -1; private void InitScrollBar() { vScrollBar1.Maximum = (weightBillGrid.RowCount - weightBillGrid.DisplayedRowCount(false) + 30) * weightBillGrid.RowTemplate.Height; @@ -541,8 +599,8 @@ namespace QualityAndOrder vScrollBar1.LargeChange = weightBillGrid.RowTemplate.Height * 30; this.vScrollBar1.Scroll += (sender, e) => { - weightBillGrid.FirstDisplayedScrollingRowIndex = e.NewValue / weightBillGrid.RowTemplate.Height; - Application.DoEvents(); + firstRoll = e.NewValue / weightBillGrid.RowTemplate.Height; + weightBillGrid.FirstDisplayedScrollingRowIndex = firstRoll; }; } } diff --git a/QualityAndOrder/QualityOrderFormForTab2.cs b/QualityAndOrder/QualityOrderFormForTab2.cs index 1ee95ff..fd286b6 100644 --- a/QualityAndOrder/QualityOrderFormForTab2.cs +++ b/QualityAndOrder/QualityOrderFormForTab2.cs @@ -16,7 +16,8 @@ namespace QualityAndOrder { List needOrderList; List orderList; - Thread tb2SyncThread; + Thread tb2SyncB3IDThread; + Thread bt2SyncTask; void Tab2Init() { @@ -73,13 +74,38 @@ namespace QualityAndOrder } private void tab2SyncBtn_Click(object sender, EventArgs e) - { - BindPreOrderGrid(); + { BindOrderGrid(); - if (tb2SyncThread == null) + if (tb2SyncB3IDThread == null) + { + tb2SyncB3IDThread = new Thread(Tab2SyncB3ID); + tb2SyncB3IDThread.Start(); + } + + if (bt2SyncTask == null || !bt2SyncTask.IsAlive) { - tb2SyncThread = new Thread(Tab2SyncB3ID); - tb2SyncThread.Start(); + bt2SyncTask = new Thread(Tb2SyncTask); + bt2SyncTask.Start(); + tab2SyncBtn.BackColor = Color.FromArgb(15, 215, 107); + tab2SyncBtn.ForeColor = Color.White; + } + else + { + bt2SyncTask.Abort(); + tab2SyncBtn.BackColor = Color.FromKnownColor(KnownColor.Control); + tab2SyncBtn.ForeColor = Color.FromKnownColor(KnownColor.ControlText); + } + } + + void Tb2SyncTask() + { + while (true) + { + this.Invoke(new InvokeHandler(delegate() + { + BindPreOrderGrid(); + })); + Thread.Sleep(5000); } } @@ -87,6 +113,11 @@ namespace QualityAndOrder { while (true) { + if (orderList == null || needOrderList == null) + { + Thread.Sleep(5000); + continue; + } bool orderChange = false; bool needListChange = false; var ids = orderList.Where(x => x.B3WeighBill_ID == null).Select(x => (long?)x.WeightBill_ID).Distinct().ToList(); @@ -128,35 +159,81 @@ namespace QualityAndOrder preOrderGrid.Refresh(); })); } - Thread.Sleep(2000); + Thread.Sleep(5000); } } + NeedOrderEntity lastPreOrder; void BindPreOrderGrid() { needOrderList = OrderDetailRpc.GetNeedOrderWeightBill(tab2DateSelect.Date.Value, GetSelectType()); preOrderGrid.DataSource = needOrderList.OrderBy(x => x.WeighTime).ToList(); + foreach (DataGridViewRow row in preOrderGrid.Rows) { var show = (bool)row.Cells["P_Show"].Value; if (!show) row.DefaultCellStyle.BackColor = Color.YellowGreen; ((DataGridViewButtonCell)row.Cells["P_Hidden"]).Value = show ? "隐藏" : "显示"; + if (lastPreOrder != null && lastPreOrder.WeightBill_ID == (long)row.Cells["P_WeightBill_ID"].Value) + { + lastPreOrder = row.DataBoundItem as NeedOrderEntity; + if (lastPreOrder.Show) + row.DefaultCellStyle.BackColor = preOrderGrid.RowsDefaultCellStyle.SelectionBackColor; + else + row.DefaultCellStyle.BackColor = Color.Yellow; + } } InitScrollBar3(); + preOrderGrid.ClearSelection(); + try + { + if (r2Roll != -1) + preOrderGrid.FirstDisplayedScrollingRowIndex = r2Roll; + } + catch + { + r2Roll = -1; + } preOrderGrid.Refresh(); } + OrderDetail lastOrderDetail; void BindOrderGrid() { orderList = OrderDetailRpc.GetOrderDetail(); orderGrid.DataSource = orderList.OrderByDescending(x => x.Order).ToList(); + if (lastOrderDetail == null && orderGrid.CurrentRow != null) + { + lastOrderDetail = orderGrid.CurrentRow.DataBoundItem as OrderDetail; + } foreach (DataGridViewRow row in orderGrid.Rows) { if ((bool)row.Cells["O_IsHurryButcher"].Value) row.DefaultCellStyle.BackColor = Color.YellowGreen; + if (lastOrderDetail != null && lastOrderDetail.ID == (long)row.Cells["O_ID"].Value) + { + var cRow = row; + if (orderGrid.Rows.IndexOf(row) == 1) + cRow = orderGrid.Rows[0]; + lastOrderDetail = cRow.DataBoundItem as OrderDetail; + if (lastOrderDetail.IsHurryButcher) + cRow.DefaultCellStyle.BackColor = Color.Yellow; + else + cRow.DefaultCellStyle.BackColor = orderGrid.RowsDefaultCellStyle.SelectionBackColor; + } } InitScrollBar2(); + orderGrid.ClearSelection(); + try + { + if (r1Roll != -1) + orderGrid.FirstDisplayedScrollingRowIndex = r1Roll; + } + catch + { + r1Roll = -1; + } orderGrid.Refresh(); } @@ -170,8 +247,8 @@ namespace QualityAndOrder if (e.ColumnIndex == preOrderGrid.ColumnCount - 2) { var currentOrder = 0; - if (orderGrid.CurrentRow != null) - currentOrder = OrderDetailRpc.GetCurrentOrder((long)orderGrid.CurrentRow.Cells["O_ID"].Value); + if (lastOrderDetail != null) + currentOrder = OrderDetailRpc.GetCurrentOrder(lastOrderDetail.ID); else currentOrder = OrderDetailRpc.GetMaxOrder(); currentOrder++; @@ -192,6 +269,34 @@ namespace QualityAndOrder BindPreOrderGrid(); } + private void preOrderGrid_CellClick(object sender, DataGridViewCellEventArgs e) + { + if (e.RowIndex == -1) + return; + var entity = preOrderGrid.CurrentRow.DataBoundItem as NeedOrderEntity; + if (e.ColumnIndex != preOrderGrid.ColumnCount - 2)//排宰 + { + if (lastPreOrder != null) + { + foreach (DataGridViewRow row in preOrderGrid.Rows) + { + if (lastPreOrder.WeightBill_ID == (long)row.Cells["P_WeightBill_ID"].Value) + { + row.DefaultCellStyle.BackColor = lastPreOrder.Show ? preOrderGrid.RowsDefaultCellStyle.BackColor : Color.YellowGreen; + break; + } + } + } + lastPreOrder = entity; + preOrderGrid.CurrentRow.DefaultCellStyle.SelectionBackColor = lastPreOrder.Show ? preOrderGrid.RowsDefaultCellStyle.SelectionBackColor : Color.Yellow; + } + else + { + lastPreOrder = null; + } + preOrderGrid.Refresh(); + } + private void orderGrid_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) @@ -223,6 +328,34 @@ namespace QualityAndOrder BindOrderGrid(); } + private void orderGrid_CellClick(object sender, DataGridViewCellEventArgs e) + { + if (e.RowIndex == -1) + return; + var entity = orderGrid.CurrentRow.DataBoundItem as OrderDetail; + if (e.ColumnIndex == orderGrid.ColumnCount - 2 && entity.PlanNumber == 0)//确定 + { + lastOrderDetail = null; + } + else + { + if (lastOrderDetail != null) + { + foreach (DataGridViewRow row in orderGrid.Rows) + { + if (lastOrderDetail.ID == (long)row.Cells["O_ID"].Value) + { + row.DefaultCellStyle.BackColor = lastOrderDetail.IsHurryButcher ? Color.YellowGreen : orderGrid.RowsDefaultCellStyle.BackColor; + break; + } + } + } + lastOrderDetail = entity; + orderGrid.CurrentRow.DefaultCellStyle.SelectionBackColor = lastOrderDetail.IsHurryButcher ? Color.Yellow : orderGrid.RowsDefaultCellStyle.SelectionBackColor; + } + orderGrid.Refresh(); + } + bool? GetSelectType() { bool? type = null; @@ -238,6 +371,7 @@ namespace QualityAndOrder BindPreOrderGrid(); } + int r1Roll = -1; private void InitScrollBar2() { vScrollBar2.Maximum = (orderGrid.RowCount - orderGrid.DisplayedRowCount(false) + 30) * orderGrid.RowTemplate.Height; @@ -246,11 +380,12 @@ namespace QualityAndOrder vScrollBar2.LargeChange = orderGrid.RowTemplate.Height * 30; this.vScrollBar2.Scroll += (sender, e) => { - orderGrid.FirstDisplayedScrollingRowIndex = e.NewValue / orderGrid.RowTemplate.Height; - Application.DoEvents(); + r1Roll = e.NewValue / orderGrid.RowTemplate.Height; + orderGrid.FirstDisplayedScrollingRowIndex = r1Roll; }; } + int r2Roll = -1; private void InitScrollBar3() { vScrollBar3.Maximum = (preOrderGrid.RowCount - preOrderGrid.DisplayedRowCount(false) + 30) * preOrderGrid.RowTemplate.Height; @@ -259,8 +394,8 @@ namespace QualityAndOrder vScrollBar3.LargeChange = preOrderGrid.RowTemplate.Height * 30; this.vScrollBar3.Scroll += (sender, e) => { - preOrderGrid.FirstDisplayedScrollingRowIndex = e.NewValue / preOrderGrid.RowTemplate.Height; - Application.DoEvents(); + r2Roll = e.NewValue / preOrderGrid.RowTemplate.Height; + preOrderGrid.FirstDisplayedScrollingRowIndex = r2Roll; }; } } diff --git a/Setup/Release/Setup.msi b/Setup/Release/Setup.msi index af4c4f6..074a9ee 100644 Binary files a/Setup/Release/Setup.msi and b/Setup/Release/Setup.msi differ diff --git a/Setup/Release/setup.exe b/Setup/Release/setup.exe index b88526e..5d008c4 100644 Binary files a/Setup/Release/setup.exe and b/Setup/Release/setup.exe differ diff --git a/Setup/Setup.vdproj b/Setup/Setup.vdproj index bb9f297..6e05f03 100644 --- a/Setup/Setup.vdproj +++ b/Setup/Setup.vdproj @@ -842,15 +842,15 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:青花瓷屠宰场管理" - "ProductCode" = "8:{C6929442-4B85-412A-83B1-A4D371AE94D0}" - "PackageCode" = "8:{1EC57DDA-707E-4FFA-B622-217A34904CEF}" + "ProductCode" = "8:{7E254F8F-01E7-4603-8A79-9F38035588A9}" + "PackageCode" = "8:{0947D084-A2AC-48FA-A9AC-0146D66C2B9C}" "UpgradeCode" = "8:{36F49E93-1C91-49B0-BB59-9984FC596D30}" "AspNetVersion" = "8:4.0.30319.0" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:TRUE" - "ProductVersion" = "8:1.0.1" + "ProductVersion" = "8:1.0.2" "Manufacturer" = "8:青花瓷软件(北京)有限公司" "ARPHELPTELEPHONE" = "8:010-62701591" "ARPHELPLINK" = "8:http://www.bwpsoft.com" diff --git a/WeighAndGrading/GradeFrom.Designer.cs b/WeighAndGrading/GradeFrom.Designer.cs index d6fe38c..d6ebd3d 100644 --- a/WeighAndGrading/GradeFrom.Designer.cs +++ b/WeighAndGrading/GradeFrom.Designer.cs @@ -35,6 +35,7 @@ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = 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 dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); this.label1 = new System.Windows.Forms.Label(); this.syncBtn = new System.Windows.Forms.Button(); @@ -434,10 +435,12 @@ this.dataGridView.Name = "dataGridView"; this.dataGridView.ReadOnly = true; this.dataGridView.RowHeadersVisible = false; - dataGridViewCellStyle8.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.dataGridView.RowsDefaultCellStyle = dataGridViewCellStyle8; - this.dataGridView.RowTemplate.Height = 40; + dataGridViewCellStyle9.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle9.ForeColor = System.Drawing.Color.Black; + dataGridViewCellStyle9.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + dataGridViewCellStyle9.SelectionForeColor = System.Drawing.Color.Black; + this.dataGridView.RowsDefaultCellStyle = dataGridViewCellStyle9; + this.dataGridView.RowTemplate.Height = 60; this.dataGridView.ScrollBars = System.Windows.Forms.ScrollBars.None; this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView.Size = new System.Drawing.Size(443, 566); @@ -501,6 +504,9 @@ // // D_FinishBtn // + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle8.Padding = new System.Windows.Forms.Padding(5, 10, 5, 10); + this.D_FinishBtn.DefaultCellStyle = dataGridViewCellStyle8; this.D_FinishBtn.HeaderText = "完毕"; this.D_FinishBtn.Name = "D_FinishBtn"; this.D_FinishBtn.ReadOnly = true; @@ -678,14 +684,6 @@ private System.Windows.Forms.Label stateLabel; private System.Windows.Forms.Panel modifyPanel; private System.Windows.Forms.Button cancelBtn; - private System.Windows.Forms.DataGridViewTextBoxColumn D_OrderDetail_ID; - private System.Windows.Forms.DataGridViewTextBoxColumn D_Technics; - private System.Windows.Forms.DataGridViewTextBoxColumn D_Finish; - private System.Windows.Forms.DataGridViewTextBoxColumn D_Order; - private System.Windows.Forms.DataGridViewTextBoxColumn D_Technics_Name; - private System.Windows.Forms.DataGridViewTextBoxColumn D_Number; - private System.Windows.Forms.DataGridViewTextBoxColumn D_Already; - private System.Windows.Forms.DataGridViewButtonColumn D_FinishBtn; private System.Windows.Forms.Button discontBtn; private System.Windows.Forms.FlowLayoutPanel discontPanel; private System.Windows.Forms.VScrollBar vScrollBar2; @@ -698,5 +696,13 @@ private System.Windows.Forms.DataGridViewTextBoxColumn H_Weight; private System.Windows.Forms.DataGridViewTextBoxColumn H_Time; private System.Windows.Forms.VScrollBar vScrollBar1; + private System.Windows.Forms.DataGridViewTextBoxColumn D_OrderDetail_ID; + private System.Windows.Forms.DataGridViewTextBoxColumn D_Technics; + private System.Windows.Forms.DataGridViewTextBoxColumn D_Finish; + private System.Windows.Forms.DataGridViewTextBoxColumn D_Order; + private System.Windows.Forms.DataGridViewTextBoxColumn D_Technics_Name; + private System.Windows.Forms.DataGridViewTextBoxColumn D_Number; + private System.Windows.Forms.DataGridViewTextBoxColumn D_Already; + private System.Windows.Forms.DataGridViewButtonColumn D_FinishBtn; } } \ No newline at end of file diff --git a/WeighAndGrading/GradeFrom.cs b/WeighAndGrading/GradeFrom.cs index a09b4a1..cc3a206 100644 --- a/WeighAndGrading/GradeFrom.cs +++ b/WeighAndGrading/GradeFrom.cs @@ -40,15 +40,13 @@ namespace WeighAndGrading ConcurrentQueue noLivestockList = new ConcurrentQueue(); ConcurrentQueue noWeightList = new ConcurrentQueue(); + Thread syncWork; #region weightNeed private IDataFormat _dataFormat; - private Thread _inQueryThread, _outQueryThread; + private Thread _inQueryThread; private bool _mainProcessIsRun; readonly StringBuilder _dataStrBuilder = new StringBuilder(); - readonly ConcurrentQueue _dataQueue = new ConcurrentQueue(); - - private string _displayValue; #endregion public GradeFrom() @@ -65,6 +63,8 @@ namespace WeighAndGrading { if (_inQueryThread != null && _inQueryThread.IsAlive) DisableWeight(); + if (syncWork != null && syncWork.IsAlive) + syncWork.Abort(); }; } @@ -115,17 +115,45 @@ namespace WeighAndGrading private void syncBtn_Click(object sender, EventArgs e) { - var date = butcherTimeInput.Date.Value; - list = GradeAndWeightRpc.GetGradeAndWeightList(date); + list = GradeAndWeightRpc.GetGradeAndWeightList(butcherTimeInput.Date.Value); BindDataGrid(); tangRow = FindRowSetSelected(tangEntity); maoRow = FindRowSetSelected(maoEntity); dataGridView.Refresh(); - details = GradeAndWeightRpc.GetDetails(date, 50); + details = GradeAndWeightRpc.GetDetails(butcherTimeInput.Date.Value, 50); FillQueue(); BindDetailGrid(); if (details.Any()) maxIndex = details.First().Index; + if (syncWork == null || !syncWork.IsAlive) + { + syncWork = new Thread(Sync); + syncWork.Start(); + syncBtn.BackColor = Color.FromArgb(15, 215, 107); + syncBtn.ForeColor = Color.White; + } + else + { + syncWork.Abort(); + syncBtn.BackColor = Color.FromKnownColor(KnownColor.Control); + syncBtn.ForeColor = Color.FromKnownColor(KnownColor.ControlText); + } + } + + void Sync() + { + while (true) + { + Thread.Sleep(5000); + this.Invoke(new InvokeHandler(delegate() + { + list = GradeAndWeightRpc.GetGradeAndWeightList(butcherTimeInput.Date.Value); + BindDataGrid(); + tangRow = FindRowSetSelected(tangEntity); + maoRow = FindRowSetSelected(maoEntity); + dataGridView.Refresh(); + })); + } } void FillQueue() @@ -160,6 +188,15 @@ namespace WeighAndGrading } InitScrollBar1(); dataGridView.ClearSelection(); + try + { + if (leftRoll != -1) + dataGridView.FirstDisplayedScrollingRowIndex = leftRoll; + } + catch + { + leftRoll = -1; + } } void BindDetailGrid() @@ -168,6 +205,26 @@ namespace WeighAndGrading if (details.Any()) historyGrid.DataSource = details; InitScrollBar2(); + if (lastSelectID.HasValue) + { + foreach (DataGridViewRow row in historyGrid.Rows) + { + if ((long)row.Cells["H_ID"].Value == lastSelectID) + { + historyGrid.CurrentCell = row.Cells[row.Cells.Count - 1]; + break; + } + } + } + try + { + if (rightRoll != -1) + historyGrid.FirstDisplayedScrollingRowIndex = rightRoll; + } + catch + { + rightRoll = -1; + } historyGrid.Refresh(); } @@ -246,9 +303,6 @@ namespace WeighAndGrading { _inQueryThread = new Thread(InQuery); _inQueryThread.Start(); - - _outQueryThread = new Thread(OutQuery); - _outQueryThread.Start(); } string format = "{0:0.00}"; @@ -278,55 +332,28 @@ namespace WeighAndGrading else if (c == _dataFormat.Endchar && _dataStrBuilder.Length == _dataFormat.DataLength - 1) { _dataStrBuilder.Append(c); - _dataQueue.Enqueue(_dataStrBuilder.ToString()); - _dataStrBuilder.Clear(); - } - else if (_dataStrBuilder.Length != 0) - { - _dataStrBuilder.Append(c); - } - } - } - } - - private void OutQuery() - { - while (_mainProcessIsRun) - { - try - { - bool isStatic; - string str; - - string subStr; - - if (!_dataQueue.TryDequeue(out subStr)) - { - Thread.Sleep(1); - continue; - } - // 解析接受的端口数据 - if (_dataFormat.ParseAscii(subStr, out str, out isStatic)) - { - if (string.IsNullOrEmpty(str)) - str = "0"; - _displayValue = string.Format(format, decimal.Parse(str)); - if (str != "0") + bool isStatic; + string str; + if (_dataFormat.ParseAscii(_dataStrBuilder.ToString(), out str, out isStatic)) { + if (string.IsNullOrEmpty(str)) + str = "0"; this.Invoke(new InvokeHandler(delegate() { - lblChengZhong.Text = _displayValue; - AddWeightDetail(decimal.Parse(_displayValue)); + lblChengZhong.Text = string.Format(format, decimal.Parse(str)); + if (str != "0") + { + AddWeightDetail(decimal.Parse(lblChengZhong.Text)); + } })); } + _dataStrBuilder.Clear(); + } + else if (_dataStrBuilder.Length != 0) + { + _dataStrBuilder.Append(c); } } - catch (Exception) - { - Thread.Sleep(1000); - continue; - } - Thread.Sleep(1); } } @@ -340,10 +367,6 @@ namespace WeighAndGrading { _inQueryThread.Abort(); } - if (_outQueryThread.IsAlive) - { - _outQueryThread.Abort(); - } if (weightPort.IsOpen) weightPort.Close(); } @@ -467,15 +490,18 @@ namespace WeighAndGrading } GradeAndWeight_Detail lastCheckItem; + long? lastSelectID = null; private void historyGrid_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) return; + var currentRow = historyGrid.CurrentRow.DataBoundItem as GradeAndWeight_Detail; + lastSelectID = currentRow.ID; if (e.ColumnIndex == 2) { - if (lastCheckItem != null && lastCheckItem.ID != (long)historyGrid.Rows[e.RowIndex].Cells[0].Value) + if (lastCheckItem != null && lastCheckItem.ID != currentRow.ID) lastCheckItem.ReadWeight = false; - lastCheckItem = historyGrid.Rows[e.RowIndex].DataBoundItem as GradeAndWeight_Detail; + lastCheckItem = currentRow; lastCheckItem.ReadWeight = !lastCheckItem.ReadWeight; modifyDetail = null; @@ -502,7 +528,7 @@ namespace WeighAndGrading } return; } - modifyDetail = historyGrid.Rows[e.RowIndex].DataBoundItem as GradeAndWeight_Detail; + modifyDetail = currentRow; stateLabel.Text = string.Format("您正在修改序号为 {0} 的信息", modifyDetail.Index); modifyPanel.Show(); } @@ -518,47 +544,46 @@ namespace WeighAndGrading { if (tangRow != null) { - if ((bool)tangRow.Cells["D_Finish"].Value) + if (tangEntity.Finish) tangRow.DefaultCellStyle.BackColor = Color.YellowGreen; else tangRow.DefaultCellStyle.BackColor = dataGridView.RowsDefaultCellStyle.BackColor; } tangRow = dataGridView.CurrentRow; - tangRow.DefaultCellStyle.BackColor = dataGridView.RowsDefaultCellStyle.SelectionBackColor; + tangRow.DefaultCellStyle.BackColor = tangRow.DefaultCellStyle.SelectionBackColor = entity.Finish ? Color.YellowGreen : dataGridView.RowsDefaultCellStyle.SelectionBackColor; tangEntity = entity; } else { if (maoRow != null) { - if ((bool)maoRow.Cells["D_Finish"].Value) + if (maoEntity.Finish) maoRow.DefaultCellStyle.BackColor = Color.YellowGreen; else maoRow.DefaultCellStyle.BackColor = dataGridView.RowsDefaultCellStyle.BackColor; } maoRow = dataGridView.CurrentRow; - maoRow.DefaultCellStyle.BackColor = dataGridView.RowsDefaultCellStyle.SelectionBackColor; + maoRow.DefaultCellStyle.BackColor = maoRow.DefaultCellStyle.SelectionBackColor = entity.Finish ? Color.YellowGreen : Color.Yellow; maoEntity = entity; } - if (e.ColumnIndex != dataGridView.ColumnCount - 1) - return; - if (entity.Finish) - return; - entity.Finish = true; - GradeAndWeightRpc.SetGradeFinish(entity.OrderDetail_ID, entity.Technics); - BindDataGrid(); - if (entity.Technics == 0) - { - maoRow = FindRowSetSelected(maoEntity); - tangEntity = null; - tangRow = null; - } - else + if (e.ColumnIndex == dataGridView.ColumnCount - 1 && !entity.Finish) { - tangRow = FindRowSetSelected(tangEntity); - maoEntity = null; - maoRow = null; + entity.Finish = true; + GradeAndWeightRpc.SetGradeFinish(entity.OrderDetail_ID, entity.Technics); + BindDataGrid(); + if (entity.Technics == 0) + { + maoRow = FindRowSetSelected(maoEntity); + tangEntity = null; + tangRow = null; + } + else + { + tangRow = FindRowSetSelected(tangEntity); + maoEntity = null; + maoRow = null; + } } dataGridView.Refresh(); } @@ -571,7 +596,15 @@ namespace WeighAndGrading { if ((long)row.Cells["D_OrderDetail_ID"].Value == tag.OrderDetail_ID && (string)row.Cells["D_Technics_Name"].Value == tag.Technics_Name) { - row.DefaultCellStyle.BackColor = dataGridView.RowsDefaultCellStyle.SelectionBackColor; + if (tag.Finish) + row.DefaultCellStyle.BackColor = Color.YellowGreen; + else + row.DefaultCellStyle.BackColor = tag.Technics == 1 ? Color.Yellow : dataGridView.RowsDefaultCellStyle.SelectionBackColor; + + if (tag.Technics == 0) + tangEntity = row.DataBoundItem as GradeAndWeight; + else + maoEntity = row.DataBoundItem as GradeAndWeight; return row; } } @@ -604,6 +637,8 @@ namespace WeighAndGrading discontPanel.Controls.Add(btn); } } + + int leftRoll = -1; private void InitScrollBar1() { vScrollBar1.Maximum = (dataGridView.RowCount - dataGridView.DisplayedRowCount(false) + 30) * dataGridView.RowTemplate.Height; @@ -612,11 +647,12 @@ namespace WeighAndGrading vScrollBar1.LargeChange = dataGridView.RowTemplate.Height * 30; this.vScrollBar1.Scroll += (sender, e) => { - dataGridView.FirstDisplayedScrollingRowIndex = e.NewValue / dataGridView.RowTemplate.Height; - Application.DoEvents(); + leftRoll = e.NewValue / dataGridView.RowTemplate.Height; + dataGridView.FirstDisplayedScrollingRowIndex = leftRoll; }; } + int rightRoll = -1; private void InitScrollBar2() { vScrollBar2.Maximum = (historyGrid.RowCount - historyGrid.DisplayedRowCount(false) + 30) * historyGrid.RowTemplate.Height; @@ -625,8 +661,8 @@ namespace WeighAndGrading vScrollBar2.LargeChange = historyGrid.RowTemplate.Height * 30; this.vScrollBar2.Scroll += (sender, e) => { - historyGrid.FirstDisplayedScrollingRowIndex = e.NewValue / historyGrid.RowTemplate.Height; - Application.DoEvents(); + rightRoll = e.NewValue / historyGrid.RowTemplate.Height; + historyGrid.FirstDisplayedScrollingRowIndex = rightRoll; }; } }