private void btnDoiMK_Click(object sender, EventArgs e)
        {
            TaiKhoan tk = TaiKhoanDAL.layTaiKhoan(this.Text);

            if (tk.MatKhau.Trim() != XuLyDAL.maHoaMK(txbMKhienTai.Text))
            {
                MessageBox.Show("Mật khẩu hiện tại không đúng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (!XuLyDAL.ktMatKhauHopLe(txbMKmoi1.Text))
            {
                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;
            }

            if (txbMKmoi1.Text != txbMKmoi2.Text)
            {
                MessageBox.Show("Mật khẩu mới nhập lại không khớp", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            XuLyDAL.doiMatKhau(this.Text, txbMKmoi1.Text);

            MessageBox.Show("Đổi mật khẩu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

            this.Close();
        }
Beispiel #2
0
 public static bool suaThongTin(string tentk, string mk)
 {
     if (!XuLyDAL.ktMatKhauHopLe(mk))
     {
         return(false);
     }
     return(true);
 }
Beispiel #3
0
 public static string doiMK(string tentk, string mkCu, string mkMoi, string mkNhapLai)
 {
     if (!XuLyDAL.ktKhopMK(tentk, mkCu))
     {
         return("kkmk");
     }
     else if (!XuLyDAL.ktMatKhauHopLe(mkMoi))
     {
         return("mkKhongHopLe");
     }
     else if (mkMoi != mkNhapLai)
     {
         return("KhacMKnhapLai");
     }
     return("ok");
 }
        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();
        }