浏览代码

添加DC校验

章政 7 年之前
父节点
当前提交
4005ba374a

+ 3 - 0
UAS-出货标签管理(泽天)/App.config

@@ -59,6 +59,9 @@
       <setting name="OutboxCapacity" serializeAs="String">
         <value>0</value>
       </setting>
+      <setting name="DCCheck" serializeAs="String">
+        <value>0</value>
+      </setting>
     </UAS_LabelMachine.Properties.Settings>
   </userSettings>
 </configuration>

+ 3 - 0
UAS-出货标签管理(泽天)/Properties/Settings.settings

@@ -23,5 +23,8 @@
     <Setting Name="OutboxCapacity" Type="System.Decimal" Scope="User">
       <Value Profile="(Default)">0</Value>
     </Setting>
+    <Setting Name="DCCheck" Type="System.Decimal" Scope="User">
+      <Value Profile="(Default)">0</Value>
+    </Setting>
   </Settings>
 </SettingsFile>

+ 12 - 0
UAS-出货标签管理(泽天)/Properties/Settings1.Designer.cs

@@ -106,5 +106,17 @@ namespace UAS_LabelMachine.Properties {
                 this["OutboxCapacity"] = value;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("0")]
+        public decimal DCCheck {
+            get {
+                return ((decimal)(this["DCCheck"]));
+            }
+            set {
+                this["DCCheck"] = value;
+            }
+        }
     }
 }

+ 113 - 80
UAS-出货标签管理(泽天)/UAS_出货标签管理.Designer.cs

@@ -75,15 +75,10 @@
             this.ExportData = new System.Windows.Forms.Button();
             this.PrintFooter = new System.Windows.Forms.Button();
             this.SetPrintStatus_label = new System.Windows.Forms.Label();
+            this.pictureBox1 = new System.Windows.Forms.PictureBox();
+            this.label1 = new System.Windows.Forms.Label();
+            this.DCCheck = new UAS_LabelMachine.CustomControl.EnterTextBox();
             this.GridPrcode = new UAS_LabelMachine.CustomControl.DataGridViewWithSerialNum();
-            this.pd_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pjd_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.CollectedNum = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_outqty = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_unit = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_brand = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pjd_zxbzs_user = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.groupBoxWithBorder1 = new UAS_LabelMachine.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
             this.label18 = new System.Windows.Forms.Label();
             this.MidBoxEnd = new UAS_LabelMachine.CustomControl.EnterTextBox();
@@ -150,8 +145,16 @@
             this.OutBoxLabelPrint = new System.Windows.Forms.Button();
             this.OutBoxLabelAutoPrint = new System.Windows.Forms.CheckBox();
             this.OutBoxCombox = new System.Windows.Forms.ComboBox();
-            this.pictureBox1 = new System.Windows.Forms.PictureBox();
+            this.pd_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pjd_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.CollectedNum = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_outqty = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_unit = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_brand = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pjd_zxbzs_user = new System.Windows.Forms.DataGridViewTextBoxColumn();
             ((System.ComponentModel.ISupportInitialize)(this.MidSource)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridPrcode)).BeginInit();
             this.groupBoxWithBorder1.SuspendLayout();
             this.CollectionProcess.SuspendLayout();
@@ -160,7 +163,6 @@
             this.MidLabel.SuspendLayout();
             this.OutBoxLabel.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.OutboxCapacity)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
             this.SuspendLayout();
             // 
             // pi_inoutno_label
@@ -530,6 +532,7 @@
             this.PrintFooter.TabIndex = 89;
             this.PrintFooter.Text = "打印唛头";
             this.PrintFooter.UseVisualStyleBackColor = true;
+            this.PrintFooter.Click += new System.EventHandler(this.PrintFooter_Click);
             // 
             // SetPrintStatus_label
             // 
@@ -542,6 +545,38 @@
             this.SetPrintStatus_label.TabIndex = 76;
             this.SetPrintStatus_label.Text = "可打印";
             // 
