Przeglądaj źródła

Merge remote-tracking branch 'refs/remotes/origin/master'

Hcsy 8 lat temu
rodzic
commit
08e314bfe9

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

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

@@ -608,6 +608,11 @@ namespace UAS_MES.Make
         {
             if (ma_code.Text.Length > 4)
             {
+                mcd_remainqty.Text = "";
+                mcd_inqty.Text = "";
+                ob_batchqty.Text = "";
+                ob_nowcheckqty.Text = "";
+                ob_sendqty.Text = "";
                 LoadCollectedNum();
                 LoadCheckQTY();
             }

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

+ 1 - 0
UAS-MES/Login.Designer.cs

@@ -154,6 +154,7 @@
             this.LoginButton.BackColor = System.Drawing.Color.White;
             this.LoginButton.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("LoginButton.BackgroundImage")));
             this.LoginButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+            this.LoginButton.Enabled = false;
             this.LoginButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
             this.LoginButton.Location = new System.Drawing.Point(153, 250);
             this.LoginButton.Name = "LoginButton";

+ 31 - 18
UAS-MES/Login.cs

@@ -7,6 +7,7 @@ using UAS_MES.PublicMethod;
 using System.Security.Cryptography.X509Certificates;
 using System.Net;
 using System.Net.Sockets;
