Эх сурвалжийг харах

Merge branch 'master' of ssh://10.10.101.21/source/mes-client

Hcsy 8 жил өмнө
parent
commit
3f8ee12dd1

+ 42 - 18
UAS-MES/CustomControl/TextBoxWithIcon/MaCodeSearchTextBox.cs

@@ -58,16 +58,22 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
         /// 查询的字段
         /// </summary>
         private string selectField;
+
         /// <summary>
         /// 设置绑定的CheckBox
         /// </summary>
         LockCheckBox LockCheckBox;
 
+        public delegate void DBSourceChange(object sender, EventArgs e);
+
+        public event DBSourceChange DbChange;
 
         DataTable dt = new DataTable();
 
         DbFind db;
 
+        DataTable ReturnData1;
+
         public override string Text
         {
             get
@@ -211,6 +217,19 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
                 TextBoxEnable1 = value;
             }
         }
+
+        public DataTable ReturnData
+        {
+            get
+            {
+                return ReturnData1;
+            }
+
+            set
+            {
+                ReturnData1 = value;
+            }
+        }
         #endregion
 
         #region 自定义事件
@@ -257,30 +276,31 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
                         fields.Add(field[i]);
                 }
                 //将查询到的结果返回界面
-                string sql = "select " + BaseUtil.AddField(fields.ToArray()) + " from " + tableName + " where " + Tag + "='" + TextBox.Text.ToUpper() + "'";
+                string sql = "select " + BaseUtil.AddField(fields.ToArray()) + " from " + tableName + " where " + Name + "='" + TextBox.Text.ToUpper() + "'";
                 if (condition != null)
                 {
                     sql += " and " + condition;
                 }
-                 dt = (DataTable)dh.ExecuteSql(sql, "select");
-                FormCollection fmCollection = Application.OpenForms;
-                ControlCollection controls = (ControlCollection)fmCollection[FormName].Controls;
-                if (dt.Rows.Count > 0)
-                {
-                    for (int i = 0; i < dt.Columns.Count; i++)
-                    {
-                        fillControl( i, fmCollection[FormName]);
-                    }
-                    LeaveFindData = true;
-                }
-                else
-                    LeaveFindData = false;
+                dt = (DataTable)dh.ExecuteSql(sql, "select");
+                ReturnDataToFrom();
+                //FormCollection fmCollection = Application.OpenForms;
+                //ControlCollection controls = (ControlCollection)fmCollection[FormName].Controls;
+                //if (dt.Rows.Count > 0)
+                //{
+                //    for (int i = 0; i < dt.Columns.Count; i++)
+                //    {
+                //        fillControl(i, fmCollection[FormName]);
+                //    }
+                //    LeaveFindData = true;
+                //}
+                //else
+                //    LeaveFindData = false;
                 //不允许工单号为空的情况
                 LockCheckBox.Checked = true;
             }
         }
 
-        private void fillControl( int i, Control ct)
+        private void fillControl(int i, Control ct)
         {
             for (int j = 0; j < setValueField.Length; j++)
             {
@@ -289,7 +309,7 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
                     Control.ControlCollection controls = ct.Controls;
                     for (int k = 0; k < ct.Controls.Count; k++)
                     {
-                        fillControl( i, controls[k]);
+                        fillControl(i, controls[k]);
                     }
                 }
                 else
@@ -316,6 +336,12 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
             }
         }
 
+        private void ReturnDataToFrom()
+        {
+            ReturnData1 = dt;
+            DbChange?.Invoke(new object(), new EventArgs());
+        }
+
         public void TextBox_Leave(object sender, EventArgs e)
         {
             GetData();
@@ -332,7 +358,5 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
         {
             TextBox.Width = this.Width - Search_Icon.Width - 3;
         }
-
-    
     }
 }

+ 41 - 12
UAS-MES/CustomControl/TextBoxWithIcon/SearchTextBox.cs

@@ -59,6 +59,8 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
         private string selectField;
         DataTable dt = new DataTable();
 
+        private DataTable returnData;
+
         public override string Text
         {
             get
@@ -203,6 +205,19 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
                 TextBoxEnable1 = value;
             }
         }
+
+        public DataTable ReturnData
+        {
+            get
+            {
+                return returnData;
+            }
+
+            set
+            {
+                returnData = value;
+            }
+        }
         #endregion
 
         #region 自定义事件
@@ -216,6 +231,10 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
         /// </summary>
         public event Icon_Click SearchIconClick;
 
