/// <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();
     }
 }
Exemplo n.º 2
0
        public void bloquear(String unUsuario)
        {
            SqlCommand comandoBloquear = new SqlCommand("UPDATE LOS_BORBOTONES.Usuario SET Habilitado = 0 WHERE User_name = @usuario", conexion);

            comandoBloquear.Parameters.AddWithValue("@usuario", unUsuario);
            int cant;

            cant = comandoBloquear.ExecuteNonQuery();
            if (cant == 1)
            {
                MessageBox.Show("Estas bloqueado, intente con otro usuario...");
                acumulador = 0;
            }
            UsuarioTB.Clear();
            PassTB.Clear();
        }
Exemplo n.º 3
0
 private void LoginBT_Click(object sender, EventArgs e)
 {
     user = UserNametb.Text.ToUpper();
     pass = PassTB.Text;
     if (new NhanVienBUS().LoginChecking(user, pass))
     {
         Workstation form = new Workstation(user, this);
         form.Show();
         UserNametb.Clear();
         PassTB.Clear();
         this.Hide();
     }
     else
     {
         UserNametb.Clear();
         PassTB.Clear();
     }
 }
Exemplo n.º 4
0
//        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);
                }
            }
        }
Exemplo n.º 5
0
        private void LoginMethod(String Proc)
        {
            try
            {
                String        ConnString = ConfigurationManager.ConnectionStrings["PayrollConn"].ConnectionString;
                SqlConnection conn       = new SqlConnection(ConnString);
                SqlDataReader reader;

                using (conn)
                {
                    SqlCommand cmd1 = new SqlCommand(Proc, conn);
                    cmd1.CommandType = CommandType.StoredProcedure;
                    cmd1.Parameters.AddWithValue("@UserId", UserNameTB.Text);
                    cmd1.Parameters.AddWithValue("@Pass", PassTB.Text);
                    conn.Open();
                    reader = cmd1.ExecuteReader();
                    reader.Read();
                    if (reader.HasRows)
                    {
                        if (comboBox1.SelectedIndex == 0)
                        {
                            if (AccountTypecomboBox.SelectedIndex == 0)
                            {
                                this.Hide();
                                AdminPortal Ap = new AdminPortal();
                                Ap.Show();
                            }
                            else if (AccountTypecomboBox.SelectedIndex == 1)
                            {
                                this.Hide();
                                AccountantPortal Ap = new AccountantPortal();
                                Ap.Show();
                            }
                            else if (AccountTypecomboBox.SelectedIndex == 2)
                            {
                                this.Hide();
                                ReceptionestPortal Ap = new ReceptionestPortal();
                                Ap.Show();
                            }
                            else if (AccountTypecomboBox.SelectedIndex == 3)
                            {
                                this.Hide();
                                GeneralEmployeePortal Ap = new GeneralEmployeePortal(UserNameTB.Text);
                                Ap.Show();
                            }
                        }
                        else
                        {
                            System.Diagnostics.Process.Start(Application.StartupPath + @"\inventorysystem\inventorysystem\bin\Debug\inventorysystem.exe");

                            UserNameTB.Clear();
                            PassTB.Clear();
                            UserNameTB.Focus();
                            comboBox1.SelectedIndex = 0;
                        }
                    }
                    else
                    {
                        MessageBox.Show(" Wrong User Name or Password, Try again", "Invalid User", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        UserNameTB.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                UserNameTB.Focus();
            }
        }