Browse Source

修改装箱采集BUG

章政 8 years ago
parent
commit
c6ae3d910b

+ 1 - 5
UAS-MES/FunctionCode/Make/Make_PackageCollection.cs

@@ -80,7 +80,7 @@ namespace UAS_MES.Make
             if (pa_outboxcode.Text != "")
             {
                 sql.Clear();
-                sql.Append("select pr_code,pa_outboxcode,pa_sccode,nvl(pa_downstatus,0) pa_downstatus,pa_checkno,pa_status,pr_packrule,pr_detail,pa_packageqty,pr_outboxinnerqty,pa_standardqty,pa_currentqty from package left join product on pa_prodcode=");
+                sql.Append("select pr_code,pa_outboxcode,pa_sccode,nvl(pa_downstatus,0) pa_downstatus,pa_checkno,pa_status,pr_packrule,pr_detail,pa_packageqty,nvl(0,pr_outboxinnerqty)pr_outboxinnerqty,pa_standardqty,pa_currentqty from package left join product on pa_prodcode=");
                 sql.Append("pr_code where pa_outboxcode='" + pa_outboxcode.Text + "'");
                 Err = "箱号";
             }
@@ -95,10 +95,6 @@ namespace UAS_MES.Make
             dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
             if (dt.Rows.Count > 0)
             {
-                if (pr_code.Text != "")
-                {
-                    dt.Columns.Remove(dt.Columns["pa_standardqty"]);
-                }
                 StandardQTY = decimal.Parse(dt.Rows[0]["pr_outboxinnerqty"].ToString());
                 BaseUtil.SetFormValue(this.Controls, dt);
             }

+ 2 - 2
UAS-MES/FunctionCode/Make/Make_PackageCollectionWeigh.cs

@@ -146,7 +146,7 @@ namespace UAS_MES.Make
             if (pa_outboxcode.Text != "")
             {
                 sql.Clear();
-                sql.Append("select pr_cartonmaxw,pr_cartonminw,pr_cartongw,pa_outboxcode,pa_sccode,nvl(pa_downstatus,0) pa_downstatus,pa_checkno,");
+                sql.Append("select pr_cartonmaxw,pr_cartonunit,pr_cartonminw,pr_cartongw,pa_outboxcode,pa_sccode,nvl(pa_downstatus,0) pa_downstatus,pa_checkno,");
                 sql.Append("pa_status,pr_packrule,pr_detail,pa_packageqty,pr_outboxinnerqty,pa_standardqty,pa_currentqty from package left join ");
                 sql.Append("product on pa_prodcode=pr_code where pa_outboxcode='" + pa_outboxcode.Text + "'");
                 Err = "箱号";
@@ -154,7 +154,7 @@ namespace UAS_MES.Make
             else
             {
                 sql.Clear();
-                sql.Append("select pr_cartonmaxw,pr_cartonminw,pr_cartongw,ms_makecode,pa_status,nvl(pa_downstatus,0) pa_downstatus,pa_sccode,");
+                sql.Append("select pr_cartonmaxw,pr_cartonunit,pr_cartonminw,pr_cartongw,ms_makecode,pa_status,nvl(pa_downstatus,0) pa_downstatus,pa_sccode,");
                 sql.Append("pa_checkno,pr_packrule,pr_code,pr_detail,nvl(pa_standardqty,pr_outboxinnerqty) pr_outboxinnerqty,pa_packageqty,pa_currentqty,");
                 sql.Append("pa_outboxcode from makeserial left join product on ms_prodcode=pr_code left join packagedetail ");
                 sql.Append("on pd_barcode=ms_sncode left join package on pa_id =pd_paid where ms_id='" + oMsID + "'");

+ 1 - 0
UAS-MES/FunctionCode/Make/Make_SpecialCartonPack.Designer.cs

@@ -319,6 +319,7 @@
             this.PackageDetail.RowTemplate.Height = 23;
             this.PackageDetail.Size = new System.Drawing.Size(881, 300);
             this.PackageDetail.TabIndex = 134;
+            this.PackageDetail.DataSourceChanged += new System.EventHandler(this.PackageDetail_DataSourceChanged);
             // 
             // pd_barcode
             // 

+ 60 - 50
UAS-MES/FunctionCode/Make/Make_SpecialCartonPack.cs

@@ -34,7 +34,7 @@ namespace UAS_MES.Make
         //最小重量
         double MinWeight;
 
-        decimal StandardQTY = 0;
+        int StandardQTY = 0;
 
         string oOutBoxCode = "";
 
@@ -122,8 +122,7 @@ namespace UAS_MES.Make
                     }
                     catch (IOException ex) { MessageBox.Show(ex.Message); }
                 }
-                else
-                    MessageBox.Show("端口已被占用,请关闭其他窗口");
+                else OperateResult.AppendText(">>端口已被占用,请关闭其他窗口\n", Color.Red);
             }
         }
 
