瀏覽代碼

上料采集修改前一工单信息

章政 8 年之前
父節點
當前提交
666b53de6c

+ 30 - 15
UAS-MES/FunctionCode/Make/Make_FeedingCollection.Designer.cs

@@ -59,6 +59,7 @@
             this.sn_code = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.LockMakeCode = new UAS_MES.CustomControl.CustomCheckBox.LockCheckBox();
             this.ma_code = new UAS_MES.CustomControl.TextBoxWithIcon.MaCodeSearchTextBox();
+            this.ma_craftcode = new System.Windows.Forms.Label();
             this.panel2.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.ClearSn_code)).BeginInit();
             this.SuspendLayout();
@@ -69,7 +70,7 @@
             this.panel2.Controls.Add(this.label1);
             this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
             this.panel2.Location = new System.Drawing.Point(0, 0);
-            this.panel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.panel2.Margin = new System.Windows.Forms.Padding(4);
             this.panel2.Name = "panel2";
             this.panel2.Size = new System.Drawing.Size(1197, 36);
             this.panel2.TabIndex = 31;
@@ -159,7 +160,7 @@
             this.Loading.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.Loading.ForeColor = System.Drawing.Color.Blue;
             this.Loading.Location = new System.Drawing.Point(24, 540);
-            this.Loading.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.Loading.Margin = new System.Windows.Forms.Padding(4);
             this.Loading.Name = "Loading";
             this.Loading.Size = new System.Drawing.Size(73, 31);
             this.Loading.TabIndex = 62;
@@ -173,7 +174,7 @@
             this.UnLoading.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.UnLoading.ForeColor = System.Drawing.Color.Blue;
             this.UnLoading.Location = new System.Drawing.Point(131, 540);
-            this.UnLoading.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.UnLoading.Margin = new System.Windows.Forms.Padding(4);
             this.UnLoading.Name = "UnLoading";
             this.UnLoading.Size = new System.Drawing.Size(73, 31);
             this.UnLoading.TabIndex = 63;
@@ -208,7 +209,7 @@
             this.iflastsn.Enabled = false;
             this.iflastsn.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.iflastsn.Location = new System.Drawing.Point(385, 588);
-            this.iflastsn.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.iflastsn.Margin = new System.Windows.Forms.Padding(4);
             this.iflastsn.Name = "iflastsn";
             this.iflastsn.Size = new System.Drawing.Size(142, 31);
             this.iflastsn.TabIndex = 72;
@@ -220,7 +221,7 @@
             this.softwareversion_label.AutoSize = true;
             this.softwareversion_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.softwareversion_label.Location = new System.Drawing.Point(907, 186);
-            this.softwareversion_label.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.softwareversion_label.Margin = new System.Windows.Forms.Padding(4);
             this.softwareversion_label.Name = "softwareversion_label";
             this.softwareversion_label.Size = new System.Drawing.Size(114, 31);
             this.softwareversion_label.TabIndex = 74;
@@ -232,7 +233,7 @@
             this.ecn_label.AutoSize = true;
             this.ecn_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.ecn_label.Location = new System.Drawing.Point(907, 278);
-            this.ecn_label.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.ecn_label.Margin = new System.Windows.Forms.Padding(4);
             this.ecn_label.Name = "ecn_label";
             this.ecn_label.Size = new System.Drawing.Size(94, 31);
             this.ecn_label.TabIndex = 75;
@@ -244,7 +245,7 @@
             this.ClearSn_code.Cursor = System.Windows.Forms.Cursors.Hand;
             this.ClearSn_code.Image = global::UAS_MES.Properties.Resources.bindingNavigatorDeleteItem_Image;
             this.ClearSn_code.Location = new System.Drawing.Point(351, 591);
-            this.ClearSn_code.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.ClearSn_code.Margin = new System.Windows.Forms.Padding(4);
             this.ClearSn_code.Name = "ClearSn_code";
             this.ClearSn_code.Size = new System.Drawing.Size(21, 20);
             this.ClearSn_code.TabIndex = 138;
@@ -316,7 +317,7 @@
             // 
             this.OperateResult.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.OperateResult.Location = new System.Drawing.Point(17, 160);
-            this.OperateResult.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.OperateResult.Margin = new System.Windows.Forms.Padding(4);
             this.OperateResult.Name = "OperateResult";
             this.OperateResult.Size = new System.Drawing.Size(856, 362);
             this.OperateResult.TabIndex = 94;
