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

+ 8 - 13
UAS-MES/CustomControl/TextBoxWithIcon/MaCodeSearchTextBox.cs

@@ -275,26 +275,20 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
                     if (i % 2 == 0)
                         fields.Add(field[i]);
                 }
+                string sql;
                 //将查询到的结果返回界面
-                string sql = "select " + BaseUtil.AddField(fields.ToArray()) + " from " + tableName + " where " + Name + "='" + TextBox.Text.ToUpper() + "'";
+                if (TextBox.Text != null) { 
+                 sql = "select " + BaseUtil.AddField(fields.ToArray()) + " from " + tableName + " where " + Name + "='" + TextBox.Text.ToUpper() + "'";
+                }
+                else { 
+                 sql = "select " + BaseUtil.AddField(fields.ToArray()) + " from " + tableName + " where " + Name + "='" + db.TextBoxValue1 + "'";
+                }
                 if (condition != null)
                 {
                     sql += " and " + condition;
                 }
                 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;
             }
@@ -329,6 +323,7 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
             if (db.IsAbleDbFind1)
             {
                 db.ShowDialog();
+                GetData();
             }
             else
             {

+ 13 - 34
UAS-MES/CustomControl/TextBoxWithIcon/SearchTextBox.cs

@@ -58,6 +58,7 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
         /// </summary>
         private string selectField;
         DataTable dt = new DataTable();
+        DbFind db;
 
         private DataTable returnData;
 
@@ -259,12 +260,13 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
         private void Search_Icon_Click(object sender, EventArgs e)
         {
             SearchIconClick?.Invoke(sender, new EventArgs());
-            DbFind db = new DbFind(Name, tableName, selectField, setValueField, caller, formName, condition);
+            db = new DbFind(Name, tableName, selectField, setValueField, caller, formName, condition);
             db.Text = DBTitle1;
             LogManager.DoLog("DbFind查询,发起窗口【" + formName + "】,查询表【" + tableName + "】,字段" + selectField + ",条件" + condition);
             if (db.IsAbleDbFind1)
             {
                 db.ShowDialog();
+                GetData();
             }
             else
             {
@@ -317,26 +319,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++)
-            {
-                if (ct.Controls.Count > 0 && ct.Name.ToString() != setValueField[j])
-                {
-                    Control.ControlCollection controls = ct.Controls;
-                    for (int k = 0; k < ct.Controls.Count; k++)
-                    {
-                        fillControl(i, controls[k]);
-                    }
-                }
-                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();
-                }
-            }
-        }
-
         public void GetData()
         {
             if (TextBox.Text != "")
@@ -350,24 +332,21 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
                     if (i % 2 == 0)
                         fields.Add(field[i]);
                 }
+                string sql;
                 //将查询到的结果返回界面
-                string sql = "select " + BaseUtil.AddField(fields.ToArray()) + " from " + tableName + " where " + Name + "='" + TextBox.Text + "'";
-                if (condition != null)
+                if (TextBox.Text != null)
+                {
+                     sql = "select " + BaseUtil.AddField(fields.ToArray()) + " from " + tableName + " where " + Name + "='" + TextBox.Text + "'";
+                }
+                else {
+                    sql = "select " + BaseUtil.AddField(fields.ToArray()) + " from " + tableName + " where " + Name + "='" + db.TextBoxValue1 + "'";
+                }
+                    if (condition != null)
                 {
                     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]);
-                //    }
-                //}          
+                ReturnDataToForm();          
             }
         }
     }

+ 17 - 66
UAS-MES/DbFind.cs

@@ -13,6 +13,9 @@ namespace UAS_MES
         //判断是否配置了DbFind
         bool IsAbleDbFind;
 
+        //双击选择的工单号
+        string TextBoxValue;
+
         DataHelper dh = new DataHelper();
 
         DataTable dt = new DataTable();
@@ -51,6 +54,18 @@ namespace UAS_MES
             }
         }
 
+        public string TextBoxValue1
+        {
+            get
+            {
+                return TextBoxValue;
+            }
+            set
+            {
+                TextBoxValue = value;
+            }
+        }
+
         /// <summary>
         /// 
         /// </summary>
@@ -189,78 +204,14 @@ namespace UAS_MES
             catch (Exception ea)
             {
                 LogManager.DoLog(ea.Message);
-                MainControl = fillFormname(FormName, (ControlCollection)fmCollection[FormName].Controls, e);
-                if (MainControl is MaCodeSearchTextBox)
-                {
-                    MaCodeSearchTextBox ctl = (MainControl as MaCodeSearchTextBox);
-                    ctl.GetData();
-                }
-                if (MainControl is SearchTextBox)
-                {
-                    SearchTextBox ctl = (MainControl as SearchTextBox);
-                    ctl.GetData();
-                }
-                MainControl.Focus();
                 SuccessReturnData = false;
             }
