protected void ContBilling(bool fromPayment, bool validate, Explore.NetSuite.DataAccess.NDAL client, ref Customer cust) { try { if (!fromPayment) { Session["RedrawForm"] = false; } bool goOn = true; if (validate) { if (!Page.IsValid) { goOn = false; } } if (goOn) { if (!fromPayment) { Session["FormClicked"] = true; } bool isStateValid = false; if (StateLabel2RadComboBox.Visible) { if (StateLabel2RadComboBox.SelectedValue != "-1") isStateValid = true; } else { if (StateLabel2TextBox.Text.Trim() != "") isStateValid = true; } if (isStateValid) { if (Session["UserID"] != null) { //HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}", // DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), // "info", // "---SaveBilling address function GetCustomer() Begin------")); //HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}", // DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), // "info", // "---SaveBilling address function GetCustomer() End------")); Address adr = new Address(); adr.DefaultBilling = true; adr.DefaultShipping = false; adr.DefaultDelivery = false; adr.Residential = false; adr.DefaultAccount = false; if (!fromPayment) { Session["RedrawForm"] = true; Session["formpage"] = "3"; } Session["BillingNameLabel"] = AttentionLabel1TextBox.Text; BillingNameLabel.Text = AttentionLabel1TextBox.Text; Session["BillingCompanyLabel"] = CompanyLabel2TextBox.Text; BillingCompanyLabel.Text = CompanyLabel2TextBox.Text; adr.CompanyName = CompanyLabel2TextBox.Text; string state = ""; if (StateLabel2RadComboBox.Visible) state = StateLabel2RadComboBox.SelectedItem.Text; else state = StateLabel2TextBox.Text; Session["BillingStateLabel"] = state; BillingStateLabel.Text = CityLabel2TextBox.Text + ", " + state + " " + ZipLabel2TextBox.Text; adr.State = state; Session["BillingCityLabel"] = CityLabel2TextBox.Text; adr.City = CityLabel2TextBox.Text; Session["BillingPhoneLabel"] = PhoneLabel2TextBox.Text; Session["BillingEx"] = ex2TextBox.Text; BillingPhoneLabel.Text = PhoneLabel2TextBox.Text; adr.Phone = PhoneLabel2TextBox.Text; if (ex2TextBox.Text.Trim() != "") { BillingPhoneLabel.Text = PhoneLabel2TextBox.Text + " x" + ex2TextBox.Text; adr.Phone = PhoneLabel2TextBox.Text + " x" + ex2TextBox.Text; } Session["BillingAttentionLabel"] = AttentionLabel1TextBox.Text; adr.Attention = AttentionLabel1TextBox.Text; Session["BillingAddressLabel"] = Address1Label2TextBox.Text; adr.Address1 = Address1Label2TextBox.Text; Session["BillingAddress2Label"] = Address2Label2TextBox.Text; adr.Address2 = Address2Label2TextBox.Text; Session["BillingZipLabel"] = ZipLabel2TextBox.Text; adr.Zip = ZipLabel2TextBox.Text; Session["BillingCountryLabel"] = CountryLabel2RadComboBox.SelectedValue; DataSet dsCount = doQuery("SELECT * FROM Countries WHERE country_name = '" + CountryLabel2RadComboBox.SelectedItem.Text + "'"); adr.Country = dsCount.Tables[0].Rows[0]["country_2_code"].ToString(); object refAdrs = (object)adr; SaveDynamicFields("2", ref refAdrs); adr = (Address)refAdrs; UpdateAddress(adr, ref cust, AddressTypes.Billing); //HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}", // DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), // "info", // "---SaveBilling address function UpdateCustomer() Begin------")); // //HttpContext.Current.Trace.Warn("FormPage_ContinuePayment()", string.Format("{0},{1},{2}", // DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), // "info", // "---SaveBilling address function UpdateCustomer() End------")); client.UpdateCustomer(cust); SamesAsCheckBox2.Checked = false; if (!fromPayment) { FillShipping(); if (Session["EditBillingClicked"] != null) if (bool.Parse(Session["EditBillingClicked"].ToString())) { Session["formpage"] = "6"; GoToForm(6, 2); SetBoxes(); BuildIt(client, cust); } else GoToForm(3, 2); else GoToForm(3, 2); } } else { ErrorLabel.Text = "user is null"; } } else { ErrorLabelBilling.Text = "State is required."; } } } catch (Exception ex) { ErrorLabel.Text = ex.ToString(); } }
protected void FillCheckOutShipping(Customer cust) { if (Session["UserID"] != null) { List<Address> addresses = cust.Addresses; Address address = new Address(); for (int i = 0; i < addresses.Count; i++) { if (addresses[i].DefaultShipping.Value) { address = addresses[i]; } } ShippingAddressLabel.Text = address.Address1; ShippingAddress2Label.Text = address.Address2; ShippingNameLabel.Text = address.Attention; ShippingCompanyLabel.Text = address.CompanyName; ShippingStateLabel.Text = address.City + ", " + address.State + " " + address.Zip; ShippingPhoneLabel.Text = address.Phone; } }
protected void FillCheckOutBilling(Customer cust) { if (Session["UserID"] != null) { HttpContext.Current.Trace.Warn("FormPage_FillCheckOutBilling()", string.Format("{0},{1},{2}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "info", "---Check out Begin------")); Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL(); List<Address> addresses = cust.Addresses; Address address = new Address(); for (int i = 0; i < addresses.Count; i++) { if (addresses[i].DefaultBilling.Value) { address = addresses[i]; } } BillingAddressLabel.Text = address.Address1; BillingAddress2Label.Text = address.Address2; BillingNameLabel.Text = address.Attention; BillingCompanyLabel.Text = address.CompanyName; BillingStateLabel.Text = address.City + ", " + address.State + " " + address.Zip; BillingPhoneLabel.Text = address.Phone; } }
protected void FillCheckOutDelivery(Customer cust) { if (Session["UserID"] != null) { List<Address> addresses = cust.Addresses; Address address = new Address(); for (int i = 0; i < addresses.Count; i++) { if (addresses[i].DefaultDelivery.Value) { address = addresses[i]; } } DeliveryAddressLabel.Text = address.Address1; DeliveryAddress2Label.Text = address.Address2; DeliveryNameLabel.Text = address.Attention; DeliveryCompanyLabel.Text = address.CompanyName; DeliveryStateLabel.Text = address.City + ", " + address.State + " " + address.Zip; DeliveryPhoneLabel.Text = address.Phone; } }
protected void BuildIt(Explore.NetSuite.DataAccess.NDAL client, Customer cust) { Session["formpage"] = "6"; Session["Edit"] = "True"; ThePanel.Controls.Clear(); try { //HttpContext.Current.Trace.Warn("FormPage_BuildReviewForm()", string.Format("{0},{1},{2}", // DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), // "info", // "---Draw Review Form GetCustomer() Begin------")); //Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL(); //Customer cust = client.GetCustomer(Session["UserID"].ToString()); //HttpContext.Current.Trace.Warn("FormPage_BuildReviewForm()", string.Format("{0},{1},{2}", // DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), // "info", // "---Draw Review Form GetCustomer() End------")); FillCheckOutBilling(cust); FillCheckOutShipping(cust); FillCheckOutDelivery(cust); FillCheckOutPayment(); string thecartID = Session["yourcart"].ToString(); int multisystemdiscountcount = (int)Session["MultiSystemCount"]; DataView dvMulti = doQueryDV("SELECT * FROM NetSuitePriceLevel WHERE CustomerType=1 AND MaxQuantity >= " + multisystemdiscountcount.ToString() + " AND MinQuantity <= " + multisystemdiscountcount.ToString()); decimal multiDiscount = 1.00M; if (dvMulti.Count > 0) multiDiscount = (1.00M - decimal.Parse(dvMulti[0]["Discount"].ToString().Trim().Replace("%", "")) / 100.00M); DataSet dsCartParent = doQuery("SELECT DISTINCT ID, NID, Quantity, isParent, SubProductID, " + "ParentID, SKU, isLoneSKU FROM Cart WHERE CartSessionID='" + thecartID + "' AND isParent ='True'"); DataSet dsProduct1 = doQuery("SELECT * FROM NetSuiteProducts WHERE NID='" + dsCartParent.Tables[0].Rows[0]["NID"].ToString()+"'"); DataSet dsCart = doQuery("SELECT * FROM Cart C WHERE C.CartSessionID='" + thecartID + "'"); DataSet dsCartNotParent = doQuery("SELECT * FROM Cart C, NetSuiteBoxes NSB WHERE " + "NSB.NID=C.SubProductID AND C.isParent='False' AND C.CartSessionID='" + thecartID + "' ORDER BY C.BoxID"); DataView dvParents = new DataView(doQuery("SELECT * FROM NetSuiteProducts").Tables[0], "", "", DataViewRowState.CurrentRows); DataSet dsProdCount = doQuery("SELECT DISTINCT ID, NID, Quantity, isParent, SubProductID, " + "ParentID FROM Cart WHERE CartSessionID='" + thecartID + "' AND isParent ='True'"); DataView dv = new DataView(dsCart.Tables[0], "", "", DataViewRowState.CurrentRows); DataView dvSub = new DataView(dsCartNotParent.Tables[0], "", "", DataViewRowState.CurrentRows); decimal estimatedTotal = 0.00M; string parentID = ""; Label lab = new Label(); lab.ID = "TheLabel"; lab.Visible = false; lab.Text = dsCartParent.Tables[0].Rows.Count.ToString(); ThePanel.Controls.Add(lab); #region forloop for (int i = 0; i < dsCartParent.Tables[0].Rows.Count; i++) { Literal ColumnsLiteral = new Literal(); Literal ColumnsLiteralEnd = new Literal(); dv.RowFilter = "NID ='" + dsProdCount.Tables[0].Rows[i]["NID"].ToString().Trim().ToUpper() + "' AND isParent = 'True'"; parentID = dsProdCount.Tables[0].Rows[i]["ID"].ToString(); dvParents.RowFilter = "NID='" + dsProdCount.Tables[0].Rows[i]["NID"].ToString().Trim().ToUpper()+"'"; //<a onclick=\"var answer = confirm('Are you sure you want to remove the " + // dvParents[0]["PriceTitle"].ToString() + // " from your cart?'); if(answer){ RemoveItem();}\" class=\"LinkUnderline\">Remove</a> string tempSKU = dsCartParent.Tables[0].Rows[i]["SKU"].ToString().Trim(); Session["tempSKU"] = "first: " + tempSKU; if (bool.Parse(dsCartParent.Tables[0].Rows[i]["isLoneSKU"].ToString())) { //DataSet dsTemp = doQuery("SELECT * FROM NetSuiteProducts WHERE NID='" + // dsCartParent.Tables[0].Rows[i]["NID"].ToString().Trim().ToUpper()+"'"); //colLiteral2.Text += "<li>" + dsTemp.Tables[0].Rows[0]["Name"].ToString() + "</li>"; } else { dvSub.RowFilter = "ParentID=" + parentID; for (int j = 0; j < dvSub.Count; j++) { tempSKU += dvSub[j]["SKU"].ToString().Trim(); Session["tempSKU"] += ", " + j + ":" + tempSKU; //allPrice += decimal.Parse(dvSub[j]["Price"].ToString()); //eduPrice += decimal.Parse(dvSub[j]["Price"].ToString()); //colLiteral2.Text += "<li>" + dvSub[j]["Name"].ToString() + "</li>"; } } Literal colLiteral2 = new Literal(); colLiteral2.Text = "<td width=\"200px\" aligh=\"left\">" + tempSKU + "<br/>"; dvSub.RowFilter = "ParentID=" + dsProdCount.Tables[0].Rows[i]["ID"].ToString(); //decimal allPrice = decimal.Parse(dvParents[0]["Price"].ToString()); //decimal eduPrice = decimal.Parse(dvParents[0]["EducationalPrice"].ToString()); Session["tempSKU"] += ", whole: "+tempSKU; DataView dvDESC = doQueryDV("SELECT * FROM NetSuiteGroupItem WHERE ItemName='"+tempSKU+"'"); colLiteral2.Text += "<ul class=\"CartUL\">"; colLiteral2.Text += "<li>" + dvDESC[0]["Description"].ToString() + "</li>"; Label label = new Label(); label.ID = "labelY" + i.ToString(); label.Visible = false; label.Text = tempSKU; ThePanel.Controls.Add(label); dv.RowFilter = "ID ='" + dsProdCount.Tables[0].Rows[i]["ID"].ToString().Trim().ToUpper() + "' AND isParent = 'True'"; colLiteral2.Text += "</ul>"; colLiteral2.Text += "</td>"; colLiteral2.Text += "<td>"; ThePanel.Controls.Add(colLiteral2); Label qtyTextBox = new Label(); qtyTextBox.ID = "TextBox" + i.ToString(); qtyTextBox.Width = 20; qtyTextBox.Height = 20; qtyTextBox.Text = dv[0]["Quantity"].ToString(); ThePanel.Controls.Add(qtyTextBox); Literal ColumnsLiteral5 = new Literal(); ColumnsLiteral5.Text += "</td>"; string msrpCSS = "PriceLabel"; if (Session["UserType"] != null) if ((NDAL.DataTypes.PriceLevels)Session["UserType"] == NDAL.DataTypes.PriceLevels.Educational) msrpCSS = "PriceLabelCrossed"; ColumnsLiteral5.Text += "<td align=\"right\">MSRP: <span class=\"" + msrpCSS + "\">$"; ThePanel.Controls.Add(ColumnsLiteral5); Literal ColumnsLiteral2 = new Literal(); Label labelAllPrice = new Label(); Session["message"] += tempSKU; labelAllPrice.Text = InsertCommaForPrice((multiDiscount*CalculatePrice(tempSKU, 1, NDAL.DataTypes.PriceLevels.MSRP)).ToString(), true); //allPrice.ToString(); labelAllPrice.ID = "labelAllPrice" + i.ToString(); ThePanel.Controls.Add(labelAllPrice); string priceClass = "PriceLabel"; Literal ColumnsLiteral3 = new Literal(); Label labelEduPrice = new Label(); if (Session["UserType"] != null) { if ((NDAL.DataTypes.PriceLevels)Session["UserType"] == NDAL.DataTypes.PriceLevels.Educational) { priceClass = "PriceLabelCrossed"; ColumnsLiteral2.Text += "</span><br/><label class=\"CartColumn\">ED Price:</label> <span class=\"PriceLabel\">$"; ThePanel.Controls.Add(ColumnsLiteral2); labelEduPrice.Text = InsertCommaForPrice(((CalculatePrice(tempSKU, multisystemdiscountcount, NDAL.DataTypes.PriceLevels.Educational))).ToString(), true); //eduPrice.ToString(); labelEduPrice.ID = "labelEduPrice" + i.ToString(); ThePanel.Controls.Add(labelEduPrice); } } ColumnsLiteral3.Text += "</span></td>"; ColumnsLiteral3.Text += "<td align=\"right\"><span class=\"" + priceClass + "\"><label id=\"allPrice" + i.ToString() + "\">$"; ThePanel.Controls.Add(ColumnsLiteral3); Literal ColumnsLiteral4 = new Literal(); Label totalAllPrice = new Label(); totalAllPrice.ID = "totalAllPrice" + i.ToString(); totalAllPrice.Text = InsertCommaForPrice((decimal.Parse(dv[0]["Quantity"].ToString()) * decimal.Parse(labelAllPrice.Text)).ToString(), false); totalAllPrice.ID = "totalAllPrice" + i.ToString(); ThePanel.Controls.Add(totalAllPrice); ColumnsLiteral4.Text += "</label></span><br/>"; if (Session["UserType"] != null) { if ((NDAL.DataTypes.PriceLevels)Session["UserType"] == NDAL.DataTypes.PriceLevels.Educational) { ColumnsLiteral4.Text += "<span class=\"PriceLabel\" id=\"eduPrice" + i.ToString() + "\"><label id=\"eduPrice" + i.ToString() + "\">$"; } } ThePanel.Controls.Add(ColumnsLiteral4); if (Session["UserType"] != null) { if ((NDAL.DataTypes.PriceLevels)Session["UserType"] == NDAL.DataTypes.PriceLevels.Educational) { Label totalEduPrice = new Label(); totalEduPrice.Text = InsertCommaForPrice((decimal.Parse(dv[0]["Quantity"].ToString()) * decimal.Parse(labelEduPrice.Text)).ToString(), false); totalEduPrice.ID = "totalEduPrice" + i.ToString(); estimatedTotal += decimal.Parse(totalEduPrice.Text); ThePanel.Controls.Add(totalEduPrice); ColumnsLiteralEnd.Text += "</label></span></td></tr>"; ColumnsLiteralEnd.Text += "<tr><td colspan=\"5\" align=\"right\" class=\"PriceLabel\">You Save: $" + InsertCommaForPrice((decimal.Parse(dv[0]["Quantity"].ToString()) * CalculatePrice(tempSKU, 1, NDAL.DataTypes.PriceLevels.MSRP) - decimal.Parse(totalEduPrice.Text)).ToString(), false) + "</td></tr><tr><td><div style=\"display: none;\">"; } else { estimatedTotal += decimal.Parse(totalAllPrice.Text); ColumnsLiteralEnd.Text += "</td></tr><tr><td><div style=\"display: none;\">"; } } else { estimatedTotal += decimal.Parse(totalAllPrice.Text); ColumnsLiteralEnd.Text += "</td></tr><tr><td><div style=\"display: none;\">"; } Label qtyLabel = new Label(); qtyLabel.ID = "qtyLabel" + i.ToString(); qtyLabel.Text = dv[0]["Quantity"].ToString(); Label idLabel = new Label(); idLabel.Visible = false; idLabel.ID = "IDLabel" + i.ToString(); idLabel.Text = parentID; Literal ColumnsLiteral6 = new Literal(); ColumnsLiteral6.Text = "</div></td></tr><tr><td colspan=\"4\" style=\"padding-top: 10px;\"></td></tr>"; ThePanel.Controls.Add(ColumnsLiteralEnd); ThePanel.Controls.Add(qtyLabel); ThePanel.Controls.Add(idLabel); ThePanel.Controls.Add(ColumnsLiteral6); //if ((NDAL.DataTypes.PriceLevels)Session["UserType"] == NDAL.DataTypes.PriceLevels.Educational) //{ // estimatedTotal += decimal.Parse((decimal.Parse(dv[0]["Quantity"].ToString()) * multiDiscount*CalculatePrice(tempSKU, 1, // NDAL.DataTypes.PriceLevels.Educational)).ToString()); //} //else //{ // estimatedTotal += decimal.Parse((decimal.Parse(dv[0]["Quantity"].ToString()) * multiDiscount*CalculatePrice(tempSKU, 1, // NDAL.DataTypes.PriceLevels.MSRP)).ToString()); //} } #endregion Session["numProds"] = dsProdCount.Tables[0].Rows.Count; //not doing promo for phase I //DataSet dsPromo = doQuery("SELECT * FROM CartPromos CP, NetSuitePromos NSP WHERE "+ // "CP.CodeID=NSP.NetSuiteID AND CP.CartSession='" + thecartID + "'"); EstimatedTotalLabel.Text = InsertCommaForPrice(estimatedTotal.ToString(), false); TheTotal.Text = InsertCommaForPrice(estimatedTotal.ToString(), false); //HttpContext.Current.Trace.Warn("FormPage_BuildReviewForm()", string.Format("{0},{1},{2}", // DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), // "info", // "---Draw Review Form GetCustomer() Begin------")); //HttpContext.Current.Trace.Warn("FormPage_BuildReviewForm()", string.Format("{0},{1},{2}", // DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), // "info", // "---Draw Review Form GetCustomer() End------")); Address shipToAddress = new Address(); for (int i = 0; i < cust.Addresses.Count; i++) { if (cust.Addresses[i].DefaultShipping.Value) { shipToAddress = cust.Addresses[i]; } } //HttpContext.Current.Trace.Warn("FormPage_BuildReviewForm()", string.Format("{0},{1},{2}", // DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), // "info", // "---Draw Review Form Get Transaction lines Begin------")); List<TransactionLineItem> transList = new List<TransactionLineItem>(); GetTransactionLines(ref transList); //HttpContext.Current.Trace.Warn("FormPage_BuildReviewForm()", string.Format("{0},{1},{2}", // DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), // "info", // "---Draw Review Form Get Transaction lines End------")); HttpContext.Current.Trace.Warn("FormPage_BuildReviewForm()", string.Format("{0},{1},{2}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "info", "---Draw Review Form GetUPSRate Begin------")); string shippingTotal = client.GetUPSRate(Session["UserID"].ToString(), shipToAddress.InternalID, ShippingMethods.UPSGround, transList); HttpContext.Current.Trace.Warn("FormPage_BuildReviewForm()", string.Format("{0},{1},{2}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "info", "---Draw Review Form GetUPSRate End------")); ShippingUPSLabel.Text = "$" + InsertCommaForPrice(shippingTotal, false); //Not doing promo for phase I //if (dsPromo.Tables.Count > 0) // if (dsPromo.Tables[0].Rows.Count > 0) // { // TheDiscountPercent.Text = dsPromo.Tables[0].Rows[0]["PercentDiscount"].ToString(); // MakePromo(dsPromo.Tables[0].Rows[0]["Code"].ToString(), // dsPromo.Tables[0].Rows[0]["PercentDiscount"].ToString()); // } decimal taxableAmount = 0.00M; decimal taxAmount = 0.00M; HttpContext.Current.Trace.Warn("FormPage_BuildReviewForm()", string.Format("{0},{1},{2}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "info", "---Draw Review Form GetTax Begin------")); decimal taxPercentage = GetTax(shipToAddress, false, ref taxableAmount, ref taxAmount); HttpContext.Current.Trace.Warn("FormPage_BuildReviewForm()", string.Format("{0},{1},{2}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "info", "---Draw Review Form GetTax End------")); TaxLabel.Text = InsertCommaForPrice(taxAmount.ToString(), false); //decimal theTax = (decimal.Parse(TaxLabel.Text) / decimal.Parse("100.00")) * (taxableAmount); //TaxLabel.Text = InsertCommaForPrice(theTax.ToString()); TheTotal.Text = (estimatedTotal + taxAmount + decimal.Parse(shippingTotal)).ToString(); EstimatedTotalLabel.Text = InsertCommaForPrice(TheTotal.Text, false); //char[] delim = { '.'}; //string[] tokens = TheTotal.Text.Split(delim); //if (tokens[0].Trim().Length > 3) //{ // //tokens[0] = tokens[0].Insert(tokens[0].Length - 3, ","); // EstimatedTotalLabel.Text = tokens[0]; // if (tokens.Length > 1) // { // EstimatedTotalLabel.Text += "." + tokens[1]; // } //} //if (tokens.Length < 2) //{ // EstimatedTotalLabel.Text += ".00"; //} } catch (Exception ex) { Literal ColumnsLiteral = new Literal(); //ColumnsLiteral.Text = "<tr><td><div>Your cart is empty.</div></td></tr>"; ColumnsLiteral.Text = ex.ToString(); //ColumnsLiteral.Text = "<tr><td><div>TempSKU: "+ex.ToString()+"</div></td></tr>"; ThePanel.Controls.Add(ColumnsLiteral); } }