コード例 #1
0
 /// <summary>
 /// move to the next textbBlock when press Enter key
 /// </summary>
 /// <param name="sender">sender of the event</param>
 /// <param name="e">e of the argument</param>
 private void Key_Down(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         PassTB.Focus();
     }
 }
コード例 #2
0
ファイル: Login.cs プロジェクト: Bilal334409/Payroll
//        Admin
//        Accountant
//        Receptionist
//        General Employee

        private void panel3_Click(object sender, EventArgs e)
        {
            if (UserNameTB.Text == "")
            {
                UserNameTB.BackColor = Color.DodgerBlue;
                MessageBox.Show("Username Is Required", "Empty", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                UserNameTB.Focus();
                return;
            }
            if (PassTB.Text == "")
            {
                PassTB.BackColor = Color.DodgerBlue;
                MessageBox.Show("Password Is Required", "Empty", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                PassTB.Focus();
                return;
            }



            if (comboBox1.SelectedIndex == 0)
            {
                if (AccountTypecomboBox.SelectedIndex == 0)
                {
                    //if (UserNameTB.Text == "Admin" && PassTB.Text == "Admin123")
                    //{
                    if (UserNameTB.Text.ToUpper() == "ADMIN" && PassTB.Text == "Admin123")
                    {
                        this.Hide();
                        AdminPortal Ap = new AdminPortal();
                        Ap.Show();
                    }
                    else
                    {
                        LoginMethod("Sp_AdminLogin");

                        //MessageBox.Show("Wrong User Name or Password, Try again", "Invalid User", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //UserNameTB.Focus();
                    }
                }


                else if (AccountTypecomboBox.SelectedIndex == 1)
                {
                    //Accountant

                    //if (UserNameTB.Text == "Account" && PassTB.Text == "Account123")
                    //{


                    LoginMethod("Sp_AccountantLogin");
                    //this.Hide();
                    //AccountantPortal Ap = new AccountantPortal();
                    //Ap.Show();
                    //}
                    //else
                    //{
                    //    MessageBox.Show("Invalid UserName Or PassWord");
                    //    UserNameTB.Focus();
                    //}
                }
                else if (AccountTypecomboBox.SelectedIndex == 2)
                {
                    // Receptionist

                    //if (UserNameTB.Text == "Rec" && PassTB.Text == "Rec123")
                    //{
                    LoginMethod("Sp_ReceptionistLogin");
                    //this.Hide();
                    //ReceptionestPortal Ap = new ReceptionestPortal();
                    //Ap.Show();
                    //}
                    //else
                    //{
                    //    MessageBox.Show("Invalid UserName Or PassWord");
                    //    UserNameTB.Focus();
                    //}
                }
                else if (AccountTypecomboBox.SelectedIndex == 3)
                {
                    //  General Employee

                    //if (UserNameTB.Text == "Emp" && PassTB.Text == "Emp123")
                    //{

                    LoginMethod("Sp_EmpLogin");
                    //this.Hide();
                    //GeneralEmployeePortal Ap = new GeneralEmployeePortal(UserNameTB.Text);
                    //Ap.Show();
                    //}
                    //else
                    //{
                    //    MessageBox.Show("Invalid UserName Or PassWord");
                    //    UserNameTB.Focus();
                    //}
                }

                else
                {
                    MessageBox.Show("Please Select Account Type", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    AccountTypecomboBox.Focus();
                }
            }

            else if (comboBox1.SelectedIndex == 1)
            {
                try
                {
                    LoginMethod("Sp_AccountantLogin");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }