Beispiel #1
0
        protected void uxSubmit_Click(object sender, EventArgs e)
        {
            if (IsUpdate)
            {
                if (Session["StudentID"] != null)
                {
                    var id   = Convert.ToInt32(Session["StudentID"]);
                    var cust = CustomersManager.Find(id);
                    cust.FirstName = uxFirstName.Text;
                    cust.LastName  = uxLastName.Text;
                    cust.City      = uxCity.Text;
                    cust.Phone     = uxPhone.Text;

                    CustomersManager.Update(cust);
                    FormsAuthentication.SignOut();
                    Session.Clear();
                    Response.Redirect("/Login");
                }
            }
            else
            {
                var cust = new Customer
                {
                    FirstName = uxFirstName.Text,
                    LastName  = uxLastName.Text,
                    City      = uxCity.Text,
                    Phone     = uxPhone.Text
                };
                CustomersManager.Add(cust);
                Response.Redirect("/Login");
            }
        }
        // get customer from custID, then set parameter of available list data source.
        protected void uxLeaseSource_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        {
            int custID;

            if (Request.Cookies["CustomerID"] != null)
            {
                custID = Convert.ToInt32(Request.Cookies["CustomerID"].Value);
            }
            else if (Session["customerID"] != null)
            {
                // Get customer ID from session.
                custID = (int)Session["customerID"];
            }
            else // display message if cookies are disabled and session custID doesn't exist.
            {
                uxMessage.Text = "Please sign in again to display leased slips.";
                return;
            }

            // find customer from ID.
            Customer cust = CustomersManager.Find(custID);

            if (cust != null) // if customer exists, set input parameter as ID
            {
                e.InputParameters["custID"] = cust.ID;
            }
            else // if customer somehow doesn't exist (how did they get past authentication?)
            {
                uxMessage.Text = "No leased slips present for this account. Lease your slip above.";
            }
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsUpdate)
            {
                if (Session["CustomerID"] != null)
                {
                    var id = Convert.ToInt32(Session["CustomerID"]);

                    var cust = CustomersManager.Find(id);

                    if (cust != null)
                    {
                        uxFirstName.Text = cust.FirstName;
                        uxLastName.Text  = cust.LastName;
                        uxCity.Text      = cust.City;
                        uxPhone.Text     = cust.Phone;
                    }
                }
            }
        }