protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Convert.ToString(Session["accesflag"]) == string.Empty) { removeextcustrecords(); } string carpicture = Request.QueryString["cartpicture"]; if (carpicture == null) { populatecartitems(); } if (carpicture == "cartalbum") { string custid = Convert.ToString(Application["Usercustid"]); var cartdisplvalues = (from q in db.Siddeswari_Addtocart where q.SiddOrgCustID == custid where q.SiddorgTranactvflag == "A" select new { q.SiddOrgimgloc, q.SiddOrgItemDesc, q.SiddOrgItemName, q.SiddOrgItemPrice, q.SiddOrgItemQty }).ToList(); var totprice = (from q in db.Siddeswari_Addtocart select new { q.SiddOrgItemtotprice }).ToList(); int sumtotprice = 0; foreach (var i in totprice) { sumtotprice = sumtotprice + Convert.ToInt32(i.SiddOrgItemtotprice.Substring(1, 2)); } string totalitemprice = Convert.ToString(sumtotprice); Lblsubtot.Text = totalitemprice; Lbltot.Text = totalitemprice; Rptbookdetails.DataSource = cartdisplvalues; Rptbookdetails.DataBind(); } } }
protected void BtRmpdt_Click(object sender, EventArgs e) { try { Session["Data"] = (sender as LinkButton).CommandArgument; string Rmbookname = Convert.ToString(Session["Data"]); var rmbookitem = db.Siddeswari_Addtocart.Where(x => x.SiddOrgItemName == Rmbookname).FirstOrDefault(); db.Siddeswari_Addtocart.Remove(rmbookitem); db.SaveChanges(); string custid = Convert.ToString(Application["Usercustid"]); var cartdisplvalues = (from q in db.Siddeswari_Addtocart where q.SiddOrgCustID == custid where q.SiddorgTranactvflag == "A" select new { q.SiddOrgimgloc, q.SiddOrgItemDesc, q.SiddOrgItemName, q.SiddOrgItemPrice, q.SiddOrgItemQty }).ToList(); Rptbookdetails.DataSource = cartdisplvalues; Rptbookdetails.DataBind(); var totprice = (from q in db.Siddeswari_Addtocart select new { q.SiddOrgItemtotprice }).ToList(); int sumtotprice = 0; foreach (var i in totprice) { sumtotprice = sumtotprice + Convert.ToInt32(i.SiddOrgItemtotprice.Substring(1, 2)); } string totalitemprice = Convert.ToString(sumtotprice); Lblsubtot.Text = totalitemprice; Lbltot.Text = totalitemprice; } catch (Exception ex) { throw (ex); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string[] separator = { ":" }; bkname = Request.QueryString["booknam"]; nitems = Convert.ToInt32(Request.QueryString["noitems"]); if (Convert.ToString(Session["rmflag"]) == "Y") { Session["cartstr"] = Session["rmcartbkstr"] + ":" + bkname; Session["cartitems"] = Session["rmcartqty"] + ":" + Convert.ToString(nitems); cartstr = Convert.ToString(Session["cartstr"]); cartitm = Convert.ToString(Session["cartitems"]); cartbkstr = cartstr.Split(separator, StringSplitOptions.RemoveEmptyEntries); cartitmstr = cartitm.Split(separator, StringSplitOptions.RemoveEmptyEntries); bkordcnt = cartbkstr.Count(); nofitemcntcnt = cartitmstr.Count(); Application["cartcnt"] = bkordcnt; } else { Session["cartstr"] = Session["cartstr"] + bkname + ":"; Session["cartitems"] = Session["cartitems"] + Convert.ToString(nitems) + ":"; cartstr = Convert.ToString(Session["cartstr"]); cartitm = Convert.ToString(Session["cartitems"]); cartbkstr = cartstr.Split(separator, StringSplitOptions.RemoveEmptyEntries); cartitmstr = cartitm.Split(separator, StringSplitOptions.RemoveEmptyEntries); bkordcnt = cartbkstr.Count(); nofitemcntcnt = cartitmstr.Count(); Application["cartcnt"] = bkordcnt; } for (int i = 0; i < bkordcnt; i++) { string bokname = cartbkstr[i]; int bokqty = Convert.ToInt32(cartitmstr[i]); if (bokname != "dummy" && bokqty != 0) { var ordchekdt = (from q in db.Siddeswari_Master_Books where q.SiddOrgBookname == bokname where q.SiddOrgDispPage == "Librarypage" select new { q.SiddOrgBookname, q.SiddOrgBookprice, q.SiddOrgBookDesc, q.SiddOrgBookimg, q.SiddOrgsaleprice }).ToList(); foreach (var n in ordchekdt) { chkfinorddetails.Add(new Finalorderdtls { SiddOrgBookDesc = n.SiddOrgBookDesc, SiddOrgBookimg = n.SiddOrgBookimg, SiddOrgBookname = n.SiddOrgBookname, SiddOrgsaleprice = n.SiddOrgsaleprice, bkqty = bokqty, lineitmtotprice = bokqty * Convert.ToInt32(n.SiddOrgsaleprice) }); } } } foreach (var t in chkfinorddetails) { cartordsuntot = cartordsuntot + t.lineitmtotprice; } Lblsubtot.Text = Convert.ToString(cartordsuntot); Lbltot.Text = Convert.ToString(Convert.ToInt32(cartordsuntot) + 15); Rptbookdetails.DataSource = chkfinorddetails; Rptbookdetails.DataBind(); } }
protected void BtRmpdt_Click(object sender, EventArgs e) { string id = (sender as LinkButton).CommandArgument; string[] separator = { ":" }; if (Convert.ToString(Session["rmflag"]) == "Y") { cartstr = Convert.ToString(Session["rmcartbkstr"]); cartitm = Convert.ToString(Session["rmcartqty"]); cartbkstr = cartstr.Split(separator, StringSplitOptions.RemoveEmptyEntries); cartitmstr = cartitm.Split(separator, StringSplitOptions.RemoveEmptyEntries); bkordcnt = cartbkstr.Count(); nofitemcntcnt = cartitmstr.Count(); } else { cartstr = Convert.ToString(Session["cartstr"]); cartitm = Convert.ToString(Session["cartitems"]); cartbkstr = cartstr.Split(separator, StringSplitOptions.RemoveEmptyEntries); cartitmstr = cartitm.Split(separator, StringSplitOptions.RemoveEmptyEntries); bkordcnt = cartbkstr.Count(); nofitemcntcnt = cartitmstr.Count(); } string replval = "dummy"; int repqty = 0; for (int i = 0; i < bkordcnt; i++) { if (cartbkstr[i] == id) { int rmindex = i; cartbkstr[i] = replval; cartitmstr[i] = Convert.ToString(repqty); Session["rmflag"] = "Y"; } } Session["rmcartbkstr"] = string.Join(":", cartbkstr); Session["rmcartqty"] = string.Join(":", cartitmstr); for (int i = 0; i < bkordcnt; i++) { string bokname = cartbkstr[i]; int bokqty = Convert.ToInt32(cartitmstr[i]); if (bokname != "dummy" && bokqty != 0) { var rmordchekdtl = (from q in db.Siddeswari_Master_Books where q.SiddOrgBookname == bokname where q.SiddOrgDispPage == "Librarypage" select new { q.SiddOrgBookname, q.SiddOrgBookprice, q.SiddOrgBookDesc, q.SiddOrgBookimg, q.SiddOrgsaleprice }).ToList(); foreach (var n in rmordchekdtl) { Rmfinorddetails.Add(new Finalorderdtls { SiddOrgBookDesc = n.SiddOrgBookDesc, SiddOrgBookimg = n.SiddOrgBookimg, SiddOrgBookname = n.SiddOrgBookname, SiddOrgsaleprice = n.SiddOrgsaleprice, bkqty = bokqty, lineitmtotprice = bokqty * Convert.ToInt32(n.SiddOrgsaleprice) }); } } } Application["cartcnt"] = Rmfinorddetails.Count; foreach (var t in Rmfinorddetails) { cartordsuntot = cartordsuntot + t.lineitmtotprice; } Rptbookdetails.DataSource = Rmfinorddetails; Rptbookdetails.DataBind(); Lblsubtot.Text = Convert.ToString(cartordsuntot); Lbltot.Text = Convert.ToString(Convert.ToInt32(cartordsuntot) + 15); }
protected void populatecartitems() { try { // Get the book details from home or library page string bookimg = this.Request.QueryString["bookimgval"]; string booknam = this.Request.QueryString["bookname"]; string bookpric = this.Request.QueryString["bookprice"]; string bookdesc = this.Request.QueryString["bookdescrp"]; // insert the add to cart line item Siddeswari_Addtocart addtocrtvalues = new Siddeswari_Addtocart(); // int linetotprice = Convert.ToInt32(bookpric.Trim()) * 1; string custid = Convert.ToString(Application["Usercustid"]); Lblcustname.Text = Convert.ToString(Application["Usercustid"]); addtocrtvalues.SiddOrgItemName = booknam.Trim(); addtocrtvalues.SiddOrgItemDesc = bookdesc.Trim(); addtocrtvalues.SiddOrgimgloc = bookimg.Trim(); addtocrtvalues.SiddOrgItemQty = "1"; addtocrtvalues.SiddOrgItemPrice = bookpric.Trim(); addtocrtvalues.SiddOrgItemtotprice = bookpric.Trim(); addtocrtvalues.SiddorgTranactvflag = "A"; addtocrtvalues.SiddOrgCrts_ts = DateTime.Now; addtocrtvalues.SiddOrgCustID = Convert.ToString(Application["Usercustid"]); var addtocnt = (from q in db.Siddeswari_Addtocart select new { }).ToList(); addtocrtvalues.CartlineitemID = "IM" + addtocnt.Count(); db.Siddeswari_Addtocart.Add(addtocrtvalues); db.SaveChanges(); var totprice = (from q in db.Siddeswari_Addtocart select new { q.SiddOrgItemtotprice }).ToList(); int sumtotprice = 0; foreach (var i in totprice) { sumtotprice = sumtotprice + Convert.ToInt32(i.SiddOrgItemtotprice.Substring(1, 2)); } string totalitemprice = Convert.ToString(sumtotprice); Lblsubtot.Text = totalitemprice; Lbltot.Text = totalitemprice; // Get the values for the total cart values for that customer var cartdisplvalues = (from q in db.Siddeswari_Addtocart where q.SiddOrgCustID == custid where q.SiddorgTranactvflag == "A" select new { q.SiddOrgimgloc, q.SiddOrgItemDesc, q.SiddOrgItemName, q.SiddOrgItemPrice, q.SiddOrgItemQty }).ToList(); Rptbookdetails.DataSource = cartdisplvalues; Rptbookdetails.DataBind(); } catch (Exception ex) { throw (ex); } }