+        public delegate void DBSourceChange(object sender, EventArgs e);
+
+        public event DBSourceChange DbChange;
+
         public delegate void OnTextKeyDown(object sender, KeyEventArgs e);
 
         public event OnTextKeyDown TextKeyDown;
@@ -253,6 +272,17 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
             }
         }
 
+        /// <summary>
+        /// 触发给界面的
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        public void ReturnDataToForm()
+        {
+            returnData = dt;
+            DbChange?.Invoke(new object(), new EventArgs());
+        }
+
         private void TextBox_Enter(object sender, EventArgs e)
         {
             TextBox.BackColor = System.Drawing.Color.GreenYellow;
@@ -287,8 +317,6 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
             TextBox.Width = this.Width - Search_Icon.Width - 3;
         }
 
-
-
         private void fillControl(int i, Control ct)
         {
             for (int j = 0; j < setValueField.Length; j++)
@@ -302,7 +330,7 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
                     }
                 }
                 else
-                {               
+                {
                     if ((setValueField[j] == dt.Columns[i].Caption.ToLower() || setValueField[j] == dt.Columns[i].ColumnName.ToLower() || setValueField[j].Contains(dt.Columns[i].Caption.ToLower()) || (ct != null && ct.Tag != null && ct.Tag.ToString() == dt.Columns[i].Caption.ToLower())) && ct.Name.ToString() == setValueField[j])
                         ct.Text = dt.Rows[0][dt.Columns[i].ColumnName].ToString();
                 }
@@ -329,16 +357,17 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
                     sql += " and " + condition;
                 }
                 dt = (DataTable)dh.ExecuteSql(sql, "select");
+                ReturnDataToForm();
                 //先判断DataTable里面是否有这个字段,然后从打开的窗口里面去获取到这个Form,从Form中的指定Panel获取到指定字段的控件
-                if (dt.Rows.Count > 0)
-                {
-                    FormCollection fmCollection = Application.OpenForms;
-                    ControlCollection controls = (ControlCollection)fmCollection[FormName].Controls;
-                    for (int i = 0; i < dt.Columns.Count; i++)
-                    {
-                        fillControl(i, fmCollection[FormName]);
-                    }
-                }          
+                //if (dt.Rows.Count > 0)
+                //{
+                //    FormCollection fmCollection = Application.OpenForms;
+                //    ControlCollection controls = (ControlCollection)fmCollection[FormName].Controls;
+                //    for (int i = 0; i < dt.Columns.Count; i++)
+                //    {
+                //        fillControl(i, fmCollection[FormName]);
+                //    }
+                //}          
             }
         }
     }

+ 21 - 3
UAS-MES/FunctionCode/Make/Make_Repair.cs

@@ -6,6 +6,7 @@ using System.Drawing;
 using System.Text;
 using System.Windows.Forms;
 using UAS_MES.CustomControl.DataGrid_View;
+using UAS_MES.CustomControl.TextBoxWithIcon;
 using UAS_MES.DataOperate;
 using UAS_MES.Entity;
 using UAS_MES.PublicMethod;
@@ -47,6 +48,8 @@ namespace UAS_MES.Make
 
         string dbtable2 = "(select distinct nvl(dsl_prodcode,msl_prodcode)prodcode from ReduceStepRecord left join devsmtlocation on dsl_linecode=rsd_linecode and dsl_makecode=rsd_macode left join makesmtlocation on msl_linecode=rsd_linecode and msl_makecode=rsd_macode where rsd_macode=':macode'  and rsd_sncode=':sncode' and ((dsl_location=':msl_location' and dsl_validtime<sysdate and sysdate<dsl_invalidtime) ) or (msl_location=':msl_location' and msl_validtime<sysdate and sysdate<msl_invalidtime)) left join product on pr_code=prodcode";
 
+        DataTable Dbfind;
+
         public Make_Repair()
         {
             InitializeComponent();
@@ -61,12 +64,14 @@ namespace UAS_MES.Make
             cr_code.SelectField = "cr_name # 工艺名称,cr_code # 工艺编号,cr_prodcode # 物料编号";
             cr_code.SetValueField = new string[] { "cr_code" };
             cr_code.DBTitle = "回流工艺";
+            cr_code.DbChange += Cr_code_DbChange;
 
             cd_stepcode.FormName = Name;
             cd_stepcode.TableName = "craftdetail left join step on st_code=cd_stepcode left join craft on cd_crid=cr_id";
             cd_stepcode.SetValueField = new string[] { "cd_stepcode" };
             cd_stepcode.SelectField = "cd_stepname # 工序名称 ,cd_stepcode # 工序编号,cd_stepno # 执行顺序";
             cd_stepcode.DBTitle = "回流工序";
+            cd_stepcode.DbChange += Cd_stepcode_DbChange;
 
             prodcode.FormName = Name;
             prodcode.TableName = dbtable1.Replace(":macode", macode).Replace(":sncode", GetSNCode.Text);
@@ -78,6 +83,19 @@ namespace UAS_MES.Make
             GetSNCode.Focus();
         }
 