+using System.Threading;
 
 namespace UAS_MES
 {
@@ -20,6 +21,10 @@ namespace UAS_MES
         //注销的时候会重新生成这边变量,所以需要用static
         static LogicHandler lgc;
 
+        Thread LoadMasterInf;
+
+
+
         public Login()
         {
             InitializeComponent();
@@ -36,26 +41,15 @@ namespace UAS_MES
 
         private void Login_Load(object sender, EventArgs e)
         {
-            ftpOperater ftp = new ftpOperater();
             //设置默认数据库
             SystemInf.DefaultDB = Properties.Settings.Default.Properties["MES"].DefaultValue.ToString();
-            dh = new DataHelper();
-            //将账套的信息查询出来赋给下拉框
-            DbComboxData = (DataTable)dh.ExecuteSql("select ms_pwd,ma_user,ma_address from master", "select");
-            DB.DataSource = DbComboxData;
-            DB.DisplayMember = "ma_user";
-            DB.ValueMember = "ma_user";
-            if (DbComboxData.Rows.Count > 0)
-            {
-                DB.Text = DbComboxData.Rows[0]["ma_user"].ToString();
-            }
-            if (Properties.Settings.Default.LastLoginSob != null)
-            {
-                DB.SelectedValue = Properties.Settings.Default.LastLoginSob;
-            }
+            CheckForIllegalCrossThreadCalls = false;
+            LoadMasterInf = new Thread(LoadMaster);
+            LoadMasterInf.Start();
             //显示上次用户登录的用户名,将输入框定位到密码
             UserName.Text = Properties.Settings.Default.LastLoginUser;
             Source.Text = Properties.Settings.Default.LastLoginResource;
+           
             if (UserName.Text != "")
                 PassWord.Select();
             else
@@ -63,6 +57,25 @@ namespace UAS_MES
             BaseUtil.SetFormCenter(this);
         }
 
+        private void LoadMaster()
+        {
+            try
+            {
+                dh = new DataHelper();
+                //将账套的信息查询出来赋给下拉框
+                DbComboxData = (DataTable)dh.ExecuteSql("select ms_pwd,ma_user,ma_address from master", "select");
+                DB.DataSource = DbComboxData;
+                DB.DisplayMember = "ma_user";
+                DB.ValueMember = "ma_user";
+                DB.Text = Properties.Settings.Default.LastLoginSob;
+                LoginButton.Enabled = true;
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+            }
+        }
+
         //点击登陆按钮的时候
         private void LoginButton_Click(object sender, EventArgs e)
         {
@@ -129,7 +142,7 @@ namespace UAS_MES
             //设置全局用户信息
             string[] field = { "em_code,em_depart,em_type,em_name,em_position,em_professname,em_type,ug_code,ug_name" };
             UserInf = dh.getFieldsDataByCondition("Employee left join cs$userresource on ur_emcode=em_code left join cs$usergroup on ug_code=ur_groupcode", field, "em_code='" + UserName.Text + "'");
-            DataTable dt = dh.getFieldsDataByCondition("source", new string[] {"sc_code", "sc_stepcode", "sc_stepname", "sc_linecode" }, "upper(sc_code)='" + Source.Text.ToUpper() + "'");
+            DataTable dt = dh.getFieldsDataByCondition("source", new string[] { "sc_code", "sc_stepcode", "sc_stepname", "sc_linecode" }, "upper(sc_code)='" + Source.Text.ToUpper() + "'");
             //存在岗位资源则要求添加
             if (dt.Rows.Count > 0)
             {
@@ -166,13 +179,13 @@ namespace UAS_MES
         private void Source_KeyDown(object sender, KeyEventArgs e)
         {
             if (e.KeyCode == Keys.Enter)
-                LoginButton_Click(sender, e);
+                LoginButton.PerformClick();
         }
 
         private void PassWord_KeyDown(object sender, KeyEventArgs e)
         {
             if (e.KeyCode == Keys.Enter)
-                LoginButton_Click(sender, e);
+                LoginButton.PerformClick();
         }
 
         /// <summary>

+ 0 - 2
UAS-MES/Main.Designer.cs

@@ -47,7 +47,6 @@
             this.Menu = new UAS_MES.CustomControl.AccordionMenu.AccordionMenu();
             this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
             this.pictureBox1 = new System.Windows.Forms.PictureBox();
-            this.RefreshDBConnect = new System.Windows.Forms.Timer(this.components);
             this.headBar1 = new UAS_MES.CustomControl.HeadBar();
             this.BasicInf.SuspendLayout();
             this.panel1.SuspendLayout();
@@ -310,7 +309,6 @@
         private System.Windows.Forms.Label inf_source;
         private System.Windows.Forms.Label Inf_linecode_label;
         private System.Windows.Forms.Label Inf_source_label;
-        private System.Windows.Forms.Timer RefreshDBConnect;
     }
 }
 

+ 1 - 5
UAS-MES/Main.cs

@@ -56,7 +56,7 @@ namespace UAS_MES
             DirectoryInfo dir = new DirectoryInfo(sysdisc + @":\Log");
             List<string> DeleteFileName = new List<string>();
             //保存6天前和今天的操作日志
-            for (int i = 1; i <= 6; i++)
+            for (int i = 1; i <= 30; i++)
             {
                 DeleteFileName.Add(DateTime.Now.AddDays(-i).ToString("yyyy-MM-dd") + ".txt");
             }
@@ -80,9 +80,6 @@ namespace UAS_MES
         {
             thread = new Thread(DeleteLog);
             thread.Start();
-            RefreshDBConnect.Interval = 600 * 1000;
-            RefreshDBConnect.Tick += RefreshDB;
-            RefreshDBConnect.Start();
             this.Tag = "ShowDialogWindow";
             this.headBar1.MouseDown += new MouseEventHandler(this.headBar_MouseDown);
             this.MainTabControl.DrawMode = TabDrawMode.OwnerDrawFixed;
@@ -259,7 +256,6 @@ namespace UAS_MES
                 this.Hide();
                 Login login = new Login();
                 login.ShowDialog();
-                RefreshDBConnect.Stop();
                 this.Close();
             }
         }

+ 0 - 3
UAS-MES/Main.resx

@@ -120,9 +120,6 @@
   <metadata name="notifyIcon1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>17, 17</value>
   </metadata>
-  <metadata name="RefreshDBConnect.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>157, 17</value>
-  </metadata>
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>

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