public ActionResult AddNewOrder(int placeId, int employeeId)
        {
            Order order = new Order();

            order.Date       = DateTime.Now;
            order.EmployeeId = employeeId;
            order.PlaceId    = placeId;
            order.Total      = 0;
            var place = placeBll.GetPlaceByIdBLL(placeId);

            if (place.Descriptions.Equals(""))
            {
                if (orderbll.AddOrder(order))
                {
                    Trace.WriteLine("add order" + order.OrderId);
                    place.Descriptions = order.OrderId.ToString();
                    placeBll.SaveChangePlaceDbBLL();
                    return(this.Json(order.OrderId, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(this.Json(Int32.Parse(place.Descriptions), JsonRequestBehavior.AllowGet));
            }
            return(this.Json(-1, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Create(Order order)
        {
            //Kiểm tra hợp lệ dữ liệu
            if (order.OrderDate == null)
            {
                order.OrderDate = new DateTime(2000, 1, 1);
            }
            if (string.IsNullOrEmpty(order.CustomerID))
            {
                ModelState.AddModelError("CustomerID", "Please select a customer");
            }
            if (order.EmployeeID == 0)
            {
                ModelState.AddModelError("EmployeeID", "Please select an Employee");
            }
            if (order.RequiredDate == null)
            {
                order.OrderDate = new DateTime(2000, 1, 1);
            }
            if (string.IsNullOrEmpty(order.ShipAddress))
            {
                ModelState.AddModelError("ShipAddress", "Please enter ship address");
            }
            if (string.IsNullOrEmpty(order.ShipCity))
            {
                ModelState.AddModelError("ShipCity", "Please enter ship city");
            }
            if (string.IsNullOrEmpty(order.ShipCountry))
            {
                ModelState.AddModelError("ShipCountry", "Please enter ship country");
            }
            if (order.ShippedDate == null)
            {
                order.ShippedDate = new DateTime(2000, 1, 1);
            }
            if (order.ShipperID == 0)
            {
                ModelState.AddModelError("ShipperID", "Please select Shipper");
            }

            if (ModelState.IsValid)
            {
                //Lưu vào DB
                if (order.OrderID == 0)
                {
                    //Tạo mới
                    OrderBLL.AddOrder(order);
                }
                else
                {
                    //Sửa
                    OrderBLL.Update(order);
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(order));
            }
        }
Example #3
0
        private void btnSiparisOlustur_Click(object sender, EventArgs e)
        {
            //Masa durumunu dolu set et++.
            var sonSiparis = OrderBLL.GetLastAddedOrder(masaID);

            if (sonSiparis.Item2 != true)
            {
                var donen = OrderBLL.AddOrder(masaID, calisanID);
                if (donen)
                {
                    MessageBox.Show("Sipariş eklendi.");
                    TableBLL.SetTableBusy(masaID);
                }
                else
                {
                    MessageBox.Show("Sipariş eklenirken hata oluştu.");
                }
            }
            else
            {
                MessageBox.Show("İçeride kapanmamış bir sipariş var.");
            }

            //int siparisID = donen.Item2.SiparisID;
            //orderID = siparisID;
        }
Example #4
0
        protected void btnPlaceOrder_Click(object sender, EventArgs e)
        {
            if (Session["uid"] == null)
            {
                Response.Redirect("/login.aspx");
            }
            if (ViewState["selected"] == null)
            {
                return;
            }
            HashSet <int> seleted = (HashSet <int>)ViewState["selected"];

            if (seleted.Count == 0)
            {
                return;
            }
            int          userid  = (int)Session["uid"];
            AddressModel address = AddressBLL.GetUserDefaultAddress(userid);

            if (address.id == 0)
            {
                Modal.Show(this, "你还没有收货地址,请前往个人中心添加");
                return;
            }
            CartModel cart = GetCart();

            OrderModel order = new OrderModel();

            order.address = address;
            foreach (BookOrderModel orderBook in cart.book)
            {
                if (seleted.Contains(orderBook.book.id))
                {
                    orderBook.price = orderBook.book.price;
                    order.books.Add(orderBook);
                }
            }
            order.comment  = "";
            order.dateTime = DateTime.Now;
            order.status   = 0;
            order.CalculateTotalPrice();
            order.user.id = userid;
            int msg = OrderBLL.AddOrder(order);

            if (msg != -1)
            {
                foreach (BookOrderModel book in order.books)
                {
                    CartBLL.DeleteBook(userid, book.book.id);
                }
                Modal.Show(this, "下单成功,即将前往付款界面", 1000, "/placeorder.aspx?orderid=" + msg);
            }
            else
            {
                Modal.Show(this, "购买失败", 1000, HttpContext.Current.Request.Url.PathAndQuery);
            }
        }
Example #5
0
        public ActionResult AddOrder()
        {
            Customers         customer = Session["Login"] as Customers;
            int               orderID  = orderBLL.AddOrder(customer);
            List <SepetModel> model    = Session["Sepet"] as List <SepetModel>;

            foreach (SepetModel item in model)
            {
                Products product = productBLL.GetProduct(item.ProductID);
                orderdetailBLL.AddOrderDetail(product, item.Quantity, orderID);
            }
            return(RedirectToAction("Index"));
        }
Example #6
0
        protected void btn_Submit_Click(object sender, EventArgs e)
        {
            string Oid = "DD" + DateTime.Now.ToString("yyyyMMddMMss");

            Orders order = new Orders()
            {
                OID        = Oid,
                MID        = Convert.ToInt32(Session["Mid"]),
                ODate      = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")),
                OConsignee = this.consignee_0.Value,
                OAddress   = this.oaddress.Value,
                OTelephone = this.tel_0.Value,
                OSumPrice  = Convert.ToInt32(this.txtSumPrice.Value),
                OState     = 1,
            };

            bool ck = OrderBLL.AddOrder(order) > 0? true :false;


            if (ck)
            {
                RepeaterItemCollection items = repgoods.Items;
                foreach (RepeaterItem item in items)
                {
                    Label   bid     = (Label)item.FindControl("bBID");
                    Label   tid     = (Label)item.FindControl("bTID");
                    Label   price   = (Label)item.FindControl("price");
                    TextBox lbcount = (TextBox)item.FindControl("lbcount");

                    OrderDetails o = new OrderDetails()
                    {
                        OID    = Oid,
                        BID    = Convert.ToInt32(bid.Text),
                        BPrice = Convert.ToDouble(price.Text),
                        BCount = Convert.ToInt32(lbcount.Text)
                    };
                    bool cko = OrderBLL.AddOrderDetails(o) > 0 ? true : false;
                    if (cko)
                    {
                        bool ckd = OrderBLL.DeleteTrade(Convert.ToInt32(tid.Text)) > 0 ? true : false;

                        if (ckd)
                        {
                            OrderBLL.UpdateBcount(Convert.ToInt32(lbcount.Text), Convert.ToInt32(bid.Text));
                        }
                    }
                }
                Response.Redirect("done.aspx?oid=" + Oid);
            }
        }
Example #7
0
        protected void btnBuy_Click(object sender, EventArgs e)
        {
            if (Session["uid"] == null)
            {
                Response.Redirect("/login.aspx");
            }
            int          userid  = (int)Session["uid"];
            AddressModel address = AddressBLL.GetUserDefaultAddress(userid);

            if (address.id == 0)
            {
                Modal.Show(this, "你还没有收货地址,请前往个人中心添加");
                return;
            }


            OrderModel order = new OrderModel();

            order.address = address;
            BookOrderModel bookOrder = new BookOrderModel();

            bookOrder.quantity = int.Parse(txtNum.Text);
            bookOrder.price    = BookOnThisPage.price;
            bookOrder.book     = BookOnThisPage;
            order.books        = new List <BookOrderModel>()
            {
                bookOrder
            };
            order.comment  = "";
            order.dateTime = DateTime.Now;
            order.status   = 0;
            order.CalculateTotalPrice();
            order.user.id = userid;
            int msg = OrderBLL.AddOrder(order);

            if (msg != -1)
            {
                Modal.Show(this, "下单成功,即将前往付款界面", 1000, "/placeorder.aspx?orderid=" + msg);
            }
            else
            {
                Modal.Show(this, "购买失败", 1000, HttpContext.Current.Request.Url.PathAndQuery);
            }
        }
Example #8
0
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to save?", "Save Notification", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                //yes...
                bool Check = false;
                OrdID = (orderBLL.AddOrder(orDer, lsOrderDetail));
                if (OrdID != -1)
                {
                    if (tableBLL.ChangeTableStatus(TabID, true, false, false) == true)
                    {
                        Table table = tableBLL.FindTableById(TabID);
                        if (table.Status == 1)
                        {
                            // Bàn này đang được order và khách đến và order
                            CustomerBLL customerBLL = new CustomerBLL();
                            if (customerBLL.DeleteCustomer(CusID) == true)
                            {
                                Check = true;
                            }
                        }
                        else
                        {
                            Check = true;
                        }
                    }
                }
                if (Check == true)
                {
                    MessageBox.Show("Saved sucessfully");
                    orDer.OrderID = OrdID;
                    mainform.loadUCTable();
                }
                else
                {
                    MessageBox.Show("Cannot save. Please try again!");
                }
            }
        }
Example #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            decimal productTotalPrice = Sessions.ProductTotalPrice;
            string  key = RequestHelper.GetForm <string>("Pay");

            //默认选择支付宝AliPay
            if (UserAgentHelper.IsWx(Request.UserAgent))
            {
                key = "WxPay";
            }
            else
            {
                key = "AliPay";
            }
            PayPluginsInfo info  = PayPlugins.ReadPayPlugins(key);
            OrderInfo      order = new OrderInfo();

            order.PayKey      = key;
            order.PayName     = info.Name;
            order.OrderNumber = ShopCommon.CreateOrderNumber();
            if (info.IsCod == 1)
            {
                order.OrderStatus = 2;
            }
            else
            {
                order.OrderStatus = 1;
            }
            order.OrderNote    = string.Empty;
            order.ProductMoney = productTotalPrice;
            //order.PayDate = RequestHelper.DateNow;
            order.UserID = UserID;
            //order.UserName = base.UserName;
            int orderID = OrderBLL.AddOrder(order);

            this.AddOrderProduct(orderID);
            if (order.OrderStatus == (int)OrderStatus.WaitPay && info.IsOnline == (int)BoolType.True)
            {
                ResponseHelper.Redirect("/Plugins/Pay/" + key + "/Pay.aspx?OrderID=" + orderID + "&Action=PayOrder");
            }
        }
Example #10
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            OrderDetails objOrder = new OrderDetails();
            User         objUser  = (User)Session["User"];

            if (Session["OrderId"] != null)
            {
                objOrder.OrderID = Convert.ToInt32(Session["OrderId"]);
            }
            else
            {
                objOrder.OrderID = 0;
            }
            objOrder.UserId      = objUser.UserId;
            objOrder.ProductName = txtProductName.Text;
            objOrder.OrderDate   = txtDate.Text;

            int addresult = obj.AddOrder(objOrder);

            Response.Redirect("View.aspx");
        }
Example #11
0
        public IActionResult AddOrder(CartToOrderVM vm)
        {
            var   userIdentity = (ClaimsIdentity)User.Identity;
            Order order1       = new Order();

            order1.ID               = Guid.NewGuid();
            order1.Status           = Status.Active;
            order1.OrderDescription = "Siparişlerim zamanında elime ulaşmıştır. Teşekkürler...";
            order1.OrderDate        = DateTime.UtcNow;
            order1.UserID           = new Guid(userIdentity.Name);
            order1.OrderPrice       = vm.TotalPrice;
            _orderBLL.AddOrder(order1);

            for (int i = 0; i < vm.ProductIDs.Count; i++)
            {
                Product product = _productBLL
                                  .GetProductByID(new Guid(vm.ProductIDs[i]));
                OrderDetail orderDetail = new OrderDetail()
                {
                    ID         = Guid.NewGuid(),
                    Status     = Status.Active,
                    OrderPrice = vm.Quantities[i] * product.ProductPrice,
                    Quantity   = vm.Quantities[i],
                    OrderID    = order1.ID,
                    ProductID  = product.ID,
                };
                _orderDetailBLL.AddOrderDetail(orderDetail);

                var cookie = Request.Cookies.FirstOrDefault(c => c.Value == vm.ProductIDs[i]);
                if (!cookie.Equals(default(KeyValuePair <string, string>)))
                {
                    Response.Cookies.Delete(cookie.Key);
                }
            }

            return(RedirectToAction("Cart", "Cart"));
        }
Example #12
0
        public ActionResult payment()
        {
            if (Session["Card"] == null || Session["Card"].ToString() == "")
            {
                return(Redirect("/Product/Index"));
            }
            if (Session["DangNhap"] == null || Session["DangNhap"].ToString() == "")
            {
                return(Redirect("/Customer/Login"));
            }
            Customer           cus = (Customer)Session["DangNhap"];
            Order              od  = new Order();
            List <ProductCart> lst = getCard();

            od.OrderID      = obll.createNewOderByID(Session["MaTK"].ToString());
            od.CustomerID   = Session["MaTK"].ToString();
            od.OrderDate    = DateTime.Now;
            od.RequiredDate = DateTime.Now;
            od.ShippedDate  = DateTime.Now.AddDays(3);
            od.ShipAddress  = cus.Address;
            od.Freight      = 0;
            List <Order_Detail> lstD = new List <Order_Detail>();

            foreach (var item in lst)
            {
                Order_Detail _od = new Order_Detail();
                _od.OrderID   = od.OrderID;
                _od.ProductID = item.iProID;
                _od.Quantity  = (short)item.iQuantity;
                _od.UnitPrice = (decimal)item.dPrice;
                lstD.Add(_od);
            }
            obll.AddOrder(od, lstD);
            setAlert("Thanh toán thành công", "Success");
            Session["Card"] = null;
            return(Redirect("/Home/Index"));
        }
Example #13
0
        public ActionResult Create(Order order, int[] productIDs, int[] quantities)
        {
            //Kiểm tra hợp lệ dữ liệu
            if (order.OrderDate == new DateTime(0001, 01, 01))
            {
                ModelState.AddModelError("OrderDate", "OrderDate is invalid");
            }
            if (string.IsNullOrEmpty(order.CustomerID))
            {
                ModelState.AddModelError("CustomerID", "Please select a customer");
            }
            if (order.EmployeeID == 0)
            {
                ModelState.AddModelError("EmployeeID", "Please select an Employee");
            }
            if (order.RequiredDate == new DateTime(0001, 01, 01))
            {
                ModelState.AddModelError("RequiredDate", "RequiredDate is invalid");
            }
            if (string.IsNullOrEmpty(order.ShipAddress))
            {
                ModelState.AddModelError("ShipAddress", "Please enter ship address");
            }
            if (string.IsNullOrEmpty(order.ShipCity))
            {
                ModelState.AddModelError("ShipCity", "Please enter ship city");
            }
            if (string.IsNullOrEmpty(order.ShipCountry))
            {
                ModelState.AddModelError("ShipCountry", "Please enter ship country");
            }
            if (order.ShippedDate == new DateTime(0001, 01, 01))
            {
                ModelState.AddModelError("ShippedDate", "ShippedDate is invalid");
            }
            if (order.ShipperID == 0)
            {
                ModelState.AddModelError("ShipperID", "Please select Shipper");
            }
            if (productIDs != null)
            {
                try
                {
                    for (int i = 0; i < productIDs.Length; i++)
                    {
                        int temp = Convert.ToInt32(productIDs[i]);
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("Quantity", "Quantity(s) must be a number");
                }
            }

            if (ModelState.IsValid)
            {
                //Lưu vào DB
                if (order.OrderID == 0)
                {
                    //Tạo mới
                    int orderID = OrderBLL.AddOrder(order);
                    if (productIDs != null && quantities != null)
                    {
                        int detailLenght = productIDs.Length;
                        for (int i = 0; i < detailLenght; i++)
                        {
                            if (productIDs[i] <= 0 || quantities[i] <= 0)
                            {
                                continue;
                            }
                            else
                            {
                                OrderBLL.AddOrderDetail(new OrderDetail() { OrderID = orderID, ProductID = productIDs[i], Quantity = quantities[i] });
                            }
                        }
                    }
                }
                else
                {
                    //Sửa
                    OrderBLL.Update(order);
                    OrderBLL.DeleteOrderDetails(order.OrderID);
                    if (productIDs != null && quantities != null)
                    {
                        int detailLenght = productIDs.Length;
                        for (int i = 0; i < detailLenght; i++)
                        {
                            if (productIDs[i] <= 0 || quantities[i] <= 0)
                            {
                                continue;
                            }
                            else
                            {
                                OrderBLL.AddOrderDetail(new OrderDetail() { OrderID = order.OrderID, ProductID = productIDs[i], Quantity = quantities[i] });
                            }
                        }
                    }
                }
                return RedirectToAction("Index");
            }
            else
            {
                order.Details = OrderBLL.ListOfOrderDetail(order.OrderID);
                if (order.Details == null)
                {
                    order.Details = new List<OrderDetail>();
                }
                return View(order);
            }
        }
Example #14
0
        /// <summary>
        /// 提交按钮点击方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            //读取用户信息
            userID = Cookies.User.GetUserID(true);
            int    pointLeft = UserBLL.ReadUserMore(userID).PointLeft;
            string userName  = Cookies.User.GetUserName(false);
            string userEmail = CookiesHelper.ReadCookieValue("UserEmail");
            //检测积分
            int id = RequestHelper.GetQueryString <int>("ID");

            product = ProductBLL.ReadProduct(id);
            ExchangeAwardInfo exchangeAward = ExchangeAwardBLL.ReadConfigInfo();
            int productPoint = 0;

            if (exchangeAward.PorudctIDList != string.Empty)
            {
                string[] productArray = exchangeAward.PorudctIDList.Split(',');
                string[] pointArray   = exchangeAward.PointList.Split(',');
                for (int i = 0; i < productArray.Length; i++)
                {
                    if (productArray[i] == id.ToString())
                    {
                        productPoint = Convert.ToInt32(pointArray[i]);
                    }
                }
            }
            if (productPoint > pointLeft)
            {
                ScriptHelper.Alert("您当前的积分不足以兑取该奖品", RequestHelper.RawUrl);
            }
            //添加订单
            OrderInfo order = new OrderInfo();

            order.OrderNumber    = ShopCommon.CreateOrderNumber();
            order.IsActivity     = (int)BoolType.True;
            order.OrderStatus    = (int)OrderStatus.WaitCheck;
            order.OrderNote      = "积分兑换奖品";
            order.ProductMoney   = 0;
            order.Balance        = 0;
            order.FavorableMoney = 0;
            order.OtherMoney     = 0;
            order.CouponMoney    = 0;
            order.Consignee      = StringHelper.AddSafe(Consignee.Text);
            SingleUnlimitClass singleUnlimitClass = new SingleUnlimitClass();

            order.RegionID            = singleUnlimitClass.ClassID;
            order.Address             = StringHelper.AddSafe(Address.Text);
            order.ZipCode             = StringHelper.AddSafe(ZipCode.Text);
            order.Tel                 = StringHelper.AddSafe(Tel.Text);
            order.Email               = userEmail;
            order.Mobile              = StringHelper.AddSafe(Mobile.Text);
            order.ShippingID          = 0;
            order.ShippingDate        = RequestHelper.DateNow;
            order.ShippingNumber      = string.Empty;
            order.ShippingMoney       = 0;
            order.PayKey              = string.Empty;
            order.PayName             = string.Empty;
            order.PayDate             = RequestHelper.DateNow;;
            order.IsRefund            = (int)BoolType.False;
            order.FavorableActivityID = 0;
            order.GiftID              = 0;
            order.InvoiceTitle        = string.Empty;
            order.InvoiceContent      = string.Empty;
            order.UserMessage         = string.Empty;
            order.AddDate             = RequestHelper.DateNow;
            order.IP       = ClientHelper.IP;
            order.UserID   = userID;
            order.UserName = userName;
            int orderID = OrderBLL.AddOrder(order);
            //添加订单详细
            OrderDetailInfo orderDetail = new OrderDetailInfo();

            orderDetail.OrderID       = orderID;
            orderDetail.ProductID     = product.ID;
            orderDetail.ProductName   = product.Name;
            orderDetail.ProductWeight = product.Weight;
            orderDetail.SendPoint     = 0;
            orderDetail.ProductPrice  = 0;
            orderDetail.BuyCount      = 1;
            orderDetail.FatherID      = 0;
            orderDetail.RandNumber    = string.Empty;
            orderDetail.GiftPackID    = 0;
            OrderDetailBLL.AddOrderDetail(orderDetail);
            //积分操作
            UserAccountRecordBLL.AddUserAccountRecord(0, -productPoint, "兑换奖品-" + product.Name, userID, userName);
            //更改产品库存订单数量
            ProductBLL.ChangeProductOrderCountByOrder(orderID, ChangeAction.Plus);
            //保存记录
            string fileName = StringHelper.Encode(ShopConfig.ReadConfigInfo().SecureKey, ShopConfig.ReadConfigInfo().SecureKey) + ".txt";

            fileName = Server.MapPath("Admin/" + fileName);
            File.AppendAllText(fileName, userName + ",订单号:" + order.OrderNumber + ",商品:" + product.Name + "\r\n", System.Text.Encoding.Default);
            ScriptHelper.Alert("成功兑换", "/User/OrderDetail.aspx?ID=" + orderID.ToString());
        }
Example #15
0
        /// <summary>
        /// 全部生成订单按钮点击方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void CreateOrderButton_Click(object sender, EventArgs e)
        {
            int groupBuyID = RequestHelper.GetQueryString <int>("GroupBuyID");

            groupBuy = GroupBuyBLL.ReadGroupBuy(groupBuyID);
            ProductInfo             product          = ProductBLL.ReadProduct(groupBuy.ProductID);
            List <UserGroupBuyInfo> userGroupBuyList = UserGroupBuyBLL.ReadUserGroupBuyList(groupBuyID);

            foreach (UserGroupBuyInfo userGroupBuy in userGroupBuyList)
            {
                if (userGroupBuy.OrderID == 0)
                {
                    decimal totalPrice = groupBuy.Price * userGroupBuy.BuyCount;
                    //添加订单
                    OrderInfo order = new OrderInfo();
                    order.OrderNumber         = ShopCommon.CreateOrderNumber();
                    order.IsActivity          = (int)BoolType.True;
                    order.OrderStatus         = (int)OrderStatus.WaitCheck;
                    order.OrderNote           = "团购活动:" + groupBuy.Name;
                    order.ProductMoney        = totalPrice;
                    order.Balance             = totalPrice;
                    order.FavorableMoney      = 0;
                    order.OtherMoney          = 0;
                    order.CouponMoney         = 0;
                    order.Consignee           = userGroupBuy.Consignee;
                    order.RegionID            = userGroupBuy.RegionID;
                    order.Address             = userGroupBuy.Address;
                    order.ZipCode             = userGroupBuy.ZipCode;
                    order.Tel                 = userGroupBuy.Tel;
                    order.Email               = userGroupBuy.Email;
                    order.Mobile              = userGroupBuy.Mobile;
                    order.ShippingID          = 0;
                    order.ShippingDate        = RequestHelper.DateNow;
                    order.ShippingNumber      = string.Empty;
                    order.ShippingMoney       = 0;
                    order.PayKey              = string.Empty;
                    order.PayName             = string.Empty;
                    order.PayDate             = userGroupBuy.Date;;
                    order.IsRefund            = (int)BoolType.False;
                    order.FavorableActivityID = 0;
                    order.GiftID              = 0;
                    order.InvoiceTitle        = string.Empty;
                    order.InvoiceContent      = string.Empty;
                    order.UserMessage         = string.Empty;
                    order.AddDate             = RequestHelper.DateNow;
                    order.IP       = userGroupBuy.IP;
                    order.UserID   = userGroupBuy.UserID;
                    order.UserName = userGroupBuy.UserName;
                    int orderID = OrderBLL.AddOrder(order);
                    //添加订单详细
                    OrderDetailInfo orderDetail = new OrderDetailInfo();
                    orderDetail.OrderID       = orderID;
                    orderDetail.ProductID     = product.ID;
                    orderDetail.ProductName   = product.Name;
                    orderDetail.ProductWeight = product.Weight;
                    orderDetail.SendPoint     = 0;
                    orderDetail.ProductPrice  = groupBuy.Price;
                    orderDetail.BuyCount      = userGroupBuy.BuyCount;
                    orderDetail.FatherID      = 0;
                    orderDetail.RandNumber    = string.Empty;
                    orderDetail.GiftPackID    = 0;
                    OrderDetailBLL.AddOrderDetail(orderDetail);
                    //更新订单 ID
                    UserGroupBuyBLL.UpdateUserGroupBuy(userGroupBuy.ID, orderID);
                    //更改产品库存订单数量
                    ProductBLL.ChangeProductOrderCountByOrder(orderID, ChangeAction.Plus);
                }
            }
            ScriptHelper.Alert("处理成功", RequestHelper.RawUrl);
        }
Example #16
0
        /// <summary>
        /// 提交数据
        /// </summary>
        protected override void PostBack()
        {
            int groupID = RequestHelper.GetForm <int>("groupID");

            buyCount = RequestHelper.GetForm <int>("buyCount");
            string url = "/GroupBuyOrder-" + groupID + "-" + buyCount + ".aspx";

            groupBuy = GroupBuyBLL.ReadGroupBuy(groupID);
            if (groupBuy.ID <= 0)
            {
                ScriptHelper.AlertFront("该团购不存在!", url);
            }
            if (UserGroupBuyBLL.ReadUserGroupBuyByUser(groupID, base.UserID).ID > 0)
            {
                ScriptHelper.AlertFront("您已经参加该团购了!", url);
            }
            if (groupBuy.StartDate > DateTime.Now)
            {
                ScriptHelper.AlertFront("该团购还未开始,不能购买!", url);
            }
            if (groupBuy.EndDate < DateTime.Now)
            {
                ScriptHelper.AlertFront("该团购已经结束,不能购买!", url);
            }
            if (buyCount <= 0)
            {
                ScriptHelper.AlertFront("购买数量有误!", url);
            }
            if (buyCount > groupBuy.EachNumber)
            {
                ScriptHelper.AlertFront("购买数量超过了该团购个人限购数!", url);
            }
            int hasBuy = 0;

            foreach (UserGroupBuyInfo userGroupBuy in UserGroupBuyBLL.ReadUserGroupBuyList(groupID))
            {
                hasBuy += userGroupBuy.BuyCount;
            }
            if (buyCount > (groupBuy.MaxCount - hasBuy))
            {
                ScriptHelper.AlertFront("购买数量超过了该团购剩余数!", url);
            }
            product = ProductBLL.ReadProduct(groupBuy.ProductID);

            //检查地址
            string consignee = StringHelper.AddSafe(RequestHelper.GetForm <string>("Consignee"));

            if (consignee == string.Empty)
            {
                ScriptHelper.AlertFront("收货人姓名不能为空", url);
            }
            string tel    = StringHelper.AddSafe(RequestHelper.GetForm <string>("Tel"));
            string mobile = StringHelper.AddSafe(RequestHelper.GetForm <string>("Mobile"));

            if (tel == string.Empty && mobile == string.Empty)
            {
                ScriptHelper.AlertFront("固定电话,手机必须得填写一个", url);
            }
            string zipCode = StringHelper.AddSafe(RequestHelper.GetForm <string>("ZipCode"));

            if (zipCode == string.Empty)
            {
                ScriptHelper.AlertFront("邮编不能为空", url);
            }
            string address = StringHelper.AddSafe(RequestHelper.GetForm <string>("Address"));

            if (address == string.Empty)
            {
                ScriptHelper.AlertFront("地址不能为空", url);
            }
            //验证配送方式
            int shippingID = RequestHelper.GetForm <int>("ShippingID");

            if (shippingID == int.MinValue)
            {
                ScriptHelper.AlertFront("请选择配送方式", url);
            }
            //检查金额
            decimal productMoney   = groupBuy.Price * buyCount;
            decimal favorableMoney = RequestHelper.GetForm <decimal>("FavorableMoney");
            decimal shippingMoney  = RequestHelper.GetForm <decimal>("ShippingMoney");
            decimal balance        = RequestHelper.GetForm <decimal>("Balance");
            decimal couponMoney    = RequestHelper.GetForm <decimal>("CouponMoney");

            if (productMoney - favorableMoney + shippingMoney - balance - couponMoney < 0)
            {
                ScriptHelper.AlertFront("金额有错误,请重新检查", url);
            }
            //支付方式
            string         payKey     = RequestHelper.GetForm <string>("Pay");
            PayPluginsInfo payPlugins = PayPlugins.ReadPayPlugins(payKey);
            //添加订单
            OrderInfo order = new OrderInfo();

            order.OrderNumber = ShopCommon.CreateOrderNumber();
            order.IsActivity  = (int)BoolType.True;
            if (productMoney - favorableMoney + shippingMoney - balance - couponMoney == 0 || payPlugins.IsCod == (int)BoolType.True)
            {
                order.OrderStatus = (int)OrderStatus.WaitCheck;
            }
            else
            {
                order.OrderStatus = (int)OrderStatus.WaitPay;
            }
            order.OrderNote      = "团购活动:" + groupBuy.Name;
            order.ProductMoney   = productMoney;
            order.Balance        = balance;
            order.FavorableMoney = favorableMoney;
            order.OtherMoney     = 0;
            order.CouponMoney    = couponMoney;
            order.Consignee      = consignee;
            SingleUnlimitClass singleUnlimitClass = new SingleUnlimitClass();

            order.RegionID = singleUnlimitClass.ClassID;
            order.Address  = address;
            order.ZipCode  = zipCode;
            order.Tel      = tel;
            string userEmail = string.Empty;

            if (base.UserID == 0)
            {
                userEmail = StringHelper.AddSafe(RequestHelper.GetForm <string>("Email"));
            }
            else
            {
                userEmail = CookiesHelper.ReadCookieValue("UserEmail");
            }
            order.Email               = userEmail;
            order.Mobile              = mobile;
            order.ShippingID          = shippingID;
            order.ShippingDate        = RequestHelper.DateNow;
            order.ShippingNumber      = string.Empty;
            order.ShippingMoney       = shippingMoney;
            order.PayKey              = payKey;
            order.PayName             = payPlugins.Name;
            order.PayDate             = RequestHelper.DateNow;;
            order.IsRefund            = (int)BoolType.False;
            order.FavorableActivityID = 0;
            order.GiftID              = 0;
            order.InvoiceTitle        = string.Empty;
            order.InvoiceContent      = string.Empty;
            order.UserMessage         = StringHelper.AddSafe(RequestHelper.GetForm <string>("UserMessage"));
            order.AddDate             = RequestHelper.DateNow;
            order.IP       = ClientHelper.IP;
            order.UserID   = base.UserID;
            order.UserName = base.UserName;
            int orderID = OrderBLL.AddOrder(order);

            OrderDetailInfo orderDetail = new OrderDetailInfo();

            orderDetail.OrderID       = orderID;
            orderDetail.ProductID     = product.ID;
            orderDetail.ProductName   = product.Name;
            orderDetail.ProductWeight = product.Weight;
            orderDetail.SendPoint     = 0;
            orderDetail.ProductPrice  = groupBuy.Price;
            orderDetail.BuyCount      = buyCount;
            orderDetail.FatherID      = 0;
            orderDetail.RandNumber    = string.Empty;
            orderDetail.GiftPackID    = 0;
            OrderDetailBLL.AddOrderDetail(orderDetail);
            //更改产品库存订单数量
            ProductBLL.ChangeProductOrderCountByOrder(orderID, ChangeAction.Plus);

            //添加团购单
            UserGroupBuyInfo buyInfo = new UserGroupBuyInfo();

            buyInfo.GroupBuyID = groupBuy.ID;
            buyInfo.Date       = RequestHelper.DateNow;
            buyInfo.IP         = ClientHelper.IP;
            buyInfo.BuyCount   = buyCount;
            buyInfo.OrderID    = orderID;
            buyInfo.UserID     = base.UserID;
            buyInfo.UserName   = base.UserName;
            buyInfo.Consignee  = consignee;
            buyInfo.RegionID   = singleUnlimitClass.ClassID;
            buyInfo.Address    = address;
            buyInfo.ZipCode    = zipCode;
            buyInfo.Tel        = tel;
            buyInfo.Email      = userEmail;
            buyInfo.Mobile     = mobile;
            UserGroupBuyBLL.AddUserGroupBuy(buyInfo);

            ResponseHelper.Redirect("/Finish-I" + orderID.ToString() + ".aspx");
        }
Example #17
0
        protected override void PostBack()
        {
            string url  = "/CheckOut.aspx";
            string str2 = StringHelper.AddSafe(RequestHelper.GetForm <string>("Consignee"));

            if (str2 == string.Empty)
            {
                ScriptHelper.Alert("收货人姓名不能为空", url);
            }
            string str3 = StringHelper.AddSafe(RequestHelper.GetForm <string>("Tel"));
            string str4 = StringHelper.AddSafe(RequestHelper.GetForm <string>("Mobile"));

            if ((str3 == string.Empty) && (str4 == string.Empty))
            {
                ScriptHelper.Alert("固定电话,手机必须得填写一个", url);
            }
            string str5 = StringHelper.AddSafe(RequestHelper.GetForm <string>("ZipCode"));

            if (str5 == string.Empty)
            {
                ScriptHelper.Alert("邮编不能为空", url);
            }
            string str6 = StringHelper.AddSafe(RequestHelper.GetForm <string>("Address"));

            if (str6 == string.Empty)
            {
                ScriptHelper.Alert("地址不能为空", url);
            }
            int form = RequestHelper.GetForm <int>("ShippingID");

            if (form == -2147483648)
            {
                ScriptHelper.Alert("请选择配送方式", url);
            }
            decimal productTotalPrice = Sessions.ProductTotalPrice;
            decimal num3 = RequestHelper.GetForm <decimal>("FavorableMoney");
            decimal num4 = RequestHelper.GetForm <decimal>("ShippingMoney");
            decimal num5 = RequestHelper.GetForm <decimal>("Balance");
            decimal num6 = RequestHelper.GetForm <decimal>("CouponMoney");

            if (((((productTotalPrice - num3) + num4) - num5) - num6) < 0M)
            {
                ScriptHelper.Alert("金额有错误,请重新检查", url);
            }
            string         key   = RequestHelper.GetForm <string>("Pay");
            PayPluginsInfo info  = PayPlugins.ReadPayPlugins(key);
            OrderInfo      order = new OrderInfo();

            order.OrderNumber = ShopCommon.CreateOrderNumber();
            order.IsActivity  = 0;
            if ((((((productTotalPrice - num3) + num4) - num5) - num6) == 0M) || (info.IsCod == 1))
            {
                order.OrderStatus = 2;
            }
            else
            {
                order.OrderStatus = 1;
            }
            order.OrderNote      = string.Empty;
            order.ProductMoney   = productTotalPrice;
            order.Balance        = num5;
            order.FavorableMoney = num3;
            order.OtherMoney     = 0M;
            order.CouponMoney    = num6;
            order.Consignee      = str2;
            SingleUnlimitClass class2 = new SingleUnlimitClass();

            order.RegionID = class2.ClassID;
            order.Address  = str6;
            order.ZipCode  = str5;
            order.Tel      = str3;
            if (base.UserID == 0)
            {
                order.Email = StringHelper.AddSafe(RequestHelper.GetForm <string>("Email"));
            }
            else
            {
                order.Email = CookiesHelper.ReadCookieValue("UserEmail");
            }
            order.Mobile              = str4;
            order.ShippingID          = form;
            order.ShippingDate        = RequestHelper.DateNow;
            order.ShippingNumber      = string.Empty;
            order.ShippingMoney       = num4;
            order.PayKey              = key;
            order.PayName             = info.Name;
            order.PayDate             = RequestHelper.DateNow;
            order.IsRefund            = 0;
            order.FavorableActivityID = RequestHelper.GetForm <int>("FavorableActivityID");
            order.GiftID              = RequestHelper.GetForm <int>("GiftID");
            order.InvoiceTitle        = StringHelper.AddSafe(RequestHelper.GetForm <string>("InvoiceTitle"));
            order.InvoiceContent      = StringHelper.AddSafe(RequestHelper.GetForm <string>("InvoiceContent"));
            order.UserMessage         = StringHelper.AddSafe(RequestHelper.GetForm <string>("UserMessage"));
            order.AddDate             = RequestHelper.DateNow;
            order.IP       = ClientHelper.IP;
            order.UserID   = base.UserID;
            order.UserName = base.UserName;
            int orderID = OrderBLL.AddOrder(order);

            if (num5 > 0M)
            {
                UserAccountRecordBLL.AddUserAccountRecord(-num5, 0, "支付订单:" + order.OrderNumber, base.UserID, base.UserName);
            }
            string str8 = RequestHelper.GetForm <string>("UserCoupon");

            if ((num6 > 0M) && (str8 != "0|0"))
            {
                UserCouponInfo userCoupon = UserCouponBLL.ReadUserCoupon(Convert.ToInt32(str8.Split(new char[] { '|' })[0]), base.UserID);
                userCoupon.IsUse   = 1;
                userCoupon.OrderID = orderID;
                UserCouponBLL.UpdateUserCoupon(userCoupon);
            }
            this.AddOrderProduct(orderID);
            ProductBLL.ChangeProductOrderCountByOrder(orderID, ChangeAction.Plus);
            ResponseHelper.Redirect("/Finish-I" + orderID.ToString() + ".aspx");
        }
Example #18
0
        public int AddOrder([FromForm] tb_Order orders, [FromForm] string lists)
        {
            List <tb_Menu> list = JsonConvert.DeserializeObject <List <tb_Menu> >(lists).ToList();

            return(bll.AddOrder(orders, list));
        }