Ejemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (Form_Dashboard fd = new Form_Dashboard())
     {
         fd.ShowDialog();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Logs-in users.
        /// </summary>
        /// <param name="sender">Contains a reference to the control that raised the event.</param>
        /// <param name="e">Contains the event data.</param>
        private void button_Login_Click(object sender, EventArgs e)
        {
            string Username = textBox_Username.Text;
            string password = textBox_Password.Text;

            us         = business.GetUser(Username);
            usersCount = business.GetAllUsers().Count();
            booksCount = business.GetAllBooks().Count();

            try
            {
                if (us.Password == EncryptString(password))
                {
                    MessageBox.Show("Welcome " + Username, "Welcome");
                    Form_Dashboard fd = new Form_Dashboard();
                    fd.Show();
                    fd.FormClosing += (obj, args) => { this.Show(); };
                    this.Hide();
                    textBox_Username.Clear();
                    textBox_Password.Clear();
                }
                else
                {
                    MessageBox.Show("Username or Password is wrong. Try again.");
                    return;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Username or Password is wrong. Try again.");
            }
        }
Ejemplo n.º 3
0
        void OnFinish()
        {
            this.Hide();
            Form_Dashboard fd = new Form_Dashboard();

            fd.ShowDialog();
        }
Ejemplo n.º 4
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string username = txtUserName.Text;
            string password = txtPassword.Text;

            try
            {
                if (Auth.Instance.Login(username, password))
                {
                    txtUserName.Text = "";
                    txtPassword.Text = "";

                    Alert.Create("Logged in successfully.", Alert.Type.Success);

                    using (Form_Dashboard fd = new Form_Dashboard())
                    {
                        fd.ShowDialog();
                    }
                }
                else
                {
                    Alert.Create("Username or Password is wrong.", Alert.Type.Error);
                }
            }
            catch (Exception)
            {
                Alert.Create("Couldn't connect to database.", Alert.Type.Error);
            }
        }
Ejemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            dbConnect dbCon = new dbConnect();

            string log  = textBox2.Text;
            string pass = textBox1.Text;

            if (count <= 3)
            {
                if (dbCon.ReadData($"SELECT * FROM users WHERE login='******' AND password ='******'") == 1)
                {
                    using (Forms.Form_Dashboard fd = new Form_Dashboard())
                    {
                        fd.ShowDialog();
                    }
                }
                else
                {
                    count2--;
                    label4.Text = $"Incorrect username or password. {count2} - attempts left";
                    count++;
                }
            }
            else
            {
                label4.Text = "No attempts!";
            }
        }
Ejemplo n.º 6
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (isFormVal())
     {
         if (checkLogin())
         {
             using (Form_Dashboard fd = new Form_Dashboard())
             {
                 fd.ShowDialog();
             }
         }
     }
 }
Ejemplo n.º 7
0
        private void btnLogin_Click_1(object sender, EventArgs e)
        {
            ID_Manager = DAO.LoginDAO.Instance.getID(txtAccount.text, MaHoaMD5(txtPassword.text));

            if (ID_Manager != "")                  // Đăng nhập thành công
            {
                if (radioBtnAdmin.Checked == true) // kiểm tra xem có phải đăng nhập với tư cách admin
                {
                    name_Permission = DAO.LoginDAO.Instance.getName_Permission(DAO.LoginDAO.Instance.getID_Permission(ID_Manager));
                    foreach (var name in name_Permission)
                    {
                        if (name == "admin")
                        {
                            Form_Dashboard gui_admin = new Form_Dashboard();
                            this.Hide();
                            gui_admin.ShowDialog();
                            this.Show();
                        }
                        else if (name == "employee")
                        {
                            MessageBox.Show("Bạn không đủ quyền truy cập");
                        }
                    }
                }
                else      // Ngược lại, kiểm tra đăng nhập với tư cách nhân viên
                {
                    name_Permission = DAO.LoginDAO.Instance.getName_Permission(DAO.LoginDAO.Instance.getID_Permission(ID_Manager));
                    foreach (var name in name_Permission)
                    {
                        if (name == "admin" || name == "employee")
                        {
                            GUI gui = new GUI();
                            this.Hide();
                            gui.Show();
                        }
                        else
                        {
                            MessageBox.Show("Bạn không đủ quyền truy cập");
                        }
                    }
                }
            }
            else      // Đăng nhập thất bại
            {
                txtAccount.text  = "";
                txtPassword.text = "";
                txtAccount.Focus();
                MessageBox.Show("Tên đăng nhập không chính xác");
            }
        }
Ejemplo n.º 8
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            Form_Dashboard db = new Form_Dashboard();

            db.ShowDialog();
        }