章政 пре 7 година
родитељ
комит
19d7e408fa
5 измењених фајлова са 33 додато и 28 уклоњено
  1. 1 0
      UAS-MES/Login.Designer.cs
  2. 31 18
      UAS-MES/Login.cs
  3. 0 2
      UAS-MES/Main.Designer.cs
  4. 1 5
      UAS-MES/Main.cs
  5. 0 3
      UAS-MES/Main.resx

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