+        private void Cd_stepcode_DbChange(object sender, EventArgs e)
+        {
+            Dbfind = cd_stepcode.ReturnData;
+            BaseUtil.SetFormValue(this.Controls, Dbfind);
+        }
+
+        private void Cr_code_DbChange(object sender, EventArgs e)
+        {
+            Dbfind = cr_code.ReturnData;
+            BaseUtil.SetFormValue(this.Controls, Dbfind);
+        }
+
+
         private void GetSNCode_KeyDown(object sender, KeyEventArgs e)
         {
             if (e.KeyCode == Keys.Enter)
@@ -122,7 +140,7 @@ namespace UAS_MES.Make
                             BadCodeTree.Nodes.Clear();
                             return;
                         }
-                        if (reworkstatus != "0"&& reworkstatus != "3")
+                        if (reworkstatus != "0" && reworkstatus != "3")
                         {
                             OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "不处于维修状态\n", Color.Red);
                             BaseUtil.CleanForm(this);
@@ -294,7 +312,7 @@ namespace UAS_MES.Make
             }
             if (ifrework != "0" && reworkstatus == "0")
             {
-                if (dh.getRowCount("Makebad", "mb_sncode='"+ms_sncode.Text+"' and mb_status=0") == 0)
+                if (dh.getRowCount("Makebad", "mb_sncode='" + ms_sncode.Text + "' and mb_status=0") == 0)
                 {
                     OperatResult.AppendText(">>维修必须维护不良代码\n", Color.Red);
                     return;
@@ -363,7 +381,7 @@ namespace UAS_MES.Make
                     string confirm = MessageBox.Show(this.ParentForm, "此操作不可撤销,是否确认报废", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk).ToString();
                     if (confirm == "Yes")
                     {
-                        DataTable dt = dh.getFieldsDataByCondition("makeserial", new string[] { "nvl(ms_ifrework,0)ms_ifrework", "ms_reworkcode"}, "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
+                        DataTable dt = dh.getFieldsDataByCondition("makeserial", new string[] { "nvl(ms_ifrework,0)ms_ifrework", "ms_reworkcode" }, "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
                         if (dt.Rows.Count > 0)
                         {
                             string ms_ifrework = dt.Rows[0]["ms_ifrework"].ToString();

+ 42 - 9
UAS-MES/FunctionCode/Make/Make_TestCollection.Designer.cs

@@ -74,6 +74,8 @@
             this.bc_groupcode = new UAS_MES.CustomControl.ComBoxWithFocus.ComBoxWithFocus();
             this.ms_sncode = new UAS_MES.CustomControl.TextBoxWithIcon.SNCodeEnterTextBox();
             this.panel1 = new System.Windows.Forms.Panel();
+            this.ob_sendqty = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.label7 = new System.Windows.Forms.Label();
             this.ob_checkno = new System.Windows.Forms.Label();
             this.SendCheck = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
             this.ob_batchqty = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
@@ -355,7 +357,7 @@
             // 
             this.mcd_inqty_label.AutoSize = true;
             this.mcd_inqty_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.mcd_inqty_label.Location = new System.Drawing.Point(209, 16);
+            this.mcd_inqty_label.Location = new System.Drawing.Point(209, 15);
             this.mcd_inqty_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.mcd_inqty_label.Name = "mcd_inqty_label";
             this.mcd_inqty_label.Size = new System.Drawing.Size(92, 27);
@@ -366,7 +368,7 @@
             // 
             this.mc_restqty_label.AutoSize = true;
             this.mc_restqty_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.mc_restqty_label.Location = new System.Drawing.Point(22, 16);
+            this.mc_restqty_label.Location = new System.Drawing.Point(22, 15);
             this.mc_restqty_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.mc_restqty_label.Name = "mc_restqty_label";
             this.mc_restqty_label.Size = new System.Drawing.Size(92, 27);
@@ -420,6 +422,7 @@
             this.ma_code.Margin = new System.Windows.Forms.Padding(4);
             this.ma_code.Name = "ma_code";
             this.ma_code.Power = null;
+            this.ma_code.ReturnData = null;
             this.ma_code.SelectField = null;
             this.ma_code.SetValueField = null;
             this.ma_code.Size = new System.Drawing.Size(157, 26);
@@ -427,6 +430,7 @@
             this.ma_code.TableName = null;
             this.ma_code.Tag = "ma_code";
             this.ma_code.TextBoxEnable = true;
+            this.ma_code.UserControlTextChanged += new UAS_MES.CustomControl.TextBoxWithIcon.MaCodeSearchTextBox.OnTextChange(this.ma_code_UserControlTextChanged);
             // 
             // LockMakeCode
             // 
@@ -446,7 +450,7 @@
             this.mcd_remainqty.AutoSize = true;
             this.mcd_remainqty.CutLength = null;
             this.mcd_remainqty.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.mcd_remainqty.Location = new System.Drawing.Point(145, 16);
+            this.mcd_remainqty.Location = new System.Drawing.Point(145, 15);
             this.mcd_remainqty.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.mcd_remainqty.MaximumSize = new System.Drawing.Size(200, 0);
             this.mcd_remainqty.Name = "mcd_remainqty";
@@ -483,7 +487,7 @@
             this.mcd_inqty.AutoSize = true;
             this.mcd_inqty.CutLength = null;
             this.mcd_inqty.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.mcd_inqty.Location = new System.Drawing.Point(331, 16);
+            this.mcd_inqty.Location = new System.Drawing.Point(331, 15);
             this.mcd_inqty.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.mcd_inqty.MaximumSize = new System.Drawing.Size(200, 0);
             this.mcd_inqty.Name = "mcd_inqty";
@@ -502,7 +506,6 @@
             this.ma_prodcode.Name = "ma_prodcode";
             this.ma_prodcode.Size = new System.Drawing.Size(0, 27);
             this.ma_prodcode.TabIndex = 53;
-            this.ma_prodcode.TextChanged += new System.EventHandler(this.ma_prodcode_TextChanged);
             // 
             // OperateResult
             // 
@@ -603,6 +606,8 @@
             // panel1
             // 
             this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+            this.panel1.Controls.Add(this.ob_sendqty);
+            this.panel1.Controls.Add(this.label7);
             this.panel1.Controls.Add(this.ob_checkno);
             this.panel1.Controls.Add(this.SendCheck);
             this.panel1.Controls.Add(this.ob_batchqty);
@@ -618,6 +623,32 @@
             this.panel1.Size = new System.Drawing.Size(419, 158);
             this.panel1.TabIndex = 71;
             // 
+            // ob_sendqty
+            // 
+            this.ob_sendqty.AutoSize = true;
+            this.ob_sendqty.CutLength = null;
+            this.ob_sendqty.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.ob_sendqty.ForeColor = System.Drawing.Color.Black;
+            this.ob_sendqty.Location = new System.Drawing.Point(145, 114);
+            this.ob_sendqty.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.ob_sendqty.MaximumSize = new System.Drawing.Size(200, 0);
+            this.ob_sendqty.Name = "ob_sendqty";
+            this.ob_sendqty.Size = new System.Drawing.Size(0, 27);
+            this.ob_sendqty.TabIndex = 78;
+            this.ob_sendqty.Tag = "ob_batchqty";
+            // 
+            // label7
+            // 
+            this.label7.AutoSize = true;
+            this.label7.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label7.ForeColor = System.Drawing.Color.Black;
+            this.label7.Location = new System.Drawing.Point(22, 114);
+            this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label7.Name = "label7";
+            this.label7.Size = new System.Drawing.Size(92, 27);
+            this.label7.TabIndex = 77;
+            this.label7.Text = "已送检数";
+            // 
             // ob_checkno
             // 
             this.ob_checkno.AutoSize = true;
@@ -658,7 +689,7 @@
             this.ob_batchqty.CutLength = null;
             this.ob_batchqty.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.ob_batchqty.ForeColor = System.Drawing.Color.Black;
-            this.ob_batchqty.Location = new System.Drawing.Point(145, 65);
+            this.ob_batchqty.Location = new System.Drawing.Point(145, 64);
             this.ob_batchqty.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.ob_batchqty.MaximumSize = new System.Drawing.Size(200, 0);
             this.ob_batchqty.Name = "ob_batchqty";
@@ -671,7 +702,7 @@
             this.ob_batchqty_label.AutoSize = true;
             this.ob_batchqty_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.ob_batchqty_label.ForeColor = System.Drawing.Color.Black;
-            this.ob_batchqty_label.Location = new System.Drawing.Point(22, 65);
+            this.ob_batchqty_label.Location = new System.Drawing.Point(22, 64);
             this.ob_batchqty_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.ob_batchqty_label.Name = "ob_batchqty_label";
             this.ob_batchqty_label.Size = new System.Drawing.Size(92, 27);
@@ -684,7 +715,7 @@
             this.ob_nowcheckqty.CutLength = null;
             this.ob_nowcheckqty.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.ob_nowcheckqty.ForeColor = System.Drawing.Color.Black;
-            this.ob_nowcheckqty.Location = new System.Drawing.Point(331, 65);
+            this.ob_nowcheckqty.Location = new System.Drawing.Point(331, 64);
             this.ob_nowcheckqty.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.ob_nowcheckqty.MaximumSize = new System.Drawing.Size(200, 0);
             this.ob_nowcheckqty.Name = "ob_nowcheckqty";
@@ -697,7 +728,7 @@
             this.ob_nowcheckqty_label.AutoSize = true;
             this.ob_nowcheckqty_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.ob_nowcheckqty_label.ForeColor = System.Drawing.Color.Black;
-            this.ob_nowcheckqty_label.Location = new System.Drawing.Point(209, 65);
+            this.ob_nowcheckqty_label.Location = new System.Drawing.Point(209, 64);
             this.ob_nowcheckqty_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.ob_nowcheckqty_label.Name = "ob_nowcheckqty_label";
             this.ob_nowcheckqty_label.Size = new System.Drawing.Size(92, 27);
@@ -824,5 +855,7 @@
         private System.Windows.Forms.Label pr_detail_label;
         private System.Windows.Forms.ColumnHeader columnHeader2;
         private System.Windows.Forms.ColumnHeader columnHeader8;
+        private CustomControl.ValueLabel.ValueLabel ob_sendqty;
+        private System.Windows.Forms.Label label7;
     }
 }

+ 32 - 15
UAS-MES/FunctionCode/Make/Make_TestCollection.cs

@@ -44,6 +44,8 @@ namespace UAS_MES.Make
 
         bool AutoCut = false;
 
+        DataTable Dbfind;
+
         public Make_TestCollection()
         {
             InitializeComponent();
@@ -65,6 +67,13 @@ namespace UAS_MES.Make
             ma_code.FormName = Name;
             ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "ma_qty", "pr_detail" };
             ma_code.Condition = "ma_statuscode='STARTED'";
+            ma_code.DbChange += Ma_code_DbChange;
+        }
+
+        private void Ma_code_DbChange(object sender, EventArgs e)
+        {
+            Dbfind = ma_code.ReturnData;
+            BaseUtil.SetFormValue(this.Controls, Dbfind);
         }
 
         /// <summary>
@@ -321,7 +330,7 @@ namespace UAS_MES.Make
                         if (LogicHandler.UpdateMakeMessage(ms_sncode.Text, ma_code.Text, "良品采集", User.UserSourceCode, User.UserCode, "检测合格", out ErrorMessage))
                         {
                             LastSncode = ms_sncode.Text;
-                            OperateResult.AppendText(">>" + ms_sncode.Text + "已采集为良品\n", Color.Green, ms_sncode);
+                            OperateResult.AppendText(">>" + ms_sncode.Text + "良品采集成功\n", Color.Green, ms_sncode);
                             //记录操作日志
                             LogicHandler.DoCommandLog(User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "采集良品", "采集良品成功", LastSncode, ob_checkno.Text);
                         }
@@ -335,7 +344,7 @@ namespace UAS_MES.Make
                         if (LogicHandler.UpdateMakeMessage(ms_sncode.Text, ma_code.Text, "良品采集", User.UserSourceCode, User.UserCode, "检测合格", out ErrorMessage))
                         {
                             LastSncode = ms_sncode.Text;
-                            OperateResult.AppendText(">>" + ms_sncode.Text + "采集为良品\n", Color.Green, ms_sncode);
+                            OperateResult.AppendText(">>" + ms_sncode.Text + "成功采集为良品\n", Color.Green, ms_sncode);
                             //记录操作日志
                             LogicHandler.DoCommandLog(User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "采集良品", "采集良品成功", LastSncode, ob_checkno.Text);
                         }
@@ -437,6 +446,7 @@ namespace UAS_MES.Make
                     {
                         dh.UpdateByCondition("makecraftdetail", "mcd_okqty=mcd_okqty-1", "mcd_macode='" + ma_code.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
                         dh.UpdateByCondition("makeserial", "ms_nextstepcode=''", "ms_sncode='" + ms_sncode.Text + "'");
+                        LogicHandler.DoCommandLog(User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "采集不良", "采集不良成功", ms_sncode.Text, ob_checkno.Text);
                     }
                     string checkno = dt.Rows[0]["ms_checkno"].ToString();
                     //存在抽检批次更新为空
@@ -448,9 +458,8 @@ namespace UAS_MES.Make
                 if (LogicHandler.SetTestNGDetail(ms_sncode.Text, ma_code.Text, User.UserCode, User.UserSourceCode, "检查未通过", bgcode, bccode, bcremark, out ErrorMessage))
                 {
                     LastSncode = ms_sncode.Text;
-                    OperateResult.AppendText(">>" + ms_sncode.Text + "采集为不良\n", Color.Green);
+                    OperateResult.AppendText(">>" + ms_sncode.Text + "成功采集为不良\n", Color.Green);
                     //记录操作日志
-                    LogicHandler.DoCommandLog(User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "采集不良", "采集不良成功", ms_sncode.Text, ob_checkno.Text);
                     ms_sncode.Text = "";
                     //清除不良信息
                     bc_code.Text = "";
@@ -459,8 +468,7 @@ namespace UAS_MES.Make
                     WaitList.Clear();
                     ChoosedList.Clear();
                 }
-                else
-                    OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
+                else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
             }
         }
 
@@ -489,14 +497,6 @@ namespace UAS_MES.Make
             }
         }
 
