Explorar o código

修改装箱采集功能

章政 %!s(int64=8) %!d(string=hai) anos
pai
achega
5b94a2d59d

+ 31 - 29
UAS-MES/FunctionCode/Make/Make_PackageCollection.Designer.cs

@@ -49,7 +49,7 @@
             this.pr_id = new System.Windows.Forms.Label();
             this.label2 = new System.Windows.Forms.Label();
             this.PrintNum = new System.Windows.Forms.NumericUpDown();
-            this.pa_code = new UAS_MES.CustomControl.TextBoxWithIcon.TextBoxGeneratePaCode();
+            this.pa_outboxcode = new UAS_MES.CustomControl.TextBoxWithIcon.TextBoxGeneratePaCode();
             this.PrintList = new UAS_MES.CustomControl.ComBoxWithFocus.PrinterCombox();
             this.OperateResult = new UAS_MES.CustomControl.RichText.RichTextAutoBottom();
             this.ma_code = new UAS_MES.CustomControl.TextBoxWithIcon.SearchTextBox();
@@ -63,7 +63,7 @@
             this.barcode = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.PackageDetail = new UAS_MES.CustomControl.DataGrid_View.DataGridViewWithSerialNum();
             this.pd_barcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pa_outboxcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pa_outboxcode1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pd_innerqty = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pa_indate = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pd_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -285,16 +285,16 @@
             0,
             0});
             // 
-            // pa_code
+            // pa_outboxcode
             // 
-            this.pa_code.ErrorMsg = null;
-            this.pa_code.Location = new System.Drawing.Point(108, 54);
-            this.pa_code.Margin = new System.Windows.Forms.Padding(4);
-            this.pa_code.Name = "pa_code";
-            this.pa_code.Pr_id = null;
-            this.pa_code.Size = new System.Drawing.Size(149, 21);
-            this.pa_code.TabIndex = 163;
-            this.pa_code.KeyDown += new System.Windows.Forms.KeyEventHandler(this.pa_code_KeyDown);
+            this.pa_outboxcode.ErrorMsg = null;
+            this.pa_outboxcode.Location = new System.Drawing.Point(108, 54);
+            this.pa_outboxcode.Margin = new System.Windows.Forms.Padding(4);
+            this.pa_outboxcode.Name = "pa_outboxcode";
+            this.pa_outboxcode.Pr_id = null;
+            this.pa_outboxcode.Size = new System.Drawing.Size(149, 21);
+            this.pa_outboxcode.TabIndex = 163;
+            this.pa_outboxcode.KeyDown += new System.Windows.Forms.KeyEventHandler(this.pa_code_KeyDown);
             // 
             // PrintList
             // 
@@ -327,7 +327,7 @@
             this.ma_code.ReturnData = null;
             this.ma_code.SelectField = null;
             this.ma_code.SetValueField = null;
-            this.ma_code.Size = new System.Drawing.Size(149, 21);
+            this.ma_code.Size = new System.Drawing.Size(150, 21);
             this.ma_code.TabIndex = 152;
             this.ma_code.TableName = null;
             this.ma_code.Tag = "ma_code";
@@ -476,7 +476,7 @@
             this.PackageDetail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
             this.PackageDetail.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
             this.pd_barcode,
-            this.pa_outboxcode,
+            this.pa_outboxcode1,
             this.pd_innerqty,
             this.pa_indate,
             this.pd_id});
@@ -489,21 +489,21 @@
             // 
             // pd_barcode
             // 
+            this.pd_barcode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
             this.pd_barcode.DataPropertyName = "pd_barcode";
             this.pd_barcode.HeaderText = "序号";
             this.pd_barcode.Name = "pd_barcode";
             this.pd_barcode.ReadOnly = true;
             this.pd_barcode.Resizable = System.Windows.Forms.DataGridViewTriState.True;
             this.pd_barcode.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Programmatic;
-            this.pd_barcode.Width = 255;
             // 
-            // pa_outboxcode
+            // pa_outboxcode1
             // 
