Exemplo n.º 1
0
        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();
                }
            }
        }
Exemplo n.º 2
0
        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";
            }
        }