@@ -330,7 +331,7 @@
             this.Clean.Image = ((System.Drawing.Image)(resources.GetObject("Clean.Image")));
             this.Clean.IsShowBorder = true;
             this.Clean.Location = new System.Drawing.Point(789, 541);
-            this.Clean.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.Clean.Margin = new System.Windows.Forms.Padding(4);
             this.Clean.MoveImage = ((System.Drawing.Image)(resources.GetObject("Clean.MoveImage")));
             this.Clean.Name = "Clean";
             this.Clean.NormalImage = ((System.Drawing.Image)(resources.GetObject("Clean.NormalImage")));
@@ -349,7 +350,7 @@
             this.softwareversion.BackColor = System.Drawing.Color.White;
             this.softwareversion.ID = null;
             this.softwareversion.Location = new System.Drawing.Point(1029, 186);
-            this.softwareversion.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.softwareversion.Margin = new System.Windows.Forms.Padding(4);
             this.softwareversion.Name = "softwareversion";
             this.softwareversion.Power = null;
             this.softwareversion.Size = new System.Drawing.Size(140, 25);
@@ -366,7 +367,7 @@
             this.ecn.BackColor = System.Drawing.Color.White;
             this.ecn.ID = null;
             this.ecn.Location = new System.Drawing.Point(1029, 282);
-            this.ecn.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.ecn.Margin = new System.Windows.Forms.Padding(4);
             this.ecn.Name = "ecn";
             this.ecn.Power = null;
             this.ecn.Size = new System.Drawing.Size(140, 25);
@@ -383,7 +384,7 @@
             this.Confirm.Image = ((System.Drawing.Image)(resources.GetObject("Confirm.Image")));
             this.Confirm.IsShowBorder = true;
             this.Confirm.Location = new System.Drawing.Point(385, 640);
-            this.Confirm.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.Confirm.Margin = new System.Windows.Forms.Padding(4);
             this.Confirm.MoveImage = ((System.Drawing.Image)(resources.GetObject("Confirm.MoveImage")));
             this.Confirm.Name = "Confirm";
             this.Confirm.NormalImage = ((System.Drawing.Image)(resources.GetObject("Confirm.NormalImage")));
@@ -401,7 +402,7 @@
             this.code.BackColor = System.Drawing.Color.White;
             this.code.ID = null;
             this.code.Location = new System.Drawing.Point(131, 642);
-            this.code.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.code.Margin = new System.Windows.Forms.Padding(4);
             this.code.Name = "code";
             this.code.Power = null;
             this.code.Size = new System.Drawing.Size(212, 25);
@@ -419,7 +420,7 @@
             this.sn_code.Enabled = false;
             this.sn_code.ID = null;
             this.sn_code.Location = new System.Drawing.Point(131, 588);
-            this.sn_code.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.sn_code.Margin = new System.Windows.Forms.Padding(4);
             this.sn_code.Name = "sn_code";
             this.sn_code.Power = null;
             this.sn_code.Size = new System.Drawing.Size(212, 25);
@@ -462,11 +463,24 @@
             this.ma_code.TextBoxEnable = true;
             this.ma_code.UserControlTextChanged += new UAS_MES.CustomControl.TextBoxWithIcon.MaCodeSearchTextBox.OnTextChange(this.ma_code_UserControlTextChanged);
             // 
+            // ma_craftcode
+            // 
+            this.ma_craftcode.AutoSize = true;
+            this.ma_craftcode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.ma_craftcode.Location = new System.Drawing.Point(1024, 56);
+            this.ma_craftcode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.ma_craftcode.Name = "ma_craftcode";
+            this.ma_craftcode.Size = new System.Drawing.Size(92, 27);
+            this.ma_craftcode.TabIndex = 142;
+            this.ma_craftcode.Text = "途程名称";
+            this.ma_craftcode.Visible = false;
+            // 
             // Make_FeedingCollection
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1197, 680);
+            this.Controls.Add(this.ma_craftcode);
             this.Controls.Add(this.ma_code);
             this.Controls.Add(this.LockMakeCode);
             this.Controls.Add(this.ClearSn_code);
@@ -497,7 +511,7 @@
             this.Controls.Add(this.ma_prodcode_label);
             this.Controls.Add(this.panel2);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
-            this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.Margin = new System.Windows.Forms.Padding(4);
             this.Name = "Make_FeedingCollection";
             this.Tag = "Make!FeedingCollection";
             this.Text = "上料采集";
