Browse Source

DBFind双击赋值错误捕获处理方法更新
DataGridViewWithCheckBOX单元格点击时勾选框勾选状态改变

Hcsy 7 years ago
parent
commit
f1939fd060

+ 1 - 0
.gitignore

@@ -214,3 +214,4 @@ ModelManifest.xml
 /MES接口/MES接口.csproj
 /UAS-出货标签管理.zip
 /UAS-MES/Tool/MES_Interface.dll
+/UAS-MES/CustomControl/DataGrid_View/DataGridViewWithSerialNum.resx

+ 1 - 1
UAS-MES/CustomControl/DataGrid_View/DataGridViewWithCheckBox.Designer.cs

@@ -34,7 +34,7 @@
             // DataGridViewWithCheckBox
             // 
             this.RowTemplate.Height = 27;
-            this.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridViewWithCheckBox_CellContentClick);
+            this.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridViewWithCheckBox_CellContentClick);
             ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
             this.ResumeLayout(false);
 

+ 8 - 2
UAS-MES/CustomControl/DataGrid_View/DataGridViewWithCheckBox.cs

@@ -18,9 +18,15 @@ namespace UAS_MES.CustomControl.DataGrid_View
 
         private void DataGridViewWithCheckBox_CellContentClick(object sender, DataGridViewCellEventArgs e)
         {
-            if (Columns[0] is DataGridViewCheckBoxColumn && e.ColumnIndex > 0)
+            if (Columns[0] is DataGridViewCheckBoxColumn && e.ColumnIndex >= 0 && e.RowIndex >= 0)
             {
-                Rows[e.RowIndex].Cells[0].Value = true;
+                if (Rows[e.RowIndex].Cells[0].Value.ToString() == "0")
+                {
+                    Rows[e.RowIndex].Cells[0].Value = 1;
+                }
+                else {
+                    Rows[e.RowIndex].Cells[0].Value = 0;
+                }
             }
         }
     }

+ 70 - 4
UAS-MES/DbFind.cs

@@ -94,8 +94,8 @@ namespace UAS_MES
                     IsAbleDbFind = true;
                 }
             }
-            catch (Exception) {
-
+            catch (Exception  EB) {
+                LogManager.DoLog(EB.Message);
                 IsAbleDbFind = false; }
         }
 
@@ -162,11 +162,11 @@ namespace UAS_MES
         //给打开窗体的对应字段赋值
         private void DbFindGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
         {
+            FormCollection fmCollection = Application.OpenForms;
+            ControlCollection controls = (ControlCollection)fmCollection[FormName].Controls;
             try
             {
                 //先判断DataTable里面是否有这个字段,然后从打开的窗口里面去获取到这个Form,从Form中的指定Panel获取到指定字段的控件
-                FormCollection fmCollection = Application.OpenForms;
-                ControlCollection controls = (ControlCollection)fmCollection[FormName].Controls;
                 for (int i = 0; i < dt.Columns.Count; i++)
                 {
                     fillControl(e, i, fmCollection[FormName]);
@@ -188,12 +188,78 @@ 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;
             }
             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 == "ob_aqlcode")
+                        {
+                            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++)

+ 0 - 1
UAS-MES/PublicMethod/AutoSizeFormClass.cs

@@ -27,7 +27,6 @@ namespace UAS_MES.PublicMethod
         {
             controlRect cR;
             mForm.Width = Screen.PrimaryScreen.WorkingArea.Width - SystemInf.NavWidth-5;
-            LogManager.DoLog(SystemInf.HeadBarHeight.ToString());
             mForm.Height = Screen.PrimaryScreen.WorkingArea.Height - 100;
             cR.Left = mForm.Left; cR.Top = mForm.Top; cR.Width = mForm.Width; cR.Height = mForm.Height;
             oldCtrl.Add(cR);//第一个为"窗体本身",只加入一次即可