Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            TaiKhoan tk = new TaiKhoan(txttaikhoan.Text, Hash_PassWord.GetMD5(txtmatkhau.Text), true, cbloaitk.Text);

            if (!tk.KiemTraTrung())
            {
                if (tk.KiemTraTK())
                {
                    HeThongBanHang.DSTaiKhoan.Add(tk);
                    if (tk.Vaitro == "Khách Hàng")
                    {
                        HeThongBanHang.DSKhachHang.Add(new KhachHang(tk.Tentaikhoan, new List <HangHoa>()));
                    }
                    MessageBox.Show("Cấp Tài Khoản Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Cấp Tài Khoản Không Thành Công", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Tài Khoản Đã Tồn Tại", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            txttaikhoan.Clear();
            txtmatkhau.Clear();
            txttaikhoan.Focus();
        }
Exemplo n.º 2
0
        //click vào đăng nhập
        private void button1_Click(object sender, EventArgs e)
        {
            bool   KiemTra    = false;
            string tentakhoan = txttaikhoan.Text;
            string matkhau    = txtmatkhau.Text;

            foreach (TaiKhoan tk in HeThongBanHang.DSTaiKhoan)
            {
                //Fix
                if (tk.Tentaikhoan == tentakhoan && tk.Matkhau == Hash_PassWord.GetMD5(matkhau))
                {
                    if (tk.Trangthai == true)
                    {
                        taikhoanhientai = tk;
                        if (tk.Vaitro == "Admin")
                        {
                            Admin frmadmin = new Admin();
                            this.Hide();
                            frmadmin.ShowDialog();
                            this.Show();
                            return;
                        }
                        else if (tk.Vaitro == "Quản Lí")
                        {
                            QuanLi frmquanli = new QuanLi();
                            this.Hide();
                            frmquanli.ShowDialog();
                            this.Show();
                            return;
                        }
                        else if (tk.Vaitro == "Khách Hàng")
                        {
                            Customer frmcustomer = new Customer();
                            this.Hide();
                            frmcustomer.ShowDialog();
                            this.Show();
                            return;
                        }
                        KiemTra = true;
                    }
                }
            }
            if (KiemTra == false)
            {
                MessageBox.Show("Đăng Nhập Thất Bại.Vui Lòng Đăng Nhập Lại", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txttaikhoan.Focus();
            }
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool Kiemtra = false;

            foreach (TaiKhoan tk in HeThongBanHang.DSTaiKhoan)
            {
                if (tk.Tentaikhoan == txttaikhoan.Text)
                {
                    tk.Matkhau = Hash_PassWord.GetMD5("1234");
                    MessageBox.Show("Reset Mật Khẩu Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Kiemtra = true;
                    break;
                }
            }
            if (Kiemtra == false)
            {
                MessageBox.Show("Không Tìm Thấy Tài Khoản", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            txttaikhoan.Clear();
            txttaikhoan.Focus();
        }