示例#1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            // check count of product in user cart.
            //if count !=0 =>> insert order then select the last order_id added then update the order_id = that id instead of null
            HttpCookie cookie = Request.Cookies["MyCookie"];

            if (cookie != null)
            {
                int User_id = int.Parse(cookie["userId"].ToString());

                //int User_id = 1; // get by login session.


                DataTable dtC = Order.getMyCartProduct_Count(User_id);
                int       myCartProduct_Count = int.Parse(dtC.Rows[0][0].ToString());
                if (myCartProduct_Count != 0)
                {
                    DataTable       d  = Carts.SelectByUserId(User_id);
                    int             id = int.Parse(d.Rows[d.Rows.Count - 1]["Cart_Id"].ToString());
                    Order_Attripute o  = new Order_Attripute {
                        Address = "aaa", Cart_Id = id, Date = new Date {
                            Day = DateTime.Now.Day, Month = DateTime.Now.Month, Year = DateTime.Now.Year
                        }, Rate = 1, State = 1, User_Id = User_id
                    };
                    Order.Insert(o);


                    DataTable dt       = Order.getLastOrder_Id();
                    int       order_id = int.Parse(dt.Rows[0][0].ToString());
                    Order.UpdateCart(order_id);

                    Response.Redirect("OrderPageNew.aspx");
                }
                else
                {
                    Response.Redirect("Home.aspx");
                }
            }

            else
            {
                Response.Redirect("LogIn.aspx");
            }
        }
示例#2
0
        public static int Update(Order_Attripute o, int id)
        {
            string state = $"Update Orders set O_State = {o.State}, Address = {o.Address}, O_Date = {o.Date}, Rate = {o.Rate}, Cart_Id = {o.Cart_Id}, User_Id = {o.User_Id}, Driv_Id = {o.Driv_Id} where O_Id = {id}";

            return(Connection.ExecuteNonQuery(state));
        }
示例#3
0
        public static int Insert(Order_Attripute o)
        {
            string state = $"insert into Orders (O_State, Address, O_Date, Rate, Cart_Id, User_Id) values ('{o.State}', '{o.Address}', '{o.Date}', '{o.Rate}', '{o.Cart_Id}', '{o.User_Id}')";

            return(Connection.ExecuteNonQuery(state));
        }