private void btnDoiMK_Click(object sender, EventArgs e)
        {
            if (txbMKhienTai.Text == "" || txbMKmoi.Text == "" || txbMKnhapLai.Text == "")
            {
                MessageBox.Show("Lỗi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string str = XuLuTK_BUS.doiMK(this.Text, txbMKhienTai.Text, txbMKmoi.Text, txbMKnhapLai.Text);

            if (str == "kkmk")
            {
                MessageBox.Show("Mật khẩu hiện tại không đúng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (str == "mkKhongHopLe")
            {
                MessageBox.Show("Mật khẩu mới không hợp lệ !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (str == "KhacMKnhapLai")
            {
                MessageBox.Show("Mật khẩu nhập lại không khớp !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                XuLyDAL.doiMatKhau(this.Text, txbMKmoi.Text);
                txbMKhienTai.Text = "";
                txbMKmoi.Text     = "";
                txbMKnhapLai.Text = "";
                MessageBox.Show("Đổi mật khẩu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #2
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            if (txbMatKhau.Text == "" || txbTenTK.Text == "")
            {
                MessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng", "Thống báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            string tentk = txbTenTK.Text;


            string matKhau = XuLyDAL.maHoaMK(txbMatKhau.Text);

            if (XuLuTK_BUS.dangNhap(tentk, matKhau))
            {
                this.Dispose(false);
                if (tentk == "admin")
                {
                    frmAdmin n = new frmAdmin();
                    n.Text = tentk;
                    n.Show();
                }
                else
                {
                    frmKhachHang n = new frmKhachHang();
                    n.Text = tentk;
                    n.Show();
                }
            }
            else
            {
                txbTenTK.Text   = "";
                txbMatKhau.Text = "";
                MessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void btnThucHien_Click(object sender, EventArgs e)
        {
            if (yeuCau == "XOA")
            {
                if (txbTenTK.Text == "admin")
                {
                    MessageBox.Show("Bạn không thể xóa tài khoản quản lý!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                else
                {
                    if (XuLuTK_BUS.xoaTK(txbTenTK.Text) == false)
                    {
                        MessageBox.Show("Tài khoản không tồn tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    else if (XuLuTK_BUS.xoaTK(txbTenTK.Text))
                    {
                        if (DialogResult.Yes == MessageBox.Show("Bạn có muốn xóa tài khoản này ?", "Chú ý", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                        {
                            XuLyDAL.xoaTK(txbTenTK.Text);

                            //trangThaiBanDau();
                            MessageBox.Show("Đã xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            trangThaiTextBoxBanDau();
                            trangThaiBanDau();
                        }
                    }
                }
            }
            else if (yeuCau == "THEM_TK")
            {
                if (txbTenTK.Text == "")
                {
                    MessageBox.Show("Tên tài khoản không được bỏ trống !", "Chú ý !", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //btnThemTK_Click(sender, e);
                    return;
                }

                else if (txbMatKhau.Text == "")
                {
                    MessageBox.Show("Mật khẩu không được bỏ trống !", "Chú ý!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                if (!XuLuTK_BUS.themTK(txbTenTK.Text))
                {
                    MessageBox.Show("Tên tài khoản đã tồn tại !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    if (XuLyDAL.ktMatKhauHopLe(txbMatKhau.Text))
                    {
                        float tienThem = 0;

                        if (txbSoTienThem.Text.Replace(" ", string.Empty) != "")
                        {
                            tienThem = float.Parse(txbSoTienThem.Text.Replace(" ", string.Empty));
                        }

                        if (txbSDT.Text.Trim() != "")
                        {
                            if (txbSDT.Text.Replace(" ", string.Empty).Length != 10)
                            {
                                MessageBox.Show("Số điện thoại không hợp lệ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                        }

                        //if(txbSDT.Text)

                        if (txbEmail.Text != "")
                        {
                            if (!TaiKhoanDAL.ktEmailHopLe(txbEmail.Text))
                            {
                                MessageBox.Show("Email không hợp lệ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }


                        XuLyDAL.themTK(txbTenTK.Text, /*XuLyDAL.maHoaMK(txbMatKhau.Text)*/ txbMatKhau.Text, tienThem);


                        XuLyDAL.themThongTin(txbTenTK.Text, txbSDT.Text.Replace(" ", string.Empty), txbEmail.Text);



                        MessageBox.Show("Tài khoản đã được thêm !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        trangThaiTextBoxBanDau();
                        trangThaiBanDau();
                    }
                    else
                    {
                        MessageBox.Show("                          Mật khẩu không hợp lệ \n ( Mật khẩu phải có ít nhất 8 kí tự, phải bao gồm cả chữ và số)", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
            }
            else if (yeuCau == "CHINH_SUA")
            {
                if (XuLuTK_BUS.suaThongTin(txbTenTK.Text, txbMatKhau.Text))
                {
                    float tienThem = 0;
                    if (txbSoTienThem.Text.Replace(" ", string.Empty) != "")
                    {
                        tienThem = float.Parse(txbSoTienThem.Text.Replace(" ", string.Empty));
                    }

                    if (txbSDT.Text.Trim() != "")
                    {
                        if (txbSDT.Text.Replace(" ", string.Empty).Length != 10)
                        {
                            MessageBox.Show("Số điện thoại không hợp lệ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }

                    //if(txbSDT.Text)

                    if (txbEmail.Text != "")
                    {
                        if (!TaiKhoanDAL.ktEmailHopLe(txbEmail.Text))
                        {
                            MessageBox.Show("Email không hợp lệ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }

                    XuLyDAL.suaThongTin(txbTenTK.Text, txbMatKhau.Text, txbSDT.Text.Replace(" ", string.Empty), txbEmail.Text, tienThem);

                    MessageBox.Show("Chỉnh sữa hoàn tất !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    trangThaiTextBoxBanDau();
                    trangThaiBanDau();
                }
                else
                {
                    MessageBox.Show("Mật khẩu không hợp lệ !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            else if (yeuCau == "THEM_TIEN")
            {
                float tienThem = 0;
                if (txbSoTienThem.Text.Replace(" ", string.Empty) != "")
                {
                    tienThem = float.Parse(txbSoTienThem.Text.Replace(" ", string.Empty));
                    XuLyDAL.themTien(txbTenTK.Text, tienThem);
                    trangThaiBanDau();
                    trangThaiTextBoxBanDau();
                    MessageBox.Show("Nạp tiền thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            yeuCau = "";

            lsvShow.Clear();
            showData();
        }