Esempio n. 1
0
 private void Login_Click(object sender, RoutedEventArgs e)
 {
     user       = username.Text.Clone().ToString();
     sql        = string.Format("server=localhost;User Id={0};password={1};Database=school", username.Text, password.Password);
     connection = new MySqlConnection(sql);
     try
     {
         connection.Open();
         MessageBox.Show(string.Format("登陆成功 , {0} !", username.Text), "登陆成功");
         login_success = true;
         if (username.Text != "root" && username.Text != "0101")
         {
             is_stu = true;
         }
         if (is_stu)
         {
             StuClient stu = new StuClient();
             stu.Show();
         }
         else
         {
             TeaClient tea = new TeaClient();
             tea.Show();
         }
         //@return.Show();
         Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "登陆失败");
     }
 }
 private void Ok_Click(object sender, RoutedEventArgs e)
 {
     if (MainWindow.login_success)
     {
         if (MainWindow.is_stu)
         {
             StuClient stu = new StuClient();
             stu.Show();
         }
         else
         {
             TeaClient tea = new TeaClient();
             tea.Show();
         }
         Close();
     }
     else
     {
         Close();
     }
 }