+            // pictureBox1
+            // 
+            this.pictureBox1.Image = global::UAS_LabelMachine.Properties.Resources.Status;
+            this.pictureBox1.Location = new System.Drawing.Point(320, 114);
+            this.pictureBox1.Name = "pictureBox1";
+            this.pictureBox1.Size = new System.Drawing.Size(136, 74);
+            this.pictureBox1.TabIndex = 93;
+            this.pictureBox1.TabStop = false;
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label1.Location = new System.Drawing.Point(3, 151);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(57, 20);
+            this.label1.TabIndex = 95;
+            this.label1.Text = "DC校验";
+            // 
+            // DCCheck
+            // 
+            this.DCCheck.ID = null;
+            this.DCCheck.Location = new System.Drawing.Point(76, 151);
+            this.DCCheck.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.DCCheck.Name = "DCCheck";
+            this.DCCheck.Size = new System.Drawing.Size(60, 21);
+            this.DCCheck.Str = null;
+            this.DCCheck.Str1 = null;
+            this.DCCheck.Str2 = null;
+            this.DCCheck.TabIndex = 94;
+            this.DCCheck.Leave += new System.EventHandler(this.DCCheck_Leave);
+            // 
             // GridPrcode
             // 
             this.GridPrcode.AllowUserToAddRows = false;
@@ -565,69 +600,9 @@
             this.GridPrcode.TabIndex = 88;
             this.GridPrcode.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.GridPrcode_CellClick);
             this.GridPrcode.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.GridPrcode_CellEndEdit);
+            this.GridPrcode.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.GridPrcode_CellPainting);
             this.GridPrcode.SelectionChanged += new System.EventHandler(this.GridPrcode_SelectionChanged);
             // 
-            // pd_pdno
-            // 
-            this.pd_pdno.DataPropertyName = "pd_pdno";
-            this.pd_pdno.HeaderText = "明细序号";
-            this.pd_pdno.Name = "pd_pdno";
-            this.pd_pdno.ReadOnly = true;
-            this.pd_pdno.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            // 
-            // pjd_id
-            // 
-            this.pjd_id.DataPropertyName = "pjd_id";
-            this.pjd_id.HeaderText = "pjd_id";
-            this.pjd_id.Name = "pjd_id";
-            this.pjd_id.Visible = false;
-            // 
-            // pd_prodcode
-            // 
-            this.pd_prodcode.DataPropertyName = "pd_prodcode";
-            this.pd_prodcode.HeaderText = "物料编号";
-            this.pd_prodcode.Name = "pd_prodcode";
-            this.pd_prodcode.ReadOnly = true;
-            this.pd_prodcode.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            // 
-            // CollectedNum
-            // 
-            this.CollectedNum.DataPropertyName = "CollectedNum";
-            this.CollectedNum.HeaderText = "已采数";
-            this.CollectedNum.Name = "CollectedNum";
-            this.CollectedNum.ReadOnly = true;
-            // 
-            // pd_outqty
-            // 
-            this.pd_outqty.DataPropertyName = "pd_outqty";
-            this.pd_outqty.HeaderText = "出库数量";
-            this.pd_outqty.Name = "pd_outqty";
-            this.pd_outqty.ReadOnly = true;
-            this.pd_outqty.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            // 
-            // pr_unit
-            // 
-            this.pr_unit.DataPropertyName = "pr_unit";
-            this.pr_unit.HeaderText = "单位";
-            this.pr_unit.Name = "pr_unit";
-            this.pr_unit.ReadOnly = true;
-            this.pr_unit.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            // 
-            // pd_brand
-            // 
-            this.pd_brand.DataPropertyName = "pd_brand";
-            this.pd_brand.HeaderText = "品牌";
-            this.pd_brand.Name = "pd_brand";
-            this.pd_brand.ReadOnly = true;
-            this.pd_brand.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            // 
-            // pjd_zxbzs_user
-            // 
-            this.pjd_zxbzs_user.DataPropertyName = "pjd_zxbzs_user";
-            this.pjd_zxbzs_user.HeaderText = "最小包装";
-            this.pjd_zxbzs_user.Name = "pjd_zxbzs_user";
-            this.pjd_zxbzs_user.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            // 
             // groupBoxWithBorder1
             // 
             this.groupBoxWithBorder1.Controls.Add(this.label18);
@@ -880,6 +855,7 @@
             this.Input.Str2 = null;
             this.Input.TabIndex = 54;
             this.Input.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Input_KeyDown);
+            this.Input.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Input_KeyUp);
             // 
             // LabelInf
             // 