-        private void ma_prodcode_TextChanged(object sender, EventArgs e)
-        {
-            //加载不良信息
-            LoadBadGroupData();
-            LoadCollectedNum();
-            LoadCheckQTY();
-        }
-
         private void LoadCheckQTY()
         {
             sql.Clear();
@@ -517,14 +517,16 @@ namespace UAS_MES.Make
             DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
             if (dt.Rows.Count > 0)
             {
+                ob_sendqty.Text = dh.getFieldDataByCondition("oqcbatch", "sum(ob_nowcheckqty)", "ob_makecode='" + ma_code.Text + "' and  ob_status<>'ENTERING'").ToString();
                 ob_batchqty.Text = dt.Rows[0]["ob_batchqty"].ToString();
                 ob_nowcheckqty.Text = dt.Rows[0]["ob_nowcheckqty"].ToString();
                 ob_checkno.Text = dt.Rows[0]["ob_checkno"].ToString();
                 nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
                 batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
-                if (nowcheckqty > batchqty)
+                if (nowcheckqty == batchqty)
                 {
                     ob_nowcheckqty.ForeColor = Color.Red;
+                    OperateResult.AppendText(">>当前采集数量已达到送检数量\n", Color.Red);
                 }
             }
             else
@@ -571,6 +573,7 @@ namespace UAS_MES.Make
             sql.Clear();
             sql.Append("update oqcbatch set ob_status='UNCHECK' where ob_checkno ='" + ob_checkno.Text + "'");
             dh.ExecuteSql(sql.GetString(), "select");
+            ob_sendqty.Text = dh.getFieldDataByCondition("oqcbatch", "sum(ob_nowcheckqty)", "ob_makecode='" + ma_code.Text + "' and  ob_status<>'ENTERING'").ToString();
             ob_nowcheckqty.Text = "";
             ob_batchqty.Text = "";
             ob_nowcheckqty.ForeColor = Color.Black;
@@ -595,5 +598,19 @@ namespace UAS_MES.Make
                 SendCheck.Enabled = true;
             }
         }
