Ejemplo n.º 1
0
 private void showDefaultFields()
 {
     comboBoxAuthType.Show();
     TextBoxAccount.Hide();
     AuthenticationLabel.Text = "Authentication";
     textBoxWarehouse.Hide();
     textBoxRole.Hide();
     labelRole.Hide();
     labelWarehouse.Hide();
 }
Ejemplo n.º 2
0
 private void enableSnowflakeFields()
 {
     // hide auth type switch and show Account, Warehouse, Role text fields
     comboBoxAuthType.Hide();
     TextBoxAccount.Show();
     AuthenticationLabel.Text = "Account";
     textBoxWarehouse.Show();
     textBoxRole.Show();
     labelRole.Show();
     labelWarehouse.Show();
 }
Ejemplo n.º 3
0
 public FormLogin()
 {
     InitializeComponent();
     this.PanelProgressBar.Width = 0;
     try
     {
         GlobalClass.StrCnn = System.Configuration.ConfigurationManager.ConnectionStrings["StrCnn"].ConnectionString.ToString();
         GlobalClass.Connection.ConnectionString = GlobalClass.StrCnn;
         TextBoxAccount.Focus();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
         GlobalClass.Connection.Close();
     }
     finally
     {
         Application.Exit();
     }
 }
Ejemplo n.º 4
0
 private void ButtonLogin_Click(object sender, EventArgs e)
 {
     if (!Regex.IsMatch(TextBoxAccount.Text, @"1\d{5}"))
     {
         MessageBox.Show("用户名不合法!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
         TextBoxAccount.Clear();
         TextBoxAccount.Focus();
     }
     else if (TextBoxPassword.Text == String.Empty)
     {
         MessageBox.Show("密码不合法!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
         TextBoxPassword.Clear();
         TextBoxPassword.Focus();
     }
     else
     {
         try
         {
             GlobalClass.Connection.Open();
             SqlCommand LoginCmd = new SqlCommand("UserLogin", GlobalClass.Connection);
             LoginCmd.CommandType = CommandType.StoredProcedure;
             LoginCmd.Parameters.Add("@No", SqlDbType.NChar, 6);
             LoginCmd.Parameters.Add("@Password", SqlDbType.NChar, 32);
             LoginCmd.Parameters.Add("@ReturnValue", SqlDbType.Int, 6);
             LoginCmd.Parameters[0].Value     = TextBoxAccount.Text;
             LoginCmd.Parameters[1].Value     = GlobalClass.MD5(TextBoxPassword.Text);
             LoginCmd.Parameters[2].Direction = ParameterDirection.ReturnValue;
             LoginCmd.ExecuteNonQuery();
             int ReturnValue = (int)LoginCmd.Parameters[2].Value;
             GlobalClass.Connection.Close();
             if (ReturnValue == 0)
             {
                 GlobalClass.UserName       = TextBoxAccount.Text;
                 GlobalClass.EmployeeNo     = TextBoxAccount.Text;
                 GlobalClass.PrivilegeLevel = (int)GlobalClass.Privilege.Administrator;
                 this.TimerProgressBar.Start();
             }
             else if (ReturnValue == 1)
             {
                 GlobalClass.UserName       = TextBoxAccount.Text;
                 GlobalClass.EmployeeNo     = TextBoxAccount.Text;
                 GlobalClass.PrivilegeLevel = (int)GlobalClass.Privilege.Director;
                 this.TimerProgressBar.Start();
             }
             else if (ReturnValue == 2)
             {
                 GlobalClass.UserName       = TextBoxAccount.Text;
                 GlobalClass.EmployeeNo     = TextBoxAccount.Text;
                 GlobalClass.PrivilegeLevel = (int)GlobalClass.Privilege.Manager;
                 this.TimerProgressBar.Start();
             }
             else if (ReturnValue == 3)
             {
                 GlobalClass.UserName       = TextBoxAccount.Text;
                 GlobalClass.EmployeeNo     = TextBoxAccount.Text;
                 GlobalClass.PrivilegeLevel = (int)GlobalClass.Privilege.Reception;
                 this.TimerProgressBar.Start();
             }
             else if (ReturnValue == 4)
             {
                 GlobalClass.UserName       = TextBoxAccount.Text;
                 GlobalClass.EmployeeNo     = TextBoxAccount.Text;
                 GlobalClass.PrivilegeLevel = (int)GlobalClass.Privilege.Logistics;
                 this.TimerProgressBar.Start();
             }
             else if (ReturnValue == 5)
             {
                 MessageBox.Show("权限不足!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 TextBoxAccount.Clear();
                 TextBoxPassword.Clear();
                 TextBoxAccount.Focus();
             }
             else if (ReturnValue == 6)
             {
                 MessageBox.Show("密码错误!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 TextBoxPassword.Clear();
                 TextBoxPassword.Focus();
             }
             else if (ReturnValue == 7)
             {
                 MessageBox.Show("用户名错误!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 TextBoxAccount.Clear();
                 TextBoxAccount.Focus();
             }
             else
             {
                 MessageBox.Show("未知错误!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
             GlobalClass.Connection.Close();
         }
     }
 }