@@ -1360,14 +1336,67 @@
             this.OutBoxCombox.TabIndex = 78;
             this.OutBoxCombox.SelectedIndexChanged += new System.EventHandler(this.OutBoxCombox_SelectedIndexChanged);
             // 
-            // pictureBox1
+            // pd_pdno
             // 
-            this.pictureBox1.Image = global::UAS_LabelMachine.Properties.Resources.Status;
-            this.pictureBox1.Location = new System.Drawing.Point(320, 114);
-            this.pictureBox1.Name = "pictureBox1";
-            this.pictureBox1.Size = new System.Drawing.Size(136, 74);
-            this.pictureBox1.TabIndex = 93;
-            this.pictureBox1.TabStop = false;
+            this.pd_pdno.DataPropertyName = "pd_pdno";
+            this.pd_pdno.HeaderText = "明细序号";
+            this.pd_pdno.Name = "pd_pdno";
+            this.pd_pdno.ReadOnly = true;
+            this.pd_pdno.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            // 
+            // pjd_id
+            // 
+            this.pjd_id.DataPropertyName = "pjd_id";
+            this.pjd_id.HeaderText = "pjd_id";
+            this.pjd_id.Name = "pjd_id";
+            this.pjd_id.Visible = false;
+            // 
+            // pd_prodcode
+            // 
+            this.pd_prodcode.DataPropertyName = "pd_prodcode";
+            this.pd_prodcode.HeaderText = "物料编号";
+            this.pd_prodcode.Name = "pd_prodcode";
+            this.pd_prodcode.ReadOnly = true;
+            this.pd_prodcode.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            // 
+            // CollectedNum
+            // 
+            this.CollectedNum.DataPropertyName = "CollectedNum";
+            this.CollectedNum.HeaderText = "已采数";
+            this.CollectedNum.Name = "CollectedNum";
+            this.CollectedNum.ReadOnly = true;
+            // 
+            // pd_outqty
+            // 
+            this.pd_outqty.DataPropertyName = "pd_outqty";
+            this.pd_outqty.HeaderText = "出库数量";
+            this.pd_outqty.Name = "pd_outqty";
+            this.pd_outqty.ReadOnly = true;
+            this.pd_outqty.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            // 
+            // pr_unit
+            // 
+            this.pr_unit.DataPropertyName = "pr_unit";
+            this.pr_unit.HeaderText = "单位";
+            this.pr_unit.Name = "pr_unit";
+            this.pr_unit.ReadOnly = true;
+            this.pr_unit.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            // 
+            // pd_brand
+            // 
+            this.pd_brand.DataPropertyName = "pd_brand";
+            this.pd_brand.HeaderText = "品牌";
+            this.pd_brand.Name = "pd_brand";
+            this.pd_brand.ReadOnly = true;
+            this.pd_brand.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            // 
+            // pjd_zxbzs_user
+            // 
+            this.pjd_zxbzs_user.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.pjd_zxbzs_user.DataPropertyName = "pjd_zxbzs_user";
+            this.pjd_zxbzs_user.HeaderText = "最小包装";
+            this.pjd_zxbzs_user.Name = "pjd_zxbzs_user";
+            this.pjd_zxbzs_user.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             // 
             // UAS_出货标签打印
             // 
@@ -1375,6 +1404,8 @@
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(233)))), ((int)(((byte)(206)))));
             this.ClientSize = new System.Drawing.Size(1257, 711);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.DCCheck);
             this.Controls.Add(this.pictureBox1);
             this.Controls.Add(this.SetPrintStatus_label);
             this.Controls.Add(this.PrintFooter);
@@ -1411,6 +1442,7 @@
             this.Load += new System.EventHandler(this.贴标机条码打印_Load);
             this.SizeChanged += new System.EventHandler(this.贴标机条码打印_SizeChanged);
             ((System.ComponentModel.ISupportInitialize)(this.MidSource)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridPrcode)).EndInit();
             this.groupBoxWithBorder1.ResumeLayout(false);
             this.groupBoxWithBorder1.PerformLayout();
@@ -1424,7 +1456,6 @@
             this.OutBoxLabel.ResumeLayout(false);
             this.OutBoxLabel.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.OutboxCapacity)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -1543,6 +1574,9 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_spec;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode2;
+        private System.Windows.Forms.PictureBox pictureBox1;
+        private CustomControl.EnterTextBox DCCheck;
+        private System.Windows.Forms.Label label1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_pdno;
         private System.Windows.Forms.DataGridViewTextBoxColumn pjd_id;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_prodcode;
