protected void Page_Load(object sender, EventArgs e) { // Check user authorised! string UserEmail = ""; // Read System Cookie for User Email / ID HttpCookie myTestCookie = new HttpCookie("UKFilmLocationAdmin"); myTestCookie = Request.Cookies["UKFilmLocationAdmin"]; // Read the cookie information and display it. if (myTestCookie != null) { // User details collected UserEmail = myTestCookie.Value; } else { // No user cookie redirect to login Response.Redirect("/"); } // Continue normal programming // Is Existing User? if (!IsPostBack) { UserID.Value = Request.QueryString["UID"]; if (!string.IsNullOrEmpty(UserID.Value)) { UK_Film_Location_Class.UserDetails objUser = new UK_Film_Location_Class.UserDetails(); objUser.getUserFromID(UserID.Value); FirstName.Text = objUser.FirstName; LastName.Text = objUser.LastName; Email.Text = objUser.Email; Password.Text = objUser.Password; if (objUser.isAgent) isAgent.Checked = true; Tel.Text = objUser.Tel; Mobile.Text = objUser.Mobile; Address.Text = objUser.Address; Street.Text = objUser.Street; Town.Text = objUser.Town; County.Text = objUser.County; Postcode.Text = objUser.Postcode; Country.Text = objUser.Country; } } }
protected void SaveBtn_Click(object sender, EventArgs e) { // Check Fields bool isOK = true; if (string.IsNullOrEmpty(FirstName.Text)) isOK = false; if (string.IsNullOrEmpty(LastName.Text)) isOK = false; if (string.IsNullOrEmpty(Email.Text)) isOK = false; if (string.IsNullOrEmpty(Password.Text)) isOK = false; if (!isOK) ErrorLabel.Text = "<div class=\"alert alert-danger\" role=\"alert\"><strong>Save Failed!</strong> Please check the details and try again.</div>"; else { UK_Film_Location_Class.UserDetails objUser = new UK_Film_Location_Class.UserDetails(); if (!string.IsNullOrEmpty(UserID.Value)) { objUser.getUserFromID(UserID.Value); } objUser.FirstName = FirstName.Text; objUser.LastName = LastName.Text; objUser.Email = Email.Text; objUser.Password = Password.Text; if (isAgent.Checked) objUser.isAgent = true; else objUser.isAgent = false; objUser.Address = Address.Text; objUser.Street = Street.Text; objUser.Town = Town.Text; objUser.County = County.Text; objUser.Postcode = Postcode.Text; objUser.Country = Country.Text; objUser.Save(); Response.Redirect("/users.aspx"); } }