+
+        /// <summary>
+        /// 工单变化修改数量
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ma_code_UserControlTextChanged(object sender, EventArgs e)
+        {
+            if (ma_code.Text.Length > 4)
+            {
+                LoadCollectedNum();
+                LoadCheckQTY();
+            }
+        }
     }
 }

+ 10 - 15
UAS-MES/FunctionCode/OQC/OQC_BatchResultJudge.cs

@@ -148,8 +148,8 @@ namespace UAS_MES.OQC
                     OperateResult.AppendText(">>判退批成功\n", Color.Green);
                     if (ReworkRequire.Checked)
                     {
-                        dh.UpdateByCondition("oqcbatch", "ob_reworkcode='"+ReworkCode+"'", "ob_checkno='"+ob_checkno.Text+"'");
-                        OperateResult.AppendText(">>生成返工需求单"+ReworkCode+"\n", Color.Green);
+                        dh.UpdateByCondition("oqcbatch", "ob_reworkcode='" + ReworkCode + "'", "ob_checkno='" + ob_checkno.Text + "'");
+                        OperateResult.AppendText(">>生成返工需求单" + ReworkCode + "\n", Color.Green);
                     }
                     GetBatch.PerformClick();
                 }
@@ -270,23 +270,18 @@ namespace UAS_MES.OQC
                 if (ob_maxngacceptqty.Text == "")
                 {
                     if (ob_aqlcode.Text == "")
-                        OperateResult.AppendText(">>最大不合格允许通过数为空的时候必须填写维护AQL标准\n", Color.Red);
+                        OperateResult.AppendText(">>AQL标准为空的时候必须填写最大不合格允许通过数\n", Color.Red);
                     else
                     {
-                        dt = (DataTable)dh.ExecuteSql("select nvl(ad_minqty,0)ad_minqty,nvl(ad_maxqty,0)ad_maxqty,nvl(ad_maxngacceptqty,0)ad_maxngacceptqty from QUA_Aql left join qua_aqldetail on ad_alid=al_id where al_code='" + ob_aqlcode.Text + "'", "select");
+                        sql.Clear();
+                        sql.Append("select nvl(ad_minqty,0)ad_minqty,nvl(ad_maxqty,0)ad_maxqty,nvl(ad_maxngacceptqty,0) ");
+                        sql.Append("ad_maxngacceptqty from QUA_Aql left join qua_aqldetail on ad_alid=al_id where ");
+                        sql.Append("al_code='" + ob_aqlcode.Text + "' and ad_minqty<='" + ob_nowcheckqty.Text + "' and ad_maxqty>='" + ob_nowcheckqty.Text + "'");
+                        dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                         if (dt.Rows.Count > 0)
                         {
-                            for (int i = 0; i < dt.Rows.Count; i++)
-                            {
-                                int batchqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
-                                int minqty = int.Parse(dt.Rows[i]["ad_minqty"].ToString());
-                                int maxqty = int.Parse(dt.Rows[i]["ad_maxqty"].ToString());
-                                if (batchqty > minqty && batchqty <= maxqty)
-                                {
-                                    ob_maxngacceptqty.Text = dt.Rows[i]["ad_maxngacceptqty"].ToString();
-                                    return true;
-                                }
-                            }
+                            ob_maxngacceptqty.Text = dt.Rows[0]["ad_maxngacceptqty"].ToString();
+                            return true;
                         }
                     }
                 }

