public static Customer Update(Customer Cust) { SqlParamsColl paramList = new SqlParamsColl(); paramList.Add("@CustomerId", SqlDbType.Int, Cust.Id); paramList.Add("@FirstName", SqlDbType.NVarChar, Cust.FirstName); paramList.Add("@LastName", SqlDbType.NVarChar, Cust.LastName); paramList.Add("@TFN", SqlDbType.NVarChar, Cust.TaxFileNumber); paramList.Add("@AddressStreet", SqlDbType.NVarChar, Cust.CustomerAddress.StreetDetail); paramList.Add("@AddressCity", SqlDbType.NVarChar, Cust.CustomerAddress.City); paramList.Add("@AddressState", SqlDbType.NVarChar, Cust.CustomerAddress.State); paramList.Add("@AddressZipCode", SqlDbType.NVarChar, Cust.CustomerAddress.ZipCode); paramList.Add("@PhoneNumber", SqlDbType.NVarChar, Cust.PhoneNumber); Customer updatedCustomer = new Customer(); SqlTools.ExecuteReader("dbo.Customer_Update", paramList, reader => { while (reader.Read()) { PopulateObjectFromReader(reader, updatedCustomer); } }); return updatedCustomer; }
public static Customer GetCustomerById(int Id) { Customer custDetail = new Customer(); SqlParamsColl paramList = new SqlParamsColl(); paramList.Add("@CustomerId", SqlDbType.Int, Id); SqlTools.ExecuteReader("Customer_Load", paramList, reader => { while (reader.Read()) { PopulateObjectFromReader(reader, custDetail); } }); return custDetail; }
public static void PopulateObjectFromReader(SqlDataReader reader, Customer NewCust) { Address customerAddress = new Address(); NewCust.Id = (int)reader["Id"]; NewCust.FirstName = reader["FirstName"].ToString().Trim(); NewCust.LastName = reader["LastName"].ToString().Trim(); NewCust.TaxFileNumber = reader["TFN"].ToString().Trim(); NewCust.PhoneNumber = reader["PhoneNumber"].ToString().Trim(); customerAddress.StreetDetail = reader["AddressStreetDetail"].ToString().Trim(); customerAddress.City = reader["AddressCity"].ToString().Trim(); customerAddress.State = reader["AddressState"].ToString().Trim(); customerAddress.ZipCode = reader["AddressZipCode"].ToString().Trim(); NewCust.CustomerAddress = customerAddress; }
public static CustomerList GetAllCustomers() { SqlParamsColl paramList = new SqlParamsColl(); CustomerList list = new CustomerList(); SqlTools.ExecuteReader("dbo.Admin_LoadCustomers", paramList, reader => { while (reader.Read()) { Customer cust = new Customer(); PopulateObjectFromReader(reader, cust); list.Add(cust); } }); return list; }
protected void Page_Load(object sender, EventArgs e) { if (Session["AdminSession"] == null) { Response.Redirect("/Login"); } if (!IsPostBack) { string customerIdString = (string)Page.RouteData.Values["CustomerId"]; int customerId = 0; try { customerId = Int32.Parse(customerIdString); } catch (FormatException) { } if (customerId != 0) { CustomerDataSource = CustomerManager.GetCustomer(customerId); if (CustomerDataSource.Id == 0) Response.Redirect("/Admin"); AccountsDataSource = AccountManager.GetAccountsByCustomer(CustomerDataSource); BindPage(); } else Response.Redirect("/Admin"); } }
public static Customer SaveCustomer(Customer cust) { return DBCustomer.Update(cust); }
protected void Page_Load(object sender, EventArgs e) { if (Session["LoggedInCustomer"] == null) { Response.Redirect("~/Login"); } if (!IsPostBack) { CustomerDataSource = (Customer)Session["LoggedInCustomer"]; AccountsDataSource = AccountManager.GetAccountsByCustomer(CustomerDataSource); BindData(); } }
public static AccountList GetAccountsByCustomer(Customer Cust) { return DBAccount.GetAccountsByCustomer(Cust.Id); }