Browse Source

对上次提交的进行优化调整

章政 8 years ago
parent
commit
d8ece0663a

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

@@ -13,7 +13,6 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
         public MaCodeSearchTextBox()
         {
             InitializeComponent();
-            TextBox.KeyDown += TextBox_KeyDown;
         }
         #endregion
 
@@ -227,11 +226,12 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
 
         private void TextBox_TextChanged(object sender, EventArgs e)
         {
-            Console.WriteLine(TextBox.Text);
-            Console.WriteLine(db.SuccessReturnData);
-            if (db.SuccessReturnData) {
-                LockCheckBox.Checked = true;
+            try
+            {
+                if (db.SuccessReturnData)
+                    LockCheckBox.Checked = true;
             }
+            catch (Exception) { }
             UserControlTextChanged?.Invoke(sender, new EventArgs());
         }
 
@@ -239,54 +239,60 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
         //Key先发起失去焦点事件,在执行用户自定义的事件
         private void TextBox_KeyDown(object sender, KeyEventArgs e)
         {
-            if (e.KeyCode == Keys.Enter)
+            if (e.KeyCode == Keys.Enter) {
+                GetData();
+            }
+        }   
+
+        public void SetLockCheckBox(CheckBox ctl)
+        {
+            LockCheckBox = ctl;
+        }
+
+        private void GetData()
+        {
+            if (TextBox.Text != "")
             {
-                if (TextBox.Text != "")
+                DataHelper dh = new DataHelper();
+                List<string> fields = new List<string>();
+                //获取查询的字段
+                string[] field = selectField.Replace(",", "#").Trim().Split('#');
+                for (int i = 0; i < field.Length; i++)
                 {
-                    DataHelper dh = new DataHelper();
-                    List<string> fields = new List<string>();
-                    //获取查询的字段
-                    string[] field = selectField.Replace(",", "#").Trim().Split('#');
-                    for (int i = 0; i < field.Length; i++)
-                    {
-                        if (i % 2 == 0)
-                            fields.Add(field[i]);
-                    }
-                    //将查询到的结果返回界面
-                    string sql = "select " + BaseUtil.AddField(fields.ToArray()) + " from " + tableName + " where " + Tag + "='" + TextBox.Text + "'";
-                    if (condition != null)
-                    {
-                        sql += " and " + condition;
-                    }
-                    DataTable dt = (DataTable)dh.ExecuteSql(sql, "select");
-                    FormCollection fmCollection = Application.OpenForms;
-                    if (dt.Rows.Count > 0)
+                    if (i % 2 == 0)
+                        fields.Add(field[i]);
+                }
+                //将查询到的结果返回界面
+                string sql = "select " + BaseUtil.AddField(fields.ToArray()) + " from " + tableName + " where " + Tag + "='" + TextBox.Text.ToUpper() + "'";
+                if (condition != null)
+                {
+                    sql += " and " + condition;
+                }
+                DataTable dt = (DataTable)dh.ExecuteSql(sql, "select");
+                FormCollection fmCollection = Application.OpenForms;
+                if (dt.Rows.Count > 0)
+                {
+                    for (int i = 0; i < dt.Columns.Count; i++)
                     {
-                        for (int i = 0; i < dt.Columns.Count; i++)
+                        for (int j = 0; j < SetValueField.Length; j++)
                         {
-                            for (int j = 0; j < SetValueField.Length; j++)
+                            //利用字段的Tag属性来和列名进行比对
+                            object tag = fmCollection[FormName].Controls[SetValueField[j]].Tag;
+                            if (SetValueField[j] == dt.Columns[i].ColumnName.ToLower() || (tag != null && tag == dt.Columns[i].ColumnName.ToLower()))
                             {
-                                //利用字段的Tag属性来和列名进行比对
-                                object tag = fmCollection[FormName].Controls[SetValueField[j]].Tag;
-                                if (SetValueField[j] == dt.Columns[i].ColumnName.ToLower() || (tag != null && tag == dt.Columns[i].ColumnName.ToLower()))
-                                {
-                                    fmCollection[FormName].Controls[SetValueField[j]].Text = dt.Rows[0][dt.Columns[i].ColumnName].ToString();
-                                }
+                                fmCollection[FormName].Controls[SetValueField[j]].Text = dt.Rows[0][dt.Columns[i].ColumnName].ToString();
                             }
                         }
-                        LeaveFindData = true;
-                        LockCheckBox.Checked = true;
                     }
-                    else
-                        LeaveFindData = false;
+                    LeaveFindData = true;
                 }
+                else
+                    LeaveFindData = false;
+                //不允许工单号为空的情况
+                LockCheckBox.Checked = true;
             }
         }
 
-        public void SetLockCheckBox(CheckBox ctl) {
-            LockCheckBox = ctl;
-        }
-
         private void Search_Icon_Click(object sender, EventArgs e)
         {
             SearchIconClick?.Invoke(sender, new EventArgs());
@@ -321,6 +327,7 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
         public void TextBox_Leave(object sender, EventArgs e)
         {
             TextBox.BackColor = System.Drawing.Color.White;
+            GetData();
         }
 
         private void SearchTextBox_Load(object sender, EventArgs e)
@@ -332,7 +339,7 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
 
         private void SearchTextBox_SizeChanged(object sender, EventArgs e)
         {
-            TextBox.Width = this.Width - Search_Icon.Width-3;
+            TextBox.Width = this.Width - Search_Icon.Width - 3;
         }
     }
 }

