public void AddOrder()
        {
            ArrayList cartList = (ArrayList)Session["cartList"];

            if (cartList != null)
            {
                ShipmentModels sm        = new ShipmentModels();
                CustomerModel  cm        = new CustomerModel();
                customer       c         = cm.GetCustomer(Request.Cookies["username"].Value.ToString());
                shipment       s         = new shipment();
                String         billAddr  = c.customer_address;
                String         shipAddr  = c.customer_address;
                int            delCost   = 0;
                int            discount  = 0;
                int            calcTotal = (int)Calc_Total();
                int            finalCost = delCost + calcTotal + discount;
                String         email     = c.customer_email;

                s.time_created                  = DateTime.UtcNow;
                s.billing_address               = billAddr;
                s.shipping_address              = shipAddr;
                s.delivery_cost                 = delCost;
                s.discount                      = 0;
                s.final_price                   = finalCost;
                s.customer_customer_email       = email;
                s.payment_type_payment_type_id  = 1;
                s.shipment_type_sipment_type_id = 1;
                statusLabel.Text                = sm.CreateShipment(s) + "\n Check your orders in your profile.";
                Session["cartList"]             = null;
            }
            else
            {
                statusLabel.Text = "ERROR: DID NOT ADD ORDER";
            }
        }
示例#2
0
        public String allShipments()
        {
            ShipmentModels  s        = new ShipmentModels();
            List <shipment> shipList = s.GetAllShipments();
            string          ship     = shipList.Count.ToString();

            return(ship);
        }
示例#3
0
        public decimal totalOrdersValue()
        {
            decimal         totalSum = 0;
            ShipmentModels  s        = new ShipmentModels();
            List <shipment> shipList = s.GetAllShipments();

            for (int i = 0; i < shipList.Count; i++)
            {
                shipment ship = shipList[i];
                totalSum = totalSum + (decimal)ship.final_price;
            }
            return(totalSum);
        }
        public ActionResult Shipment(ShipmentModels model)
        {
            MembershipUser user   = Membership.GetUser();
            Guid           userId = Guid.Parse(user.ProviderUserKey.ToString());

            using (var context = db)
            {
                var dept = context.aspnet_CustomProfile.Where(w => w.UserId == userId).FirstOrDefault();
                if (dept == null || !dept.DeptId.HasValue || dept.DeptId == Guid.Empty)
                {
                    ModelState.AddModelError("", "请设置操作员部门信息");
                    return(View(model));
                }
                var tps = context.Transports.Where(w => w.Id == model.Id && w.Status == 1).ToList();
                if (tps.Count != 1)
                {
                    ModelState.AddModelError("", "此车未装车或在运输途中");
                    return(View(model));
                }

                if (string.IsNullOrEmpty(model.Shipment_CheckUser))
                {
                    ModelState.AddModelError("", "请输入签收人");
                    return(View(model));
                }
                if (model.Shipment_Quantity == 0)
                {
                    ModelState.AddModelError("", "请输入卸货数量");
                    return(View(model));
                }

                DXInfo.Models.Transport tp = tps[0];
                tp.Shipment_Date   = DateTime.Now;
                tp.Shipment_DeptId = dept.DeptId.Value;
                tp.Shipment_UserId = userId;
                tp.Comment         = model.Comment;

                tp.Shipment_Quantity  = model.Shipment_Quantity;
                tp.Shipment_CheckUser = model.Shipment_CheckUser;

                tp.Status = 2;

                context.SaveChanges();
            }
            return(View("ShipmentSucess"));
        }