protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.Session["Username"] != null) { String sessionuname = (String)HttpContext.Current.Session["Username"]; var db = new DataLinqDataContext(); var userdetails = (from g in db.Users where sessionuname.Equals(g.Username) select g).FirstOrDefault(); lblun.InnerText = "Username: "******"First Name: " + userdetails.FirstName; Labelln.InnerText = "Surname: " + userdetails.Surname; Lble.InnerText = "E-Mail: " + userdetails.Email; Labelp.InnerText = "Province/city: " + userdetails.AddressLine1; Lblc.InnerText = "Physical Address: " + userdetails.AddressLine2; Lblzip.InnerText = "Zip Code: " + userdetails.ZipCode; string strDisplay = "<h3>Invoice History:</h3>"; //this code is copied from brij's attempt with the useraccountinfopage.aspx dynamic InvoicesList = from invoices in db.Invoices where (invoices.Username).Equals(Session["Username"]) // where (invoices.Username).Equals("Eva")//.....checking purpose only select invoices; if (InvoicesList != null) { foreach (Invoice inv in InvoicesList) { strDisplay += "<p></p>"; strDisplay += "<div class='payment-details p-30'>"; strDisplay += "<h4>Invoice: " + inv.Invoice_Id + "</h4>"; strDisplay += "<table>"; dynamic ItemsList = from item in db.Items where (inv.Invoice_Id).Equals(item.Invoice_Id) select item; foreach (Item itm in ItemsList) { var Product = (from product in db.Products where (product.Product_Id).Equals(itm.Product_Id) select product).FirstOrDefault(); strDisplay += "<tr>"; strDisplay += "<td class='td-title-1'>" + Product.Product_Name + " X " + itm.Item_Qty + "</td>"; strDisplay += "<td class='td-title-2'>R" + String.Format("{0:0.00}", itm.Item_SellingPrice) + "</td>"; strDisplay += "</tr>"; } strDisplay += "<tr>"; strDisplay += "<td class='order-total'>Order Total</td>"; strDisplay += "<td class='order-total-price'>R" + String.Format("{0:0.00}", inv.Invoice_Total) + "</td>"; strDisplay += "</tr>"; strDisplay += "</table>"; strDisplay += "</div>"; } Invoices.InnerHtml = strDisplay; } } }
protected void Page_Load(object sender, EventArgs e) { var db = new DataLinqDataContext(); dynamic products = from a in db.Products select a; string display = ""; foreach (Product p in products) { display += "<div class=\"col-sm-6 col-xs-12\">"; display += " <div class=\"blog-item-2\">"; display += " <div class=\"row\">"; display += " <div class=\"col-md-6 col-xs-12\">"; display += " <div class=\"blog-desc\">"; display += " <h5 class=\"blog -title-2\">" + p.Product_OnHand + "</h5>"; display += " <p>" + p.Product_Name + "</p>"; display += " </div>"; display += " </div>"; display += " </div>"; display += " </div>"; display += " </div>"; } main.InnerHtml = display; }
protected void Page_Load(object sender, EventArgs e) { var db = new DataLinqDataContext(); dynamic products = from a in db.Products select a; int productCount = 0; int specialCount = 0; int recentCount = 0; foreach (Product p in products) { productCount++; if (p.Product_IsSpecial) { specialCount++; } if (p.Product_DateAdded > DateTime.Now.AddMonths(-3)) { recentCount++; } } numProducts.InnerHtml = "<h2 class=uppercase mb-30>Total Number of Products: " + productCount + "</h2>"; numSpecial.InnerHtml = "<h2 class=uppercase mb-30>Total Number of Products on Special: " + specialCount + "</h2>"; numRecent.InnerHtml = "<h2 class=uppercase mb-30>Recent Products: " + recentCount + "</h2>"; }
protected void Page_Load(object sender, EventArgs e) { var db = new DataLinqDataContext(); Decimal grossRevenue = 0; dynamic items = from c in db.Items select c; foreach (Item d in items) { grossRevenue += d.Item_Qty * d.Item_SellingPrice; } grossRev.InnerHtml = "<h2 class=uppercase mb-30>Gross Revenue: " + grossRevenue + "</h2>"; Decimal recentRevenue = 0; dynamic invoices = from v in db.Invoices select v; foreach (Invoice inv in invoices) { if (inv.Invoice_Date > DateTime.Now.AddMonths(-3)) { recentRevenue += inv.Invoice_Total; } } recentRev.InnerHtml = "<h2 class=uppercase mb-30>Revenue from past 3 months: " + recentRevenue + "</h2>"; }
protected void Page_Load(object sender, EventArgs e) { var db = new DataLinqDataContext(); dynamic users = from a in db.Users select a; dynamic products = from b in db.Products select b; int userCount = 0; foreach (User u in users) { userCount++; } numRegUsers.InnerHtml = "<p>Number of total registered users is:</br><h1>" + userCount + "</h1></p>"; int productCount = 0; foreach (Product p in products) { productCount++; } numProducts.InnerHtml = "<p>Number of total products is:</br><h1>" + productCount + "</h1></p>"; Decimal grossRevenue = 0; dynamic items = from c in db.Items select c; foreach (Item d in items) { grossRevenue = d.Item_Qty * d.Item_SellingPrice; } grossRev.InnerHtml = "<p>Gross Revenue:</br><h1>R" + grossRevenue + "</h1></p>"; }
protected void Page_Load(object sender, EventArgs e) { var db = new DataLinqDataContext(); dynamic pro = from p in db.Products select p; String ImgDisplay = ""; foreach (Product pr in pro) { decimal v = Convert.ToDecimal((100 - pr.Product_SpclPercantage) / 100); decimal discountedprice = Convert.ToDecimal(pr.Product_Price) * v; //todisplay = todisplay + "<img src=" + pr.Product_Img + " height=300 width=270 alt=''>"; ImgDisplay += " <div class='col-md-4 col-sm-4 col-xs-12'>"; ImgDisplay += " <div class='product-item'>"; ImgDisplay += " <div class='product-info'>"; ImgDisplay += " <h6 class='product-title'>"; ImgDisplay += "<a href=Controlsingleproduct.aspx?ProductId=" + pr.Product_Id + ">" + pr.Product_Name + "</a>";; ImgDisplay += " </h6>"; ImgDisplay += "<p>Current Discounted Product price:R " + String.Format("{0:0.00}", discountedprice) + " and Current Discount Percentage: " + pr.Product_SpclPercantage + " </p>"; ImgDisplay += " </div>"; ImgDisplay += " </div>"; ImgDisplay += " </div>"; } cspec.InnerHtml = ImgDisplay; }
protected void regBtn_Click(object sender, EventArgs e) { var db = new DataLinqDataContext(); dynamic users = from a in db.Users select a; var user = username.Value; var password1 = Secrecy.Secrecy.HashPassword(pass1.Value); var password2 = Secrecy.Secrecy.HashPassword(pass2.Value); bool isReg = false; foreach (User u in users) { if (u.Username == user) { alertReg.InnerHtml = "<strong>Oh snap!</strong> Username already exists."; isReg = true; if (u.Email == email.Value) { alertReg.InnerHtml = "<strong>Oh snap!</strong> Email already exists."; isReg = true; } } } if (password1 != password2) { alertReg.InnerHtml = "<strong>Oh snap!</strong> Passwords do not match"; } if (isReg == false) { User regUser = new User { Username = user, Password = password1, UserType = "User", FirstName = firstname.Value, Surname = lastname.Value, Email = email.Value, AddressLine1 = add1.Value, AddressLine2 = add2.Value, ZipCode = zip.Value, DateRegistered = DateTime.Now.Date }; db.Users.InsertOnSubmit(regUser); try { db.SubmitChanges(); Session["AuthLevel"] = "User"; Session["Username"] = user; Response.Redirect("index.aspx"); } catch (Exception ex) { ex.GetBaseException(); } } }
protected void savebtn_Click(object sender, EventArgs e) { if (HttpContext.Current.Session["Username"] != null) { String sessionuname = (String)HttpContext.Current.Session["Username"]; var db = new DataLinqDataContext(); User userd = (from g in db.Users where sessionuname.Equals(g.Username) select g).FirstOrDefault(); if (!(fname.Value.Equals(""))) { userd.FirstName = fname.Value; } if (!(lname.Value.Equals(""))) { userd.Surname = lname.Value; } if (!(email.Value.Equals(""))) { userd.Email = email.Value; } if (!(location1.Value.Equals(""))) { userd.AddressLine1 = location1.Value; } if (!(location2.Value.Equals(""))) { userd.AddressLine2 = location2.Value; } if (!(zipcode.Value.Equals(""))) { userd.ZipCode = zipcode.Value; } if (Secrecy.Secrecy.HashPassword(oldPassword.Value).Equals(userd.Password)) { if (!(pass1.Value.Equals(""))) { if (pass1.Value.Equals(pass2.Value)) { userd.Password = Secrecy.Secrecy.HashPassword(pass1.Value); result.InnerText = "Password Changed"; } } } try { db.SubmitChanges(); } catch (Exception exep) { exep.GetBaseException(); } Response.Redirect("UserHomePage.aspx"); } }
protected void removeBtn_Click(object sender, EventArgs e) { var db = new DataLinqDataContext(); int id = int.Parse(deleteId.Value); var deleteP = (from p in db.Products where p.Product_Id == id select p).FirstOrDefault(); deleteP.Product_IsActive = false; db.SubmitChanges(); Response.Redirect("AdminHomePage.aspx"); }
protected void Page_Load(object sender, EventArgs e) { var db = new DataLinqDataContext(); var cart = (from Cart c in db.Carts where c.Product_Id.Equals(Request.QueryString["ProductId"]) select c).FirstOrDefault(); db.Carts.DeleteOnSubmit(cart); db.SubmitChanges(); Response.Redirect("Wishlist.aspx"); }
protected void Page_Load(object sender, EventArgs e) { prdctID = Request.QueryString["EdtPrdctID"]; txtprdctNmOld.Attributes.Add("readonly", "readonly"); txtOldPrdctPrc.Attributes.Add("readonly", "readonly"); txtOldDesrp.Attributes.Add("readonly", "readonly"); txtOldPrdctTyp.Attributes.Add("readonly", "readonly"); txtOldPrdctSldNum.Attributes.Add("readonly", "readonly"); txtOldPrdctHnd.Attributes.Add("readonly", "readonly"); txtOldPrctSpcl.Attributes.Add("readonly", "readonly"); txtOldPrdctSpclPerc.Attributes.Add("readonly", "readonly"); txtOldPrdctBrnd.Attributes.Add("readonly", "readonly"); txtOldPrdctActv.Attributes.Add("readonly", "readonly"); var db = new DataLinqDataContext(); var Product = (from product in db.Products where (product.Product_Id).Equals(Request.QueryString["EdtPrdctID"]) select product).FirstOrDefault(); txtprdctNmOld.Text = Product.Product_Name; txtOldPrdctPrc.Text = "R" + String.Format("{0:0.00}", Product.Product_Price); txtOldDesrp.InnerText = Product.Product_Description; txtOldPrdctTyp.Text = Product.Product_Type; txtOldPrdctSldNum.Text = Convert.ToString(Product.Product_NumSold); txtOldPrdctHnd.Text = Convert.ToString(Product.Product_OnHand); if (Product.Product_IsSpecial == true) { txtOldPrctSpcl.Checked = true; txtOldPrctSpcl.Text = "Product on Special"; } else { txtOldPrctSpcl.Checked = false; txtOldPrctSpcl.Text = "Product not on Special"; } txtOldPrdctSpclPerc.Text = Convert.ToString(Product.Product_SpclPercantage) + "%"; txtOldPrdctBrnd.Text = Product.Product_Brand; if (Product.Product_IsActive == true) { txtOldPrdctActv.Checked = true; txtOldPrdctActv.Text = "Product is Avtive"; } else { txtOldPrdctActv.Checked = false; txtOldPrdctActv.Text = "Product is not Active"; } }
protected void btnupdate_Click(object sender, EventArgs e) { ProductID = Convert.ToInt32(Request.QueryString["ProductId"]); if (ProductID == 0) { Response.Redirect("ControlSpecials.aspx", false); } else { var db = new DataLinqDataContext(); string todisplay = "<p> Updating of price of product </p>"; Product Pro = (from p in db.Products where p.Product_Id.Equals(ProductID) select p).FirstOrDefault(); int newpercent = Convert.ToInt32(newper.Value); Pro.Product_SpclPercantage = newpercent; int newcostdiff = Convert.ToInt32(Pro.Product_Price * (newpercent / 100)); int totalcost = Convert.ToInt32(Pro.Product_Price - newcostdiff); //if (Cbspecial.Checked==true) //{ // Debug.WriteLine("Checked"); // Pro.Product_IsSpecial = true; //} //else if (Cbspecial.Checked == false) //{ // Pro.Product_IsSpecial = false; //} if (newpercent == 0) { Pro.Product_IsSpecial = false; } else { Pro.Product_IsSpecial = true; } try { db.SubmitChanges(); } catch (Exception exep) { exep.GetBaseException(); } todisplay = todisplay + "New Price:R " + totalcost; singlepro.InnerHtml = todisplay; Response.Redirect("ControlSpecials.aspx", false); } }
protected void Page_Load(object sender, EventArgs e) { //.....................................................................For Displaying Logged-In User's Invoices var db = new DataLinqDataContext(); dynamic InvoicesList = from invoices in db.Invoices //where (invoices.Username).Equals(Session["Username"]) where (invoices.Username).Equals("Eva") //.....checking purpose only select invoices; if (InvoicesList != null) { string strMnDisplay = ""; foreach (Invoice inv in InvoicesList) { string strDisplay = "<div class='payment-details p-30'>"; strDisplay += "<table>"; dynamic ItemsList = from item in db.Items where (inv.Invoice_Id).Equals(item.Invoice_Id) select item; foreach (Item itm in ItemsList) { var Product = (from product in db.Products where (product.Product_Id).Equals(itm.Product_Id) select product).FirstOrDefault(); strDisplay += "<tr>"; strDisplay += "<td class='td-title-1'>" + Product.Product_Name + " X " + itm.Item_Qty + "</td>"; strDisplay += "<td class='td-title-2'>R" + String.Format("{0:0.00}", itm.Item_SellingPrice) + "</td>"; strDisplay += "</tr>"; } strDisplay += "<tr>"; strDisplay += "<td class='order-total'>Order Total</td>"; strDisplay += "<td class='order-total-price'>R" + String.Format("{0:0.00}", inv.Invoice_Total) + "</td>"; strDisplay += "</tr>"; strDisplay += "</table>"; strDisplay += "<button class='submit-btn-1 mt-20 btn-hover-1' type='submit' value='register'>Save</button>"; strDisplay += "</div>"; strMnDisplay += strDisplay; } Invoices.InnerHtml = strMnDisplay; } }
}//.......................................................................................end of pageload protected void btnPlus_Click(object sender, EventArgs e) { int intQty = Convert.ToInt32(lblQty.Text); var db = new DataLinqDataContext(); int getPrdct = (from product in db.Products where (product.Product_Id.Equals(Request.QueryString["AddToShpCrt"])) || (product.Product_Id.Equals(Request.QueryString["AddToWshLst"])) || (product.Product_Id.Equals(Request.QueryString["ProductId"])) select product.Product_OnHand).FirstOrDefault(); if (intQty < getPrdct) { lblQty.Text = (Convert.ToString(intQty + 1)); PrdctQty = Convert.ToInt32(lblQty.Text); } Debug.WriteLine(lblQty.Text); }
protected void Page_Load(object sender, EventArgs e) { var db = new DataLinqDataContext(); var cart = (from Cart c in db.Carts where c.Product_Id.Equals(Request.QueryString["ProductId"]) select c).FirstOrDefault(); var product = (from Product p in db.Products where p.Product_Id.Equals(cart.Product_Id) select p).FirstOrDefault(); if (cart.Quantity != 1) { cart.Quantity -= 1; } db.SubmitChanges(); Response.Redirect("Wishlist.aspx"); }
private void btnDangNhap_Click(object sender, EventArgs e) { string connectionString = "Data Source=" + cboIP.Text.Trim() + ";Initial Catalog= QuanLyChungCu" + ";User ID=" + txtTaiKhoanDB.Text.Trim() + ";Password="******""; DataLinqDataContext context = new DataLinqDataContext(connectionString); try { PropertieConst.connectionString = connectionString; PropertieConst.accountDB = txtTaiKhoanDB.Text.Trim(); PropertieConst.passDB = txtMatKhauDB.Text.Trim(); var userLogin = context.kiemtraDangNhap(PropertieConst.accountDB, PropertieConst.passDB).FirstOrDefault(); PropertieConst.quyen = userLogin.quyen; OnEventConnection(); } catch (Exception ex) { MessageBox.Show("Thông tin kết nối tới cơ sở dữ liệu không chính xác !", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected void editBtn_Click(object sender, EventArgs e) { var db = new DataLinqDataContext(); int productID = int.Parse(prodId.Value); var prodd = (from Product a in db.Products where a.Product_Id.Equals(productID) select a).FirstOrDefault(); var thingtochange = edit.Value; string value = prodEdit1.Value; if (thingtochange.Equals("editName")) { prodd.Product_Name = value; } if (thingtochange.Equals("editPrice")) { prodd.Product_Price = Convert.ToDecimal(value); } if (thingtochange.Equals("editDesc")) { prodd.Product_Description = value; } if (thingtochange.Equals("editType")) { prodd.Product_Type = value; } if (thingtochange.Equals("editImg")) { prodd.Product_Img = value; } if (thingtochange.Equals("editOH")) { prodd.Product_OnHand = int.Parse(value); } if (thingtochange.Equals("editBrand")) { prodd.Product_Brand = value; } db.SubmitChanges(); }
protected void login_Click(object sender, EventArgs e) { var db = new DataLinqDataContext(); dynamic userL = from u in db.Users select u; string display = ""; foreach (User x in userL) { if (x.Email == loginEmail.Value) { if (x.Password == Secrecy.Secrecy.HashPassword(loginPassword.Value)) { Session["Username"] = x.Username; Session["AuthLevel"] = x.UserType; //.........................................Redirects user to Products PAge if (HttpContext.Current.Session["AddListItm"] != null) { Response.Redirect("ProductPage.aspx?ProductId=" + HttpContext.Current.Session["AddListItm"]); } Response.Redirect("index.aspx"); } else { error.Visible = true; display = "<strong>Oh snap!</strong> Username or password was incorrect."; error.InnerHtml = display; } } else { error.Visible = true; display = "<strong>Oh snap!</strong> Username or password was incorrect."; error.InnerHtml = display; } } }
protected void Page_Load(object sender, EventArgs e) { var db = new DataLinqDataContext(); dynamic products = from a in db.Products select a; string displayDelete = ""; string displayEdit = ""; foreach (Product p in products) { if (p.Product_IsActive == true) { displayDelete += "<p>Product ID: " + p.Product_Id + " </p>"; displayDelete += "<p>Product Name: " + p.Product_Name + "</p></br>"; } displayEdit += "<p>Product ID: " + p.Product_Id + " </p>"; displayEdit += "<p>Product Name: " + p.Product_Name + "</p></br>"; } removeProd.InnerHtml = displayDelete; editProd.InnerHtml = displayEdit; }
protected void addProd_Click(object sender, EventArgs e) { var db = new DataLinqDataContext(); dynamic products = from a in db.Products select a; bool isReg = false; if (isReg == false) { Product newProd = new Product { Product_Name = prodName.Value, Product_Price = Convert.ToDecimal(prodPrice.Value), Product_Description = prodDesc.Value, Product_Type = prodType.Value, Product_Img = prodImg.Value, Product_OnHand = int.Parse(prodOnHand.Value), Product_Brand = prodBrand.Value, Product_DateAdded = DateTime.Now, Product_IsActive = true, Product_IsSpecial = false, Product_NumSold = 0, Product_SpclPercantage = 0 }; db.Products.InsertOnSubmit(newProd); try { db.SubmitChanges(); Response.Redirect("AdminHomePage.aspx"); } catch (Exception ex) { ex.GetBaseException(); addResponse.InnerHtml = "<div class=alert alert-danger><strong>Warning!</strong> An error occurred, please try again.</div>"; } } }
protected void Page_Load(object sender, EventArgs e) { var db = new DataLinqDataContext(); string todisplay = "<p> Updating of price of product </p>"; Product Pro = (from p in db.Products where p.Product_Id.Equals(Request.QueryString["ProductId"]) select p).FirstOrDefault(); todisplay = todisplay + "<img src=" + Pro.Product_Img + " alt=''>"; todisplay = todisplay + "<p>" + Pro.Product_Name + "</p>"; todisplay = todisplay + "<p>Current Product price:R " + Pro.Product_Price + "</p>"; todisplay = todisplay + "<p>Current Discount Percentage: " + Pro.Product_SpclPercantage + "</p>"; //if (Pro.Product_IsSpecial == true) //{ // Cbspecial.Checked = true; //} //else //{ // Cbspecial.Checked = false; //} singlepro.InnerHtml = todisplay; }
protected void Page_Load(object sender, EventArgs e) { var db = new DataLinqDataContext(); var wishlist = (from Wishlist w in db.Wishlists where w.Product_Id.Equals(Request.QueryString["ProductId"]) select w).FirstOrDefault(); var newCart = new Cart { Quantity = 1, Product_Id = wishlist.Product_Id, Username = Convert.ToString(Session["Username"]) }; db.Carts.InsertOnSubmit(newCart); db.SubmitChanges(); db.Wishlists.DeleteOnSubmit(wishlist); db.SubmitChanges(); Response.Redirect("Wishlist.aspx"); }
//protected int intNumToShow = 3; protected void Page_Load(object sender, EventArgs e) { var db = new DataLinqDataContext(); //...........................................................................................Product Category List string divCategoryDisplay = ""; dynamic ProductList = from product in db.Products group product by product.Product_Type into productTypeLst select productTypeLst.Key; divCategoryDisplay += " <li class='closed'><a href='CategoryPage.aspx?Category=AllSpecial'>View All Special Products</a></li>"; foreach (string prdctType in ProductList) { divCategoryDisplay += " <li class='closed'><a href='CategoryPage.aspx?Category=" + prdctType + "'>" + prdctType + "</a>"; dynamic ProductItmLst = (from item in db.Products where (item.Product_Type.Equals(prdctType) && (item.Product_IsActive == true)) select item).Take(3); divCategoryDisplay += "<ul>"; divCategoryDisplay += "<li><a href='CategoryPage.aspx?Category=" + prdctType + "'>View All " + prdctType + "</a></li>"; //divCategoryDisplay += "<li><a href='CategoryPage.aspx?CategorySpcl=" + prdctType + "'>View All " + prdctType + " Specials</a></li>"; foreach (Product prdctItm in ProductItmLst) { divCategoryDisplay += "<li><a href='ProductPage.aspx?ProductId=" + prdctItm.Product_Id + "'>" + prdctItm.Product_Name + "</a></li>"; } //divCategoryDisplay += "<li><a href='CategoryPage.aspx?Category="+prdctType+"'>View All "+prdctType+"</a></li>"; divCategoryDisplay += "<li><a href='CategoryPage.aspx?CategorySpcl=" + prdctType + "'>View All " + prdctType + " Specials</a></li>"; divCategoryDisplay += "</ul>"; divCategoryDisplay += "</li>"; } ulCategoryList.InnerHtml = divCategoryDisplay; //.............................................................................................Populate Web page With Image string ImgDisplay = ""; string ImgDisplay2 = ""; //...........................Search value if (strSrch.Equals("")) { strSrch = txtSrch.Value; } strPrcRng = amount.Value;//.........................amount range value int intVal1 = 0; int intVal2 = 0; var ProductImgLst = (from productImg in db.Products where productImg.Product_Type.Equals(Request.QueryString["Category"]) select productImg); //..............................................where price range match for particular category //if (!strPrcRng.Equals("")) //{ // ProductImgLst = (from productImg in db.Products // where (productImg.Product_Type.Equals(Request.QueryString["Category"])) // //&& ((productImg.Product_Price) >= intVal1 && (productImg.Product_Price) <= intVal2) // select productImg); //} //............................................................................View Products by Brand if (Request.QueryString["BrndNm"] != null) { ProductImgLst = from productImg in db.Products where (productImg.Product_Brand.Equals(Request.QueryString["BrndNm"])) select productImg; } //............................................................................Default start Page Image Load if (!ProductImgLst.Any()) { ProductImgLst = (from productImg in db.Products select productImg); //...............................................make price range on default list if (!strPrcRng.Equals("")) { ProductImgLst = (from productImg in db.Products where ((productImg.Product_Price) > intVal1 && (productImg.Product_Price) < intVal2) select productImg); } } //.............................................................................Specials for particular category if ((Request.QueryString["CategorySpcl"]) != null) { //strSrch = ""; ProductImgLst = from productImg in db.Products where ((productImg.Product_Type).Equals(Request.QueryString["CategorySpcl"])) && ((productImg.Product_IsSpecial).Equals(true)) select productImg; } //...................................................................Specials for all products if ((Request.QueryString["Category"]) == "AllSpecial") { //strSrch = ""; ProductImgLst = (from productImg in db.Products where ((productImg.Product_IsSpecial).Equals(true)) select productImg); } //..............................................................Search for product if ((!strSrch.Equals(""))) { ProductImgLst = (from productImg in db.Products where (((productImg.Product_Name).ToLower()).Contains(strSrch.ToLower())) select productImg); } if (HttpContext.Current.Session["PgNum"] == null) { Session["PgNum"] = 9; } if (!strPrcRng.Equals("")) { intVal1 = Convert.ToInt32(strPrcRng.Substring(strPrcRng.IndexOf("R") + 1, strPrcRng.IndexOf("-") - 1)); intVal2 = Convert.ToInt32(strPrcRng.Substring(strPrcRng.IndexOf("-") + 3)); if (ascSort == true) { ProductImgLst = (from productImg in ProductImgLst orderby productImg.Product_Price ascending where ((productImg.Product_IsActive) == true) && ((productImg.Product_Price) >= intVal1 && (productImg.Product_Price) <= intVal2) select productImg).Take(Convert.ToInt16(HttpContext.Current.Session["PgNum"])); } else { ProductImgLst = (from productImg in ProductImgLst orderby productImg.Product_Price descending where ((productImg.Product_IsActive) == true) && ((productImg.Product_Price) >= intVal1 && (productImg.Product_Price) <= intVal2) select productImg).Take(Convert.ToInt16(HttpContext.Current.Session["PgNum"])); } //ProductImgLst = (from productImg in ProductImgLst // where ((productImg.Product_IsActive) == true) // && ((productImg.Product_Price) >= intVal1 && (productImg.Product_Price) <= intVal2) // select productImg).Take(Convert.ToInt16(HttpContext.Current.Session["PgNum"])); } else { if (ascSort == true) { ProductImgLst = (from productImg in ProductImgLst orderby productImg.Product_Price ascending where ((productImg.Product_IsActive) == true) select productImg).Take(Convert.ToInt16(HttpContext.Current.Session["PgNum"])); } else { ProductImgLst = (from productImg in ProductImgLst orderby productImg.Product_Price descending where ((productImg.Product_IsActive) == true) select productImg).Take(Convert.ToInt16(HttpContext.Current.Session["PgNum"])); } //ProductImgLst = (from productImg in ProductImgLst // where ((productImg.Product_IsActive) == true) // select productImg).Take(Convert.ToInt16(HttpContext.Current.Session["PgNum"])); } foreach (Product prdctImg in ProductImgLst) { //...................................................................For GridView Display ImgDisplay += " <div class='col-md-4 col-sm-4 col-xs-12'>"; ImgDisplay += " <div class='product-item'>"; ImgDisplay += " <div class='product-img'>"; ImgDisplay += " <a href=ProductPage.aspx?ProductId=" + prdctImg.Product_Id + ">"; ImgDisplay += " <img src=" + prdctImg.Product_Img + " height=300 width=270 alt=/>"; ImgDisplay += " </a>"; ImgDisplay += " </div>"; ImgDisplay += " <div class='product-info'>"; ImgDisplay += " <h6 class='product-title'>"; ImgDisplay += " <a href=ProductPage.aspx?ProductId=" + prdctImg.Product_Id + " >" + prdctImg.Product_Name + "</a>"; //Session["ProductId"] = prdctImg.Product_Id; ImgDisplay += " </h6>"; ImgDisplay += " <h3 class='pro-price'>R" + String.Format("{0:0.00}", prdctImg.Product_Price) + "</h3>"; ImgDisplay += " <ul class='action-button'>"; ImgDisplay += " <li>"; ImgDisplay += " <a href='ProductPage.aspx?AddToWshLst=" + prdctImg.Product_Id + "' title=Wishlist><i class='zmdi zmdi-favorite'></i></a>"; ImgDisplay += " </li>"; //ImgDisplay += " <li>"; //ImgDisplay += " <a href='#' data-toggle=modal data-target=#productModal title=Quickview id='QckVw' OnServerClick='setProductID("+ prdctImg.Product_Id + ")'><i class='zmdi zmdi-zoom-in'></i></a>"; //ImgDisplay += " <a href='CategoryPage.aspx?s=<%=Session('"+ prdctImg.Product_Id + "')%> data -toggle=modal data-target=#productModal title=Quickview id='QckVw' OnServerClick='setProductID(" + prdctImg.Product_Id + ")'><i class='zmdi zmdi-zoom-in'></i></a>"; //ImgDisplay += " <asp:LinkButton href='#' data-toggle=modal data-target=#productModal title=Quickview id='btnQckVw' runat='server' CommandArgument='"+prdctImg.Product_Id+ "' OnClick='btnQckVw_Click'><i class='zmdi zmdi-zoom-in'></i></asp:LinkButton>"; //ImgDisplay += " </li>"; //ImgDisplay += " <li>"; //ImgDisplay += " <a href=# title=Compare><i class='zmdi zmdi-refresh'></i></a>"; //ImgDisplay += " </li>"; ImgDisplay += " <li>"; ImgDisplay += " <a href='ProductPage.aspx?AddToShpCrt=" + prdctImg.Product_Id + "' title=Add to cart><i class='zmdi zmdi-shopping-cart-plus'></i></a>"; ImgDisplay += " </li>"; ImgDisplay += " </ul>"; ImgDisplay += " </div>"; ImgDisplay += " </div>"; ImgDisplay += " </div>"; //........................................................................For List View Display ImgDisplay2 += " <div class='col-md-12'>"; ImgDisplay2 += " <div class='shop-list product-item'>"; ImgDisplay2 += " <div class='product-img'>"; ImgDisplay2 += " <a href=ProductPage.aspx?ProductId=" + prdctImg.Product_Id + ">"; ImgDisplay2 += " <img src=" + prdctImg.Product_Img + " height=300 width=270 alt=/>"; ImgDisplay2 += " </a>"; ImgDisplay2 += " </div>"; ImgDisplay2 += " <div class='clearfix'>"; ImgDisplay2 += " <h6 class='product-title'>"; ImgDisplay2 += " <a href=ProductPage.aspx?ProductId=" + prdctImg.Product_Id + " >" + prdctImg.Product_Name + "</a>"; ImgDisplay2 += " </h6>"; ImgDisplay2 += "<h6 class='brand-name mb-30'>" + prdctImg.Product_Brand + "</h6>"; ImgDisplay2 += " <h3 class='pro-price'>R" + String.Format("{0:0.00}", prdctImg.Product_Price) + "</h3>"; ImgDisplay2 += "<p>" + prdctImg.Product_Description + "</p>"; ImgDisplay2 += " <ul class='action-button'>"; ImgDisplay2 += " <li>"; ImgDisplay2 += " <a href=# title=Wishlist><i class='zmdi zmdi-favorite'></i></a>"; ImgDisplay2 += " </li>"; //ImgDisplay += " <li>"; //ImgDisplay += " <a href='#' data-toggle=modal data-target=#productModal title=Quickview id='QckVw' OnServerClick='setProductID("+ prdctImg.Product_Id + ")'><i class='zmdi zmdi-zoom-in'></i></a>"; //ImgDisplay += " <a href='CategoryPage.aspx?s=<%=Session('"+ prdctImg.Product_Id + "')%> data -toggle=modal data-target=#productModal title=Quickview id='QckVw' OnServerClick='setProductID(" + prdctImg.Product_Id + ")'><i class='zmdi zmdi-zoom-in'></i></a>"; //ImgDisplay += " <asp:LinkButton href='#' data-toggle=modal data-target=#productModal title=Quickview id='btnQckVw' runat='server' CommandArgument='"+prdctImg.Product_Id+ "' OnClick='btnQckVw_Click'><i class='zmdi zmdi-zoom-in'></i></asp:LinkButton>"; //ImgDisplay += " </li>"; //ImgDisplay += " <li>"; //ImgDisplay += " <a href=# title=Compare><i class='zmdi zmdi-refresh'></i></a>"; //ImgDisplay += " </li>"; ImgDisplay2 += " <li>"; ImgDisplay2 += " <a href=# title=Add to cart><i class='zmdi zmdi-shopping-cart-plus'></i></a>"; ImgDisplay2 += " </li>"; ImgDisplay2 += " </ul>"; ImgDisplay2 += " </div>"; ImgDisplay2 += " </div>"; ImgDisplay2 += " </div>"; } listImg.InnerHtml = ImgDisplay2; gridImg.InnerHtml = ImgDisplay; //...........................................................................................Populate Recent Products dynamic RecentProductList = (from product in db.Products where (product.Product_IsActive == true) orderby product.Product_DateAdded descending select product).Take(3); string strDisplayRcnt = "<h6 class='widget-title border-left mb-20'>recent products</h6>"; foreach (Product prdct in RecentProductList) { strDisplayRcnt += " <div class='product-item'>"; strDisplayRcnt += " <div class='product-img'>"; strDisplayRcnt += " <a href='ProductPage.aspx?ProductId=" + prdct.Product_Id + "'>"; strDisplayRcnt += " <img src='" + prdct.Product_Img + "' alt='' width=90 height=80/>"; strDisplayRcnt += " </a>"; strDisplayRcnt += " </div>"; strDisplayRcnt += " <div class='product-info'>"; strDisplayRcnt += " <h6 class='product-title'>"; strDisplayRcnt += " <a href='ProductPage.aspx?ProductId=" + prdct.Product_Id + "'>" + prdct.Product_Name + "</a>"; strDisplayRcnt += " </h6>"; strDisplayRcnt += " <h3 class='pro-price'>R" + String.Format("{0:0.00}", prdct.Product_Price) + "</h3>"; strDisplayRcnt += " </div>"; strDisplayRcnt += " </div>"; } WidgetProduct.InnerHtml = strDisplayRcnt; strSrch = ""; strPrcRng = ""; }//..........................................................end of page load
protected void btnUpdate_Click(object sender, EventArgs e) { var db = new DataLinqDataContext(); var Product = (from product in db.Products where (product.Product_Id).Equals(prdctID) select product).FirstOrDefault(); if (!((txtNwPrdctNm.Text).Trim()).Equals("")) { Product.Product_Name = txtNwPrdctNm.Text; } if (!((txtNwPrdctPrc.Text).Trim()).Equals("")) { Product.Product_Price = Convert.ToDecimal(txtNwPrdctPrc.Text); } if (!((txtNwDesrp.InnerText).Trim()).Equals("")) { Product.Product_Description = txtNwDesrp.InnerText; } if (!((txtNwPrdctTyp.Text).Trim()).Equals("")) { Product.Product_Type = txtNwPrdctTyp.Text; } if (!((txtNwPrdctSldNum.Text).Trim()).Equals("")) { Product.Product_NumSold = Convert.ToInt32(txtNwPrdctSldNum.Text); } if (!((txtnwPrdctHnd.Text).Trim()).Equals("")) { Product.Product_OnHand = Convert.ToInt32(txtnwPrdctHnd.Text); } if (txtNwPrctSpcl.Checked == true) { Product.Product_IsSpecial = true; } else { Product.Product_IsSpecial = false; } if (!((txtNwPrdctSpclPerc.Text).Trim()).Equals("")) { Product.Product_SpclPercantage = (float)Convert.ToDouble(txtNwPrdctSpclPerc.Text); } if (!((txtNwPrdctBrnd.Text).Trim()).Equals("")) { Product.Product_Brand = txtNwPrdctBrnd.Text; } if (txtNwPrdctActv.Checked == true) { Product.Product_IsActive = true; } else { Product.Product_IsActive = true; } try { db.SubmitChanges(); }catch (Exception ex) { ex.GetBaseException(); } }
protected void Page_Load(object sender, EventArgs e) { var db = new DataLinqDataContext(); var regUsers = from a in db.Users select a; int day1 = 0; int day2 = 0; int day3 = 0; int day4 = 0; int day5 = 0; int day6 = 0; int day7 = 0; int numRegs = (from User b in db.Users select b).Count(); numReg.InnerHtml = "<h2>" + numRegs + "</h2>"; foreach (User u in regUsers) { if (u.DateRegistered == DateTime.Now.Date) { day1++; } if (u.DateRegistered == DateTime.Now.AddDays(-1).Date) { day2++; } if (u.DateRegistered == DateTime.Now.AddDays(-2).Date) { day3++; } if (u.DateRegistered == DateTime.Now.AddDays(-3).Date) { day4++; } if (u.DateRegistered == DateTime.Now.AddDays(-4).Date) { day5++; } if (u.DateRegistered == DateTime.Now.AddDays(-5).Date) { day6++; } if (u.DateRegistered == DateTime.Now.AddDays(-6).Date) { day7++; } } string display = ""; display += "<h3>" + DateTime.Now.Date + "</h3><br>"; display += "<h4>" + day1 + "</h4><br><hr>"; display += "<h3>" + DateTime.Now.AddDays(-1).Date + "</h3><br>"; display += "<h4>" + day2 + "</h4><br><hr>"; display += "<h3>" + DateTime.Now.AddDays(-2).Date + "</h3><br>"; display += "<h4>" + day3 + "</h4><br><hr>"; display += "<h3>" + DateTime.Now.AddDays(-3).Date + "</h3><br>"; display += "<h4>" + day4 + "</h4><br><hr>"; display += "<h3>" + DateTime.Now.AddDays(-4).Date + "</h3><br>"; display += "<h4>" + day5 + "</h4><br><hr>"; display += "<h3>" + DateTime.Now.AddDays(-5).Date + "</h3><br>"; display += "<h4>" + day6 + "</h4><br><hr>"; display += "<h3>" + DateTime.Now.AddDays(-6).Date + "</h3><br>"; display += "<h4>" + day7 + "</h4>"; numRegGraph.InnerHtml = display; }
protected void final_Click(object sender, EventArgs e) { var db = new DataLinqDataContext(); var cpu = (from Product b in db.Products where b.Product_Id.Equals(Request.QueryString["cpu"]) select b).FirstOrDefault(); Cart aa = new Cart { Product_Id = cpu.Product_Id, Quantity = 1, Username = Convert.ToString(Session["Username"]) }; db.Carts.InsertOnSubmit(aa); db.SubmitChanges(); var mobo = (from Product c in db.Products where c.Product_Id.Equals(Request.QueryString["mobo"]) select c).FirstOrDefault(); Cart bb = new Cart { Product_Id = mobo.Product_Id, Quantity = 1, Username = Convert.ToString(Session["Username"]) }; db.Carts.InsertOnSubmit(bb); db.SubmitChanges(); var cool = (from Product d in db.Products where d.Product_Id.Equals(Request.QueryString["cool"]) select d).FirstOrDefault(); Cart cc = new Cart { Product_Id = cool.Product_Id, Quantity = 1, Username = Convert.ToString(Session["Username"]) }; db.Carts.InsertOnSubmit(cc); db.SubmitChanges(); var gpu = (from Product f in db.Products where f.Product_Id.Equals(Request.QueryString["gpu"]) select f).FirstOrDefault(); Cart dd = new Cart { Product_Id = gpu.Product_Id, Quantity = 1, Username = Convert.ToString(Session["Username"]) }; db.Carts.InsertOnSubmit(dd); db.SubmitChanges(); var mem = (from Product g in db.Products where g.Product_Id.Equals(Request.QueryString["mem"]) select g).FirstOrDefault(); Cart ff = new Cart { Product_Id = mem.Product_Id, Quantity = 1, Username = Convert.ToString(Session["Username"]) }; db.Carts.InsertOnSubmit(ff); db.SubmitChanges(); var hard = (from Product h in db.Products where h.Product_Id.Equals(Request.QueryString["hard"]) select h).FirstOrDefault(); Cart gg = new Cart { Product_Id = hard.Product_Id, Quantity = 1, Username = Convert.ToString(Session["Username"]) }; db.Carts.InsertOnSubmit(gg); db.SubmitChanges(); var psu = (from Product i in db.Products where i.Product_Id.Equals(Request.QueryString["psu"]) select i).FirstOrDefault(); Cart pp = new Cart { Product_Id = psu.Product_Id, Quantity = 1, Username = Convert.ToString(Session["Username"]) }; db.Carts.InsertOnSubmit(pp); db.SubmitChanges(); var casee = (from Product j in db.Products where j.Product_Id.Equals(Request.QueryString["case"]) select j).FirstOrDefault(); Cart hh = new Cart { Product_Id = casee.Product_Id, Quantity = 1, Username = Convert.ToString(Session["Username"]) }; db.Carts.InsertOnSubmit(hh); db.SubmitChanges(); Response.Redirect("Index.aspx"); }
public fQuanLyDichVuCanHo() { InitializeComponent(); context = new DataLinqDataContext(PropertieConst.connectionString); LoadData(); }
public fTraCuuPhiSinhHoat() { InitializeComponent(); context = new DataLinqDataContext(PropertieConst.connectionString); LoadData(); }
protected void Page_Load(object sender, EventArgs e) { var db = new DataLinqDataContext(); var cpu = (from Product b in db.Products where b.Product_Id.Equals(Request.QueryString["cpu"]) select b).FirstOrDefault(); var mobo = (from Product c in db.Products where c.Product_Id.Equals(Request.QueryString["mobo"]) select c).FirstOrDefault(); var cool = (from Product d in db.Products where d.Product_Id.Equals(Request.QueryString["cool"]) select d).FirstOrDefault(); var gpu = (from Product f in db.Products where f.Product_Id.Equals(Request.QueryString["gpu"]) select f).FirstOrDefault(); var mem = (from Product g in db.Products where g.Product_Id.Equals(Request.QueryString["mem"]) select g).FirstOrDefault(); var hard = (from Product h in db.Products where h.Product_Id.Equals(Request.QueryString["hard"]) select h).FirstOrDefault(); var psu = (from Product i in db.Products where i.Product_Id.Equals(Request.QueryString["psu"]) select i).FirstOrDefault(); var casee = (from Product j in db.Products where j.Product_Id.Equals(Request.QueryString["case"]) select j).FirstOrDefault(); string display = ""; display += "<table class=text-center>"; display += "<thead>"; display += "<tr>"; display += "<th class=product-thumbnail>product</th>"; display += "<th class=product-price>price</th>"; display += "</tr>"; display += "</thead>"; display += "<tbody>"; display += "<tr>"; display += "<td class=\"product-thumbnail\">"; display += "<div class=\"pro-thumbnail-img\">"; display += "<img src=" + cpu.Product_Img + " alt=>"; display += "</div>"; display += "<div class=\"pro-thumbnail-info text-left\">"; display += "<h6 class=\"product-title-2\">"; display += "<a target=\"_blank\" rel=\"noopener noreferrer\" href=ProductPage.aspx?ProductId=" + cpu.Product_Id + ">" + cpu.Product_Name + "</a>"; display += "</h6>"; display += "<p>Brand: " + cpu.Product_Brand + "</p>"; display += "</div>"; display += "</td>"; display += "<td class=\"product-price\">" + cpu.Product_Price + "</td>"; display += "<tbody>"; display += "<tr>"; display += "<td class=\"product-thumbnail\">"; display += "<div class=\"pro-thumbnail-img\">"; display += "<img src=" + mobo.Product_Img + " alt=>"; display += "</div>"; display += "<div class=\"pro-thumbnail-info text-left\">"; display += "<h6 class=\"product-title-2\">"; display += "<a target=\"_blank\" rel=\"noopener noreferrer\" href=ProductPage.aspx?ProductId=" + mobo.Product_Id + ">" + mobo.Product_Name + "</a>"; display += "</h6>"; display += "<p>Brand: " + mobo.Product_Brand + "</p>"; display += "</div>"; display += "</td>"; display += "<td class=\"product-price\">" + mobo.Product_Price + "</td>"; display += "<tbody>"; display += "<tr>"; display += "<td class=\"product-thumbnail\">"; display += "<div class=\"pro-thumbnail-img\">"; display += "<img src=" + cool.Product_Img + " alt=>"; display += "</div>"; display += "<div class=\"pro-thumbnail-info text-left\">"; display += "<h6 class=\"product-title-2\">"; display += "<a target=\"_blank\" rel=\"noopener noreferrer\" href=ProductPage.aspx?ProductId=" + cool.Product_Id + ">" + cool.Product_Name + "</a>"; display += "</h6>"; display += "<p>Brand: " + cool.Product_Brand + "</p>"; display += "</div>"; display += "</td>"; display += "<td class=\"product-price\">" + cool.Product_Price + "</td>"; display += "<tbody>"; display += "<tr>"; display += "<td class=\"product-thumbnail\">"; display += "<div class=\"pro-thumbnail-img\">"; display += "<img src=" + gpu.Product_Img + " alt=>"; display += "</div>"; display += "<div class=\"pro-thumbnail-info text-left\">"; display += "<h6 class=\"product-title-2\">"; display += "<a target=\"_blank\" rel=\"noopener noreferrer\" href=ProductPage.aspx?ProductId=" + gpu.Product_Id + ">" + gpu.Product_Name + "</a>"; display += "</h6>"; display += "<p>Brand: " + gpu.Product_Brand + "</p>"; display += "</div>"; display += "</td>"; display += "<td class=\"product-price\">" + gpu.Product_Price + "</td>"; display += "<tbody>"; display += "<tr>"; display += "<td class=\"product-thumbnail\">"; display += "<div class=\"pro-thumbnail-img\">"; display += "<img src=" + mem.Product_Img + " alt=>"; display += "</div>"; display += "<div class=\"pro-thumbnail-info text-left\">"; display += "<h6 class=\"product-title-2\">"; display += "<a target=\"_blank\" rel=\"noopener noreferrer\" href=ProductPage.aspx?ProductId=" + mem.Product_Id + ">" + mem.Product_Name + "</a>"; display += "</h6>"; display += "<p>Brand: " + mem.Product_Brand + "</p>"; display += "</div>"; display += "</td>"; display += "<td class=\"product-price\">" + mem.Product_Price + "</td>"; display += "<tbody>"; display += "<tr>"; display += "<td class=\"product-thumbnail\">"; display += "<div class=\"pro-thumbnail-img\">"; display += "<img src=" + hard.Product_Img + " alt=>"; display += "</div>"; display += "<div class=\"pro-thumbnail-info text-left\">"; display += "<h6 class=\"product-title-2\">"; display += "<a target=\"_blank\" rel=\"noopener noreferrer\" href=ProductPage.aspx?ProductId=" + hard.Product_Id + ">" + hard.Product_Name + "</a>"; display += "</h6>"; display += "<p>Brand: " + hard.Product_Brand + "</p>"; display += "</div>"; display += "</td>"; display += "<td class=\"product-price\">" + hard.Product_Price + "</td>"; display += "<tr>"; display += "<td class=\"product-thumbnail\">"; display += "<div class=\"pro-thumbnail-img\">"; display += "<img src=" + psu.Product_Img + " alt=>"; display += "</div>"; display += "<div class=\"pro-thumbnail-info text-left\">"; display += "<h6 class=\"product-title-2\">"; display += "<a target=\"_blank\" rel=\"noopener noreferrer\" href=ProductPage.aspx?ProductId=" + psu.Product_Id + ">" + psu.Product_Name + "</a>"; display += "</h6>"; display += "<p>Brand: " + psu.Product_Brand + "</p>"; display += "</div>"; display += "</td>"; display += "<td class=\"product-price\">" + psu.Product_Price + "</td>"; display += "<tr>"; display += "<td class=\"product-thumbnail\">"; display += "<div class=\"pro-thumbnail-img\">"; display += "<img src=" + casee.Product_Img + " alt=>"; display += "</div>"; display += "<div class=\"pro-thumbnail-info text-left\">"; display += "<h6 class=\"product-title-2\">"; display += "<a target=\"_blank\" rel=\"noopener noreferrer\" href=ProductPage.aspx?ProductId=" + casee.Product_Id + ">" + casee.Product_Name + "</a>"; display += "</h6>"; display += "<p>Brand: " + casee.Product_Brand + "</p>"; display += "</div>"; display += "</td>"; display += "<td class=\"product-price\">" + casee.Product_Price + "</td>"; display += "</tr>"; display += "</tbody>"; display += "</table>"; stuff.InnerHtml = display; }
protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.Session["Username"] != null) { ifloggedin.Visible = true; if ((String)HttpContext.Current.Session["AuthLevel"] == "Admin") { myadminaccountlink.Visible = true; footaccAdmin.Visible = true; } if ((String)HttpContext.Current.Session["AuthLevel"] == "User") { myuseraccountlink.Visible = true; footaccuser.Visible = true; } loginlink.Visible = false; logoutlink.Visible = true; } //......................................................Show number of items in whishlist if (Session["username"] != null) { var db = new DataLinqDataContext(); var list = from w in db.Wishlists where w.Username.Equals(Session["username"]) select w; int tot = 0; foreach (Wishlist w in list) { ++tot; } wishlist.InnerHtml = " <i class='zmdi zmdi-favorite'></i>" + "Wish List(" + Convert.ToString(tot) + ")"; wishlist.Visible = true; } //......................................................Shopping cart preview if (HttpContext.Current.Session["Username"] != null) { string DspCart = ""; var db = new DataLinqDataContext(); dynamic UserCart = from cart in db.Carts where ((cart.Username).Equals(HttpContext.Current.Session["Username"])) select cart; int itmCnt = (from cart in db.Carts where ((cart.Username).Equals(HttpContext.Current.Session["Username"])) select cart).Count(); DspCart += "<div class='total-cart-in'>"; DspCart += "<div class='cart-toggler'>"; DspCart += "<a href='Wishlist.aspx'>"; DspCart += "<span class='cart-quantity'>" + itmCnt + "</span><br>"; DspCart += "<span class='cart-icon'>"; DspCart += "<i class='zmdi zmdi-shopping-cart-plus'></i>"; DspCart += "</span>"; DspCart += "</a>"; DspCart += "</div>"; DspCart += "<ul>"; DspCart += "<li>"; DspCart += "<div class='top-cart-inner your-cart'>"; DspCart += "<h5 class='text-capitalize'>" + HttpContext.Current.Session["Username"] + "'s Cart</h5>"; DspCart += "</div>"; DspCart += "</li>"; DspCart += "<li>"; DspCart += "<div class='total-cart-pro'>"; Decimal Total = 0; if (UserCart != null) { foreach (Cart crt in UserCart) { var UserProduct = (from product in db.Products where (crt.Product_Id).Equals(product.Product_Id) select product).FirstOrDefault(); DspCart += "<div class='single-cart clearfix'>"; DspCart += "<div class='cart-img f-left'>"; DspCart += "<a href='ProductPage.aspx?ProductId=" + crt.Product_Id + "'>"; DspCart += "<img src='" + UserProduct.Product_Img + "' alt='Cart Product' width=100 height=111 />"; DspCart += "</a>"; DspCart += "<div class='del-icon'>"; DspCart += "<a href='ProductPage.aspx?DelFrmShpCrt=" + crt.Product_Id + "'>"; DspCart += "<i class='zmdi zmdi-close'></i>"; DspCart += "</a>"; DspCart += "</div>"; DspCart += "</div>"; DspCart += "<div class='cart-info f-left'>"; DspCart += "<h6 class='text-capitalize'>"; DspCart += "<a href='ProductPage.aspx?ProductId=" + crt.Product_Id + "'>" + UserProduct.Product_Name + "</a>"; DspCart += "</h6>"; DspCart += "<p>"; DspCart += "<span>Brand <strong>:</strong></span>" + UserProduct.Product_Brand; DspCart += "</p>"; DspCart += "<p>"; if (UserProduct.Product_IsSpecial == true) { decimal prc = ((UserProduct.Product_Price) - Convert.ToDecimal((UserProduct.Product_Price) * Convert.ToDecimal(UserProduct.Product_SpclPercantage / 100))); Total += ((crt.Quantity) * prc); DspCart += "<span>Price <strong>:</strong></span>R " + String.Format("{0:0.00}", prc); } else { Decimal prc2 = UserProduct.Product_Price; Total += ((crt.Quantity) * prc2); DspCart += "<span>Price <strong>:</strong></span>R " + String.Format("{0:0.00}", prc2); } DspCart += "</p>"; DspCart += "<p>"; DspCart += "<span>Quantity <strong>:</strong></span>" + crt.Quantity; DspCart += "</p>"; DspCart += "</div>"; DspCart += "</div>"; }//...............................end of forloop DspCart += "</div>"; DspCart += "</li>"; DspCart += "<li>"; DspCart += "<div class='top-cart-inner subtotal'>"; DspCart += "<h4 class='text-uppercase g-font-2'>Total ="; DspCart += "<span>R " + String.Format("{0:0.00}", Total) + "</span>"; DspCart += "</h4>"; DspCart += "</div>"; DspCart += "</li>"; DspCart += "<li>"; DspCart += "<div class='top-cart-inner view-cart'>"; DspCart += "<h4 class='text-uppercase'>"; DspCart += "<a href='Wishlist.aspx'>View cart</a>"; DspCart += "</h4>"; DspCart += "</div>"; DspCart += "</li>"; DspCart += "</ul>"; }//..................................................end of if PrvwCart.InnerHtml = DspCart; } }