From 1f0fcef50b32bc51fe2ac1b45213570a333c24dc Mon Sep 17 00:00:00 2001 From: wugang <1029149336@qq.com> Date: Tue, 7 Nov 2017 21:36:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E6=88=90=20=E9=87=8D=E9=87=8F?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=8E=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BO/Utils/BillRpc/GradeAndWeightRpc.cs | 24 +- .../SegmentationWeightForm.Designer.cs | 38 +- SegmentationWeight/SegmentationWeightForm.cs | 7 +- WeighAndGrading/GradeFrom.Designer.cs | 343 ++++++++-------- WeighAndGrading/GradeFrom.cs | 377 +++++++++++++----- 5 files changed, 501 insertions(+), 288 deletions(-) diff --git a/BO/Utils/BillRpc/GradeAndWeightRpc.cs b/BO/Utils/BillRpc/GradeAndWeightRpc.cs index f882a93..0f30ff6 100644 --- a/BO/Utils/BillRpc/GradeAndWeightRpc.cs +++ b/BO/Utils/BillRpc/GradeAndWeightRpc.cs @@ -6,6 +6,7 @@ using Forks.EnterpriseServices.SqlDoms; using Forks.JsonRpc.Client; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -86,6 +87,17 @@ namespace BO.Utils.BillRpc } } + public static void DeleteBySID(long sid) + { + var delDom=new DQDeleteDom(typeof(GradeAndWeight_Detail)); + delDom.Where.Conditions.Add(DQCondition.EQ("SID",sid)); + using (var session = DmoSession.New()) + { + session.ExecuteNonQuery(delDom); + session.Commit(); + } + } + public static void UpdateLosted(long sid) { var updateDom = new DQUpdateDom(typeof(GradeAndWeight_Detail)); @@ -99,16 +111,24 @@ namespace BO.Utils.BillRpc } } - public static List GetDetails(DateTime date, int top = 15) + public static BindingList GetDetails(DateTime date, int top = 15) { + var bindList=new BindingList(); + var list=new List(); + var query = new DmoQuery(typeof(GradeAndWeight_Detail)); query.Where.Conditions.Add(DQCondition.EQ("Date", date)); query.OrderBy.Expressions.Add(DQOrderByExpression.Create("Index", true)); query.Range = SelectRange.Top(top); using (var session = DmoSession.New()) { - return session.ExecuteList(query).Cast().ToList(); + list= session.ExecuteList(query).Cast().ToList(); + } + foreach (GradeAndWeight_Detail detail in list) + { + bindList.Add(detail); } + return bindList; } public static int GetTangTuiSumNumber(DateTime date) diff --git a/SegmentationWeight/SegmentationWeightForm.Designer.cs b/SegmentationWeight/SegmentationWeightForm.Designer.cs index 2605de3..bddcb3a 100644 --- a/SegmentationWeight/SegmentationWeightForm.Designer.cs +++ b/SegmentationWeight/SegmentationWeightForm.Designer.cs @@ -28,9 +28,9 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle19 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle20 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle21 = new System.Windows.Forms.DataGridViewCellStyle(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.panel1 = new System.Windows.Forms.Panel(); this.btnGoodsSet = new System.Windows.Forms.Button(); @@ -160,7 +160,6 @@ // this.splitContainer2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; this.splitContainer2.Location = new System.Drawing.Point(0, 0); this.splitContainer2.Name = "splitContainer2"; // @@ -180,8 +179,9 @@ // // flpGoods // - this.flpGoods.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); + this.flpGoods.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.flpGoods.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.flpGoods.Location = new System.Drawing.Point(4, 87); this.flpGoods.Name = "flpGoods"; @@ -204,20 +204,20 @@ this.uDataGridView1.AllowUserToDeleteRows = false; this.uDataGridView1.AllowUserToResizeColumns = false; this.uDataGridView1.AllowUserToResizeRows = false; - dataGridViewCellStyle13.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.uDataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle13; + dataGridViewCellStyle19.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.uDataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle19; this.uDataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.uDataGridView1.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle14.Font = new System.Drawing.Font("宋体", 12F); - dataGridViewCellStyle14.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle14.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle14.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.uDataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle14; + dataGridViewCellStyle20.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle20.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle20.Font = new System.Drawing.Font("宋体", 12F); + dataGridViewCellStyle20.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle20.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle20.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle20.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.uDataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle20; this.uDataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.uDataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.序号, @@ -230,9 +230,9 @@ this.uDataGridView1.Name = "uDataGridView1"; this.uDataGridView1.ReadOnly = true; this.uDataGridView1.RowHeadersVisible = false; - dataGridViewCellStyle15.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle15.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.uDataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle15; + dataGridViewCellStyle21.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle21.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.uDataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle21; this.uDataGridView1.RowTemplate.Height = 23; this.uDataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.uDataGridView1.Size = new System.Drawing.Size(483, 374); diff --git a/SegmentationWeight/SegmentationWeightForm.cs b/SegmentationWeight/SegmentationWeightForm.cs index b23814e..f740b73 100644 --- a/SegmentationWeight/SegmentationWeightForm.cs +++ b/SegmentationWeight/SegmentationWeightForm.cs @@ -36,7 +36,7 @@ namespace SegmentationWeight public SegmentationWeightForm() { InitializeComponent(); - + uDataGridView1.AutoGenerateColumns = false; weightPort = new SerialPort(); this.FormClosing += delegate { @@ -294,7 +294,8 @@ namespace SegmentationWeight var btn=new Button(); btn.Text = text; btn.Click += Btn_Click; - + btn.Width = 100; + btn.Height = 60; return btn; } @@ -329,6 +330,8 @@ namespace SegmentationWeight btn.Text = set.Goods_Name; btn.Tag = set; btn.Click += BtnGoods_Click; + btn.Width = 100; + btn.Height = 60; return btn; } diff --git a/WeighAndGrading/GradeFrom.Designer.cs b/WeighAndGrading/GradeFrom.Designer.cs index f6d2c7e..4a4107d 100644 --- a/WeighAndGrading/GradeFrom.Designer.cs +++ b/WeighAndGrading/GradeFrom.Designer.cs @@ -28,19 +28,19 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle16 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle19 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle21 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle20 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle22 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle23 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle26 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle24 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle25 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle53 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle54 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle56 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle55 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle57 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle58 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle60 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle59 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle61 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle62 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle65 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle63 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle64 = new System.Windows.Forms.DataGridViewCellStyle(); this.label1 = new System.Windows.Forms.Label(); this.syncBtn = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); @@ -70,9 +70,19 @@ this.mbPanel = new System.Windows.Forms.FlowLayoutPanel(); this.lblMaoBo = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.lblHeJi = new System.Windows.Forms.Label(); this.vScrollBar2 = new System.Windows.Forms.VScrollBar(); this.label12 = new System.Windows.Forms.Label(); this.historyGrid = new BWP.WinFormControl.UDataGridView(); + this.H_SID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.H_Livestock_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.IsLostWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.H_ReadWeight = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.H_Index = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.H_Technics = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.H_Livestock_Name = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.H_Weight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.H_Time = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.enableWeight = new System.Windows.Forms.CheckBox(); this.isPrintCheckBox = new System.Windows.Forms.CheckBox(); this.printBtn = new System.Windows.Forms.Button(); @@ -90,16 +100,7 @@ this.btnLockItem = new System.Windows.Forms.Button(); this.btnClearLast = new System.Windows.Forms.Button(); this.btnAbnormalModify = new System.Windows.Forms.Button(); - this.H_SID = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.H_Livestock_ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.IsLostWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.H_ReadWeight = new System.Windows.Forms.DataGridViewCheckBoxColumn(); - this.H_Index = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.H_Technics = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.H_Livestock_Name = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.H_Weight = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.H_Time = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.lblHeJi = new System.Windows.Forms.Label(); + this.lblSucessed = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tangGridView)).BeginInit(); this.groupBox2.SuspendLayout(); @@ -215,17 +216,17 @@ this.tangGridView.AllowUserToDeleteRows = false; this.tangGridView.AllowUserToResizeColumns = false; this.tangGridView.AllowUserToResizeRows = false; - dataGridViewCellStyle14.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.tangGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle14; + dataGridViewCellStyle53.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.tangGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle53; this.tangGridView.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle15.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle15.Font = new System.Drawing.Font("宋体", 12F); - dataGridViewCellStyle15.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle15.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle15.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.tangGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle15; + dataGridViewCellStyle54.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle54.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle54.Font = new System.Drawing.Font("宋体", 12F); + dataGridViewCellStyle54.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle54.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle54.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle54.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.tangGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle54; this.tangGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.tangGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.T_OrderDetail_ID, @@ -239,11 +240,11 @@ this.tangGridView.Name = "tangGridView"; this.tangGridView.ReadOnly = true; this.tangGridView.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.tangGridView.RowsDefaultCellStyle = dataGridViewCellStyle17; + dataGridViewCellStyle56.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle56.ForeColor = System.Drawing.Color.Black; + dataGridViewCellStyle56.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + dataGridViewCellStyle56.SelectionForeColor = System.Drawing.Color.Black; + this.tangGridView.RowsDefaultCellStyle = dataGridViewCellStyle56; this.tangGridView.RowTemplate.Height = 50; this.tangGridView.ScrollBars = System.Windows.Forms.ScrollBars.None; this.tangGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -293,9 +294,9 @@ // // T_FinishBtn // - dataGridViewCellStyle16.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle16.Padding = new System.Windows.Forms.Padding(5, 10, 5, 10); - this.T_FinishBtn.DefaultCellStyle = dataGridViewCellStyle16; + dataGridViewCellStyle55.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle55.Padding = new System.Windows.Forms.Padding(5, 10, 5, 10); + this.T_FinishBtn.DefaultCellStyle = dataGridViewCellStyle55; this.T_FinishBtn.HeaderText = "完毕"; this.T_FinishBtn.Name = "T_FinishBtn"; this.T_FinishBtn.ReadOnly = true; @@ -327,17 +328,17 @@ this.maoGridView.AllowUserToDeleteRows = false; this.maoGridView.AllowUserToResizeColumns = false; this.maoGridView.AllowUserToResizeRows = false; - dataGridViewCellStyle18.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.maoGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle18; + dataGridViewCellStyle57.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.maoGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle57; this.maoGridView.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle19.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle19.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle19.Font = new System.Drawing.Font("宋体", 12F); - dataGridViewCellStyle19.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle19.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle19.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle19.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.maoGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle19; + dataGridViewCellStyle58.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle58.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle58.Font = new System.Drawing.Font("宋体", 12F); + dataGridViewCellStyle58.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle58.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle58.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle58.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.maoGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle58; this.maoGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.maoGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.M_OrderDetail_ID, @@ -351,11 +352,11 @@ this.maoGridView.Name = "maoGridView"; this.maoGridView.ReadOnly = true; this.maoGridView.RowHeadersVisible = false; - dataGridViewCellStyle21.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle21.ForeColor = System.Drawing.Color.Black; - dataGridViewCellStyle21.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - dataGridViewCellStyle21.SelectionForeColor = System.Drawing.Color.Black; - this.maoGridView.RowsDefaultCellStyle = dataGridViewCellStyle21; + dataGridViewCellStyle60.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle60.ForeColor = System.Drawing.Color.Black; + dataGridViewCellStyle60.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + dataGridViewCellStyle60.SelectionForeColor = System.Drawing.Color.Black; + this.maoGridView.RowsDefaultCellStyle = dataGridViewCellStyle60; this.maoGridView.RowTemplate.Height = 50; this.maoGridView.ScrollBars = System.Windows.Forms.ScrollBars.Horizontal; this.maoGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -405,9 +406,9 @@ // // M_FinishBtn // - dataGridViewCellStyle20.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle20.Padding = new System.Windows.Forms.Padding(5, 10, 5, 10); - this.M_FinishBtn.DefaultCellStyle = dataGridViewCellStyle20; + dataGridViewCellStyle59.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle59.Padding = new System.Windows.Forms.Padding(5, 10, 5, 10); + this.M_FinishBtn.DefaultCellStyle = dataGridViewCellStyle59; this.M_FinishBtn.HeaderText = "完毕"; this.M_FinishBtn.Name = "M_FinishBtn"; this.M_FinishBtn.ReadOnly = true; @@ -444,6 +445,16 @@ this.groupBox3.TabStop = false; this.groupBox3.Text = "记录"; // + // lblHeJi + // + this.lblHeJi.AutoSize = true; + this.lblHeJi.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.lblHeJi.Location = new System.Drawing.Point(6, 624); + this.lblHeJi.Name = "lblHeJi"; + this.lblHeJi.Size = new System.Drawing.Size(82, 24); + this.lblHeJi.TabIndex = 53; + this.lblHeJi.Text = "合计:"; + // // vScrollBar2 // this.vScrollBar2.Location = new System.Drawing.Point(425, 36); @@ -467,17 +478,17 @@ this.historyGrid.AllowUserToDeleteRows = false; this.historyGrid.AllowUserToResizeColumns = false; this.historyGrid.AllowUserToResizeRows = false; - dataGridViewCellStyle22.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); - this.historyGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle22; + dataGridViewCellStyle61.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); + this.historyGrid.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle61; this.historyGrid.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle23.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle23.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle23.Font = new System.Drawing.Font("宋体", 12F); - dataGridViewCellStyle23.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle23.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle23.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle23.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.historyGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle23; + dataGridViewCellStyle62.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle62.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle62.Font = new System.Drawing.Font("宋体", 12F); + dataGridViewCellStyle62.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle62.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle62.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle62.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.historyGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle62; this.historyGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.historyGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.H_SID, @@ -494,9 +505,9 @@ this.historyGrid.Name = "historyGrid"; this.historyGrid.ReadOnly = true; this.historyGrid.RowHeadersVisible = false; - dataGridViewCellStyle26.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle26.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); - this.historyGrid.RowsDefaultCellStyle = dataGridViewCellStyle26; + dataGridViewCellStyle65.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle65.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(66)))), ((int)(((byte)(163)))), ((int)(((byte)(218))))); + this.historyGrid.RowsDefaultCellStyle = dataGridViewCellStyle65; this.historyGrid.RowTemplate.Height = 40; this.historyGrid.ScrollBars = System.Windows.Forms.ScrollBars.None; this.historyGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -504,6 +515,81 @@ this.historyGrid.TabIndex = 0; this.historyGrid.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.historyGrid_CellClick); // + // H_SID + // + this.H_SID.DataPropertyName = "SID"; + this.H_SID.HeaderText = "SID"; + this.H_SID.Name = "H_SID"; + this.H_SID.ReadOnly = true; + this.H_SID.Visible = false; + // + // H_Livestock_ID + // + this.H_Livestock_ID.HeaderText = "Livestock_ID"; + this.H_Livestock_ID.Name = "H_Livestock_ID"; + this.H_Livestock_ID.ReadOnly = true; + this.H_Livestock_ID.Visible = false; + // + // IsLostWeight + // + this.IsLostWeight.DataPropertyName = "IsLostWeight"; + this.IsLostWeight.HeaderText = "IsLostWeight"; + this.IsLostWeight.Name = "IsLostWeight"; + this.IsLostWeight.ReadOnly = true; + this.IsLostWeight.Visible = false; + // + // H_ReadWeight + // + this.H_ReadWeight.DataPropertyName = "ReadWeight"; + this.H_ReadWeight.HeaderText = ""; + this.H_ReadWeight.Name = "H_ReadWeight"; + this.H_ReadWeight.ReadOnly = true; + this.H_ReadWeight.Width = 30; + // + // H_Index + // + this.H_Index.DataPropertyName = "Index"; + this.H_Index.HeaderText = "序号"; + this.H_Index.Name = "H_Index"; + this.H_Index.ReadOnly = true; + this.H_Index.Width = 65; + // + // H_Technics + // + this.H_Technics.DataPropertyName = "Technics_Name"; + this.H_Technics.HeaderText = "工艺"; + this.H_Technics.Name = "H_Technics"; + this.H_Technics.ReadOnly = true; + this.H_Technics.Width = 65; + // + // H_Livestock_Name + // + this.H_Livestock_Name.DataPropertyName = "Livestock_Name"; + this.H_Livestock_Name.HeaderText = "级别"; + this.H_Livestock_Name.Name = "H_Livestock_Name"; + this.H_Livestock_Name.ReadOnly = true; + this.H_Livestock_Name.Width = 90; + // + // H_Weight + // + this.H_Weight.DataPropertyName = "Weight"; + dataGridViewCellStyle63.Format = "#0.######"; + this.H_Weight.DefaultCellStyle = dataGridViewCellStyle63; + this.H_Weight.HeaderText = "重量"; + this.H_Weight.Name = "H_Weight"; + this.H_Weight.ReadOnly = true; + this.H_Weight.Width = 70; + // + // H_Time + // + this.H_Time.DataPropertyName = "Time"; + dataGridViewCellStyle64.Format = "HH:mm:ss"; + dataGridViewCellStyle64.NullValue = null; + this.H_Time.DefaultCellStyle = dataGridViewCellStyle64; + this.H_Time.HeaderText = "时间"; + this.H_Time.Name = "H_Time"; + this.H_Time.ReadOnly = true; + // // enableWeight // this.enableWeight.AutoCheck = false; @@ -577,7 +663,7 @@ // closeBtn // this.closeBtn.Font = new System.Drawing.Font("宋体", 15F); - this.closeBtn.Location = new System.Drawing.Point(1272, 20); + this.closeBtn.Location = new System.Drawing.Point(1256, 20); this.closeBtn.Name = "closeBtn"; this.closeBtn.Size = new System.Drawing.Size(102, 60); this.closeBtn.TabIndex = 33; @@ -660,29 +746,30 @@ // btnLockItem // this.btnLockItem.Font = new System.Drawing.Font("宋体", 15F); - this.btnLockItem.Location = new System.Drawing.Point(903, 20); + this.btnLockItem.Location = new System.Drawing.Point(867, 2); this.btnLockItem.Name = "btnLockItem"; - this.btnLockItem.Size = new System.Drawing.Size(102, 60); + this.btnLockItem.Size = new System.Drawing.Size(102, 25); this.btnLockItem.TabIndex = 34; this.btnLockItem.Text = "锁定"; this.btnLockItem.UseVisualStyleBackColor = true; + this.btnLockItem.Visible = false; this.btnLockItem.Click += new System.EventHandler(this.btnLockItem_Click); // // btnClearLast // this.btnClearLast.Font = new System.Drawing.Font("宋体", 15F); - this.btnClearLast.Location = new System.Drawing.Point(1027, 20); + this.btnClearLast.Location = new System.Drawing.Point(1011, 20); this.btnClearLast.Name = "btnClearLast"; this.btnClearLast.Size = new System.Drawing.Size(102, 60); this.btnClearLast.TabIndex = 34; - this.btnClearLast.Text = "清空"; + this.btnClearLast.Text = "删除"; this.btnClearLast.UseVisualStyleBackColor = true; this.btnClearLast.Click += new System.EventHandler(this.btnClearLast_Click); // // btnAbnormalModify // this.btnAbnormalModify.Font = new System.Drawing.Font("宋体", 15F); - this.btnAbnormalModify.Location = new System.Drawing.Point(1149, 20); + this.btnAbnormalModify.Location = new System.Drawing.Point(1133, 20); this.btnAbnormalModify.Name = "btnAbnormalModify"; this.btnAbnormalModify.Size = new System.Drawing.Size(102, 60); this.btnAbnormalModify.TabIndex = 34; @@ -690,96 +777,25 @@ this.btnAbnormalModify.UseVisualStyleBackColor = true; this.btnAbnormalModify.Click += new System.EventHandler(this.btnAbnormalModify_Click); // - // H_SID + // lblSucessed // - this.H_SID.DataPropertyName = "SID"; - this.H_SID.HeaderText = "SID"; - this.H_SID.Name = "H_SID"; - this.H_SID.ReadOnly = true; - this.H_SID.Visible = false; - // - // H_Livestock_ID - // - this.H_Livestock_ID.HeaderText = "Livestock_ID"; - this.H_Livestock_ID.Name = "H_Livestock_ID"; - this.H_Livestock_ID.ReadOnly = true; - this.H_Livestock_ID.Visible = false; - // - // IsLostWeight - // - this.IsLostWeight.DataPropertyName = "IsLostWeight"; - this.IsLostWeight.HeaderText = "IsLostWeight"; - this.IsLostWeight.Name = "IsLostWeight"; - this.IsLostWeight.ReadOnly = true; - this.IsLostWeight.Visible = false; - // - // H_ReadWeight - // - this.H_ReadWeight.DataPropertyName = "ReadWeight"; - this.H_ReadWeight.HeaderText = ""; - this.H_ReadWeight.Name = "H_ReadWeight"; - this.H_ReadWeight.ReadOnly = true; - this.H_ReadWeight.Width = 30; - // - // H_Index - // - this.H_Index.DataPropertyName = "Index"; - this.H_Index.HeaderText = "序号"; - this.H_Index.Name = "H_Index"; - this.H_Index.ReadOnly = true; - this.H_Index.Width = 65; - // - // H_Technics - // - this.H_Technics.DataPropertyName = "Technics_Name"; - this.H_Technics.HeaderText = "工艺"; - this.H_Technics.Name = "H_Technics"; - this.H_Technics.ReadOnly = true; - this.H_Technics.Width = 65; - // - // H_Livestock_Name - // - this.H_Livestock_Name.DataPropertyName = "Livestock_Name"; - this.H_Livestock_Name.HeaderText = "级别"; - this.H_Livestock_Name.Name = "H_Livestock_Name"; - this.H_Livestock_Name.ReadOnly = true; - this.H_Livestock_Name.Width = 90; - // - // H_Weight - // - this.H_Weight.DataPropertyName = "Weight"; - dataGridViewCellStyle24.Format = "#0.######"; - this.H_Weight.DefaultCellStyle = dataGridViewCellStyle24; - this.H_Weight.HeaderText = "重量"; - this.H_Weight.Name = "H_Weight"; - this.H_Weight.ReadOnly = true; - this.H_Weight.Width = 70; - // - // H_Time - // - this.H_Time.DataPropertyName = "Time"; - dataGridViewCellStyle25.Format = "HH:mm:ss"; - dataGridViewCellStyle25.NullValue = null; - this.H_Time.DefaultCellStyle = dataGridViewCellStyle25; - this.H_Time.HeaderText = "时间"; - this.H_Time.Name = "H_Time"; - this.H_Time.ReadOnly = true; - // - // lblHeJi - // - this.lblHeJi.AutoSize = true; - this.lblHeJi.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.lblHeJi.Location = new System.Drawing.Point(6, 624); - this.lblHeJi.Name = "lblHeJi"; - this.lblHeJi.Size = new System.Drawing.Size(82, 24); - this.lblHeJi.TabIndex = 53; - this.lblHeJi.Text = "合计:"; + this.lblSucessed.BackColor = System.Drawing.Color.Lime; + this.lblSucessed.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.lblSucessed.ForeColor = System.Drawing.Color.Red; + this.lblSucessed.Location = new System.Drawing.Point(691, 70); + this.lblSucessed.Name = "lblSucessed"; + this.lblSucessed.Size = new System.Drawing.Size(267, 39); + this.lblSucessed.TabIndex = 39; + this.lblSucessed.Text = "插入级别成功"; + this.lblSucessed.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lblSucessed.Visible = false; // // GradeFrom // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1379, 842); + this.ClientSize = new System.Drawing.Size(1382, 843); + this.Controls.Add(this.lblSucessed); this.Controls.Add(this.statePic); this.Controls.Add(this.discontPanel); this.Controls.Add(this.lblMaoBo); @@ -805,13 +821,11 @@ this.Controls.Add(this.butcherTimeInput); this.Controls.Add(this.label1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.KeyPreview = true; this.MaximizeBox = false; this.Name = "GradeFrom"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "称重定级"; this.Load += new System.EventHandler(this.GradeFrom_Load); - this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.GradeFrom_KeyPress); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.tangGridView)).EndInit(); @@ -891,5 +905,6 @@ private System.Windows.Forms.DataGridViewTextBoxColumn H_Weight; private System.Windows.Forms.DataGridViewTextBoxColumn H_Time; private System.Windows.Forms.Label lblHeJi; + private System.Windows.Forms.Label lblSucessed; } } \ No newline at end of file diff --git a/WeighAndGrading/GradeFrom.cs b/WeighAndGrading/GradeFrom.cs index 25b1629..9105947 100644 --- a/WeighAndGrading/GradeFrom.cs +++ b/WeighAndGrading/GradeFrom.cs @@ -45,7 +45,7 @@ namespace WeighAndGrading const short MAO_TECH = 1; List tangList; List maoList; - List details; + BindingList details; List localTang, localMao; string maoFilePath, tangFilePath; @@ -97,29 +97,29 @@ namespace WeighAndGrading GradeAndWeight_Detail modifyDetail; - private void GradeFrom_KeyPress(object sender, KeyPressEventArgs e) - { - Char keyChar = e.KeyChar; - var key = keyChar.ToString().ToLower(); - foreach (Button btn in ttPanel.Controls) - { - var livestockTag = btn.Tag as CTuple; - if (livestockTag.Item4.ToLower() == key) - { - JiBieButtonClick(btn); - SetJiBieSelectBackColor(btn.Text); - } - } - foreach (Button btn in mbPanel.Controls) - { - var livestockTag = btn.Tag as CTuple; - if (livestockTag.Item4.ToLower() == key) - { - JiBieButtonClick(btn); - SetJiBieSelectBackColor(btn.Text); - } - } - } +// private void GradeFrom_KeyPress(object sender, KeyPressEventArgs e) +// { +// Char keyChar = e.KeyChar; +// var key = keyChar.ToString().ToLower(); +// foreach (Button btn in ttPanel.Controls) +// { +// var livestockTag = btn.Tag as CTuple; +// if (livestockTag.Item4.ToLower() == key) +// { +// JiBieButtonClick(btn); +// SetJiBieSelectBackColor(btn.Text); +// } +// } +// foreach (Button btn in mbPanel.Controls) +// { +// var livestockTag = btn.Tag as CTuple; +// if (livestockTag.Item4.ToLower() == key) +// { +// JiBieButtonClick(btn); +// SetJiBieSelectBackColor(btn.Text); +// } +// } +// } //点击 级别 void JiBieButtonClick(Button btn) @@ -129,6 +129,9 @@ namespace WeighAndGrading MessageBox.Show("请先同步数据"); return; } + + SetlblSucessVisibleTrue(); + var livestockTag = btn.Tag as CTuple; if (modifyDetail == null) AddDetail(livestockTag); @@ -143,6 +146,8 @@ namespace WeighAndGrading modifyDetail = null; modifyPanel.Hide(); } + + SetlblSucessVisibleFalse(); } void AddLivestockBtn() @@ -158,7 +163,7 @@ namespace WeighAndGrading livestocks = XmlUtil.DeserializeFromFile>>(fileName); foreach (var item in livestocks) { - var btn = new Button() { Name = "_" + item.Item1, Text = item.Item2 + "(" + item.Item4.ToLower() + ")", Tag = item, Size = new Size(90, 75), TextAlign = ContentAlignment.MiddleCenter, Margin = new Padding { All = 15 }, Font = new Font("宋体", 18) }; + var btn = new Button() { Name = "_" + item.Item1, Text = item.Item2 , Tag = item, Size = new Size(90, 75), TextAlign = ContentAlignment.MiddleCenter, Margin = new Padding { All = 15 }, Font = new Font("宋体", 18) }; btn.Click += (sender, e) => { @@ -198,12 +203,16 @@ namespace WeighAndGrading }; if (item.Item3 == TANG_TECH) { - btn.Click += delegate { SetJiBieSelectBackColor(btn.Text); }; + btn.KeyDown += Btn_KeyDown; + btn.KeyUp += Btn_KeyUp; + ttPanel.Controls.Add(btn); } else { - btn.Click += delegate { SetJiBieSelectBackColor(btn.Text); }; + btn.KeyDown += Btn_KeyDown; + btn.KeyUp += Btn_KeyUp; + mbPanel.Controls.Add(btn); } } @@ -211,34 +220,46 @@ namespace WeighAndGrading SetMargin(mbPanel); } - private void SetJiBieSelectBackColor(string btnText) + private void Btn_KeyUp(object sender, KeyEventArgs e) { - foreach (Control control in ttPanel.Controls) - { - if (control.Text == btnText) - { - control.BackColor = Color.Aqua; - } - else - { - control.BackColor = SystemColors.Control; - } - } - - foreach (Control control in mbPanel.Controls) - { - if (control.Text == btnText) - { - control.BackColor = Color.Aqua; - } - else - { - control.BackColor = SystemColors.Control; - } - } + var btn = sender as Button; + btn.BackColor = SystemColors.Control; + } + private void Btn_KeyDown(object sender, KeyEventArgs e) + { + var btn = sender as Button; + btn.BackColor = Color.Aqua; } + // private void SetJiBieSelectBackColor(string btnText) + // { + // foreach (Control control in ttPanel.Controls) + // { + // if (control.Text == btnText) + // { + // control.BackColor = Color.Aqua; + // } + // else + // { + // control.BackColor = SystemColors.Control; + // } + // } + // + // foreach (Control control in mbPanel.Controls) + // { + // if (control.Text == btnText) + // { + // control.BackColor = Color.Aqua; + // } + // else + // { + // control.BackColor = SystemColors.Control; + // } + // } + // + // } + void SetMargin(FlowLayoutPanel panel) { @@ -575,12 +596,12 @@ namespace WeighAndGrading var allowInterval = GradeContext.Config.AllowInterval; //如果间隔时间内多条的话不处理 - var timeSpanTotalSeconds= (DateTime.Now - lastWeightDateTime).TotalSeconds; - if (Convert.ToDecimal(timeSpanTotalSeconds) > allowInterval) - { +// var timeSpanTotalSeconds= (DateTime.Now - lastWeightDateTime).TotalSeconds; +// if (Convert.ToDecimal(timeSpanTotalSeconds) > allowInterval) +// { AddWeightDetail(decimal.Parse(lblChengZhong.Text)); - lastWeightDateTime = DateTime.Now; - } +// lastWeightDateTime = DateTime.Now; +// } } })); @@ -699,7 +720,81 @@ namespace WeighAndGrading static object _obj = new object(); - void AddDetail(CTuple livestock) + +// void AddDetail(CTuple livestock) +// { +// lock (_obj) +// { +// var currentRow = livestock.Item3 == 0 ? tangEntity : maoEntity; +// var tech = livestock.Item3 == TANG_TECH ? "烫褪" : "毛剥"; +// +// GradeAndWeight_Detail first; +// if (noLivestockList.TryPeek(out first) && first.Livestock_ID == null) +// { +// noLivestockList.TryDequeue(out first); +// if (currentRow != null) +// first.OrderDetail_ID = currentRow.OrderDetail_ID; +// first.Date = butcherTimeInput.Date.Value; +// first.Livestock_ID = livestock.Item1; +// first.Livestock_Name = livestock.Item2; +// first.Technics = livestock.Item3; +// first.Technics_Name = tech; +// if (disBtn != null) +// { +// first.Weight = (first.Weight ?? 0) - Convert.ToDecimal(disBtn.Tag); +// SetBtnUnCheck(disBtn); +// disBtn = null; +// } +// LocalGradeAndWeightBL.Update(first, "OrderDetail_ID", "Date", "Livestock_ID", "Livestock_Name", "Technics", "Technics_Name", "Weight"); +// historyGrid.Refresh(); +// } +// else//add +// { +// maxIndex++; +// var entity = new GradeAndWeight_Detail(); +// entity.Index = maxIndex; +// if (currentRow != null) +// entity.OrderDetail_ID = currentRow.OrderDetail_ID; +// entity.Date = butcherTimeInput.Date.Value; +// entity.Livestock_ID = livestock.Item1; +// entity.Livestock_Name = livestock.Item2; +// entity.Technics = livestock.Item3; +// entity.Technics_Name = tech; +// entity.Time = DateTime.Now; +// entity.Date = butcherTimeInput.Date.Value; +// if (disBtn != null) +// { +// entity.Weight = -Convert.ToDecimal(disBtn.Tag); +// SetBtnUnCheck(disBtn); +// disBtn = null; +// } +// if (details.Count == 50) +// details.RemoveAt(49); +// details.Insert(0, entity); +// LocalGradeAndWeightBL.Insert(entity); +// noWeightList.Enqueue(entity); +// BindDetailGrid(); +// } +// if (currentRow != null) +// { +// currentRow.Already = currentRow.Already + 1; +// orderLabel.Text = currentRow.Order.ToString(); +// alreadyLabel.Text = currentRow.Already.ToString(); +// tangGridView.Refresh(); +// } +// else +// { +// orderLabel.Text = string.Empty; +// alreadyLabel.Text = string.Empty; +// } +// +// //计算合计 +// ReSetHistorySum(); +// } +// } + + + void AddDetail(CTuple livestock) { lock (_obj) { @@ -726,7 +821,7 @@ namespace WeighAndGrading LocalGradeAndWeightBL.Update(first, "OrderDetail_ID", "Date", "Livestock_ID", "Livestock_Name", "Technics", "Technics_Name", "Weight"); historyGrid.Refresh(); } - else//add + else//add { maxIndex++; var entity = new GradeAndWeight_Detail(); @@ -746,12 +841,17 @@ namespace WeighAndGrading SetBtnUnCheck(disBtn); disBtn = null; } + //如果手动点击新增明细,则明细的重量=0 + entity.Weight = 0; + entity.IsLostWeight = true; + if (details.Count == 50) details.RemoveAt(49); details.Insert(0, entity); LocalGradeAndWeightBL.Insert(entity); - noWeightList.Enqueue(entity); +// noWeightList.Enqueue(entity); // 添加的掉猪明细不加入到没有称重队列 BindDetailGrid(); + } if (currentRow != null) { @@ -771,6 +871,22 @@ namespace WeighAndGrading } } + void SetlblSucessVisibleFalse() + { + + this.Invoke(new Action(() => + { + Thread.Sleep(1000); + lblSucessed.Visible = false; + })); + } + void SetlblSucessVisibleTrue() + { + lblSucessed.Visible = true; + Application.DoEvents(); + } + + void ReSetHistorySum() { var tangtui=LocalGradeAndWeightBL.GetTangTuiSumNumber(butcherTimeInput.Date.Value); @@ -784,33 +900,36 @@ namespace WeighAndGrading lock (_obj) { weight -= (GradeContext.Config.Discont ?? 0); - GradeAndWeight_Detail first; - if (noWeightList.TryPeek(out first)) - { - noWeightList.TryDequeue(out first); - if (first.Weight < 0) - first.Weight = (first.Weight ?? 0) + weight; - else - first.Weight = weight; - LocalGradeAndWeightBL.Update(first, "Weight"); - historyGrid.Refresh(); - } - else//add +// GradeAndWeight_Detail first; +// if (noWeightList.TryPeek(out first)) +// { +// noWeightList.TryDequeue(out first); +// if (first.Weight < 0) +// first.Weight = (first.Weight ?? 0) + weight; +// else +// first.Weight = weight; +// LocalGradeAndWeightBL.Update(first, "Weight"); +// historyGrid.Refresh(); +// } +// else//add { - //todo 目前先去掉 称重增加记录的功能 - - // maxIndex++; - // var entity = new GradeAndWeight_Detail(); - // entity.Index = maxIndex; - // entity.Weight = (entity.Weight ?? 0) + weight; - // entity.Time = DateTime.Now; - // entity.Date = butcherTimeInput.Date.Value; - // if (details.Count == 50) - // details.RemoveAt(49); - // details.Insert(0, entity); - // LocalGradeAndWeightBL.Insert(entity); - // noLivestockList.Enqueue(entity); - // BindDetailGrid(); + + + maxIndex++; + var entity = new GradeAndWeight_Detail(); + entity.Index = maxIndex; + entity.Weight = (entity.Weight ?? 0) + weight; + entity.Time = DateTime.Now; + entity.Date = butcherTimeInput.Date.Value; + if (details.Count == 50) + details.RemoveAt(49); + details.Insert(0, entity); + LocalGradeAndWeightBL.Insert(entity); + noLivestockList.Enqueue(entity); + BindDetailGrid(); + +// SetlblSucessVisibleTrue(); +// SetlblSucessVisibleFalse(); } } @@ -826,36 +945,92 @@ namespace WeighAndGrading private void btnClearLast_Click(object sender, EventArgs e) { -// if (MessageBox.Show("确定清空最后一次称重?", "确定清空最后一次称重?", MessageBoxButtons.OKCancel) == DialogResult.Cancel) + if (MessageBox.Show("确定删除最后一条记录?", "确定删除最后一条记录?", MessageBoxButtons.OKCancel) == DialogResult.Cancel) + { + return; + } + + // if (mCurrentSlectItem == null) + // { + // return; + // } + + + #region 原来逻辑 清空最后一条有重量的值 + // //有称重重量的 并且不是掉猪的最大的一条 + // var fuhemaxsid = details.Where(x => x.Weight.HasValue && !x.IsLostWeight).Max(x => x.SID); + // var fd = details.First(x => x.SID == fuhemaxsid); + // fd.Weight = null; + // + // //清空数据库重量记录 + // LocalGradeAndWeightBL.ClearWeightBySID(fuhemaxsid); + + +// historyGrid.Refresh(); +// +// noWeightList = new ConcurrentQueue(); +// var stack = new Stack(); +// foreach (var item in details) // { -// return; +// if (item.SID > fd.SID) +// { +// stack.Push(item); +// } // } - -// if (mCurrentSlectItem == null) +// while (stack.Count > 0) // { -// return; +// noWeightList.Enqueue(stack.Pop()); // } + #endregion -//有称重重量的 并且不是掉猪的最大的一条 - var fuhemaxsid = details.Where(x => x.Weight.HasValue && !x.IsLostWeight).Max(x => x.SID); - var fd = details.First(x => x.SID == fuhemaxsid); - fd.Weight = null; + if (details.Count == 0) + { + return; + } + var lastItem = details[0]; + //如果级别不为空 则返回 + if (!string.IsNullOrWhiteSpace(lastItem.Livestock_Name)) + { + return; + } - //清空数据库重量记录 - LocalGradeAndWeightBL.ClearWeightBySID(fuhemaxsid); + details.RemoveAt(0); + //删除数据库 + LocalGradeAndWeightBL.DeleteBySID(lastItem.SID); historyGrid.Refresh(); - noWeightList = new ConcurrentQueue(); + + + //从新赋值 没有级别的 + // noLivestockList=new ConcurrentQueue(); + // + // + // + // GradeAndWeight_Detail first; + // if (noLivestockList.TryPeek(out first) && first.Livestock_ID == null) + // { + // noLivestockList.TryDequeue(out first); + // } + + //重新设置没有级别的 + noLivestockList = new ConcurrentQueue(); var stack = new Stack(); - foreach (var item in details) + + //找到锁定的最大id + var suodingmaxsid = details.Where(x => x.IsLostWeight).Max(x => x.SID); + //把没有级别的记录加进去 + var livestockNoNameList = details.Where(x => string.IsNullOrWhiteSpace(x.Livestock_Name)); + foreach (var item in livestockNoNameList) { - if (item.SID >= fd.SID) + if (item.SID > suodingmaxsid) { stack.Push(item); } } while (stack.Count > 0) - noWeightList.Enqueue(stack.Pop()); + { + noLivestockList.Enqueue(stack.Pop()); + } } private void btnLockItem_Click(object sender, EventArgs e) @@ -910,7 +1085,7 @@ namespace WeighAndGrading foreach (DataGridViewRow row in historyGrid.Rows) { if ((bool)row.Cells["IsLostWeight"].Value) - row.DefaultCellStyle.BackColor = Color.Red; + row.DefaultCellStyle.ForeColor = Color.Red; } }