protected void UpdateCustomer_Click(object sender, EventArgs e) { cust = CustomerDB.GetCustomer(Session["custuser"].ToString());//old value newcust = new Customer(); setCustomerReg(newcust); //get modified textbox value to newcust object // lblError.Text = newcust.CustFirstName; if (CustomerDB.UpdateCustomer(newcust, cust)) { getCustomerReg(newcust); lblError.Text = cust.CustUser + " has successfully updated your info !"; } else { lblError.Text = "There is another user is updating or deleting your info!"; } }
protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.Session["ID"] != null) { int id = Convert.ToInt32(HttpContext.Current.Session["ID"]); Customer customer = new Customer(); customer = CustomerDB.GetCustomer(id); Label1.Text = customer.ID.ToString(); Label2.Text = customer.FirstName + " " + customer.LastName; Label4.Text = customer.Phone; Label5.Text = customer.City; Label6.Text = customer.FirstName + " " + customer.LastName; int customerID = Convert.ToInt32(HttpContext.Current.Session["ID"]); GridViewCurrentLease.DataSource = LeaseDB.GetLeasesByCustomerID(customerID); GridViewCurrentLease.DataBind(); } }
protected void LoginButton_Click(object sender, EventArgs e) { string username = TextBox7.Text; string hashpwd = CustomerDB.Md5Encrypt32(TextBox8.Text); Customer customer = CustomerDB.GetCustomer(username); if (customer.UserName == username && hashpwd == customer.PassWord) { // If both usemname and password match database, set session["ID"] and redirect to home page // Response.Write("<script>alert('Match!')</script>"); Session["ID"] = customer.ID; Response.Redirect("Account.aspx"); } else { // If neither username nor password match record, pop up error message. string message = "Incorrect username or password. Please try again."; Response.Write("<script>alert('" + message + "')</script>"); } }
public void TestDeleteCustomer() { /*Create the test variables.*/ Customer c = new Customer(); c.Name = "Mickey Mouse"; c.Address = "101 Main Street"; c.City = "Orlando"; c.State = "FL"; c.ZipCode = "10101"; int customerID = CustomerDB.AddCustomer(c); c = CustomerDB.GetCustomer(customerID); /* Test the command.*/ bool isCustomerDeleted = CustomerDB.DeleteCustomer(c); /* If it affected the database in some way, the test was successful. */ Assert.AreEqual(true, isCustomerDeleted); }
public void TestAddCustomer() { /*Create the test variables.*/ Customer c = new Customer(); c.Name = "Mickey Mouse"; c.Address = "101 Main Street"; c.City = "Orlando"; c.State = "FL"; c.ZipCode = "10101"; /* Test the command.*/ int customerID = CustomerDB.AddCustomer(c); c = CustomerDB.GetCustomer(customerID); /* If the test subject has a name within the database, the test was successful. */ Assert.AreEqual("Mickey Mouse", c.Name); /*Clean up the test*/ CustomerDB.DeleteCustomer(c); }
protected void Page_Load(object sender, EventArgs e) { Response.Cache.SetCacheability(HttpCacheability.NoCache); //remove caches Response.Cache.SetExpires(DateTime.Now.AddDays(-1)); //set session Expire Response.Cache.SetNoStore(); if (Session["custid"] == null)//tell whether login or not { Response.Redirect("logIn.aspx"); } if (!IsPostBack) //first time to load page { List <string> Prolist = new List <string>(new string[] { "AB", "BC", "MB", "NB", "NL", "NT", "NS", "NU", "ON", "PE", "QC", "SK", "YT" }); //initialize province name dplProvince.DataSource = Prolist; dplProvince.DataBind(); cust = CustomerDB.GetCustomer(Session["custuser"].ToString()); //get cust object for custuser= getCustomerReg(cust); //set textbox initial values get from database } }
public Customer GetCustomer(int id) { return(cDb.GetCustomer(id)); }
public Customer GetCustomer(string username) { return(_customerDB.GetCustomer(username)); }
public void TestGetCustomer() { Customer c = CustomerDB.GetCustomer(1); Assert.AreEqual(1, c.CustomerID); }