protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["username"] != null && Request.Cookies["password"] != null) { string username = Request.Cookies["username"].Value; string password = Request.Cookies["password"].Value; if (Validation.isValidPhoneNumber(username) && Validation.isValidPassword(password)) { UsersDatabaseAccessor db = new UsersDatabaseAccessor(username, password); if (db.isLoggedIn()) { createTable(db); } else { Response.Cookies["username"].Expires = DateTime.Now; Response.Cookies["password"].Expires = DateTime.Now; Response.Redirect("login.aspx"); } } else { Response.Cookies["username"].Expires = DateTime.Now; Response.Cookies["password"].Expires = DateTime.Now; Response.Redirect("login.aspx"); } } else { Response.Redirect("login.aspx"); } }
public void addEntry(Object sender, EventArgs e) { if (Request.Cookies["username"] != null && Request.Cookies["password"] != null) { string username = Request.Cookies["username"].Value; string password = Request.Cookies["password"].Value; if (Validation.isValidPhoneNumber(username) && Validation.isValidPassword(password)) { UsersDatabaseAccessor db = new UsersDatabaseAccessor(username, password); if (db.isLoggedIn()) { if (db.CanAdd()) { string entryUsername = addEntryPhone.Value; string entryPassword = addEntryPass.Value; if (Validation.isValidPhoneNumber(entryUsername) && Validation.isValidPassword(entryPassword)) { db.addUser(entryUsername, entryPassword); Response.Redirect(Request.RawUrl); } } } } } }
private void deleteEntry(object sender, EventArgs e) { if (Request.Cookies["username"] != null && Request.Cookies["password"] != null) { string username = Request.Cookies["username"].Value; string password = Request.Cookies["password"].Value; if (Validation.isValidPhoneNumber(username) && Validation.isValidPassword(password)) { UsersDatabaseAccessor db = new UsersDatabaseAccessor(username, password); if (db.isLoggedIn()) { if (db.CanDelete()) { db.deleteUser(((Button)sender).ID.Split('_')[1]); Response.Redirect(Request.RawUrl); } } } } }
private void permitModify(Object sender, EventArgs e) { if (Request.Cookies["username"] != null && Request.Cookies["password"] != null) { string username = Request.Cookies["username"].Value; string password = Request.Cookies["password"].Value; if (Validation.isValidPhoneNumber(username) && Validation.isValidPassword(password)) { UsersDatabaseAccessor db = new UsersDatabaseAccessor(username, password); if (db.isLoggedIn()) { if (db.CanModify()) { db.switchModify(((CheckBox)sender).ID.Split('_')[1]); Response.Redirect(Request.RawUrl); } } } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["username"] != null && Request.Cookies["password"] != null) { string username = Request.Cookies["username"].Value; string password = Request.Cookies["password"].Value; if (Validation.isValidPhoneNumber(username) && Validation.isValidPassword(password)) { UsersDatabaseAccessor db = new UsersDatabaseAccessor(username, password); if (db.isLoggedIn()) { RidesDatabaseAccessor rdb = new RidesDatabaseAccessor(); if (IsPostBack) { string dest = ""; string depart = ""; string date = ""; string time = ""; if (destInput.Text != "" && Validation.isValidPlacesID(destInput.Text)) { dest = destInput.Text; } if (departInput.Text != "" && Validation.isValidPlacesID(departInput.Text)) { depart = departInput.Text; } if (dateInput.Text != "" && Validation.isValidDateString(dateInput.Text)) { date = dateInput.Text; } if (timeInput.Text != "" && Validation.isValidTimeString(timeInput.Text)) { time = timeInput.Text; } RidesDatabaseAccessor.Filters filters = new RidesDatabaseAccessor.Filters { destinationID = dest, departureID = depart }; if (date != "" || time != "") { DateTime dateObj; if (date != "") { dateObj = DateTime.Parse(date); } else { dateObj = DateTime.Today; } if (time != "") { filters.time = dateObj.Add(DateTime.Parse(time).TimeOfDay); } else { filters.time = dateObj; } } rdb.setFilters(filters); } createTable(rdb); } else { Response.Cookies["username"].Expires = DateTime.Now; Response.Cookies["password"].Expires = DateTime.Now; Response.Redirect("login.aspx"); } } else { Response.Cookies["username"].Expires = DateTime.Now; Response.Cookies["password"].Expires = DateTime.Now; Response.Redirect("login.aspx"); } } else { Response.Redirect("login.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["username"] != null && Request.Cookies["password"] != null) { string username = Request.Cookies["username"].Value; string password = Request.Cookies["password"].Value; if (Validation.isValidPhoneNumber(username) && Validation.isValidPassword(password)) { UsersDatabaseAccessor db = new UsersDatabaseAccessor(username, password); if (db.isLoggedIn()) { if (IsPostBack) { string dest = ""; string depart = ""; string date = ""; string time = ""; string through = ""; string comment = ""; if (destInput.Text != "" && Validation.isValidPlacesID(destInput.Text)) { dest = destInput.Text; } if (departInput.Text != "" && Validation.isValidPlacesID(departInput.Text)) { depart = departInput.Text; } if (dateInput.Text != "" && Validation.isValidDateString(dateInput.Text)) { date = dateInput.Text; } if (timeInput.Text != "" && Validation.isValidTimeString(timeInput.Text)) { time = timeInput.Text; } if (throughInput.Text != "" && Validation.isValidComment(throughInput.Text)) { through = throughInput.Text; } if (commentInput.Text != "" && Validation.isValidComment(commentInput.Text)) { comment = commentInput.Text; } if (dest == "" || depart == "") { return; } DateTime dt = default(DateTime); if (date != "") { dt = DateTime.Parse(date); } else { dt = DateTime.Today; } if (time != "") { dt = dt.Add(DateTime.Parse(time).TimeOfDay); } else { if (date == "") { dt = DateTime.Now; } } RidesDatabaseAccessor rdb = new RidesDatabaseAccessor(); rdb.updateEntry(new RidesDatabaseAccessor.Entry { phone = username, destinationID = dest, departureID = depart, time = dt, through = through, comment = comment }); } } else { Response.Cookies["username"].Expires = DateTime.Now; Response.Cookies["password"].Expires = DateTime.Now; Response.Redirect("login.aspx"); } } else { Response.Cookies["username"].Expires = DateTime.Now; Response.Cookies["password"].Expires = DateTime.Now; Response.Redirect("login.aspx"); } } else { Response.Redirect("login.aspx"); } }