-            this.pa_outboxcode.DataPropertyName = "pa_outboxcode";
-            this.pa_outboxcode.HeaderText = "箱号";
-            this.pa_outboxcode.Name = "pa_outboxcode";
-            this.pa_outboxcode.ReadOnly = true;
-            this.pa_outboxcode.Width = 240;
+            this.pa_outboxcode1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+            this.pa_outboxcode1.DataPropertyName = "pa_outboxcode";
+            this.pa_outboxcode1.HeaderText = "箱号";
+            this.pa_outboxcode1.Name = "pa_outboxcode1";
+            this.pa_outboxcode1.ReadOnly = true;
             // 
             // pd_innerqty
             // 
@@ -511,15 +511,17 @@
             this.pd_innerqty.HeaderText = "箱内数量";
             this.pd_innerqty.Name = "pd_innerqty";
             this.pd_innerqty.ReadOnly = true;
-            this.pd_innerqty.Width = 230;
+            this.pd_innerqty.Visible = false;
+            this.pd_innerqty.Width = 80;
             // 
             // pa_indate
             // 
+            this.pa_indate.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
             this.pa_indate.DataPropertyName = "pa_indate";
             this.pa_indate.HeaderText = "装箱日期";
             this.pa_indate.Name = "pa_indate";
             this.pa_indate.ReadOnly = true;
-            this.pa_indate.Width = 230;
+            this.pa_indate.Width = 300;
             // 
             // pd_id
             // 
@@ -535,7 +537,7 @@
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1019, 608);
             this.Controls.Add(this.PrintNum);
-            this.Controls.Add(this.pa_code);
+            this.Controls.Add(this.pa_outboxcode);
             this.Controls.Add(this.label2);
             this.Controls.Add(this.pr_id);
             this.Controls.Add(this.label3);
@@ -610,18 +612,18 @@
         private CustomControl.ButtonUtil.NormalButton Printing;
         private CustomControl.TextBoxWithIcon.SearchTextBox ma_code;
         private System.Windows.Forms.Label pa_id;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pd_barcode;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pa_outboxcode;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pd_innerqty;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pa_indate;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pd_id;
         private CustomControl.RichText.RichTextAutoBottom OperateResult;
         private CustomControl.ComBoxWithFocus.PrinterCombox PrintList;
         private System.Windows.Forms.ComboBox PrintLabel;
         private System.Windows.Forms.Label label3;
         private System.Windows.Forms.Label pr_id;
         private System.Windows.Forms.Label label2;
-        private CustomControl.TextBoxWithIcon.TextBoxGeneratePaCode pa_code;
+        private CustomControl.TextBoxWithIcon.TextBoxGeneratePaCode pa_outboxcode;
         private System.Windows.Forms.NumericUpDown PrintNum;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pd_barcode;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pa_outboxcode1;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pd_innerqty;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pa_indate;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pd_id;
     }
 }

+ 56 - 44
UAS-MES/FunctionCode/Make/Make_PackageCollection.cs

@@ -8,6 +8,7 @@ using UAS_MES.Entity;
 using UAS_MES.PublicMethod;
 using System.Drawing;
 using System.Threading;
+using UAS_MES.PublicForm;
 
 namespace UAS_MES.Make
 {
@@ -21,6 +22,8 @@ namespace UAS_MES.Make
         Thread thread;
         DataTable Dbfind;
 
+        System.DateTime[] indate;
+
         public Make_PackageCollection()
         {
             InitializeComponent();
@@ -35,18 +38,20 @@ namespace UAS_MES.Make
         private void 包装采集_Load(object sender, EventArgs e)
         {
             dh = new DataHelper();
-            thread = new Thread(NewPrint);
-            thread.Start();
             AutoPrint.Checked = true;
             //设置DbFind的必须的数据
             ma_code.FormName = Name;
-            ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "ma_prodname", "pr_id" };
+            ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "ma_prodname" };
             ma_code.TableName = "Make left join product on  ma_prodcode=pr_code";
-            ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 物料编号,ma_qty # 数量,ma_prodname # 物料名册,ma_wccode # 工作中心编号";
+            ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 物料编号,pr_detail # 物料名称";
             ma_code.Condition = "ma_statuscode='STARTED'";
             ma_code.DbChange += Ma_code_DbChange;
             PrintNum.Value = 1;
             asc.controllInitializeSize(this);
+            thread = new Thread(NewPrint);
+            SetLoadingWindow stw = new SetLoadingWindow(thread, "初始化打印程序");
+            BaseUtil.SetFormCenter(stw);
+            stw.ShowDialog();
         }
 
         private void Ma_code_DbChange(object sender, EventArgs e)
@@ -62,35 +67,41 @@ namespace UAS_MES.Make
 
         private void 包装采集_Activated(object sender, EventArgs e)
         {
-            pa_code.Focus();
+            pa_outboxcode.Focus();
         }
 
         //刷新表单的数据的数据
         private void LoadData()
         {
-            //加载Grid数据
-            dt = (DataTable)dh.ExecuteSql("select pa_outboxcode,pd_barcode,pd_innerqty,pa_indate from packageDetail left join package on pa_id=pd_paid where pa_outboxcode='" + pa_code.Text + "'", "select");
-            BaseUtil.FillDgvWithDataTable(PackageDetail, dt);
             //加载表单数据
             sql.Clear();
-            sql.Append("select pr_id,pa_id,pa_totalqty,pa_packageqty,pa_totalqty-pa_packageqty pa_restqty,ma_prodcode,pr_detail,pr_colorboxmaxw,pr_colorboxminw,pr_code,pa_makecode as ma_code ");
-            sql.Append("from package left join packagedetail on pd_paid=pa_id left join product left join make on ma_prodcode=pr_code on pa_prodcode=pr_code where pa_outboxcode='" + pa_code.Text + "' and rownum=1");
+            sql.Append("select pa_outboxcode,pr_id,pa_id,pa_totalqty,pa_packageqty,pa_totalqty-pa_packageqty pa_restqty,ma_prodcode,pr_detail,");
+            sql.Append("pr_colorboxmaxw,pr_colorboxminw,pr_code,pa_makecode as ma_code from package left join packagedetail on  ");
+            sql.Append("pd_paid=pa_id left join product left join make on ma_prodcode=pr_code on pa_prodcode=pr_code where ");
+            sql.Append("(pa_outboxcode='" + pa_outboxcode.Text + "' or pd_barcode='" + barcode.Text + "') and rownum=1 ");
             dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
             BaseUtil.SetFormValue(this.Controls, dt);
+            //加载Grid数据
+            dt = (DataTable)dh.ExecuteSql("select pa_outboxcode,pd_barcode,pd_innerqty,pa_indate from packageDetail left join package on pa_id=pd_paid where pa_outboxcode='" + pa_outboxcode.Text + "'", "select");
+            BaseUtil.FillDgvWithDataTable(PackageDetail, dt);
+            barcode.Clear();
         }
 
         private void InsertDetail()
         {
-            //插入工序表MakeSerial,如果是第一道工序的话
-            //插入PackageDetail从表信息
-            sql.Clear();
-            sql.Append("insert into packagedetail(pd_id,pd_paid,pd_outboxcode,pd_innerqty,pd_barcode) ");
-            sql.Append("select packagedetail_seq.nextval,pa_id,pa_outboxcode,pa_totalqty,'" + barcode.Text + "' from package where pa_outboxcode='" + pa_code.Text + "'");
-            dh.ExecuteSql(sql.GetString(), "insert");
-            dh.UpdateByCondition("Package", "pa_packageqty=pa_packageqty+1", "pa_outboxcode='" + pa_code.Text + "'");
-            OperateResult.AppendText("序列号" + barcode.Text + "采集成功!\n", Color.Green);
-            barcode.Clear();
-            LoadData();
+            if (int.Parse(pa_restqty.Text == "" ? "1" : pa_restqty.Text) > 0)
+            {
+                sql.Clear();
+                sql.Append("insert into packagedetail(pd_id,pd_paid,pd_outboxcode,pd_innerqty,pd_barcode) ");
+                sql.Append("select packagedetail_seq.nextval,pa_id,pa_outboxcode,pa_totalqty,'" + barcode.Text + "' from package where pa_outboxcode='" + pa_outboxcode.Text + "'");
+                dh.ExecuteSql(sql.GetString(), "insert");
+                dh.UpdateByCondition("Package", "pa_packageqty=pa_packageqty+1", "pa_outboxcode='" + pa_outboxcode.Text + "'");
+                OperateResult.AppendText("序列号" + barcode.Text + "采集成功!\n", Color.Green);
+                barcode.Clear();
+                LoadData();
+            }
+            else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "已采集满\n", Color.Red);
+
         }
 
         private void Print_Click(object sender, EventArgs e)
