protected void setCoupoCodePanel() { if (Session["Discount"] != null) { Control footer = rptrCart.Controls[rptrCart.Controls.Count - 1].Controls[0]; Panel pnlCoupon = (Panel)footer.FindControl("pnlCoupon"); pnlCoupon.Visible = false; Panel pnlCouponapplied = (Panel)footer.FindControl("pnlCouponapplied"); pnlCouponapplied.Visible = true; Label lblGrandTotal = (Label)footer.FindControl("lblGrandTotal"); Label lblDiscount = (Label)footer.FindControl("lblDiscount"); Label lblDiscountPer = (Label)footer.FindControl("lblDiscountPer"); Label lblCoupon = (Label)footer.FindControl("lblCoupon"); Label lblFinalTotal = (Label)footer.FindControl("lblFinalTotal"); clsCart = new clsAddToCart(); lblGrandTotal.Text = Math.Round(clsCart.TotalPrice()).ToString(); lblCoupon.Text = Session["CouponCode"].ToString(); lblDiscount.Text = Math.Round((Convert.ToDouble(lblFinalTotal.Text) - Convert.ToDouble(lblGrandTotal.Text))).ToString(); lblDiscountPer.Text = "(" + Session["Discount"].ToString() + "%) Discount"; Session["DiscountValue"] = Convert.ToDouble(lblDiscount.Text); } else { Control footer = rptrCart.Controls[rptrCart.Controls.Count - 1].Controls[0]; Panel pnlCoupon = (Panel)footer.FindControl("pnlCoupon"); pnlCoupon.Visible = true; Panel pnlCouponapplied = (Panel)footer.FindControl("pnlCouponapplied"); pnlCouponapplied.Visible = false; } }
//protected int checkCoupon(string CouponName) //{ // int flag = 1; // int a, b, c; // if (Session["MemberInfo"] != null) // { // a = 1; // DataTable dtUser; // dtUser = new DataTable(); // dtUser = (DataTable)Session["MemberInfo"]; // if (dtUser.Rows[0]["memberId"].ToString() == "0") // { // a = 2; // } // } // else // { // a = 2; // } // clsBSD = new BillingShippingDetails(); // DataTable dtbilship1 = new DataTable(); // dtbilship1 = clsBSD.BindBillShip(); // if (cls.CheckExistField("CheckExistField", "InvoiceBillingShipping", "ColourName", txtcolourname.Text, "and IsActive = 1")) // { // } // DataTable dt = new DataTable(); // dt = cls.ReturnDataTable("Select_CouponOnName", new SqlParameter("@CouponName", CouponName)); // if (dt.Rows.Count > 0) // { // } // else // { // flag = 2; // coupon not exist // } // return flag; //} protected string ValidateCoupon(string CouponName) { string amount = ""; int memberid; double orderval; string email; string couponname; if (Session["MemberInfo"] != null) { DataTable dtUser; dtUser = new DataTable(); dtUser = (DataTable)Session["MemberInfo"]; memberid = Convert.ToInt32(dtUser.Rows[0]["memberId"].ToString()); // set memberid } else { memberid = 0; } clsCart = new clsAddToCart(); orderval = clsCart.TotalPriceWithoutDiscount(); // set ordervalue clsBSD = new BillingShippingDetails(); DataTable dtbilship1 = new DataTable(); dtbilship1 = clsBSD.BindBillShip(); email = dtbilship1.Rows[0]["SEmail"].ToString(); // set email couponname = CouponName; // set couponname amount = cls.ReturnScalerObject("GetDiscountOnCoupon", new SqlParameter("@CouponName", couponname), new SqlParameter("@MemberId", memberid), new SqlParameter("@Email", email), new SqlParameter("@OrderValue", orderval)).ToString(); return(amount); }
protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.Session["MemberInfo"] != null) { if (HttpContext.Current.Session["Cart"] != null) { clsCart = new clsAddToCart(); if (clsCart.TotalItems() <= 0) { Response.Redirect("MemberDashBoard.aspx"); } } if (!IsPostBack) { BindShippingInfo(); BindOrderSummary(); } } else { HttpContext.Current.Session["CameFrom"] = "CheckOut_Login"; Response.Redirect("Register.aspx"); } pnlShippingPin.Visible = false; }
protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.Session["MemberInfo"] != null) { if (HttpContext.Current.Session["Cart"] != null) { clsCart = new clsAddToCart(); if (clsCart.TotalItems() <= 0) { Response.Redirect("Checkout_Login.aspx"); } } if (!IsPostBack) { BindCart(); BindFinalAmt(); BindOrderSummary(); BindShippingSummary(); setCoupoCodePanel(); } } else { HttpContext.Current.Session["CameFrom"] = "CheckOut_Login"; Response.Redirect("Checkout_Login.aspx"); } }
protected void BindOrderSummary() { clsCart = new clsAddToCart(); lblTotalItems.Text = clsCart.TotalItems().ToString(); lblTotalAmount.Text = "Rs. " + Math.Round(clsCart.TotalPrice()).ToString(); lblFinalAmount1.Text = "Rs. " + Math.Round(clsCart.TotalPrice()).ToString(); }
protected void BindTopCartItems() { Label lblTopNoItems = (Label)this.Page.Master.FindControl("lblTopNoItems"); Label lblTopTotal = (Label)this.Page.Master.FindControl("lblTopTotal"); if (Session["Cart"] != null) { clsCart = new clsAddToCart(); lblTopNoItems.Text = clsCart.TotalItems().ToString(); if (clsCart.TotalItems() != 0) { lblTopTotal.Text = Math.Round(clsCart.TotalPrice()).ToString(); } else { lblTopTotal.Text = "0"; } } else { lblTopNoItems.Text = "0"; lblTopTotal.Text = "0"; } }
protected void rptrCart_ItemCommand(object source, RepeaterCommandEventArgs e) { string ProductId = e.CommandArgument.ToString(); Label lblProPrice = (Label)e.Item.FindControl("lblProPrice"); TextBox txtQty = (TextBox)e.Item.FindControl("txtQty"); Label lblSize = (Label)e.Item.FindControl("lblSize"); Label lblColor = (Label)e.Item.FindControl("lblColor"); Control footer = rptrCart.Controls[rptrCart.Controls.Count - 1].Controls[0]; TextBox txtCoupon = (TextBox)footer.FindControl("txtCoupon"); string amount; amount = ValidateCoupon(txtCoupon.Text.Trim()); if (e.CommandName == "UpdateCart") { if (amount == "") // coupon code not applicable { RemoveDiscountSession(); } clsCart = new clsAddToCart(); clsCart.SetQtyAndPriceWithSizeColor(ProductId, Convert.ToDouble(txtQty.Text), Convert.ToDouble(lblProPrice.Text), lblSize.Text, lblColor.Text); //BindCart(); //setCoupoCodePanel(); } else if (e.CommandName == "Remove") { if (amount == "") // coupon code not applicable { RemoveDiscountSession(); } clsCart = new clsAddToCart(); clsCart.RemoveItem(e.Item.ItemIndex); // BindCart(); // setCoupoCodePanel(); } else if (e.CommandName == "Coupon") { if (amount != "")//coupon code applicable { Session["Discount"] = Convert.ToDouble(amount); Session["CouponCode"] = txtCoupon.Text; } else { MsgBox("Coupon not Applicable"); return; } } BindCart(); BindFinalAmt(); BindTopCartItems(); BindOrderSummary(); setCoupoCodePanel(); }
protected void BindCart() { clsCart = new clsAddToCart(); if (clsCart.TotalItems() <= 0) { ShowMessageThenRedirectTo("Cart is empty", "default"); } rptrCart.DataSource = clsCart.BindCart(); rptrCart.DataBind(); }
protected void BindFinalAmt() { //double ftotal = 0; //foreach (RepeaterItem rptitem in dlMail.Items) //{ // Label lblamt = (Label)rptitem.FindControl("lblfprice"); // ftotal = ftotal + Convert.ToDouble(lblamt.Text); //} Control footer = rptrCart.Controls[rptrCart.Controls.Count - 1].Controls[0]; Label lblFinalTotal = (Label)footer.FindControl("lblFinalTotal"); clsCart = new clsAddToCart(); lblFinalTotal.Text = Math.Round(clsCart.TotalPriceWithoutDiscount()).ToString(); }
//#End Region protected void btnOrder_Click(object sender, System.EventArgs e) { clsCart = new clsAddToCart(); if (Session["captcha"] != null) { if (Session["captcha"].ToString() != txtCode.Text) { lblMsg.Text = "Invalid Code"; FillCapctha(); txtCode.Text = ""; } else { //place order if (clsCart.CheckIsCod()) { MaxCOD = (double)cls.ReturnScaler("Select_CODLimit"); if (clsCart.TotalPrice() > MaxCOD) { MsgBox("Cash On Delivery not available on your order, as it exceeds max limit of " + MaxCOD); return; } else { //place order and insert into db Session["PaySuccess"] = "1"; Session["PayMode"] = "Cash On Delivery"; Response.Redirect("PaymentSuccess.aspx"); } } else { MsgBox("Cash On Delivery not available on your order, as some of the products in cart not available on Cash On Delivery"); return; } } } else { FillCapctha(); } }
protected void RemoveSession() { clsCart = new clsAddToCart(); clsCart.RemoveFromSession(); clsBSD = new BillingShippingDetails(); clsBSD.RemoveFromSession(); Session.Remove("PayMode"); Session.Remove("PaypalId"); Session.Remove("PaySuccess"); Session.Remove("PayOrderId"); if (Session["CameFrom"] != null) { Session.Remove("CameFrom"); } Session.Remove("CameAgain"); if (Session["Discount"] != null) { Session.Remove("Discount"); Session.Remove("CouponCode"); Session.Remove("DiscountValue"); } if (Session["captcha"] != null) { Session.Remove("captcha"); } if (Session["captcha1"] != null) { Session.Remove("captcha1"); } if (Session["captcha2"] != null) { Session.Remove("captcha2"); } if (Session["RedirectTo"] != null) { Session.Remove("RedirectTo"); } //Session.Remove("Msg"); }
protected void setValueForccAvenue() { // seting ordersummary clsCart = new clsAddToCart(); order_id.Value = Session["PayOrderId"].ToString(); amount.Value = clsCart.TotalPrice().ToString(); // seting bilingshiping info clsBSD = new BillingShippingDetails(); DataTable dtBillingShipping = new DataTable(); dtBillingShipping = clsBSD.BindBillShip(); if (dtBillingShipping.Rows.Count > 0) { //billing_name.Value = dtBillingShipping.Rows[0]["Company"].ToString(); billing_name.Value = dtBillingShipping.Rows[0]["SName"].ToString(); billing_address.Value = dtBillingShipping.Rows[0]["Address1"].ToString(); billing_zip.Value = dtBillingShipping.Rows[0]["Zipcode"].ToString(); billing_city.Value = dtBillingShipping.Rows[0]["City"].ToString(); billing_state.Value = dtBillingShipping.Rows[0]["State"].ToString(); billing_country.Value = dtBillingShipping.Rows[0]["Country"].ToString(); billing_tel.Value = dtBillingShipping.Rows[0]["Contact"].ToString(); billing_email.Value = dtBillingShipping.Rows[0]["SEmail"].ToString(); delivery_name.Value = dtBillingShipping.Rows[0]["SName"].ToString(); delivery_address.Value = dtBillingShipping.Rows[0]["SAddress1"].ToString(); delivery_zip.Value = dtBillingShipping.Rows[0]["SZipcode"].ToString(); delivery_city.Value = dtBillingShipping.Rows[0]["SCity"].ToString(); delivery_state.Value = dtBillingShipping.Rows[0]["SState"].ToString(); delivery_country.Value = dtBillingShipping.Rows[0]["SCountry"].ToString(); delivery_tel.Value = dtBillingShipping.Rows[0]["SContact"].ToString(); //merchant_param1.Value = dtBillingShipping.Rows[0]["Name"].ToString(); //merchant_param2.Value = dtBillingShipping.Rows[0]["Email"].ToString(); merchant_param1.Value = ""; merchant_param2.Value = ""; } }
protected void BindTopCartItems() { if (Session["Cart"] != null) { clsCart = new clsAddToCart(); lblTopNoItems.Text = clsCart.TotalItems().ToString(); if (clsCart.TotalItems() != 0) { lblTopTotal.Text = Math.Round(clsCart.TotalPrice()).ToString(); } else { lblTopTotal.Text = "0"; } } else { lblTopNoItems.Text = "0"; lblTopTotal.Text = "0"; } }
protected void BindCart() { clsCart = new clsAddToCart(); rptrCart.DataSource = clsCart.BindCart(); rptrCart.DataBind(); }
//Insert into DB functions protected string InsertIntoDB() { clsCart = new clsAddToCart(); long orderid; A: orderid = (long)cls.ReturnScaler("Select_MaxOrderID"); if (cls.CheckExistField("CheckExistField", "InvoiceMaster", "OrderId", orderid.ToString(), " and IsActive=1")) { goto A; } long Memberid = 0; DataTable dtMember = new DataTable(); dtMember = (DataTable)Session["MemberInfo"]; foreach (DataRow dr in dtMember.Rows) { Memberid = Convert.ToInt64(dr["MemberId"]); } bool IsPaid = false; bool IsCOD = false; double discount = 0; double discountValue = 0; if (Session["Discount"] != null) { discount = (double)Session["Discount"]; discountValue = (double)Session["DiscountValue"]; } //Insert into invoice master Int32 invoiceid; invoiceid = (Int32)cls.ReturnScaler("Insert_InvoiceMasterForOnlinePay", new SqlParameter("MemberId", Memberid), new SqlParameter("@OrderId", orderid), new SqlParameter("@ShippingCharges", "0"), new SqlParameter("@OrderAmount", clsCart.TotalPrice()), new SqlParameter("@OrderQty", clsCart.TotalQty()), new SqlParameter("@PaypalId", ""), new SqlParameter("@IsPaid", IsPaid), new SqlParameter("@IsCOD", IsCOD), new SqlParameter("@PaymentMode", Session["PayMode"].ToString()), new SqlParameter("@DiscountPer", discount), new SqlParameter("@DiscountAmount", discountValue), new SqlParameter("@OriginalAmount", clsCart.TotalPriceWithoutDiscount())); //Insert into invoice coupon if (Session["CouponCode"] != null) { DataTable dtCoupon = new DataTable(); dtCoupon = cls.ReturnDataTable("Select_CouponOnName", new SqlParameter("@CouponName", Session["CouponCode"].ToString())); if (dtCoupon.Rows.Count > 0) { cls.ExecuteDA("Insert_InvoiceCoupon", new SqlParameter("@InvoiceId", invoiceid), new SqlParameter("@CouponName", dtCoupon.Rows[0]["CouponName"]), new SqlParameter("@CriteriaAVal", dtCoupon.Rows[0]["CriteriaAVal"]), new SqlParameter("@CriteriaBVal", dtCoupon.Rows[0]["CriteriaBVal"]), new SqlParameter("@CriteriaCVal", dtCoupon.Rows[0]["CriteriaCVal"])); } } //insert into invoice product table DataTable dt = new DataTable(); dt = clsCart.BindCart(); foreach (DataRow dr in dt.Rows) { cls.ExecuteDA("Insert_InvoiceProduct", new SqlParameter("@InvoiceId", invoiceid), new SqlParameter("@ProductId", Convert.ToInt32(dr["ProductId"])), new SqlParameter("@CategoryName", dr["CategoryName"]), new SqlParameter("@SubCategoryName", dr["SubCategoryName"]), new SqlParameter("@ProductName", dr["ProductName"]), new SqlParameter("@Productdescp", dr["Productdescp"]), new SqlParameter("@BrandName", dr["BrandName"]), new SqlParameter("@SupplierName", dr["SupplierName"]), new SqlParameter("@Unit", dr["Unit"]), new SqlParameter("@ColourName", dr["ColourName"]), new SqlParameter("@SizeName", dr["SizeName"]), new SqlParameter("@ProductCode", dr["ProductCode"]), new SqlParameter("@SupplierProductCode", dr["SupplierProductCode"]), new SqlParameter("@PackSize", dr["PackSize"]), new SqlParameter("@ProductCost", dr["ProductCost"]), new SqlParameter("@ProductWeight", dr["ProductWeight"]), new SqlParameter("@Image", dr["Image"]), new SqlParameter("@Certification", dr["Certification"]), new SqlParameter("@Description", dr["Description"]), new SqlParameter("@Margin", Convert.ToDouble(dr["Margin"])), new SqlParameter("@SalePrice", Convert.ToDouble(dr["SalePrice"])), new SqlParameter("@Tax", Convert.ToDouble(dr["Tax"])), new SqlParameter("@SalesPrice_Incl", Convert.ToDouble(dr["SalesPrice_Incl"])), new SqlParameter("@MRP", Convert.ToDouble(dr["MRP"])), new SqlParameter("@Discount", Convert.ToDouble(dr["Discount"])), new SqlParameter("@CalDiscount", Convert.ToDouble(dr["CalDiscount"])), new SqlParameter("@ShippingCost", Convert.ToDouble(dr["ShippingCost"])), new SqlParameter("@FinalSellingPrice", Convert.ToDouble(dr["FinalSellingPrice"])), new SqlParameter("@TaxFinalPrice", Convert.ToDouble(dr["TaxFinalPrice"])), new SqlParameter("@Quantity", Convert.ToDouble(dr["Qty"])), new SqlParameter("@ShippingDays", dr["ShippingDays"]), new SqlParameter("@IsCOD", Convert.ToBoolean(dr["IsCOD"]))); } //inserting into billing and delivery details clsBSD = new BillingShippingDetails(); DataTable dtbilship = new DataTable(); dtbilship = clsBSD.BindBillShip(); foreach (DataRow drow in dtbilship.Rows) { ViewState["ToMail"] = drow["SEmail"]; cls.ExecuteDA("Insert_InvoiceBillingShipping", new SqlParameter("@InvoiceId", invoiceid), new SqlParameter("@Name", drow["Name"]), new SqlParameter("@Email", drow["Email"]), new SqlParameter("@Company", drow["Company"]), new SqlParameter("@Contact", drow["Contact"]), new SqlParameter("@Address1", drow["Address1"]), new SqlParameter("@Address2", drow["Address2"]), new SqlParameter("@City", drow["City"]), new SqlParameter("@State", drow["State"]), new SqlParameter("@Country", drow["Country"]), new SqlParameter("@Zipcode", drow["Zipcode"]), new SqlParameter("@SName", drow["SName"]), new SqlParameter("@SEmail", drow["SEmail"]), new SqlParameter("@SCompany", drow["SCompany"]), new SqlParameter("@SContact", drow["SContact"]), new SqlParameter("@SAddress1", drow["SAddress1"]), new SqlParameter("@SAddress2", drow["SAddress2"]), new SqlParameter("@SCity", drow["SCity"]), new SqlParameter("@SState", drow["SState"]), new SqlParameter("@SCountry", drow["SCountry"]), new SqlParameter("@SZipcode", drow["SZipcode"])); } // Session["OrderId"] = orderid.ToString(); // lblOredrId.Text = orderid.ToString(); setPdfandMail(invoiceid, orderid); return(orderid.ToString()); }
protected void rptrProductDetail_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "AddCart") { ProductId = e.CommandArgument.ToString(); DataTable dtproduct; dtproduct = new DataTable(); dtproduct = cls.ReturnDataTable("Select_ProductDetailOnId", new SqlParameter("@pid", ProductId)); if (dtproduct.Rows.Count <= 0) { MsgBox("This Product is no longer available."); return; } else { foreach (DataRow dr in dtproduct.Rows) { ProductId = dr["Id"].ToString(); CategoryName = dr["CategoryName"].ToString(); SubCategoryName = dr["SubCategoryName"].ToString(); ProductName = dr["ProductName"].ToString(); Productdescp = dr["Productdescp"].ToString(); BrandName = dr["BrandName"].ToString(); SupplierName = dr["SupplierName"].ToString(); Unit = dr["Unit"].ToString(); ProductCode = dr["ProductCode"].ToString(); SupplierProductCode = dr["SupplierProductCode"].ToString(); PackSize = dr["PackSize"].ToString(); ProductCost = Convert.ToDouble(dr["ProductCost"].ToString()); ProductWeight = Convert.ToDouble(dr["ProductWeight"].ToString()); Image = dr["Image"].ToString(); Certification = dr["Certification"].ToString(); Description = dr["Description"].ToString(); Margin = Convert.ToDouble(dr["Margin"].ToString()); SalePrice = Convert.ToDouble(dr["SalePrice"].ToString()); Tax = Convert.ToDouble(dr["Tax"].ToString()); SalesPrice_Incl = Convert.ToDouble(dr["SalesPrice_Incl"].ToString()); MRP = Convert.ToDouble(dr["MRP"].ToString()); Discount = Convert.ToDouble(dr["Discount"].ToString()); CalDiscount = Convert.ToDouble(dr["CalDiscount"].ToString()); ShippingCost = Convert.ToDouble(dr["ShippingCost"].ToString()); FinalSellingPrice = Convert.ToDouble(dr["FinalSellingPrice"].ToString()); TaxFinalPrice = Convert.ToDouble(dr["TaxFinalPrice"].ToString()); MinQty = Convert.ToDouble(dr["Quantity"].ToString()); ShippingDays = dr["ShippingDays"].ToString(); IsCOD = Convert.ToBoolean(dr["IsCOD"]); } Label lblSize = (Label)e.Item.FindControl("lblSize"); Label lblColor = (Label)e.Item.FindControl("lblColor"); SizeName = lblSize.Text; ColourName = lblColor.Text; Price = MinQty * FinalSellingPrice; clsCart = new clsAddToCart(); if (clsCart.FindExistItemWithSizeColor(ProductId, SizeName, ColourName)) { clsCart.UpdateQtyAndPriceWithSizeColor(ProductId, MinQty, FinalSellingPrice, SizeName, ColourName); } else { clsCart.AddToCart(ProductId, CategoryName, SubCategoryName, ProductName, Productdescp, BrandName, SupplierName, Unit, ColourName, SizeName, ProductCode, SupplierProductCode, PackSize, ProductCost, ProductWeight, Image, Certification, Description, Margin, SalePrice, Tax, SalesPrice_Incl, MRP, Discount, CalDiscount, ShippingCost, FinalSellingPrice, TaxFinalPrice, MinQty, ShippingDays, IsCOD, Price); } Response.Redirect("Cart.aspx"); BindTopCartItems(); } } }
protected void rptrProductDetail_ItemCommand(object source, RepeaterCommandEventArgs e) { bool IsLogin; // Add to Cart if (e.CommandName == "AddCart") { RadioButtonList rdbSize = (RadioButtonList)e.Item.FindControl("rdbSize"); Panel pnlSize = (Panel)e.Item.FindControl("pnlSize"); if (!pnlSize.Visible) { SizeName = "NA"; } else if (rdbSize.SelectedIndex > -1) { SizeName = rdbSize.SelectedItem.Text; } else { MsgBox("Please Select Size"); return; } RadioButtonList rdbColor = (RadioButtonList)e.Item.FindControl("rdbColor"); Panel pnlColor = (Panel)e.Item.FindControl("pnlColour"); if (!pnlColor.Visible) { ColourName = "NA"; } else if (rdbColor.SelectedIndex > -1) { ColourName = rdbColor.SelectedItem.Text; } else { MsgBox("Please Select Color"); return; } TextBox txtQty = (TextBox)e.Item.FindControl("txtQty"); Qty = Convert.ToDouble(txtQty.Text); dtproduct = new DataTable(); dtproduct = cl.getdataset("select ProductCategory.CategoryName,ProductSubCategory.SubCategoryName,Brand.BrandName,product.*,(case Productdescp when '' then ProductName else ProductName +' ('+Productdescp+')' end ) as pname, (case Productdescp when '' then '' else '('+Productdescp+')' end ) as pline2, Supplier.SupplierName,Unit.Unit, c.*,c.discount as crmdiscount from Product inner join ProductCategory on Product.ProductCategoryId=ProductCategory.Id inner join ProductSubCategory on Product.ProductSubCategoryId=ProductSubCategory.Id inner join Brand on Product.BrandId=Brand.Id left join unit on Product.UnitId=Unit.Id inner join crm c on c.productid=Product.id left join Supplier on Product.SupplierId=Supplier.Id where Product.IsActive=1 and Product.Id='" + pid + "' and c.cusotmerid='" + memberid + "'"); if (dtproduct != null) { foreach (DataRow dr in dtproduct.Rows) { ProductId = dr["Id"].ToString(); CategoryName = dr["CategoryName"].ToString(); SubCategoryName = dr["SubCategoryName"].ToString(); ProductName = dr["ProductName"].ToString(); Productdescp = dr["Productdescp"].ToString(); BrandName = dr["BrandName"].ToString(); SupplierName = dr["SupplierName"].ToString(); Unit = dr["Unit"].ToString(); ProductCode = dr["ProductCode"].ToString(); SupplierProductCode = dr["SupplierProductCode"].ToString(); PackSize = dr["PackSize"].ToString(); ProductCost = Convert.ToDouble(dr["ProductCost"].ToString()); ProductWeight = Convert.ToDouble(dr["ProductWeight"].ToString()); Image = dr["Image"].ToString(); Certification = dr["Certification"].ToString(); Description = dr["Description"].ToString(); Margin = Convert.ToDouble(dr["Margin"].ToString()); SalePrice = Convert.ToDouble(dr["SalePrice"].ToString()); Tax = Convert.ToDouble(dr["Tax"].ToString()); SalesPrice_Incl = Convert.ToDouble(dr["SalesPrice_Incl"].ToString()); MRP = Convert.ToDouble(dr["MRP"].ToString()); Discount = Convert.ToDouble(dr["Discount"].ToString()); CalDiscount = Convert.ToDouble(dr["CalDiscount"].ToString()); ShippingCost = Convert.ToDouble(dr["ShippingCost"].ToString()); FinalSellingPrice = Convert.ToDouble(dr["netsaleprice"].ToString()); TaxFinalPrice = Convert.ToDouble(dr["TaxFinalPrice"].ToString()); MinQty = Convert.ToDouble(dr["Quantity"].ToString()); ShippingDays = dr["ShippingDays"].ToString(); IsCOD = Convert.ToBoolean(dr["IsCOD"]); } if (Qty < MinQty) { MsgBox("Minimum Qty required for order is : " + MinQty); return; } Price = Qty * FinalSellingPrice; clsCart = new clsAddToCart(); if (clsCart.FindExistItemWithSizeColor(ProductId, SizeName, ColourName)) { clsCart.UpdateQtyAndPriceWithSizeColor(ProductId, Qty, FinalSellingPrice, SizeName, ColourName); } else { clsCart.AddToCart(ProductId, CategoryName, SubCategoryName, ProductName, Productdescp, BrandName, SupplierName, Unit, ColourName, SizeName, ProductCode, SupplierProductCode, PackSize, ProductCost, ProductWeight, Image, Certification, Description, Margin, SalePrice, Tax, SalesPrice_Incl, MRP, Discount, CalDiscount, ShippingCost, FinalSellingPrice, TaxFinalPrice, Qty, ShippingDays, IsCOD, Price); } if (Qty > 0) { Response.Redirect("Cart.aspx"); } else { //Response.Redirect("Cart.aspx"); //BindTopCartItems(); MsgBox("Please Select Color"); } } else { BindProductDetail(pid); } } // Add to Wishlist else if (e.CommandName == "AddWishlist") { RadioButtonList rdbSize = (RadioButtonList)e.Item.FindControl("rdbSize"); Panel pnlSize = (Panel)e.Item.FindControl("pnlSize"); if (!pnlSize.Visible) { SizeName = "NA"; } else if (rdbSize.SelectedIndex > -1) { SizeName = rdbSize.SelectedItem.Text; } else { MsgBox("Please Select Size"); return; } RadioButtonList rdbColor = (RadioButtonList)e.Item.FindControl("rdbColor"); Panel pnlColor = (Panel)e.Item.FindControl("pnlColour"); if (!pnlColor.Visible) { ColourName = "NA"; } else if (rdbColor.SelectedIndex > -1) { ColourName = rdbColor.SelectedItem.Text; } else { MsgBox("Please Select Color"); return; } //TextBox txtQty = (TextBox)e.Item.FindControl("txtQty"); //if (string.IsNullOrEmpty(txtQty.Text)) //{ // Qty = 0; //} //else //{ // Qty = Convert.ToDouble(txtQty.Text); //} dtproduct = new DataTable(); dtproduct = cl.getdataset("select ProductCategory.CategoryName,ProductSubCategory.SubCategoryName,Brand.BrandName,product.*,(case Productdescp when '' then ProductName else ProductName +' ('+Productdescp+')' end ) as pname, (case Productdescp when '' then '' else '('+Productdescp+')' end ) as pline2, Supplier.SupplierName,Unit.Unit, c.*,c.discount as crmdiscount from Product inner join ProductCategory on Product.ProductCategoryId=ProductCategory.Id inner join ProductSubCategory on Product.ProductSubCategoryId=ProductSubCategory.Id inner join Brand on Product.BrandId=Brand.Id left join unit on Product.UnitId=Unit.Id inner join crm c on c.productid=Product.id left join Supplier on Product.SupplierId=Supplier.Id where Product.IsActive=1 and Product.Id='" + pid + "' and c.cusotmerid='" + memberid + "'"); foreach (DataRow dr in dtproduct.Rows) { ProductId = dr["Id"].ToString(); CategoryName = dr["CategoryName"].ToString(); SubCategoryName = dr["SubCategoryName"].ToString(); ProductName = dr["ProductName"].ToString(); Productdescp = dr["Productdescp"].ToString(); BrandName = dr["BrandName"].ToString(); SupplierName = dr["SupplierName"].ToString(); Unit = dr["Unit"].ToString(); ProductCode = dr["ProductCode"].ToString(); SupplierProductCode = dr["SupplierProductCode"].ToString(); PackSize = dr["PackSize"].ToString(); ProductCost = Convert.ToDouble(dr["ProductCost"].ToString()); ProductWeight = Convert.ToDouble(dr["ProductWeight"].ToString()); Image = dr["Image"].ToString(); Certification = dr["Certification"].ToString(); Description = dr["Description"].ToString(); Margin = Convert.ToDouble(dr["Margin"].ToString()); SalePrice = Convert.ToDouble(dr["SalePrice"].ToString()); Tax = Convert.ToDouble(dr["Tax"].ToString()); SalesPrice_Incl = Convert.ToDouble(dr["SalesPrice_Incl"].ToString()); MRP = Convert.ToDouble(dr["MRP"].ToString()); Discount = Convert.ToDouble(dr["Discount"].ToString()); CalDiscount = Convert.ToDouble(dr["CalDiscount"].ToString()); ShippingCost = Convert.ToDouble(dr["ShippingCost"].ToString()); FinalSellingPrice = Convert.ToDouble(dr["netsaleprice"].ToString()); TaxFinalPrice = Convert.ToDouble(dr["TaxFinalPrice"].ToString()); MinQty = Convert.ToDouble(dr["Quantity"].ToString()); ShippingDays = dr["ShippingDays"].ToString(); IsCOD = Convert.ToBoolean(dr["IsCOD"]); } Price = MinQty * FinalSellingPrice; clsWishlist = new clsWishlist(); if (clsWishlist.FindExistItemWithSizeColor(ProductId, SizeName, ColourName)) { clsWishlist.UpdateQtyAndPriceWithSizeColor(ProductId, MinQty, FinalSellingPrice, SizeName, ColourName); } else { clsWishlist.AddToWishlist(ProductId, CategoryName, SubCategoryName, ProductName, Productdescp, BrandName, SupplierName, Unit, ColourName, SizeName, ProductCode, SupplierProductCode, PackSize, ProductCost, ProductWeight, Image, Certification, Description, Margin, SalePrice, Tax, SalesPrice_Incl, MRP, Discount, CalDiscount, ShippingCost, FinalSellingPrice, TaxFinalPrice, MinQty, ShippingDays, IsCOD, Price); } IsLogin = CheckUserSession(); if (!IsLogin) { Session["CameFrom"] = "Wishlist"; MessageThenRedirectTo("Please Login to Save Wishlist", "Register"); return; } else { Response.Redirect("WishList.aspx"); } } //check pincode else if (e.CommandName == "CheckPincode") { TextBox txtPinCode = (TextBox)e.Item.FindControl("txtPinCode"); if (txtPinCode != null) { DataTable dt = new DataTable(); dt = getStateCityOnPincode(Convert.ToInt64(txtPinCode.Text)); Panel pnlShippingAvailable = (Panel)e.Item.FindControl("pnlShippingAvailable"); Panel pnlShippingPin = (Panel)e.Item.FindControl("pnlShippingPin"); if (dt.Rows.Count > 0) { pnlShippingAvailable.Visible = true; pnlShippingPin.Visible = false; } else { pnlShippingAvailable.Visible = false; pnlShippingPin.Visible = true; } } } }
protected void Addingitemincart(string ProductId, string size, string color, double quantity) { DataTable dt = new DataTable(); clsWishlist = new clsWishlist(); dt = clsWishlist.BindWishlistOnProductSizeColor(ProductId, size, color); foreach (DataRow dr in dt.Rows) { ProductId = dr["ProductId"].ToString(); CategoryName = dr["CategoryName"].ToString(); SubCategoryName = dr["SubCategoryName"].ToString(); ProductName = dr["ProductName"].ToString(); Productdescp = dr["Productdescp"].ToString(); BrandName = dr["BrandName"].ToString(); SupplierName = dr["SupplierName"].ToString(); Unit = dr["Unit"].ToString(); ProductCode = dr["ProductCode"].ToString(); SupplierProductCode = dr["SupplierProductCode"].ToString(); PackSize = dr["PackSize"].ToString(); ProductCost = Convert.ToDouble(dr["ProductCost"].ToString()); ProductWeight = Convert.ToDouble(dr["ProductWeight"].ToString()); Image = dr["Image"].ToString(); Certification = dr["Certification"].ToString(); Description = dr["Description"].ToString(); Margin = Convert.ToDouble(dr["Margin"].ToString()); SalePrice = Convert.ToDouble(dr["SalePrice"].ToString()); Tax = Convert.ToDouble(dr["Tax"].ToString()); SalesPrice_Incl = Convert.ToDouble(dr["SalesPrice_Incl"].ToString()); MRP = Convert.ToDouble(dr["MRP"].ToString()); Discount = Convert.ToDouble(dr["Discount"].ToString()); CalDiscount = Convert.ToDouble(dr["CalDiscount"].ToString()); ShippingCost = Convert.ToDouble(dr["ShippingCost"].ToString()); FinalSellingPrice = Convert.ToDouble(dr["FinalSellingPrice"].ToString()); TaxFinalPrice = Convert.ToDouble(dr["TaxFinalPrice"].ToString()); MinQty = Convert.ToDouble(dr["Qty"].ToString()); ShippingDays = dr["ShippingDays"].ToString(); IsCOD = Convert.ToBoolean(dr["IsCOD"]); } SizeName = size; ColourName = color; if (quantity < MinQty) { MsgBox("Minimum Qty required for order is : " + MinQty); return; } Price = quantity * FinalSellingPrice; clsCart = new clsAddToCart(); if (quantity != 0) { if (clsCart.FindExistItemWithSizeColor(ProductId, SizeName, ColourName)) { clsCart.UpdateQtyAndPriceWithSizeColor(ProductId, Qty, FinalSellingPrice, SizeName, ColourName); } else { clsCart.AddToCart(ProductId, CategoryName, SubCategoryName, ProductName, Productdescp, BrandName, SupplierName, Unit, ColourName, SizeName, ProductCode, SupplierProductCode, PackSize, ProductCost, ProductWeight, Image, Certification, Description, Margin, SalePrice, Tax, SalesPrice_Incl, MRP, Discount, CalDiscount, ShippingCost, FinalSellingPrice, TaxFinalPrice, Qty, ShippingDays, IsCOD, Price); } } }