private void searchByCategoy(string selectedCategory) { using (WebDL.Team2_BookDBEntities context = new WebDL.Team2_BookDBEntities()) { List <WebDL.category> cats = context.categories.ToList(); var data = from p in context.products where p.category.categoryName == selectedCategory select p; DataList1.DataSource = data.ToList(); DataList1.DataBind(); } }
private void searchByBookName(string bookName) { using (WebDL.Team2_BookDBEntities context = new WebDL.Team2_BookDBEntities()) { List <WebDL.category> cats = context.categories.ToList(); var data = from p in context.products where p.productName == bookName select p; List <product> products = data.ToList(); DataList1.DataSource = products; DataList1.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { using (WebDL.Team2_BookDBEntities cntx = new WebDL.Team2_BookDBEntities()) { string loginUserName = Session["userName"].ToString(); var editUser = cntx.users.Where(a => a.userName.Equals(loginUserName)).FirstOrDefault(); if (editUser != null) { txtUserName.Text = editUser.userName; editUser.roleID = 2; txtPassword.Text = editUser.userPassword; txtEmail.Text = editUser.userEmail; txtPhoneNo.Text = Convert.ToString(editUser.userPhone); txtAddress.Text = editUser.userAddress; txtDesc.Text = editUser.userDescription; } } }
private Table loadPaymentTable() { using (WebDL.Team2_BookDBEntities bke = new WebDL.Team2_BookDBEntities()) { var data = from sc in bke.shoppingCarts where sc.userID == userId select sc; List <shoppingCart> scs = data.ToList(); TableRow headerRow = new TableRow(); TableCell Name = new TableCell(); TableCell Desc = new TableCell(); TableCell price = new TableCell(); TableCell Quantiy = new TableCell(); Name.Text = "Name"; Desc.Text = "Description"; price.Text = "Price"; Quantiy.Text = "Quantiy"; headerRow.Cells.Add(Name); headerRow.Cells.Add(Desc); headerRow.Cells.Add(price); headerRow.Cells.Add(Quantiy); t.Rows.Add(headerRow); foreach (shoppingCart s in scs) { TableRow row = new TableRow(); TableCell c1 = new TableCell(); c1.Text = s.product.productName; TableCell c2 = new TableCell(); c2.Text = s.product.productDescription; TableCell c3 = new TableCell(); c3.Text = s.product.productPrice.ToString(); TableCell c4 = new TableCell(); c4.Text = s.quantity.ToString(); row.Cells.Add(c1); row.Cells.Add(c2); row.Cells.Add(c3); row.Cells.Add(c4); t.Rows.Add(row); } } return(t); }
private void createPaymentRecord(ArrayList alOrderDetailID) { using (WebDL.Team2_BookDBEntities bke = new WebDL.Team2_BookDBEntities()) { payment addPayment = new payment(); for (int i = 0; i < alOrderDetailID.Count; i++) { addPayment.userID = userId; addPayment.ordersDetailID = Convert.ToInt32(alOrderDetailID[i]); addPayment.paymentStatus = "pending"; addPayment.paymentAmount = Convert.ToDouble(lbTotal.Text); addPayment.paymentDescription = ""; addPayment.paymentMode = rblPaymentMode.SelectedValue.ToString(); addPayment.paymentDate = DateTime.Now.Date; bke.payments.Add(addPayment); bke.SaveChanges(); } } }
protected void btnAddToCart_Click(object sender, EventArgs e) { Button btn = (Button)sender; string productName = btn.CssClass; using (WebDL.Team2_BookDBEntities context = new WebDL.Team2_BookDBEntities()) { string userNameFromSession = Session["userName"].ToString(); var data = from p in context.products where p.productName == productName select p; var data2 = from u in context.users where u.userName == userNameFromSession select u; WebDL.user userGetFromSession = data2.First(); WebDL.product pToBeAdded = data.First(); WebDL.shoppingCart sc = new WebDL.shoppingCart(); sc.product = pToBeAdded; sc.quantity = 1; sc.userID = userGetFromSession.userID; sc.shoppingCartExpiredDate = DateTime.Now.Date; context.shoppingCarts.Add(sc); context.SaveChanges(); lbMsg.Text = "product: " + productName + " is added to shopping cart"; } }