+ 0 - 2
UAS-MES/CustomControl/TextBoxWithIcon/MaCodeTextBox.cs

@@ -78,8 +78,6 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
             this.BackColor = Color.White;
         }
 
-
-
         //手动添加全选功能
         private void MaCodeTextBox_KeyDown(object sender, KeyEventArgs e)
         {

+ 0 - 2
UAS-MES/DbFind.cs

@@ -208,9 +208,7 @@ namespace UAS_MES
                     ColumnWidth += DbFindGridView.Columns[i].Width;
                     //如果有列被完全遮蔽,设置对应的输入框宽度为0
                     if (ColumnWidth < ScrollNewValue)
-                    {
                         Controls[dt.Columns[i].Caption].Width = 0;
-                    }
                     else if (ColumnWidth > ScrollNewValue)
                     {
                         Controls[dt.Columns[i].Caption].Width = ColumnWidth - ScrollNewValue;

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

@@ -385,7 +385,7 @@
             // 
             this.LockMakeCode.AutoSize = true;
             this.LockMakeCode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.LockMakeCode.Location = new System.Drawing.Point(175, 43);
+            this.LockMakeCode.Location = new System.Drawing.Point(175, 46);
             this.LockMakeCode.Name = "LockMakeCode";
             this.LockMakeCode.Size = new System.Drawing.Size(91, 24);
             this.LockMakeCode.TabIndex = 66;

+ 0 - 7
UAS-MES/FunctionCode/Make/Make_TestCollection.cs

@@ -215,9 +215,7 @@ namespace UAS_MES.Make
                 //第一列是勾选列,设置列头文本为空
                 lvi.Text = "";
                 for (int j = 0; j < dt.Columns.Count; j++)
-                {
                     lvi.SubItems.Add(dt.Rows[i][j].ToString());
-                }
                 WaitRejectList.Items.Add(lvi);
             }
             WaitRejectList.EndUpdate();
@@ -313,10 +311,5 @@ namespace UAS_MES.Make
                     OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
             }
         }
-
-        private void ma_code_TextKeyDown(object sender, KeyEventArgs e)
-        {
-            if (e.KeyCode == Keys.Enter) { }
-        }
     }
 }

+ 0 - 4
UAS-MES/PublicMethod/BaseUtil.cs

@@ -671,13 +671,9 @@ namespace UAS_MES.PublicMethod
             }
             //如果所有的控件传入的都是空值则返回也为空
             if (EmptyControlCount == Condition.Length)
-            {
                 return "";
-            }
             else
-            {
                 condition = " where " + condition;
-            }
             return condition;
         }
 

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

@@ -38,7 +38,7 @@
     <SuiteName>优软MES系统</SuiteName>
     <MinimumRequiredVersion>1.0.0.59</MinimumRequiredVersion>
     <WebPage>publish.htm</WebPage>
-    <ApplicationRevision>184</ApplicationRevision>
+    <ApplicationRevision>185</ApplicationRevision>
     <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
     <UseApplicationTrust>true</UseApplicationTrust>
     <CreateDesktopShortcut>true</CreateDesktopShortcut>