private void LoadCustomer() { Customer customer = customerRepo.GetById(ToSQL.SQLToInt(Request.QueryString["Id"])); if (customer != null) { lbUsername.Text = ToSQL.EmptyNull(customer.Username); txtFirstName.Text = ToSQL.EmptyNull(customer.FirstName); txtLastName.Text = ToSQL.EmptyNull(customer.LastName); txtEmail.Text = ToSQL.EmptyNull(customer.Email); txtPhone.Text = ToSQL.EmptyNull(customer.Phone); txtDateOfBirth.Text = ToSQL.SQLToDateTime(customer.DateOfBirth).ToShortDateString(); rdbtnGender.SelectedIndex = ToSQL.SQLToBool(customer.Gender) ? 0 : 1; lbDateCreated.Text = ToSQL.EmptyNull(customer.DateCreated); } else { Response.Redirect("Management-Customer.aspx"); } }
protected void btnCreditCard_Click(object sender, EventArgs e) { Customer customer = (Customer)Session["Customer"]; customer = customerRepo.GetById(customer.ID); if (customer.CreditCard == null) { customer.CreditCard = new CreditCard(); customer.CreditCard.DateCreated = DateTime.Now; } customer.CreditCard.CardNumber = ToSQL.EmptyNull(txtCardNum.Text); customer.CreditCard.SecurityCode = ToSQL.EmptyNull(txtCVCCode.Text); customer.CreditCard.ExpirationDate = ToSQL.SQLToDateTime(drdYear.SelectedValue + "/" + ddlMonth.SelectedValue + "/" + "1"); customer.CreditCard.CreditCardType_ID = ToSQL.SQLToIntNull(ddlTypeCard.SelectedValue); customer.CreditCard.Name = ToSQL.EmptyNull(txtFullName.Text); int i = customerRepo.UpdateCustomer(customer); Session["Customer"] = customerRepo.GetById(customer.ID); }
protected void btnGenaral_Click(object sender, EventArgs e) { Customer customer = (Customer)Session["Customer"]; customer = customerRepo.GetById(customer.ID); customer.FirstName = ToSQL.EmptyNull(txtFirstName.Text); customer.LastName = ToSQL.EmptyNull(txtLastName.Text); customer.Email = ToSQL.EmptyNull(txtEmail.Text); customer.Phone = ToSQL.EmptyNull(txtPhone.Text); customer.DateOfBirth = ToSQL.SQLToDateTime(txtDateOfBirth.Text); customer.Gender = rdbtnGender.SelectedIndex == 0 ? true : false; int i = customerRepo.UpdateCustomer(customer); Session["Customer"] = customerRepo.GetById(customer.ID); Response.Redirect(Request.Url.PathAndQuery); //using (var context = new B2C_ECEntities()) //{ // context.Customers.Find(customer.ID).LastName = "Phong 1989"; // context.SaveChanges(); //} }
private void LoadCustomer() { if (Session["Customer"] != null) { Customer customer = (Customer)Session["Customer"]; customer = customerRepo.GetById(customer.ID); lbUsername.Text = ToSQL.EmptyNull(customer.Username); txtFirstName.Text = ToSQL.EmptyNull(customer.FirstName); txtLastName.Text = ToSQL.EmptyNull(customer.LastName); txtEmail.Text = ToSQL.EmptyNull(customer.Email); txtPhone.Text = ToSQL.EmptyNull(customer.Phone); txtDateOfBirth.Text = ToSQL.SQLToDateTime(customer.DateOfBirth).ToShortDateString(); rdbtnGender.SelectedIndex = ToSQL.SQLToBool(customer.Gender) ? 0 : 1; lbDateCreated.Text = ToSQL.EmptyNull(customer.DateCreated); if (customer.Address != null) { txtStreet1.Text = ToSQL.EmptyNull(customer.Address.Street1); txtStreet2.Text = ToSQL.EmptyNull(customer.Address.Street2); txtCity.Text = ToSQL.EmptyNull(customer.Address.City); txtState.Text = ToSQL.EmptyNull(customer.Address.State); txtCountry.Text = ToSQL.EmptyNull(customer.Address.Country); txtZipCode.Text = ToSQL.EmptyNull(customer.Address.ZipCode); } if (customer.CreditCard != null) { txtCardNum.Text = ToSQL.EmptyNull(customer.CreditCard.CardNumber); txtCVCCode.Text = ToSQL.EmptyNull(customer.CreditCard.SecurityCode); ddlMonth.SelectedIndex = ToSQL.SQLToInt(customer.CreditCard.ExpirationDate.Month); drdYear.SelectedValue = ToSQL.EmptyNull(ToSQL.SQLToInt(customer.CreditCard.ExpirationDate.Year)); ddlTypeCard.SelectedValue = ToSQL.EmptyNull(customer.CreditCard.CreditCardType_ID); txtFullName.Text = ToSQL.EmptyNull(customer.CreditCard.Name); } if (customer.Orders != null) { rptOrder.DataSource = customer.Orders.OrderByDescending(o => o.ID); rptOrder.DataBind(); } } }