private void saveOrder(DevMod.Models.MOrderMaster mom, List <DevMod.Models.MOrderLine> orderLine) { DevMod.Classes.COrder co = new DevMod.Classes.COrder(); if (co.Save(mom, orderLine) > 0) { SendMessageToPage("Your order has been sent"); } else { SendMessageToPage("There was a problem sendingyour order"); } return; }
protected void lkNext_Click(object sender, EventArgs e) { if (Page.IsPostBack) { switch (nextButtonClick()) { case 1: { string firstName = txtFirstName.Text; string lastName = txtLastName.Text; string Address = txtAddress.Text; string phoneNumber1 = txtPhone1.Text; string additionalPhoneNumber = txtAdditionalPhoneNumber.Text; string alternateEmail = txtAlternateEmail.Text; string email = txtEmail.Text; DevMod.Models.MCommon.MDataObjects.MCheckOutDetails mcd = new DevMod.Models.MCommon.MDataObjects.MCheckOutDetails(); mcd.AdditionalPhoneNumber = additionalPhoneNumber; mcd.Address = Address; mcd.AlternateEmail = alternateEmail; mcd.Email = email; mcd.FirstName = firstName; mcd.LastName = lastName; mcd.Phone1 = phoneNumber1; Session["checkoutDetails"] = mcd; break; } case 2: { if (grdProducts.Rows.Count > 0) { List <DevMod.Models.MCommon.MDataObjects.MCheckOutProductDetails> checkoutProducts = new List <DevMod.Models.MCommon.MDataObjects.MCheckOutProductDetails>(); for (int i = 0; i < grdProducts.Rows.Count; i++) { string productId = grdProducts.Rows[i].Cells[0].Text.ToString(); string Image = grdProducts.Rows[i].Cells[1].Text.ToString(); string Name = grdProducts.Rows[i].Cells[2].Text.ToString(); string Price = grdProducts.Rows[i].Cells[3].Text.ToString(); DropDownList ddlColor = (DropDownList)grdProducts.Rows[i].FindControl("ddlColors"); string Color = ddlColor.SelectedItem.Text; TextBox txtUnits = (TextBox)grdProducts.Rows[i].FindControl("txtUnits"); string Units = txtUnits.Text; DevMod.Models.MCommon.MDataObjects.MCheckOutProductDetails mpc = new DevMod.Models.MCommon.MDataObjects.MCheckOutProductDetails(); mpc.color = Color; mpc.ImageUrl = Image; mpc.Name = Name; mpc.Price = Price; mpc.ProductId = productId; mpc.units = Units; checkoutProducts.Add(mpc); } Session["checkoutProducts"] = checkoutProducts; DevMod.Models.MCommon.MDataObjects.MCheckOutDetails mcd = new DevMod.Models.MCommon.MDataObjects.MCheckOutDetails(); if (Session["checkoutDetails"] != null) { mcd = (DevMod.Models.MCommon.MDataObjects.MCheckOutDetails)Session["checkoutDetails"]; } lblAdditionalPhoneNumber.Text = mcd.AdditionalPhoneNumber; lblAddress.Text = mcd.Address; lblAlternateEmail.Text = mcd.AlternateEmail; lblEmail.Text = mcd.Email; lblFirstName.Text = mcd.FirstName; lblLastName.Text = mcd.LastName; lblPhoneNumber1.Text = mcd.Phone1; } break; } case 3: { if (Session["checkoutProducts"] != null) { List <DevMod.Models.MCommon.MDataObjects.MCheckOutProductDetails> checkoutProducts = (List <DevMod.Models.MCommon.MDataObjects.MCheckOutProductDetails>)Session["checkoutProducts"]; grdProductConfirmation.DataSource = checkoutProducts; grdProductConfirmation.DataBind(); } break; } case 4: { if (grdProducts.Rows.Count > 0) { List <DevMod.Models.MOrderLine> orderLine = new List <DevMod.Models.MOrderLine>(); DevMod.Models.MOrderMaster mom = new DevMod.Models.MOrderMaster(); mom.Date = DateTime.Now.ToShortDateString(); mom.Total = lblTotal.Text; for (int i = 0; i < grdProducts.Rows.Count; i++) { DevMod.Models.MCommon.MDataObjects.MCheckOutDetails mcd = new DevMod.Models.MCommon.MDataObjects.MCheckOutDetails(); DevMod.Models.MOrderLine mol = new DevMod.Models.MOrderLine(); string productId = grdProducts.Rows[i].Cells[0].Text.ToString(); string Image = grdProducts.Rows[i].Cells[1].Text.ToString(); string Name = grdProducts.Rows[i].Cells[2].Text.ToString(); string Price = grdProducts.Rows[i].Cells[3].Text.ToString(); DropDownList ddlColor = (DropDownList)grdProducts.Rows[i].FindControl("ddlColors"); string Color = ddlColor.SelectedItem.Text; TextBox txtUnits = (TextBox)grdProducts.Rows[i].FindControl("txtUnits"); string Units = txtUnits.Text; string firstName = string.Empty, lastName = string.Empty, Address = string.Empty, phoneNumber1 = string.Empty, additionalPhoneNumber = string.Empty, alternateEmail = string.Empty, email = string.Empty; if (Session["checkoutDetails"] != null) { mcd = (DevMod.Models.MCommon.MDataObjects.MCheckOutDetails)Session["checkoutDetails"]; } #region formdetails mol.AdditionalPhoneNumber = mcd.AdditionalPhoneNumber; mol.Address = mcd.Address; mol.AlternateEmail = mcd.AlternateEmail; mol.Email = mcd.Email; mol.FirstName = mcd.FirstName; mol.LastName = mcd.LastName; mol.Phone1 = mcd.Phone1; #endregion #region product details mol.color = Color; mol.ImageUrl = Image; mol.Name = Name; mol.Price = Price; mol.ProductId = productId; mol.units = Units; #endregion orderLine.Add(mol); } saveOrder(mom, orderLine); } break; } default: break; } } }