Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        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");
            }
        }
Ejemplo n.º 6
0
 public static Customer SaveCustomer(Customer cust)
 {
     return DBCustomer.Update(cust);
 }
Ejemplo n.º 7
0
        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();
            }
        }
Ejemplo n.º 8
0
 public static AccountList GetAccountsByCustomer(Customer Cust)
 {
     return DBAccount.GetAccountsByCustomer(Cust.Id);
 }