+            TextBoxValue = DbFindGridView.Rows[e.RowIndex].Cells[0].Value.ToString();
             Dispose();
             Close();
         }
 
 
-        private Control fillFormname(string fromname, ControlCollection controls, DataGridViewCellEventArgs e)
-        {
-            Control ct = null;
-            if (e.RowIndex >= 0)
-            {               
-                switch (fromname)
-                {
-                    case "Make_TestCollection":
-                        controls[MainField].Text = DbFindGridView.Rows[e.RowIndex].Cells["工单号"].Value.ToString();
-                        ct = controls[MainField];
-                        break;
-                    case "Make_Repair":
-                        if (MainField == "cr_code")
-                        {
-                            controls[MainField].Text = DbFindGridView.Rows[e.RowIndex].Cells["工艺编号"].Value.ToString();
-                        }
-                        else if (MainField == "cd_stepcode")
-                        {
-                            controls[MainField].Text = DbFindGridView.Rows[e.RowIndex].Cells["工序编号"].Value.ToString();
-                        }
-                        else
-                        {
-                            controls[MainField].Text = DbFindGridView.Rows[e.RowIndex].Cells["零件名称"].Value.ToString();
-                        }
-                        ct = controls[MainField];
-                        break;
-                    case "OQC_PlanMaintain":
-                        if (MainField == "al_code")
-                        {
-                            Control.ControlCollection ctL = controls["panel1"].Controls;
-                            ctL[MainField].Text = DbFindGridView.Rows[e.RowIndex].Cells["流水编号"].Value.ToString();
-                            ct = ctL[MainField];
-                        }
-                        else
-                        {
-                            controls[MainField].Text = DbFindGridView.Rows[e.RowIndex].Cells["方案编号"].Value.ToString();
-                            ct = controls[MainField];
-                        }
-                        break;
-                    case "OQC_Inspection":
-                        controls[MainField].Text = DbFindGridView.Rows[e.RowIndex].Cells["工单号"].Value.ToString();
-                        ct = controls[MainField];
-                        break;
-                    case "Make_FeedingCollection":
-                        controls[MainField].Text = DbFindGridView.Rows[e.RowIndex].Cells["工单号"].Value.ToString();
-                        ct = controls[MainField];
-                        break;
-                }
-            }
-            return ct;
-
-        }
-
         private void fillControl(DataGridViewCellEventArgs e, int i, Control ct)
         {
             for (int j = 0; j < SetValueField.Length; j++)
@@ -275,7 +226,7 @@ namespace UAS_MES
                 }
                 else
                 {
-                    if ((SetValueField[j] == dt.Columns[i].Caption || SetValueField[j] == dt.Columns[i].ColumnName || SetValueField[j].Contains(dt.Columns[i].Caption) || (ct != null && ct.Tag != null && ct.Tag.ToString() == dt.Columns[i].Caption)) && ct.Name.ToString() == SetValueField[j])
+                    if ((SetValueField[j] == dt.Columns[i].Caption || SetValueField[j] == dt.Columns[i].ColumnName || SetValueField[j].Contains(dt.Columns[i].Caption) || (ct != null && ct.Tag != null && ct.Tag.ToString() == dt.Columns[i].Caption)) && ct.Name.ToString().ToUpper() == SetValueField[j].ToUpper())
                         ct.Text = DbFindGridView.Rows[e.RowIndex].Cells[dt.Columns[i].ColumnName].Value.ToString();
                     if (ct.Name == MainField)
                     {

+ 3 - 3
UAS-MES/FunctionCode/OQC/OQC_PlanMaintain.cs

@@ -30,14 +30,14 @@ namespace UAS_MES.OQC
 
             pr_code.TableName = "QUA_Project";
             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.SetValueField = new string[] { "pr_code" };
             pr_code.FormName = Name;
             pr_code.DbChange += Pr_code_DbChange;
 
             al_code.TableName = "QUA_AQL";
             al_code.DBTitle = "抽样标准查询";
-            al_code.SelectField = "AL_CODE  # 流水编号,AL_NAME # 检验标准名称";
-            al_code.SetValueField = new string[] { "ob_aqlcode" };
+            al_code.SelectField = "al_code  # 流水编号,AL_NAME # 检验标准名称";
+            al_code.SetValueField = new string[] { "al_code" };
             al_code.FormName = Name;
             al_code.Condition = "al_statuscode='AUDITED'";
             al_code.DbChange += Al_code_DbChange;