Exemplo n.º 1
0
        private void LoginUser()
        {
            using (SqlConnection conn = new SqlConnection(Connectionstring))
            {
                string query = "SELECT * FROM [User] WHERE USERNAME = '******' AND PASSWORD = '******'";
                using (SqlCommand cmd = new SqlCommand(query, conn))
                {
                    conn.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            _loginCount++;
                            _user.UserName    = reader["username"].ToString();
                            _user.Password    = reader["password"].ToString();
                            _user.Name        = reader["name"].ToString();
                            _user.Email       = reader["email"].ToString();
                            _user.Address     = reader["address"].ToString();
                            _user.ContactNo   = reader["contact_no"].ToString();
                            _user.JoinDate    = reader["join_date"].ToString();
                            _user.AccountType = reader["account_type"].ToString();
                        }
                    }
                }
            }

            if (_loginCount == 1 && _user.AccountType == "Admin")
            {
                Hide();
                FormAdminPanel adminPanel = new FormAdminPanel(txtUserName.Text);
                adminPanel.Show();
                Hide();
            }
            else if (_loginCount == 1 && _user.AccountType == "Employee")
            {
                Hide();
                FormEmployeePanel employeePanel = new FormEmployeePanel(txtUserName.Text);
                employeePanel.Show();
            }
            else
            {
                MessageBox.Show(@"Access Denied", @"Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        public static void Verification(string username, string password, FormHome home)
        {
            string trueFalseValue = firstStepOfVerification(username, password);


            if (trueFalseValue == "1")
            {
                //--------------successfull Log In
                MessageBox.Show("Successfull Log In", "Message");

                //-----------------close Home Form and Open Admin Form
                home.Hide();

                FormAdminPanel fap = new FormAdminPanel(ref username);
                fap.ShowDialog();
            }
            else
            {
                //--------------Failed Log In
                MessageBox.Show("Log In Failed", "Message");
            }
        }