@@ -104,7 +115,7 @@ namespace UAS_MES.Make
                     try
                     {
                         OperateResult.AppendText("开始打印\n", Color.Green);
-                        Print.CodeSoft(lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrintList.Text, barcode.Text);
+                        Print.CodeSoft(lbl, PrintLabel.Text.Split(':')[1], PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), indate[PrintLabel.SelectedIndex]);
                     }
                     catch
                     {
@@ -115,7 +126,7 @@ namespace UAS_MES.Make
             else
             {
                 if (PrintLabel.SelectedValue != null)
-                    Print.CodeSoft(lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrintList.Text, barcode.Text);
+                    Print.CodeSoft(lbl, PrintLabel.Text.Split(':')[1], PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), indate[PrintLabel.SelectedIndex]);
             }
         }
 
@@ -144,7 +155,7 @@ namespace UAS_MES.Make
             if (e.KeyCode == Keys.Enter)
             {
                 //先判断箱号不为空
-                if (pa_code.Text != "" && barcode.Text != "")
+                if (pa_outboxcode.Text != "" && barcode.Text != "")
                 {
                     //判断箱内总数必须大于0
                     if (pa_totalqty.Text == "" || pa_totalqty.Text == "0")
@@ -159,19 +170,20 @@ namespace UAS_MES.Make
                         if (dh.CheckExist("packagedetail", "pd_barcode='" + barcode.Text + "'"))
                         {
                             OperateResult.AppendText("序列号" + barcode.Text + "已经装箱!\n", Color.Red);
+                            barcode.Clear();
                         }
                         else
                         {
                             //箱号不存在的情况
-                            if (!dh.CheckExist("package", "pa_outboxcode='" + pa_code.Text + "'"))
+                            if (!dh.CheckExist("package", "pa_outboxcode='" + pa_outboxcode.Text + "'"))
                             {
                                 //插入Package主表箱号信息
                                 sql.Clear();
                                 sql.Append("insert into package (pa_id,pa_outboxcode,pa_packageqty,pa_totalqty,pa_status,pa_indate,pa_makecode,pa_prodcode,pa_salecode,pa_custcode)");
-                                sql.Append("select package_seq.nextval,'" + pa_code.Text + "',0," + pa_totalqty.Text + ",0,");
+                                sql.Append("select package_seq.nextval,'" + pa_outboxcode.Text + "',0," + pa_totalqty.Text + ",0,");
                                 sql.Append("sysdate,'" + ma_code.Text + "', ma_prodcode,ma_salecode,ma_custcode from make where ma_code = '" + ma_code.Text + "'");
                                 dh.ExecuteSql(sql.GetString(), "insert");
-                                OperateResult.AppendText("箱号" + pa_code.Text + "采集成功!\n", Color.Green);
+                                OperateResult.AppendText("箱号" + pa_outboxcode.Text + "采集成功!\n", Color.Green);
                                 //验证序列号插入明细表的数据
                                 InsertDetail();
                             }
@@ -203,21 +215,21 @@ namespace UAS_MES.Make
                     //勾选了取消箱号先验证箱号存不存在,存在的话移除掉,重新加载一次数据
                     else
                     {
-                        dt = (DataTable)dh.ExecuteSql("select pd_outboxcode from packagedetail where pd_outboxcode='" + pa_code.Text + "' and pd_barcode='" + barcode.Text + "'", "select");
+                        dt = (DataTable)dh.ExecuteSql("select pd_outboxcode from packagedetail where pd_outboxcode='" + pa_outboxcode.Text + "' and pd_barcode='" + barcode.Text + "'", "select");
                         if (dt.Rows.Count > 0)
                         {
                             //删除明细行的数据
-                            dh.ExecuteSql("delete from packagedetail where pd_barcode='" + barcode.Text + "' and pd_paid=(select pa_id from package where pa_outboxcode='" + pa_code.Text + "')", "delete");
+                            dh.ExecuteSql("delete from packagedetail where pd_barcode='" + barcode.Text + "' and pd_paid=(select pa_id from package where pa_outboxcode='" + pa_outboxcode.Text + "')", "delete");
                             //更新已装数 
-                            dh.UpdateByCondition("Package", "pa_packageqty=pa_packageqty-1", "pa_outboxcode='" + pa_code.Text + "'");
+                            dh.UpdateByCondition("Package", "pa_packageqty=pa_packageqty-1", "pa_outboxcode='" + pa_outboxcode.Text + "'");
                             dh.UpdateByCondition("makeserial", "ms_nextstepcode=ms_stepcode", "ms_sncode='" + barcode.Text + "'");
-                            OperateResult.AppendText(">>已从该箱中移除序列号\n", Color.Green);
+                            OperateResult.AppendText(">>已从该箱中移除序列号" + barcode.Text + "\n", Color.Green);
                             LoadData();
                         }
                         else OperateResult.AppendText(">>序列号" + barcode.Text + "不在该箱内,请输入正确的序列号\n", Color.Red);
                     }
                 }
-                else OperateResult.AppendText(">>请先输入箱号和工单号\n", Color.Red);
+                else LoadData();
             }
         }
 
