private void b_Register_Click(object sender, EventArgs e) { FormSignup fm = new FormSignup(); fm.Show(); }
public ActionResult Signup(FormSignup signup) { string status; string UserName = signup.dkUserName; string Email = signup.dkEmail; string Name = signup.dkName; string Password1 = signup.dkPass1; string Password2 = signup.dkPass2; UserDAO userDAO = new UserDAO(); if (UserName == "" || Email == "" || Name == "" || Password1 == "" || Password2 == "") { status = "empty"; return(new JsonResult { Data = new { status = status } }); } else if (UserName.Length < 6) { status = "userlength"; return(new JsonResult { Data = new { status = status } }); } else if (userDAO.checkUsered(UserName)) { status = "user"; return(new JsonResult { Data = new { status = status } }); } else if (!Tools.IsValidEmail(Email)) { status = "email"; return(new JsonResult { Data = new { status = status } }); } else if (Password1.Length < 8) { status = "passlength"; return(new JsonResult { Data = new { status = status } }); } else if (!Password1.Equals(Password2)) { status = "pass"; return(new JsonResult { Data = new { status = status } }); } else { DBModel db1 = new DBModel(); account tmpAccount = new account(); tmpAccount.USERNAME = UserName; tmpAccount.HO_TEN = Name; tmpAccount.ID_ACCOUNT = userDAO.generateIDAccount(); tmpAccount.PASSWORD = Tools.MD5(Password1); tmpAccount.LEVEL = "5"; tmpAccount.ACTIVE = "1"; db1.accounts.Add(tmpAccount); db1.SaveChangesAsync(); DBModel db2 = new DBModel(); ct_account tmpCTAccount = new ct_account(); tmpCTAccount.ID_ACCOUNT = tmpAccount.ID_ACCOUNT; tmpCTAccount.EMAIL = Email; tmpCTAccount.SDT = null; tmpCTAccount.DIA_CHI = null; tmpCTAccount.GIOI_TINH = 1; tmpCTAccount.NGAY_SINH = null; db2.ct_account.Add(tmpCTAccount); db2.SaveChangesAsync(); User userVM = userDAO.getUser(userDAO.getID(UserName)); HttpContext.Session.Add("User", userVM); status = "success"; return(new JsonResult { Data = new { status = status } }); } }