@@ -145,15 +144,15 @@ namespace UAS_MES.Make
             if (pa_outboxcode.Text != "")
             {
                 sql.Clear();
-                sql.Append("select pr_cartonmaxw,pr_cartonminw,pr_cartongw,pa_outboxcode,pa_sccode,nvl(pa_downstatus,0) pa_downstatus,pa_checkno,");
-                sql.Append("pa_status,pr_packrule,pr_detail,pa_packageqty,pr_outboxinnerqty,pa_standardqty,pa_currentqty from package left join ");
+                sql.Append("select pr_cartonmaxw,pr_cartonunit,pr_cartonminw,pr_cartongw,pa_outboxcode,pa_sccode,nvl(pa_downstatus,0) pa_downstatus,pa_checkno,");
+                sql.Append("pa_status,pr_packrule,pr_detail,pa_packageqty,nvl(pa_standardqty,pr_outboxinnerqty) pr_outboxinnerqty,pa_standardqty,pa_currentqty from package left join ");
                 sql.Append("product on pa_prodcode=pr_code where pa_outboxcode='" + pa_outboxcode.Text + "'");
                 Err = "箱号";
             }
             else
             {
                 sql.Clear();
-                sql.Append("select pr_cartonmaxw,pr_cartonminw,pr_cartongw,ms_makecode,pa_status,nvl(pa_downstatus,0) pa_downstatus,pa_sccode,");
+                sql.Append("select pr_cartonmaxw,pr_cartonunit,pr_cartonminw,pr_cartongw,ms_makecode,pa_status,nvl(pa_downstatus,0) pa_downstatus,pa_sccode,");
                 sql.Append("pa_checkno,pr_packrule,pr_code,pr_detail,nvl(pa_standardqty,pr_outboxinnerqty) pr_outboxinnerqty,pa_packageqty,pa_currentqty,");
                 sql.Append("pa_outboxcode from makeserial left join product on ms_prodcode=pr_code left join packagedetail ");
                 sql.Append("on pd_barcode=ms_sncode left join package on pa_id =pd_paid where ms_id='" + oMsID + "'");
@@ -170,7 +169,7 @@ namespace UAS_MES.Make
                 Weight = double.Parse(_weight == "" ? "0" : _weight);
                 MaxWeight = double.Parse(_maxweight == "" ? "0" : _maxweight);
                 MinWeight = double.Parse(_minweight == "" ? "0" : _minweight);
-                StandardQTY = decimal.Parse(dt.Rows[0]["pr_outboxinnerqty"].ToString());
+                StandardQTY = int.Parse(dt.Rows[0]["pr_outboxinnerqty"].ToString());
                 BaseUtil.SetFormValue(this.Controls, dt);
                 if (Weight - MinWeight == MaxWeight - Weight)
                     pr_cartonboxgw.Text = Weight + "±" + (MaxWeight - Weight);
@@ -252,14 +251,17 @@ namespace UAS_MES.Make
                     {
                         if (pa_outboxcode.Text == "")
                         {
+                            sql.Clear();
+                            sql.Append("select ms_prodcode from makeserial where ms_id='" + oMsID + "'");
+                            dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                            pa_outboxcode.MakeCode = oMakeCode;
+                            pa_outboxcode.ProdCode = dt.Rows[0]["ms_prodcode"].ToString();
+                            pa_outboxcode.Caller = "PACKAGE";
                             LoadData();
                             if (dh.getFieldDataByCondition("makeserial", "ms_outboxcode", "ms_id='" + oMsID + "'").ToString() != "")
                                 LoadGridData();
                             else
-                            {
-                                LoadData();
                                 pa_outboxcode.GeneratePaCode_Click(new object(), new EventArgs());
-                            }
                         }
                         //判断箱内总数必须大于0
                         if (pr_outboxinnerqty.Text == "" || pr_outboxinnerqty.Text == "0")
@@ -296,14 +298,9 @@ namespace UAS_MES.Make
                                         //满箱更新状态为1
                                         if (int.Parse(pa_currentqty.Text == "" ? "0" : pa_currentqty.Text) + 1 == int.Parse(pr_outboxinnerqty.Text))
                                         {
-                                            //检查重量合格
-                                            if (float.Parse(weight.Text) > MinWeight && float.Parse(weight.Text) < MaxWeight)
-                                            {
-                                                dh.UpdateByCondition("package", "pa_status=1,pa_weight='" + weight.Text + "'", "pa_outboxcode='" + pa_outboxcode.Text + "'");
-                                                if (AutoPrint.Checked)
-                                                    Print_Click(new object(), new EventArgs());
-                                            }
-                                            else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "重量不符合标准重量\n", Color.Red);
+                                            dh.UpdateByCondition("package", "pa_status=1,pa_weight='" + weight.Text + "'", "pa_outboxcode='" + pa_outboxcode.Text + "'");
+                                            if (AutoPrint.Checked)
+                                                Print_Click(new object(), new EventArgs());
                                         }
                                         LoadGridData();
                                         sn_code.Clear();
@@ -315,25 +312,33 @@ namespace UAS_MES.Make
                         //勾选了取消箱号先验证箱号存不存在,存在的话移除掉,重新加载一次数据
                         else
                         {
-                            string outboxcode = dh.getFieldDataByCondition("makeserial", "ms_outboxcode", "ms_id='" + oMsID + "'").ToString();
-                            if (outboxcode != "")
+                            if (LogicHandler.Packing(sn_code.Text, pa_outboxcode.Text, AutoGenBoxCode.Checked, "特殊", User.UserSourceCode, User.UserCode, pr_outboxinnerqty.Text, Cancel.Checked, out oOutBoxCode, out ErrorMessage))
                             {
-                                if (outboxcode == pa_outboxcode.Text)
-                                {
-                                    dh.UpdateByCondition("package", "pa_status=0", "pa_outboxcode='" + pa_outboxcode.Text + "'");
-                                    //删除明细行的数据
-                                    dh.ExecuteSql("delete from packagedetail where pd_barcode='" + sn_code.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_currentqty=pa_currentqty-1", "pa_outboxcode='" + pa_outboxcode.Text + "'");
-                                    //清除序列号箱号
-                                    dh.UpdateByCondition("makeserial", "ms_outboxcode=''", "ms_id='" + oMsID + "'");
-                                    LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "装箱采集", "取消采集成功", sn_code.Text, "");
-                                    OperateResult.AppendText(">>已从该箱中移除序列号" + sn_code.Text + "\n", Color.Green);
-                                    LoadGridData();
-                                }
-                                else OperateResult.AppendText(">>序列号" + sn_code.Text + "不在箱" + pa_outboxcode.Text + "内\n", Color.Red);
+                                LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "装箱采集", "取消采集成功", sn_code.Text, "");
+                                LoadGridData();
+                                OperateResult.AppendText(">>已从该箱中移除序列号" + sn_code.Text + "\n", Color.Green, sn_code);
                             }
-                            else OperateResult.AppendText(">>序列号" + sn_code.Text + "尚未装箱\n", Color.Red);
+                            else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Green, sn_code);
+
+                            //string outboxcode = dh.getFieldDataByCondition("makeserial", "ms_outboxcode", "ms_id='" + oMsID + "'").ToString();
+                            //if (outboxcode != "")
+                            //{
+                            //    if (outboxcode == pa_outboxcode.Text)
+                            //    {
+                            //        dh.UpdateByCondition("package", "pa_status=0", "pa_outboxcode='" + pa_outboxcode.Text + "'");
+                            //        //删除明细行的数据
+                            //        dh.ExecuteSql("delete from packagedetail where pd_barcode='" + sn_code.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_currentqty=pa_currentqty-1", "pa_outboxcode='" + pa_outboxcode.Text + "'");
+                            //        //清除序列号箱号
+                            //        dh.UpdateByCondition("makeserial", "ms_outboxcode=''", "ms_id='" + oMsID + "'");
+                            //        LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "装箱采集", "取消采集成功", sn_code.Text, "");
+                            //        OperateResult.AppendText(">>已从该箱中移除序列号" + sn_code.Text + "\n", Color.Green);
+                            //        LoadGridData();
+                            //    }
+                            //    else OperateResult.AppendText(">>序列号" + sn_code.Text + "不在箱" + pa_outboxcode.Text + "内\n", Color.Red);
+                            //}
+                            //else OperateResult.AppendText(">>序列号" + sn_code.Text + "尚未装箱\n", Color.Red);
                         }
                     }
                     else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, sn_code);
