Bläddra i källkod

修改放大镜赋值

Hcsy 8 år sedan
förälder
incheckning
2e0a00393d

+ 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
             {

+ 1 - 31
UAS-MES/CustomControl/TextBoxWithIcon/SearchTextBox.cs

@@ -317,26 +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++)
-            {
-                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 != "")
@@ -357,17 +337,7 @@ 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]);
-                //    }
-                //}          
+                ReturnDataToForm();          
             }
         }
     }

+ 16 - 65
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++)

+ 10 - 1
UAS-MES/UAS-MES.csproj

@@ -81,7 +81,7 @@
     <GenerateManifests>true</GenerateManifests>
   </PropertyGroup>
   <PropertyGroup>
-    <SignManifests>true</SignManifests>
+    <SignManifests>false</SignManifests>
   </PropertyGroup>
   <PropertyGroup>
     <StartupObject>UAS_MES.Program</StartupObject>
@@ -343,6 +343,12 @@
     <Compile Include="CustomControl\TextBoxWithIcon\SearchTextBox.Designer.cs">
       <DependentUpon>SearchTextBox.cs</DependentUpon>
     </Compile>
+    <Compile Include="CustomControl\TextBoxWithIcon\SNCodeEnterTextBox.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="CustomControl\TextBoxWithIcon\SNCodeEnterTextBox.Designer.cs">
+      <DependentUpon>SNCodeEnterTextBox.cs</DependentUpon>
+    </Compile>
     <Compile Include="CustomControl\TextBoxWithIcon\TextAreaForm.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -869,6 +875,9 @@
     <EmbeddedResource Include="CustomControl\TextBoxWithIcon\SearchTextBox.resx">
       <DependentUpon>SearchTextBox.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="CustomControl\TextBoxWithIcon\SNCodeEnterTextBox.resx">
+      <DependentUpon>SNCodeEnterTextBox.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="CustomControl\TextBoxWithIcon\TextAreaForm.resx">
       <DependentUpon>TextAreaForm.cs</DependentUpon>
     </EmbeddedResource>