+ 26 - 16
UAS-MES/FunctionCode/OQC/OQC_PlanMaintain.cs

@@ -17,7 +17,7 @@ namespace UAS_MES.OQC
         DataTable dt;
         DataHelper dh;
         string ErrorMessage = "";
-
+        DataTable Dbfind;
         public OQC_PlanMaintain()
         {
             InitializeComponent();
@@ -32,6 +32,7 @@ namespace UAS_MES.OQC
             pr_code.SelectField = "pr_code # 方案编号,pr_name # 方案名称,pr_class # 检验单类型,pr_standard # 方案标准,pr_startdate # 生效日期,pr_enddate #失效日期 ,pr_status # 状态";
             pr_code.SetValueField = new string[] { "ob_projectcode" };
             pr_code.FormName = Name;
+            pr_code.DbChange += Pr_code_DbChange;
 
             al_code.TableName = "QUA_AQL";
             al_code.DBTitle = "抽样标准查询";
@@ -39,9 +40,22 @@ namespace UAS_MES.OQC
             al_code.SetValueField = new string[] { "ob_aqlcode" };
             al_code.FormName = Name;
             al_code.Condition = "al_statuscode='AUDITED'";
+            al_code.DbChange += Al_code_DbChange;
             ChooseAll.ChooseAll(CheckTypeDGV);
         }
 
