Ejemplo n.º 1
0
        /// <summary>
        /// 根据条件查询订单信息
        /// </summary>
        /// <param name="con"></param>
        /// <returns></returns>
        public List <Order_Table> GetOrderTableByConn(string attr, string con)
        {
            List <Order_Table> list  = new List <Order_Table> ();
            string             attrs = "@" + attr;
            SqlDataReader      dr    = DBHerlper.ExecuteReader(
                "Select * from Order_Table where " + attr + "=" + attrs,
                CommandType.Text, new SqlParameter[] {
                new SqlParameter(attrs, con)
            });

            if (dr.Read())
            {
                Order_Table obj = new Order_Table()
                {
                    O_id         = Convert.ToInt32(dr["O_id"]),
                    OState_id    = (int)dr["OState_id"],
                    O_DateTime   = (DateTime)dr["O_DateTime"],
                    E_id         = (int)dr["E_id"],
                    O_DealWay    = dr["O_DealWay"].ToString(),
                    O_LeaveWords = dr["O_LeaveWords"].ToString(),
                    O_Remark     = dr["O_Remark"].ToString(),
                    P_id         = (int)dr["P_id"],
                    U_id         = (int)dr["U_id"]
                };
                list.Add(obj);
            }
            dr.Close();
            return(list);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据条件查询订单信息并且进行分页
        /// </summary>
        /// <param name="id">用户ID</param>
        /// <param name="pageNo">当前页(用户选中的页数)</param>
        /// <param name="pageSize">显示数据</param>
        /// <returns></returns>
        public List <Order_Table> GetOrderTableByConn_Page(int id, int pageNo, int pageSize)
        {
            List <Order_Table> list = new List <Order_Table>();
            SqlDataReader      dr   = DBHerlper.ExecuteReader(
                "proc_OrderPage",
                CommandType.Text, new SqlParameter[] {
                new SqlParameter("@U_id", id),
                new SqlParameter("@PageNo", pageNo),
                new SqlParameter("@PageSize", pageSize)
            });

            if (dr.Read())
            {
                Order_Table obj = new Order_Table()
                {
                    O_id         = Convert.ToInt32(dr["O_id"]),
                    OState_id    = (int)dr["OState_id"],
                    O_DateTime   = (DateTime)dr["O_DateTime"],
                    E_id         = (int)dr["E_id"],
                    O_DealWay    = dr["O_DealWay"].ToString(),
                    O_LeaveWords = dr["O_LeaveWords"].ToString(),
                    O_Remark     = dr["O_Remark"].ToString(),
                    P_id         = (int)dr["P_id"],
                    U_id         = (int)dr["U_id"]
                };
                list.Add(obj);
            }
            dr.Close();
            return(list);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取全部的订单
        /// </summary>
        /// <returns></returns>
        public List <Order_Table> GetOrderTableAll()
        {
            List <Order_Table> list = new List <Order_Table>();
            SqlDataReader      dr   = DBHerlper.ExecuteReader(GetSqlString("Select"),
                                                              CommandType.StoredProcedure);

            while (dr.Read())
            {
                Order_Table obj = new Order_Table()
                {
                    O_id         = Convert.ToInt32(dr["O_id"]),
                    OState_id    = (int)dr["OState_id"],
                    O_DateTime   = (DateTime)dr["O_DateTime"],
                    E_id         = (int)dr["E_id"],
                    O_DealWay    = dr["O_DealWay"].ToString(),
                    O_LeaveWords = dr["O_LeaveWords"].ToString(),
                    O_Remark     = dr["O_Remark"].ToString(),
                    P_id         = (int)dr["P_id"],
                    U_id         = (int)dr["U_id"]
                };
                list.Add(obj);
            }
            dr.Close();
            return(list);
        }
Ejemplo n.º 4
0
        private void btn_ConfirmTrade_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("確定送出訂單?", "系統提醒", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (result == DialogResult.Yes)
            {
                var NOrder = new Order_Table()
                {
                    MemberID         = MemberData.MemberID,
                    OrderDate        = DateTime.Now,
                    DeliveryCounty   = cb_County2.Text,
                    DeliveryDistrict = cb_District2.Text,
                    DeliveryAddress  = tb_Address2.Text,
                    PayMethod        = cb_PayWay.Text,
                    DeliveredDate    = null,
                    OrderStatus      = "處理中",
                    RecieveMethod    = cb_HowtoRecieve.Text
                };
                dbContext.Order_Table.Add(NOrder);
                dbContext.SaveChanges();

                var _NOID = from M in dbContext.Order_Table
                            where  M.MemberID == MemberData.MemberID
                            select M.OrderID;
                int NOID = _NOID.AsEnumerable().Last();

                for (int i = 0; i < dgv_Cart.Rows.Count; i++)
                {
                    var NOrderDetails = new Order_Detail_Table()
                    {
                        OrderiD        = NOID,
                        IngredientID   = (int)dgv_Cart.Rows[i].Cells[0].Value,
                        Price          = (decimal)dgv_Cart.Rows[i].Cells[3].Value,
                        Discount       = 0,
                        InCartQuantity = (int)dgv_Cart.Rows[i].Cells[2].Value
                    };
                    dbContext.Order_Detail_Table.Add(NOrderDetails);

                    int SellID = (int)dgv_Cart.Rows[i].Cells[0].Value;
                    int Sell   = (int)dgv_Cart.Rows[i].Cells[2].Value;

                    var NIAmount = dbContext.Ingredient_Table.Where(I => I.IngredientID == SellID).Select(I => I).FirstOrDefault();
                    NIAmount.AmountInStore = NIAmount.AmountInStore - Sell;
                }

                var RCart = dbContext.Shopping_Cart_table.Where(RC => RC.MemberID == MemberData.MemberID).Select(N => N);
                foreach (var item in RCart)
                {
                    dbContext.Shopping_Cart_table.Remove(item);
                }
                dbContext.SaveChanges();
                dgv_Cart.DataSource = null;

                MessageBox.Show("成交!我們將盡速為您處裡訂單!", "成交!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ToShelf();
                int HowManyInCart = dbContext.Shopping_Cart_table.Where(M => M.MemberID == MemberData.MemberID).Select(M => M).Count();
                llb_toCart.Text  = $"({HowManyInCart})購物車";
                llb_ToCart2.Text = $"({HowManyInCart})購物車";
            }
        }
Ejemplo n.º 5
0
        public JsonResult add_cart(int id)
        {
            string      user = Session["user"].ToString();
            int         usid = db.User_Table.Where(x => x.UserName == user).Select(x => x.UserId).FirstOrDefault();
            Order_Table obj  = db.Order_Table.Where(x => x.OrderStatus == 0 & x.OrderIsDeleted == false & x.Userid == usid).FirstOrDefault();

            if (obj == null)
            {
                Order_Table obj1 = new Order_Table();
                obj1.OrderStatus    = 0;
                obj1.OrderIsDeleted = false;
                string     name = Session["user"].ToString();
                User_Table uid  = db.User_Table.Where(x => x.UserName == name).FirstOrDefault();
                obj1.Userid           = uid.UserId;
                obj1.OrderCreatedBy   = name;
                obj1.OrderUpdatedBy   = name;
                obj1.OrderCreatedDate = System.DateTime.Now;
                obj1.OrderUpdatedDate = System.DateTime.Now;
                db.Order_Table.Add(obj1);
                db.SaveChanges();
                Order_Table       obj2       = db.Order_Table.Where(x => x.OrderStatus == 0 & x.OrderIsDeleted == false & x.Userid == uid.UserId).FirstOrDefault();
                OrderDetail_Table detail_obj = new OrderDetail_Table();
                detail_obj.Orderid   = obj2.OrderId;
                detail_obj.Productid = id;
                detail_obj.Quantity  = 1;
                detail_obj.Amount    = db.Product_Table.Where(x => x.ProductId == id).Select(x => x.ProductPrice).FirstOrDefault();
                db.OrderDetail_Table.Add(detail_obj);
                db.SaveChanges();
            }
            else
            {
                bool flag  = false;
                var  check = db.OrderDetail_Table.Where(x => x.Orderid == obj.OrderId).Select(x => x.Productid).ToList();
                foreach (var item in check)
                {
                    if (item == id)
                    {
                        flag = true;
                    }
                }
                if (flag == false)
                {
                    OrderDetail_Table detail_obj = new OrderDetail_Table();
                    detail_obj.Orderid   = obj.OrderId;
                    detail_obj.Productid = id;
                    detail_obj.Quantity  = 1;
                    detail_obj.Amount    = db.Product_Table.Where(x => x.ProductId == id).Select(x => x.ProductPrice).FirstOrDefault();
                    db.OrderDetail_Table.Add(detail_obj);
                    db.SaveChanges();
                }
            }


            count_cart();
            var redirectUrl = new UrlHelper(Request.RequestContext).Action("Product_page", "Buyer");

            return(Json(new { Url = redirectUrl }, JsonRequestBehavior.AllowGet));
        }
        //Returns the Delivery for an order
        public Delivery GetDeliveryForOrder(int orderID)
        {
            //Get the order
            Order_Table ord = GetInvoice(orderID);
            Delivery    del = new Delivery();

            del = GetDelivery(ord.Delivery_Id);

            return(del);
        }
        //<-----Moving from cart to Order----->
        public bool placeOrder(int userId, int shipping, int paymentId)
        {
            Cart[]  items = GetAllCartItemsForClient(userId).ToArray();
            decimal perc  = 0;

            if (CalculateTotalQuantity(userId) >= 5000)
            {
                perc = 5;
            }


            Order_Table order = new Order_Table
            {
                Order_date     = DateTime.Now,
                Order_Total    = CalculateTotalPrice(userId),
                Order_Quantity = CalculateTotalQuantity(userId),
                Order_Tax      = CalculateTotalPrice(userId) * (decimal)0.15,
                Order_Status   = "Ordered",
                Order_Discount = perc > 0 ? 0 : (perc / 100) * CalculateTotalPrice(userId),
                Order_Shipping = CalculateTotalQuantity(userId) > 10000 ? 0 : CalculateTotalQuantity(userId) * (decimal)0.02,
                Delivery_Id    = shipping
            };

            db.Order_Tables.InsertOnSubmit(order);
            db.SubmitChanges();
            int orderId = (from o in db.Order_Tables where o.Order_date.Equals(order.Order_date) select o).FirstOrDefault().Order_Id;

            order.Order_Total = order.Order_Total + order.Order_Tax + order.Order_Shipping - order.Order_Discount;


            foreach (Cart c in items)
            {
                Order_Item oi = new Order_Item
                {
                    Quantity   = c.Quantity,
                    Product_Id = c.Product_Id,
                    Order_Id   = order.Order_Id,
                };

                db.Order_Items.InsertOnSubmit(oi);
            }

            ClearTheCart(userId);
            PayClient pc = new PayClient
            {
                User_Id    = userId,
                Payment_Id = paymentId,
                Order_Id   = orderId,
            };

            db.PayClients.InsertOnSubmit(pc);

            db.SubmitChanges();
            return(ClearTheCart(userId));
        }
Ejemplo n.º 8
0
        public ActionResult purchase_all(Book obj)
        {
            string name = Session["user"].ToString();
            int    usid = db.User_Table.Where(x => x.UserName == name).Select(x => x.UserId).FirstOrDefault();

            Order_Table order = db.Order_Table.Where(x => x.OrderStatus == 0 & x.OrderIsDeleted == false & x.Userid == usid).FirstOrDefault();

            order.OrderDeliveryAddress = obj.OrderDelivryAddress;
            order.TotalAmount          = Convert.ToInt32(TempData["tcart_amt"]);
            order.OrderNotification    = "00";
            order.OrderDeliveryDate    = System.DateTime.Now.AddDays(5);
            order.OrderStatus          = 1;
            db.SaveChanges();
            var odetail = db.OrderDetail_Table.Where(x => x.Orderid == order.OrderId).Select(x => x.OrderDetailId).ToList();

            foreach (var item in odetail)
            {
                int               flag     = 0;
                List <int>        availid1 = TempData["avail1"] as List <int>;
                OrderDetail_Table obj1     = db.OrderDetail_Table.Where(x => x.OrderDetailId == item).FirstOrDefault();
                foreach (var pro in availid1)
                {
                    if (obj1.Productid == pro)
                    {
                        Product_Table pobj  = db.Product_Table.Where(x => x.ProductId == pro).FirstOrDefault();
                        int           stock = Convert.ToInt32(pobj.ProductStock);
                        int           qty   = Convert.ToInt32(obj1.Quantity);
                        pobj.ProductStock = stock - qty;
                        db.SaveChanges();
                        flag = 1;
                    }
                }
                if (flag == 1)
                {
                    int           lid    = Convert.ToInt32(Session["location"]);
                    Service_Table serboj = db.Service_Table.Where(x => x.ServiceProviderid == obj.UserId && x.Locationid == lid).FirstOrDefault();
                    obj1.Serviceid = serboj.ServiceId;
                    db.SaveChanges();
                }
                else
                {
                    db.OrderDetail_Table.Remove(obj1);
                    db.SaveChanges();
                }
            }
            count_cart();
            Session["location"] = null;
            return(RedirectToAction("notification"));
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 添加订单
 /// </summary>
 /// <param name="obj">带入参数</param>
 /// <returns></returns>
 public int Insert_OrderTableData(Order_Table obj)
 {
     return(DBHerlper.ExecuteNonQuery(GetSqlString("Insert"),
                                      CommandType.StoredProcedure,
                                      new SqlParameter[] {
         new SqlParameter("@O_id", obj.O_id),
         new SqlParameter("@O_DateTime", obj.O_DateTime),
         new SqlParameter("@E_id", obj.E_id),
         new SqlParameter("@O_DealWay", obj.O_DealWay),
         new SqlParameter("@O_LeaveWords", obj.O_LeaveWords),
         new SqlParameter("@O_Remark", obj.O_Remark),
         new SqlParameter("@P_id", obj.P_id),
         new SqlParameter("@U_id", obj.U_id)
     }));
 }
Ejemplo n.º 10
0
        public void DisableNotification()
        {
            Order_Table obj   = new Order_Table();
            var         order = (from a in db.Order_Table where a.OrderIsDeleted == false select a).ToList();

            foreach (var item in order)
            {
                if (item.OrderNotification == "00")
                {
                    item.OrderNotification = "10";
                }
                else if (item.OrderNotification == "01")
                {
                    item.OrderNotification = "11";
                }
            }
            db.SaveChanges();
        }
Ejemplo n.º 11
0
        public JsonResult remove_cart(int id)
        {
            OrderDetail_Table obj = db.OrderDetail_Table.Where(x => x.Productid == id).FirstOrDefault();

            db.OrderDetail_Table.Remove(obj);
            db.SaveChanges();
            OrderDetail_Table obj1 = db.OrderDetail_Table.Where(x => x.Orderid == obj.Orderid).FirstOrDefault();

            if (obj1 == null)
            {
                Order_Table obj2 = db.Order_Table.Where(x => x.OrderId == obj.Orderid).FirstOrDefault();
                obj2.OrderIsDeleted = true;
                db.SaveChanges();
            }
            count_cart();
            var redirectUrl = new UrlHelper(Request.RequestContext).Action("cart", "Buyer");

            return(Json(new { Url = redirectUrl }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// For disabling notification number in navigation bar after seen by the user
        /// </summary>
        public void DisableNotification()
        {
            Order_Table obj   = new Order_Table();
            var         order = (from a in db.Order_Table select a).ToList();

            foreach (var item in order)
            {
                if (item.OrderNotification == "00")         //notification satus=00,when new order is placed
                {
                    item.OrderNotification = "01";          //changing status to 01, indicating service provider has seen the notification
                }
                else if (item.OrderNotification == "10")    //notification satus = 10, when new order is seen by seller but not service provider
                {
                    item.OrderNotification = "11";          //changing status to 11, indicating both seller and service provider has seen the notification
                }
            }

            db.SaveChanges();

            Notification_Count();
        }
Ejemplo n.º 13
0
        public ActionResult order(Book obj, string amt)
        {
            string name  = Session["user"].ToString();
            int    pid   = Convert.ToInt32(Session["pro_id"].ToString());
            int    stock = db.Product_Table.Where(x => x.ProductId == pid).Select(x => x.ProductStock).FirstOrDefault();

            if (obj.Quantity <= stock)
            {
                Order_Table       order        = new Order_Table();
                OrderDetail_Table order_detail = new OrderDetail_Table();
                order.TotalAmount          = Convert.ToInt32(amt);
                order.OrderDeliveryAddress = obj.OrderDelivryAddress;
                order.OrderDeliveryDate    = System.DateTime.Now.AddDays(5);
                order.Userid            = db.User_Table.Where(x => x.UserName == name).Select(x => x.UserId).FirstOrDefault();
                order.OrderCreatedBy    = name;
                order.OrderUpdatedBy    = name;
                order.OrderCreatedDate  = System.DateTime.Now;
                order.OrderUpdatedDate  = System.DateTime.Now;
                order.OrderIsDeleted    = false;
                order.OrderStatus       = 1;
                order.OrderNotification = "00";
                db.Order_Table.Add(order);
                db.SaveChanges();
                int oid = order.OrderId;
                order_detail.Orderid   = oid;
                order_detail.Productid = pid;
                int           lid    = Convert.ToInt32(Session["location"]);
                Service_Table serboj = db.Service_Table.Where(x => x.ServiceProviderid == obj.UserId && x.Locationid == lid).FirstOrDefault();
                order_detail.Serviceid = serboj.ServiceId;
                order_detail.Quantity  = obj.Quantity;
                order_detail.Amount    = Convert.ToInt32(amt);
                db.OrderDetail_Table.Add(order_detail);
                db.SaveChanges();
                Product_Table pobj = db.Product_Table.Where(x => x.ProductId == pid).FirstOrDefault();
                pobj.ProductStock = stock - obj.Quantity;
                db.SaveChanges();
            }
            Session["location"] = null;
            return(RedirectToAction("notification"));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Get the logged in user's id
            int client_ID = 5 /*Convert.ToInt32(Session["LoggedInUser"])*/;

            //If user is logged in
            if (client_ID > 0)
            {
                //Get the client's invoice/s
                dynamic allInvoices = SR.GetInvoicebyclient(client_ID);
                //Get client's details
                var    user           = SR.GetUser(client_ID);
                string displayInvoice = "";

                //Loop through all the invoices
                foreach (Order_Table i in allInvoices)
                {
                    //Get one invoice based off id
                    Order_Table invoice = SR.GetInvoice(i.Order_Id);

                    displayInvoice += "<tr><td class='name'>" + user.Name + "</td>";
                    displayInvoice += "<td class='date'>" + invoice.Order_date + "</td>";
                    displayInvoice += "<td class='quantity'>" + invoice.Order_Quantity + "</td>";
                    displayInvoice += "<td class='status'>" + invoice.Order_Status + "</td>";
                    displayInvoice += "<td class='total'>R" + Math.Round(invoice.Order_Total, 2) + "</td>";
                    displayInvoice += "<td class='see-more'><div class='seeMore-btn'><div class='row'><div class='col-lg-5 offset-lg-1 text-left text-lg-right'>";
                    displayInvoice += " <a href='Invoice.aspx'?ID=" + invoice.Order_Id + "class='site-btn update-btn'>See more</a></div></div></div></td></tr>";

                    invoice = null;
                }
                AllInvoiceID.InnerHtml = displayInvoice;
            }
            //If user is not logged in
            else
            {
                Response.Redirect("Home.aspx");
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// 添加订单信息
 /// </summary>
 /// <param name="obj">带入参数</param>
 /// <returns></returns>
 public int Insert_OrderTableData(Order_Table obj)
 {
     return(relevanceClass.Insert_OrderTableData(obj));
 }
Ejemplo n.º 16
0
 /// <summary>
 /// 更改订单信息
 /// </summary>
 /// <param name="obj">带入参数</param>
 /// <returns></returns>
 public int Update_OrderTableData(Order_Table obj)
 {
     return(relevanceClass.Update_OrderTableData(obj));
 }