/* This is the partial view mentioned above. Given a customer ID, the database will return a form propogated * with the current information. Any change made to this form on submit will change the data in the database * */ public PartialViewResult customerUpdateForm(FormCollection frm) { UpdateCustomerModel cu = new UpdateCustomerModel(); DataSet CustomerInfo = new DataSet(); int customerID = Convert.ToInt32(Request.Form["lstCustomerID"]); CustomerInfo = ac.findCustomerInfo(customerID); foreach (DataTable item in CustomerInfo.Tables) { foreach (DataRow row in item.Rows) { cu.lstCustomer.Add(new findCustomerInfo() { first = Convert.ToString(row["Fname"]), last = Convert.ToString(row["Lname"]), phone = Convert.ToString(row["Phone"]), email = Convert.ToString(row["Email"]), address = Convert.ToString(row["Address"]), id = Convert.ToInt32(row["ID"]) }); } } return PartialView("_updateCustomer", cu); }
/*This is the initial page to update a customer. The text box accepts the customer ID to update and uses * AJAX to post back and create a partial view. * */ public ActionResult CustomerUpdateView() { UpdateCustomerModel uc = new UpdateCustomerModel(); DataSet CustomerIDs = new DataSet(); CustomerIDs = ac.getCustomerInfo(); foreach (DataTable customer in CustomerIDs.Tables) { foreach (DataRow row in customer.Rows) { uc.CustomerID.Add(Convert.ToInt32(row["ID"])); } } return View(uc); }