+        private void Al_code_DbChange(object sender, EventArgs e)
+        {
+            Dbfind = al_code.ReturnData;
+            BaseUtil.SetFormValue(this.Controls, Dbfind);
+        }
+
+        private void Pr_code_DbChange(object sender, EventArgs e)
+        {
+            Dbfind = pr_code.ReturnData;
+            BaseUtil.SetFormValue(this.Controls, Dbfind);
+        }
+
         private void 抽样计划维护_SizeChanged(object sender, EventArgs e)
         {
             asc.controlAutoSize(this);
@@ -185,6 +199,10 @@ namespace UAS_MES.OQC
             }
             else
             {
+                if (ob_maxngacceptqty.Text == "")
+                {
+                    ob_maxngacceptqty.Text = dh.getFieldDataByCondition("QUA_Aql left join qua_aqldetail on ad_alid=al_id", "nvl(ad_maxngacceptqty,0)", "al_code='" + al_code.Text + "' and ad_minqty<='" + ob_nowcheckqty.Text + "' and ad_maxqty>='" + ob_nowcheckqty.Text + "'").ToString();
+                }
                 int result = (int)dh.ExecuteSql("update OQCBatch set ob_projectcode='" + pr_code.Text + "',ob_remark = '" + ob_remark.Text + "',ob_aqlcode='" + al_code.Text + "',ob_maxngacceptqty='" + ob_maxngacceptqty.Text + "',ob_actsampleqty='" + ob_sampleqty.Text + "' where ob_checkno='" + ob_checkno.Text + "' ", "update");
                 return result > 0;
             }