@@ -543,5 +557,6 @@
         private System.Windows.Forms.PictureBox ClearSn_code;
         private CustomControl.CustomCheckBox.LockCheckBox LockMakeCode;
         private CustomControl.TextBoxWithIcon.MaCodeSearchTextBox ma_code;
+        private System.Windows.Forms.Label ma_craftcode;
     }
 }

+ 52 - 55
UAS-MES/FunctionCode/Make/Make_FeedingCollection.cs

@@ -63,10 +63,10 @@ namespace UAS_MES.Make
 
             //工单号放大镜配置
             ma_code.TableName = "make left join product on ma_prodcode=pr_code";
-            ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 产品编号,ma_qty # 工单数量,pr_detail # 产品名称";
+            ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 产品编号,ma_qty # 工单数量,ma_craftcode # 途程编号,pr_detail # 产品名称";
             ma_code.FormName = Name;
             ma_code.DBTitle = "工单查询";
-            ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "ma_qty", "pr_detail" };
+            ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "ma_qty", "pr_detail", "ma_craftcode" };
             ma_code.Condition = "ma_statuscode='STARTED'";
             ma_code.DbChange += Ma_code_DBChange;
             dh = new DataHelper();
@@ -76,7 +76,11 @@ namespace UAS_MES.Make
         {
             DBFind = ma_code.ReturnData;
             BaseUtil.SetFormValue(this.Controls, DBFind);
-            dh.ExecuteSql("select sp_ifforsn from make left join stepproduct on ma_prodcode=sp_soncode", "select");
+            string ifforsn = dh.getFieldDataByCondition("make left join stepbom on ma_prodcode=sb_prodcode left join stepproduct on sb_id=sp_sbid", "nvl(sp_ifforsn,0) sp_ifforsn", "ma_code='" + ma_code.Text + "' and sp_craftcode='" + ma_craftcode.Text + "' order by sp_detno").ToString();
+            if (ifforsn != "" && ifforsn != "0")
+                iflastsn.Checked = true;
+            else
+                iflastsn.Checked = false;
         }
 
         private void 上料采集_SizeChanged(object sender, EventArgs e)
