Пример #1
0
 private void btnDangKi_Click(object sender, EventArgs e)
 {
     if (Register.checkMK(txtMatKhau.Text, txtXNMK.Text) == false)
     {
         MessageBox.Show("Mật khẩu xác nhận không đúng", "Thông báo", MessageBoxButtons.OKCancel);
     }
     else if (Register.checkTK(txtTaikhoan.Text) != true)
     {
         TAIKHOAN tk = new TAIKHOAN();
         tk.HoTen     = txtHoten.Text;
         tk.Email     = txtEmail.Text;
         tk.Matkhau   = txtMatKhau.Text;
         tk.TaiKhoan1 = txtTaikhoan.Text;
         tk.Phone     = txtPhone.Text;
         if (txtMatKhau.TextLength < 8 || txtMatKhau.TextLength > 16)
         {
             MessageBox.Show("Mật khẩu quá ngắn, mật khẩu tối thiểu là 8 kí tự và tối đa là 15 kí tự. \n\n Xin vui lòng nhập lại mật khẩu.", "", MessageBoxButtons.OKCancel);
             txtMatKhau.Focus();
         }
         else
         if (Register.addNew(db, tk))
         {
             MessageBox.Show("Đăng ký thành công.", "Thông báo", MessageBoxButtons.OKCancel);
             db.SaveChanges();
         }
         else
         {
             MessageBox.Show("Đăng ký không thành công. \n\nXin vui lòng đăng ký lai.", "Thông báo", MessageBoxButtons.OKCancel);
         }
     }
     else
     {
         MessageBox.Show("Tài khoản này hiện đã tồn tại. \n\nXin vui lòng nhập tài khoản khác.", "Thông báo", MessageBoxButtons.OKCancel);
     }
 }
Пример #2
0
        public static bool checkTK(string a)
        {
            QuanLyHomestayEntities db = new QuanLyHomestayEntities();
            TAIKHOAN s = (from i in db.TAIKHOANs where i.TaiKhoan1.Equals(a) select i).FirstOrDefault();

            if (s != null)
            {
                return(true);
            }
            return(false);
        }
Пример #3
0
 public static bool testLogin(string tk, string mk)
 {
     db = new QuanLyHomestayEntities();
     try
     {
         TAIKHOAN s = (from i in db.TAIKHOANs where i.TaiKhoan1 == tk && i.Matkhau == mk select i).FirstOrDefault();
         if (s != null)
         {
             return(true);
         }
     }
     catch
     {
     }
     return(false);
 }
Пример #4
0
 public static bool addNew(QuanLyHomestayEntities db, TAIKHOAN a)
 {
     if (checkTK(a.TaiKhoan1))
     {
         return(false);
     }
     else if (a.Matkhau == null || a.Matkhau == "")
     {
         return(false);
     }
     else if (a.Matkhau.Length < 8 || a.Matkhau.Length > 16)
     {
         return(false);
     }
     else if (a.HoTen == null || a.HoTen == "")
     {
         return(false);
     }
     else if (a.Phone == null || a.Phone == "")
     {
         return(false);
     }
     else if (a.TaiKhoan1 == null || a.TaiKhoan1 == "")
     {
         return(false);
     }
     else if (a != null)
     {
         db.TAIKHOANs.Add(a);
         db.SaveChanges();
         return(true);
     }
     else
     {
         return(false);
     }
 }