浏览代码

放大镜赋值方法修改,测试界面放大镜调整

章政 8 年之前
父节点
当前提交
060140485e

+ 26 - 0
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 自定义事件
@@ -304,6 +323,7 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
         {
             SearchIconClick?.Invoke(sender, new EventArgs());
             db = new DbFind(Name, tableName, selectField, setValueField, caller, formName, condition);
+            db.FormClosing += Db_FormClosing;
             db.Text = DBTitle1;
             LogManager.DoLog("DbFind查询,发起窗口【" + formName + "】,查询表【" + tableName + "】,字段" + selectField + ",条件" + condition);
             if (db.IsAbleDbFind1)
@@ -316,6 +336,12 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
             }
         }
 
+        private void Db_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            ReturnData1 = dt;
+            DbChange?.Invoke(sender, new EventArgs());
+        }
+
         public void TextBox_Leave(object sender, EventArgs e)
         {
             GetData();

+ 41 - 9
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;
@@ -242,6 +261,7 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
             SearchIconClick?.Invoke(sender, new EventArgs());
             DbFind db = new DbFind(Name, tableName, selectField, setValueField, caller, formName, condition);
             db.Text = DBTitle1;
+            db.FormClosing += Db_FormClosing;
             LogManager.DoLog("DbFind查询,发起窗口【" + formName + "】,查询表【" + tableName + "】,字段" + selectField + ",条件" + condition);
             if (db.IsAbleDbFind1)
             {
@@ -253,6 +273,17 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
             }
         }
 
+        /// <summary>
+        /// 触发给界面的
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        public void Db_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            returnData = dt;
+            DbChange?.Invoke(sender, new EventArgs());
+        }
+
         private void TextBox_Enter(object sender, EventArgs e)
         {
             TextBox.BackColor = System.Drawing.Color.GreenYellow;
@@ -329,16 +360,17 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
                     sql += " and " + condition;
                 }
                 dt = (DataTable)dh.ExecuteSql(sql, "select");
+                returnData = dt;
                 //先判断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]);
+                //    }
+                //}          
             }
         }
     }

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

@@ -420,6 +420,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);

+ 10 - 1
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>
@@ -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();
                     //存在抽检批次更新为空
@@ -450,7 +460,6 @@ namespace UAS_MES.Make
                     LastSncode = ms_sncode.Text;
                     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 = "";