@@ -232,14 +244,8 @@ namespace UAS_MES.Make
             {
                 if (pa_totalqty.Text == pa_packageqty.Text)
                 {
-                    try
-                    {
-                        Print.CodeSoft(lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrintList.Text, barcode.Text);
-                    }
-                    catch
-                    {
-                        BaseUtil.ShowError("打印程序异常,请检查是否连接打印机或者打印软件是否安装");
-                    }
+                    OperateResult.AppendText(">>打印箱号"+pa_outboxcode.Text+"\n", Color.Green);
+                    Print.CodeSoft(lbl, PrintLabel.Text.Split(':')[1], PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), indate[PrintLabel.SelectedIndex]);
                 }
             }
         }
@@ -254,20 +260,22 @@ namespace UAS_MES.Make
 
         private void pr_code_TextChanged(object sender, EventArgs e)
         {
-            dt = (DataTable)dh.ExecuteSql("select pl_labelname,pl_labelcode from productlabel where pl_prodcode='" + ma_prodcode.Text + "'", "select");
+            dt = (DataTable)dh.ExecuteSql("select pl_labelcode||':'||pl_labelname pl_laname,pl_labelname,pl_labelcode,pl_labelurl,pl_indate from productlabel where pl_prodcode='" + ma_prodcode.Text + "'", "select");
             PrintLabel.DataSource = dt;
-            PrintLabel.DisplayMember = "pl_labelname";
+            PrintLabel.DisplayMember = "pl_laname";
             PrintLabel.ValueMember = "pl_labelcode";
             ftpOperater ftp = new ftpOperater();
+            indate = new System.DateTime[dt.Rows.Count];
             for (int i = 0; i < dt.Rows.Count; i++)
             {
-                ftp.Download(dt.Rows[i]["pl_labelname"].ToString());
+                BaseUtil.GetPrintLabel(dt.Rows[i]["pl_labelname"].ToString(), dt.Rows[i]["pl_labelurl"].ToString(), dt.Rows[i]["pl_indate"].ToString());
+                indate[i] = Convert.ToDateTime(dt.Rows[i]["pl_indate"].ToString());
             }
         }
 
         private void pr_id_TextChanged(object sender, EventArgs e)
         {
-            pa_code.Pr_id = pr_id.Text;
+            pa_outboxcode.Pr_id = pr_id.Text;
         }
 
         private void 包装采集_FormClosing(object sender, FormClosingEventArgs e)
@@ -279,7 +287,11 @@ namespace UAS_MES.Make
         {
             if (ma_code.Text.Length > 5)
             {
-
+                //加载表单数据
+                sql.Clear();
+                sql.Append("select ma_prodcode,pr_detail,pr_id,ma_code from product left join make on ma_prodcode=pr_code where ma_code='" + ma_code.Text + "'");
+                dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                BaseUtil.SetFormValue(this.Controls, dt);
             }
         }
     }

+ 1 - 1
UAS-MES/FunctionCode/Make/Make_PackageCollection.resx

@@ -383,7 +383,7 @@
   <metadata name="pd_barcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="pa_outboxcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+  <metadata name="pa_outboxcode1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
   <metadata name="pd_innerqty.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">