@@ -109,75 +113,68 @@ namespace UAS_MES.Make
                     //如果录入框和工单号均有输入
                     if (code.Text != "" && ma_code.Text != "" && sn_code.Text == "")
                     {
-                        if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, code.Text, User.UserCode, out oMakeCode, out oMsid, out ErrorMessage))
+                        //根据序列号查出ma_code,ma_prodcode,stepcode
+                        dt = (DataTable)dh.ExecuteSql("select ms_id,ms_makecode,ms_craftcode,ms_status,ms_nextstepcode,ms_prodcode,ms_code from makeserial where ms_sncode='" + code.Text + "' and ms_makecode<>'" + ma_code.Text + "' order by ms_id desc", "select");
+                        if (dt.Rows.Count > 0)
+                        {
+                            ms_id = dt.Rows[0]["ms_id"].ToString();
+                            make_code = dt.Rows[0]["ms_makecode"].ToString();
+                            ms_craftcode = dt.Rows[0]["ms_craftcode"].ToString();
+                            make_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
+                            nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
+                            ms_status = dt.Rows[0]["ms_status"].ToString();
+                        }
+                        //勾选了前一工单
+                        if (iflastsn.Checked)
                         {
-                            //根据序列号查出ma_code,ma_prodcode,stepcode
-                            dt = (DataTable)dh.ExecuteSql("select ms_id,ms_makecode,ms_craftcode,ms_status,ms_nextstepcode,ms_prodcode,ms_code from makeserial where ms_sncode='" + code.Text + "' and ms_makecode<>'" + ma_code.Text + "' order by ms_id desc", "select");
                             if (dt.Rows.Count > 0)
-                            {
-                                ms_id = dt.Rows[0]["ms_id"].ToString();
-                                make_code = dt.Rows[0]["ms_makecode"].ToString();
-                                ms_craftcode = dt.Rows[0]["ms_craftcode"].ToString();
-                                make_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
-                                nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
-                                ms_status = dt.Rows[0]["ms_status"].ToString();
-                            }
-                            //勾选了前一工单
-                            if (iflastsn.Checked)
                             {
                                 //判断序列号的前一工单是否已经完工
                                 if (dt.Rows[0]["ms_makecode"].ToString() != ma_code.Text && dt.Rows[0]["ms_status"].ToString() == "2")
                                 {
                                     //验证当前工单是否存在序列号
-                                    if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, sn_code.Text, User.UserCode, out oMakeCode, out oMsid, out ErrorMessage))
+                                    if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, code.Text, User.UserCode, out oMakeCode, out oMsid, out ErrorMessage))
                                     {
-                                        dt = (DataTable)dh.ExecuteSql("select sp_id from stepproduct where sp_mothercode='" + make_prodcode + "' and sp_stepcode='" + nextstepcode + "' and sp_soncode='" + make_prodcode + "'", "select");
-                                        string sp_id = dt.Rows[0]["sp_id"].ToString();
+                                        sql.Clear();
+                                        sql.Append("select sp_id from make inner join stepbom on ma_prodcode=sb_prodcode and ma_bomversion=sb_bomversion left ");
+                                        sql.Append("join stepproduct on sp_sbid=sb_id where ma_code='" + ma_code.Text + "' and sp_craftcode='" + ma_craftcode.Text + "' ");
+                                        sql.Append("and sp_stepcode='" + User.CurrentStepCode + "' and nvl(sp_ifforsn,0)<>0");
+                                        dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                                         if (dt.Rows.Count > 0)
                                         {
-                                            if (!dh.CheckExist("Craftmaterial", "cm_makecode='" + ma_code.Text + "' and cm_sncode='" + sn_code.Text + "'"))
+                                            string sp_id = dt.Rows[0]["sp_id"].ToString();
+                                            if (!dh.CheckExist("Craftmaterial", "cm_makecode='" + ma_code.Text + "' and cm_sncode='" + code.Text + "'"))
                                             {
                                                 sql.Clear();
-                                                sql.Append("insert into Craftmaterial (cm_id, cm_makecode,cm_maid,cm_maprodcode,");
-                                                sql.Append("cm_soncode,cm_mscode,cm_sncode,cm_stepcode,cm_stepname,cm_craftcode,cm_craftname,");
-                                                sql.Append("cm_barcode,cm_inqty,cm_indate,cm_inman,cm_linecode,cm_wccode,cm_sourcecode,cm_spid,cm_status,cm_materialtype,cm_firstsn) ");
-                                                sql.Append("select Craftmaterial_seq.nextval, ma_code, ma_id, ma_prodcode, sp_soncode,");
-                                                sql.Append("'" + code.Text + "','" + code.Text + "',mcd_stepcode,mcd_stepname,ma_craftcode");
-                                                sql.Append(",ma_craftname,'" + code.Text + "',1,sysdate,'" + User.UserName + "',ma_linecode,ma_wccode,");
-                                                sql.Append("'" + User.UserSourceCode + "','" + sp_id + "',0,1,ms_firstsn from make left join makecraftdetail on mcd_macode=ma_code");
-                                                sql.Append(" left join stepproduct on sp_stepcode=mcd_stepcode  where ma_code = '" + make_code + "'and ");
-                                                sql.Append("sp_id = " + sp_id + " and mcd_stepcode='" + nextstepcode + "'");
+                                                sql.Append("insert into Craftmaterial (cm_id, cm_makecode,cm_maid,cm_maprodcode,cm_soncode,cm_mscode,");
+                                                sql.Append("cm_sncode,cm_stepcode,cm_stepname,cm_craftcode,cm_craftname,cm_barcode,cm_inqty,cm_indate");
+                                                sql.Append(",cm_inman,cm_linecode,cm_wccode,cm_sourcecode,cm_spid,cm_status,cm_materialtype,cm_firstsn)");
+                                                sql.Append("select Craftmaterial_seq.nextval, ma_code, ma_id, ma_prodcode, sp_soncode,'" + code.Text + "'");
+                                                sql.Append(",'" + code.Text + "',mcd_stepcode,mcd_stepname,ma_craftcode,ma_craftname,'" + code.Text + "'");
+                                                sql.Append(",1,sysdate,'" + User.UserName + "',ma_linecode,ma_wccode,'" + User.UserSourceCode + "',");
+                                                sql.Append("'" + sp_id + "',0,1,ms_firstsn from make left join makeserial on ms_makecode=ma_code left ");
+                                                sql.Append("join makecraftdetail on mcd_macode=ma_code left join stepproduct on sp_stepcode=mcd_stepcode ");
+                                                sql.Append("where ma_code = '" + ma_code.Text + "'and sp_id = " + sp_id + " and mcd_stepcode=");
+                                                sql.Append("'" + User.CurrentStepCode + "' and ms_sncode='" + code.Text + "'");
                                                 dh.ExecuteSql(sql.GetString(), "insert");
-                                                if (make_code == ma_code.Text && nextstepcode == "")
-                                                {
-                                                    sn_code.Text = code.Text;
-                                                    sql.Clear();
-                                                    sql.Append("select ma_code,ma_prodcode,pr_detail,ma_qty from makeserial left ");
-                                                    sql.Append("join product on ms_prodcode=pr_code left join make on ms_makecode=ma_code ");
-                                                    sql.Append("left join makecraftdetail on mcd_macode=ms_makecode where ms_sncode='" + sn_code.Text + "'");
-                                                    dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
-                                                    BaseUtil.SetFormValue(this.Controls, dt);
-                                                    //将录入框的值给序列号
-                                                    OperateResult.AppendText(">>获取序列号" + code.Text + "成功\n", Color.Green);
-                                                    code.Text = "";
-                                                }
-                                                else OperateResult.AppendText(">>序列号无前段工单\n", Color.Red);
+                                                OperateResult.AppendText(">>序列号" + code.Text + "上料成功\n", Color.Green, code);
                                             }
-                                            else OperateResult.AppendText(">>序列号无前段工单\n", Color.Red);
+                                            else OperateResult.AppendText(">>序列号" + code.Text + "已经上料\n", Color.Red, code);
                                         }
+                                        else OperateResult.AppendText(">>序列号" + code.Text + "不存在于其他工单\n", Color.Red, code);
                                     }