@@ -349,21 +354,7 @@ namespace UAS_MES.Make
 
         private void pr_code_TextChanged(object sender, EventArgs e)
         {
-            LoadCheckQTY();
-            pa_outboxcode.MakeCode = ms_makecode.Text;
-            pa_outboxcode.ProdCode = pr_code.Text;
-            pa_outboxcode.Caller = "PACKAGE";
-            dt = (DataTable)dh.ExecuteSql("select pl_labelcode||':'||pl_labelname pl_laname,pl_labelname,pl_labelcode,pl_labelurl,pl_indate from productlabel where pl_prodcode='" + pr_code.Text + "' order by pl_isdefault desc ", "select");
-            PrintLabel.DataSource = dt;
-            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++)
-            {
-                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 包装采集_FormClosing(object sender, FormClosingEventArgs e)
@@ -523,5 +514,24 @@ namespace UAS_MES.Make
                 pr_outboxinnerqty.Value = StandardQTY;
             }
         }
+
+        private void PackageDetail_DataSourceChanged(object sender, EventArgs e)
+        {
+            if (PackageDetail.RowCount == 1)
+            {
+                LoadCheckQTY();
+                dt = (DataTable)dh.ExecuteSql("select pl_labelcode||':'||pl_labelname pl_laname,pl_labelname,pl_labelcode,pl_labelurl,pl_indate from productlabel where pl_prodcode='" + pr_code.Text + "' order by pl_isdefault desc ", "select");
+                PrintLabel.DataSource = dt;
+                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++)
+                {
+                    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());
+                }
+            }
+        }
     }
 }