Exemplo n.º 1
0
 protected void btnRegister_Click(object sender, EventArgs e)
 {
     CustomerRepo customerrepo = new CustomerRepo();
     lbMessage.Text = "";
     if (customerrepo.DoesUsernameExist(txtUsername.Text))
     {
         lbMessage.Text = "Username already exists!";
         lbMessage.ForeColor = System.Drawing.Color.Red;
         txtUsername.Text = "";
         return;
     }
     if (customerrepo.DoesEmailExist(txtEmail.Text))
     {
         lbMessage.Text = "Email already exists!";
         lbMessage.ForeColor = System.Drawing.Color.Red;
         txtEmail.Text = "";
         return;
     }
     Model.Customer customer = new Model.Customer();
     customer.FirstName = txtFirstName.Text;
     customer.LastName = txtLastName.Text;
     customer.Username = txtUsername.Text;
     customer.Password = Security.Encrypt(ConfigurationManager.AppSettings["KeyCustomer"], txtPassword.Text);
     customer.Key = ConfigurationManager.AppSettings["KeyCustomer"];
     customer.Email = txtEmail.Text;
     customer.Phone = txtPhone.Text;
     customer.DateOfBirth = ToSQL.SQLToDateTimeNull(txtDateOfBirth.Text);
     customer.Gender = rdbtnGender.SelectedIndex == 0 ? true : false;
     customer.DateCreated = DateTime.Now;
     int i = customerrepo.CreateCustomer(customer);
     Session["Customer"] = customer;
     Response.Redirect("CustomerInfo.aspx");
 }
Exemplo n.º 2
0
 protected void Login(object sender, EventArgs e)
 {
     Customer customer = new CustomerRepo().GetCustomerByUsername(txtUsername.Text);
     if (customer != null)
     {
         string Password = Security.Encrypt(customer.Key, txtPassword.Text);
         if (customer.Password.Equals(Password))
         {
             Session["Customer"] = customer;
             WelcomeCustomer();
             Response.Redirect(Request.Url.PathAndQuery);
         }
         else
         {
             lbLogin.Text = "Username/password provided is incorrect!";
             txtUsername.Attributes["value"] = "";
             txtPassword.Attributes["value"] = "";
             ModalPopupLogin.Show();
         }
     }
     else
     {
         lbLogin.Text = "Username/password provided is incorrect!";
         txtUsername.Attributes["value"] = "";
         txtPassword.Attributes["value"] = "";
         ModalPopupLogin.Show();
     }
 }
Exemplo n.º 3
0
        protected void btnRemove_Click(object sender, EventArgs e)
        {
            try
            {
                LinkButton lnk = (LinkButton)sender;
                int Id = ToSQL.SQLToInt(lnk.CommandArgument);
                if (Id > 0)
                {
                    int i = new CustomerRepo().DeleteCustomer(Id);
                    BindItemsList();
                }
            }
            catch
            {

            }
        }
Exemplo n.º 4
0
        private void LoadDropDownList()
        {
            List<OrderStatu> orderStatus = new OrderStatusRepo().GetAllOrderStatu();
            ddlOrderStatus.DataSource = orderStatus;
            ddlOrderStatus.DataBind();
            ddlOrderStatus.Items.Insert(0, new ListItem("(All)", ""));

            List<Customer> customers = new CustomerRepo().GetAllCustomer();
            ddlCustomer.DataSource = customers;
            ddlCustomer.DataBind();
            ddlCustomer.Items.Insert(0, new ListItem("(All)", ""));
        }
Exemplo n.º 5
0
 protected void gvOrders_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     Order order = (Order)e.Row.DataItem;
     if (order != null)
     {
         OrderStatu orderStatus = new OrderStatusRepo().GetById(ToSQL.SQLToInt(order.OrderStatus_ID));
         if (orderStatus != null)
         {
             e.Row.Cells[2].Text = orderStatus.Name;//order stat
         }
         Customer customer = new CustomerRepo().GetById(ToSQL.SQLToInt(order.Customer_ID));
         if (customer != null)
         {
             e.Row.Cells[3].Text = customer.FirstName;//customer nam
         }
         Model.Payment payment = new PaymentRepo().GetById(ToSQL.SQLToInt(order.Payment_ID));
         if (payment != null)
         {
             e.Row.Cells[4].Text = payment.Name;//payment method
         }
         ShippingAddress shippingAddress = new ShippingAddressRepo().GetById(ToSQL.SQLToInt(order.ShippingAddress_ID));
         if (shippingAddress != null)
         {
             e.Row.Cells[5].Text = shippingAddress.Name;//Recipient's Name
             e.Row.Cells[6].Text = shippingAddress.Phone;
             string strAddress = new AddressRepo().GetToString(shippingAddress.Address);
             e.Row.Cells[7].Text = new AddressRepo().ShortString(strAddress);
             e.Row.Cells[7].ToolTip = strAddress;
         }
     }
 }