@@ -1551,6 +1585,5 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_unit;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_brand;
         private System.Windows.Forms.DataGridViewTextBoxColumn pjd_zxbzs_user;
-        private System.Windows.Forms.PictureBox pictureBox1;
     }
 }

+ 73 - 2
UAS-出货标签管理(泽天)/UAS_出货标签管理.cs

@@ -185,7 +185,7 @@ namespace UAS_LabelMachine
             Width = ScreenArea.Width;
             Height = ScreenArea.Height;
             OutboxCapacity.Value = Properties.Settings.Default.OutboxCapacity;
-
+            DCCheck.Text = Properties.Settings.Default.DCCheck.ToString();
             asc.controllInitializeSize(this);
             asc.controlAutoSize(this);
             //实例化打印进程
@@ -249,7 +249,7 @@ namespace UAS_LabelMachine
                     return;
                 }
                 CollectInputData();
-                Input.Text = "";
+                //Input.Select(0,Input.Text.Length);
             }
         }
 
@@ -309,6 +309,11 @@ namespace UAS_LabelMachine
                         break;
                 }
             }
+            if (!CheckDateCode(Data["DATECODE"]))
+            {
+                MessageBox.Show("物料DateCode超出校验日期");
+                return;
+            }
             if (Data["PRCODE"] != CurrentPrCode)
             {
                 MessageBox.Show("当前采集物料编号不对应,请重新采集", "提示");
@@ -420,6 +425,7 @@ namespace UAS_LabelMachine
             //采集后重新计数,自动跳到下一行
             collectqty = (LabelInfDataTable.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
             CollectQty = (collectqty == "" ? 0 : int.Parse(collectqty));
+            //采集达到了数量进行换行
             if (CollectQty == int.Parse(CurrentPrCount))
             {
                 for (int i = 0; i < GridPrcode.Rows.Count; i++)
@@ -1818,5 +1824,70 @@ namespace UAS_LabelMachine
         {
             GridPrcode.Rows[e.RowIndex].Selected = true;
         }
+
+        private void DCCheck_Leave(object sender, EventArgs e)
+        {
+            try
+            {
+                Properties.Settings.Default.DCCheck = int.Parse(DCCheck.Text);
+                Properties.Settings.Default.Save();
+            }
+            catch (Exception)
+            {
+                MessageBox.Show("DC校验时间必须是整数");
+            }
+        }
+
+        /// <summary>
+        /// 校验DateCode
+        /// </summary>
+        /// <param name="DateCode"></param>
+        private bool CheckDateCode(string DateCode)
+        {
+            //根据DateCode计算的日期
+            string Year = DateCode.Substring(0, 2);
+            System.DateTime dt = new System.DateTime(int.Parse("20" + Year), 01, 01);
+            string Week = DateCode.Substring(2, 2);
+            System.DateTime dt1 = dt.AddDays(int.Parse(Week) * 7);
+
+            //减去DC校验后的日期
+            System.DateTime now = System.DateTime.Now;
+            System.DateTime now1 = now.AddDays(-int.Parse(DCCheck.Text));
+            //物料的DateCode大于限制日期即可
+            if (dt1 > now1)
+            {
+                return true;
+            }
+            return false;
+        }
+
+        private void PrintFooter_Click(object sender, EventArgs e)
+        {
+
+        }
+
+        private void Input_KeyUp(object sender, KeyEventArgs e)
+        {
+            if (e.KeyCode == Keys.Enter)
+                Input.SelectAll();
+        }
+
+        private void GridPrcode_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
+        {
+            bool mouseOver = e.CellBounds.Contains(this.PointToClient(Cursor.Position));
+            if (e.ColumnIndex > 0)
+            {
+                if (GridPrcode.Columns[e.ColumnIndex].Name == "CollectedNum" || GridPrcode.Columns[e.ColumnIndex].Name == "pd_outqty")
+                {
+                    SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
+                    e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.LightSeaGreen, e.CellBounds);
+                    Rectangle border = e.CellBounds;
+                    border.Width -= 1;
+                    e.Graphics.DrawRectangle(Pens.White, border);
+                    e.PaintContent(e.CellBounds);
+                    e.Handled = true;
+                }
+            }
+        }
     }
 }