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); } }