Ejemplo n.º 1
0
        public static List <cart_data> fill_page()
        {  // this class will fetch all the product data from class to home page
            PurchaseModel   model        = new PurchaseModel();
            ProductModel    productmodel = new ProductModel();
            string          userId       = Convert.ToString(HttpContext.Current.Session["Userid"]);
            List <Purchase> purchases    = new List <Purchase>();

            purchases = model.get_ordersinCart(userId);

            List <cart_data> info = new List <cart_data>();


            foreach (Purchase purchase in purchases)
            {
                cart_data cart    = new cart_data();
                Product   product = productmodel.get_product_ef(purchase.ProductID);
                cart.image          = product.Image;
                cart.name           = product.Name;
                cart.price          = product.Price;
                cart.avail_quantity = product.AvailableQuantity;
                cart.quantity       = purchase.Quantity;
                cart.purchaseid     = purchase.ID;
                cart.productid      = product.ID;
                info.Add(cart);
            }



            return(info);
        }
Ejemplo n.º 2
0
        protected void createBtn_Click(object sender, EventArgs e)
        {
            int customerid = Convert.ToInt32(HttpContext.Current.Session["customerid"]);

            if (customerid != 0)
            {
                OrderModel db = new OrderModel();

                orders order = new orders();

                order.full_name       = FullName.Text;
                order.email           = email.Text;
                order.contact_num     = Convert.ToInt64(ContactNum.Text);
                order.current_address = address.Text;

                db.update_userinfo(customerid, order);
            }
            else
            {
                if (validation())
                {
                    OrderModel db         = new OrderModel();
                    string     userid     = Convert.ToString(HttpContext.Current.Session["userid"]);
                    orders     order      = new orders();
                    DateTime   date_added = DateTime.Now;
                    order.full_name             = FullName.Text;
                    order.email                 = email.Text;
                    order.contact_num           = Convert.ToInt64(ContactNum.Text);
                    order.current_address       = address.Text;
                    order.bank_code             = Convert.ToInt64(code.Text);
                    order.transection_date_time = datetime.Text;
                    order.total_price           = Convert.ToInt32(HttpContext.Current.Session["total_price"]);
                    order.User_ID               = userid;
                    order.Order_Date            = Convert.ToString(date_added);
                    order.status                = "Pending";
                    db.save_order(order);

                    int order_id = db.get_order(userid);

                    PurchaseModel   model     = new PurchaseModel();
                    List <Purchase> purchases = new List <Purchase>();
                    purchases = model.get_ordersinCart(userid);

                    foreach (Purchase purchase in purchases)
                    {
                        ordered_items items = new ordered_items();
                        items.product_id = purchase.ProductID;
                        items.quantity   = purchase.Quantity;
                        items.ordersID   = order_id;

                        db.save_order_items(items);
                    }

                    model.delete_purchase_by_userid(userid);
                    Response.Redirect("order_success.aspx");
                }
            }
        }
Ejemplo n.º 3
0
        private void GetPurchasesInCart(string userId)
        {
            PurchaseModel model    = new PurchaseModel();
            double        subTotal = 0;

            //generate html for each element in the purchaselist
            List <Purchase> purchaselist = model.get_ordersinCart(userId);
            //CreateShopTable(purchaselist, out subTotal);

            //add totals to the page
            double totalAmount = subTotal;

            //display values on page
        }