Bläddra i källkod

关闭进程代码位置调整

Hcsy 8 år sedan
förälder
incheckning
7b96b68837
2 ändrade filer med 24 tillägg och 22 borttagningar
  1. 23 19
      UAS-MES/CustomControl/HeadBar/HeadBar.cs
  2. 1 3
      UAS-MES/Main.cs

+ 23 - 19
UAS-MES/CustomControl/HeadBar/HeadBar.cs

@@ -60,11 +60,15 @@ namespace UAS_MES.CustomControl
                 if (logout_confirm == "Yes")
                 {
                     this.FindForm().Close();
+                    //杀死全部未关闭的进程
+                    System.Environment.Exit(0);
                 }
             }
             else
             {
                 this.FindForm().Close();
+                //杀死全部未关闭的进程
+                System.Environment.Exit(0);
             }
         }
 
@@ -93,28 +97,28 @@ namespace UAS_MES.CustomControl
             if (NeedConfirm.Contains(this.FindForm().Name))
             {
                 string logout_confirm = MessageBox.Show(this.ParentForm, "退出登录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
-            if (logout_confirm == "Yes")
-            {
-                //注销的时候切换回默认数据库
-                SystemInf.ConnectionString = Properties.Settings.Default.Properties["MES"].DefaultValue.ToString();
-                DataHelper.DBConnectionString = SystemInf.ConnectionString;
-                //清除上个用户的权限信息
-                SystemInf.Caller.Clear();
-                //清除已经打开过的窗口的信息
-                AccordionMenu.AccordionMenu.OpenedFormName.Clear();
-                //注销的时候将除了登陆窗口之外的全部窗口关闭
-                for (int i = 0; i < Application.OpenForms.Count; i++)
+                if (logout_confirm == "Yes")
                 {
-                    if (Application.OpenForms[i].Name != "Login")
-                        Application.OpenForms[i].Close();
-                }
-                    this.FindForm().Hide();
-                    Login login = new Login();
-                    login.ShowDialog();
-                    this.FindForm().Close();
+                        //注销的时候切换回默认数据库
+                        SystemInf.ConnectionString = Properties.Settings.Default.Properties["MES"].DefaultValue.ToString();
+                        DataHelper.DBConnectionString = SystemInf.ConnectionString;
+                        //清除上个用户的权限信息
+                        SystemInf.Caller.Clear();
+                        //清除已经打开过的窗口的信息
+                        AccordionMenu.AccordionMenu.OpenedFormName.Clear();
+                        //注销的时候将除了登陆窗口之外的全部窗口关闭
+                        for (int i = 0; i < Application.OpenForms.Count; i++)
+                        {
+                            if (Application.OpenForms[i].Name != "Login")
+                                Application.OpenForms[i].Close();
+                        }
+                        this.FindForm().Hide();
+                        Login login = new Login();
+                        login.ShowDialog();
+                        this.FindForm().Close();
+                    }
             }
         }
-        }
 
         private void LoginOut_MouseEnter(object sender, EventArgs e)
         {

+ 1 - 3
UAS-MES/Main.cs

@@ -298,9 +298,7 @@ namespace UAS_MES
         }
 
         private void Main_FormClosing(object sender, FormClosingEventArgs e)
-        {
-            //杀死全部未关闭的进程
-            System.Environment.Exit(0);
+        { 
         }
     }
 }