public bool ThemMember(THONGTINMEMBER member) { //Kiem tra tai khoan nay da ton tai chua var taiKhoan = TAIKHOANs.SingleOrDefault(g => g.UserName == member.UserName); if (taiKhoan != null) { return(false); } else { try { using (TransactionScope ts = new TransactionScope()) { #region ThemTaiKhoanMoi TAIKHOAN newTaiKhoan = new TAIKHOAN(); newTaiKhoan.MaTK = member.MaTK; newTaiKhoan.Avatar = null; newTaiKhoan.DiaChi = member.DiaChi; newTaiKhoan.Email = member.Email; newTaiKhoan.MaTT = member.MaTT; newTaiKhoan.Password = member.Password; newTaiKhoan.SDT = member.SDT; newTaiKhoan.UserName = member.UserName; TAIKHOANs.Add(newTaiKhoan); this.SaveChanges(); #endregion #region ThemMember THONGTINMEMBERs.Add(member); this.SaveChanges(); #endregion ts.Complete(); } return(true); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } //throw; } return(false); } }
public bool KiemTraThongTinDangNhap(string userName, string password) { TAIKHOAN tk = TAIKHOANs.SingleOrDefault(p => p.Password == password && p.UserName == userName); if (tk == null) { return(false); } else { return(true); } }
public bool ThemMember(THONGTINMEMBER member) { //Kiem tra tai khoan nay da ton tai chua var taiKhoan = TAIKHOANs.SingleOrDefault(g => g.UserName == member.UserName); if (taiKhoan != null) return false; else { try { using (TransactionScope ts = new TransactionScope()) { #region ThemTaiKhoanMoi TAIKHOAN newTaiKhoan = new TAIKHOAN(); newTaiKhoan.MaTK = member.MaTK; newTaiKhoan.Avatar = null; newTaiKhoan.DiaChi = member.DiaChi; newTaiKhoan.Email = member.Email; newTaiKhoan.MaTT = member.MaTT; newTaiKhoan.Password = member.Password; newTaiKhoan.SDT = member.SDT; newTaiKhoan.UserName = member.UserName; TAIKHOANs.Add(newTaiKhoan); this.SaveChanges(); #endregion #region ThemMember THONGTINMEMBERs.Add(member); this.SaveChanges(); #endregion ts.Complete(); } return true; } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } //throw; } return false; } }
public ActionResult NewBusiness(accountBusiness business) { TAIKHOAN t = new TAIKHOAN(business.maTK, business.userName, business.passWord, business.email, business.avatar, "TT01", business.diachi, business.sdt); THONGTINDOANHNGHIEP dn = new THONGTINDOANHNGHIEP(business.maTK, business.website, business.tenDN); db.TAIKHOANs.Add(t); db.SaveChanges(); db.THONGTINDOANHNGHIEPs.Add(dn); db.SaveChanges(); return View(); }
public TAIKHOAN LayTaiKhoanTheoMaTK(string MaTK) { TAIKHOAN tk = TAIKHOANs.SingleOrDefault(p => p.MaTK == MaTK); return(tk); }
public string LayUserNameTheoMaTK(string MaTK) { TAIKHOAN taiKhoan = TAIKHOANs.SingleOrDefault(p => p.MaTK == MaTK); return(taiKhoan.UserName); }