public ActionResult SignUp(LoginRegTable l) { ViewBag.passerror = ""; if ((l.usrFirstName != null) && (l.usrEmail != null) && (l.usrLastName != null) && (l.usrPasswd != null) && (l.usrCity != null)) { if (l.usrPasswd.Equals(l.usrConfPasswd)) { DataSet ds = GetData(); try { DataRow dr = ds.Tables["LoginRegTable"].NewRow(); dr["usrFirstName"] = l.usrFirstName; dr["usrLastName"] = l.usrLastName; dr["usrEmail"] = l.usrEmail; dr["usrPasswd"] = l.usrPasswd; dr["usrDOB"] = l.usrDOB; dr["usrCity"] = l.usrCity; ds.Tables["LoginRegTable"].Rows.Add(dr); SqlCommandBuilder cmb = new SqlCommandBuilder(da); int a = da.Update(ds.Tables["LoginRegTable"]); if (a > 0) { return(View("LogIn")); } else { ViewBag.logError = "Something is not right" + l.usrPasswd + " " + l.usrConfPasswd; ViewBag.dis = "display"; return(View("LogIn")); } } catch (FormatException f) { ViewBag.logError = "Something is not right" + l.usrPasswd + " " + l.usrConfPasswd; ViewBag.dis = "display"; return(View("LogIn")); } } else { ViewBag.logError = "Password do not match" + l.usrPasswd + " " + l.usrConfPasswd; ViewBag.dis = "display"; return(View("LogIn")); } } else { ViewBag.logError = "All fields must be filled"; ViewBag.dis = "display"; return(View("LogIn")); } }
public ActionResult LogIn(LoginRegTable l) { DataSet ds = GetData(); foreach (DataRow dr in ds.Tables["LoginRegTable"].Rows) { if (Convert.ToString(dr["usrEmail"]) == l.usrEmail) { if (Convert.ToString(dr["usrPasswd"]) == l.usrPasswd) { ViewBag.User = dr["usrFirstName"]; Session["usrid"] = Convert.ToInt32(dr["usrid"]); return(View("Category")); } else { ViewBag.logError = "Incorrect Password"; return(View()); } } } ViewBag.logError = "Email is not registered."; return(View()); }