+                                    else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, code);
                                 }
-                                else if (make_code == ma_code.Text && nextstepcode == User.CurrentStepCode)
-                                {
-                                    sn_code.Text = code.Text;
-                                    OperateResult.AppendText(">>获取序列号" + code.Text + "成功\n", Color.Green);
-                                    code.Text = "";
-                                }
+                                else OperateResult.AppendText(">>序列号" + code.Text + "已被工单"+ dt.Rows[0]["ms_makecode"].ToString() + "绑定,尚未完工\n", Color.Red, code);
                             }
+                            else OperateResult.AppendText(">>序列号" + code.Text + "不存在于其他工单\n", Color.Red, code);
+                        }
+                        else
+                        {
                             //未勾选上一工序
-                            else
+                            if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, code.Text, User.UserCode, out oMakeCode, out oMsid, out ErrorMessage))
                             {
-                                dt = (DataTable)dh.ExecuteSql("select ms_status,ms_stepcode,ms_nextstepcode from makeserial where ms_sncode='" + code.Text + "' and ms_makecode='" + ma_code.Text + "'", "select");
+                                dt = (DataTable)dh.ExecuteSql("select ms_status,ms_stepcode,ms_nextstepcode from makeserial where ms_sncode='" + code.Text + "' and ms_makecode='" + ma_code.Text + "' order by ms_id desc", "select");
                                 nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
                                 ms_status = dt.Rows[0]["ms_status"].ToString();
                                 //如果尚未开始工序或者已经在产线并且当前工序和人员负责工序一致
@@ -196,8 +193,8 @@ namespace UAS_MES.Make
                                 }
                                 else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, code);
                             }
+                            else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, code);
                         }
-                        else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, code);
                     }
                     //输入框有值但未选择工单号
                     else if (code.Text != "" && ma_code.Text == "" && sn_code.Text == "")
@@ -352,7 +349,7 @@ namespace UAS_MES.Make
             sql.Clear();
             sql.Append("select ma_prodcode,ma_bomversion,ma_qty,ma_code,pr_detail,ms_status,ms_id,ms_craftcode,ms_nextstepcode");
             sql.Append(",ms_prodcode,ms_makecode,ms_code,ms_stepname  from makeserial left join make on ma_code=ms_makecode ");
-            sql.Append("left join product on ms_prodcode=pr_code where ms_sncode='" + code.Text + "'");
+            sql.Append("left join product on ms_prodcode=pr_code where ms_sncode='" + code.Text + "' order by ms_id desc");
             dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
             if (dt.Rows.Count > 0)
             {
@@ -455,7 +452,7 @@ namespace UAS_MES.Make
             sn_code.Clear();
             CollectData.Clear();
             CollectDataSonCode.Clear();
-            dt1.Clear();
+            BaseUtil.CleanDataTableData(dt1);
             RemainIndex = 0;
         }