@@ -217,24 +235,16 @@ namespace UAS_MES.OQC
         {
             if (al_code.Text != "")
             {
-                bool Find = false;
-                dt = (DataTable)dh.ExecuteSql("select nvl(ad_minqty,0)ad_minqty,nvl(ad_maxqty,0)ad_maxqty,nvl(ad_maxngacceptqty,0)ad_maxngacceptqty,ad_qty from QUA_Aql left join qua_aqldetail on ad_alid=al_id where al_code='" + al_code.Text + "'", "select");
+                sql.Clear();
+                sql.Append("select nvl(ad_minqty,0)ad_minqty,nvl(ad_maxqty,0)ad_maxqty,nvl(ad_maxngacceptqty,0)ad_maxngacceptqty,ad_qty from QUA_Aql ");
+                sql.Append("left join qua_aqldetail on ad_alid=al_id where al_code='" + al_code.Text + "' and ad_minqty<='" + ob_nowcheckqty.Text + "' and ad_maxqty>='" + ob_nowcheckqty.Text + "'");
+                dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                 if (dt.Rows.Count > 0)
                 {
-                    for (int i = 0; i < dt.Rows.Count; i++)
-                    {
-                        int batchqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
-                        int minqty = int.Parse(dt.Rows[i]["ad_minqty"].ToString());
-                        int maxqty = int.Parse(dt.Rows[i]["ad_maxqty"].ToString());
-                        if (batchqty > minqty && batchqty <= maxqty)
-                        {
-                            ob_maxngacceptqty.Text = dt.Rows[i]["ad_maxngacceptqty"].ToString();
-                            ob_sampleqty.Text = dt.Rows[i]["ad_qty"].ToString();
-                            Find = true;
-                        }
-                    }
+                    ob_maxngacceptqty.Text = dt.Rows[0]["ad_maxngacceptqty"].ToString();
+                    ob_sampleqty.Text = dt.Rows[0]["ad_qty"].ToString();
                 }
-                if (!Find)
+                else
                 {
                     ob_maxngacceptqty.Text = "";
                     ob_sampleqty.Text = "";

+ 3 - 3
UAS-MES/PublicMethod/LogicHandler.cs

@@ -466,9 +466,9 @@ namespace UAS_MES.PublicMethod
         {
             sql.Clear();
             sql.Append("insert into commandlog(cl_id,cl_man,cl_date,cl_linecode,cl_sourcecode,cl_makecode,cl_operate,");
-            sql.Append("cl_result,cl_sncode,cl_code) values(commandlog_seq.nextval,:iUserCode,sysdate,:iLineCode ,");
-            sql.Append(":iSourceCode ,:iMakeCode,:iOperate,:iResult,:iSncode,:iCheckno )");
-            dh.ExecuteSql(sql.ToString(), "insert", iUserCode, iLineCode, iSourceCode, iMakeCode, iOperate, iResult, iSncode, iCheckno);
+            sql.Append("cl_result,cl_sncode,cl_code) select commandlog_seq.nextval,:iUserCode,sysdate,:iLineCode ,");
+            sql.Append(":iSourceCode ,ms_makecode,:iOperate,:iResult,:iSncode,ms_checkno from makeserial where ms_sncode=:iSncode");
+            dh.ExecuteSql(sql.ToString(), "insert", iUserCode, iLineCode, iSourceCode, iOperate, iResult, iSncode, iSncode);
         }
 
         /// <summary>