public void Initialize()
        {
            customer1 = new Customer("00001", "LiuFeifan", "18812345678");
            customer2 = new Customer("00002", "Liuxia", "18202939333");

            pc     = new Goods("computer", "Lenovo 16G 512G i5", 4325.99, 1000);
            guitar = new Goods("guitar", "Mesopotamia S200 41", 2680, 2000);
            shirt  = new Goods("T-Shirt", "Li-Ning 2021", 129.98, 50);
            bag    = new Goods("handbag", "Dior Latest", 10000, 500);

            item0 = new OrderDetails(pc, 1);
            item1 = new OrderDetails(guitar, 2);
            item2 = new OrderDetails(shirt, 3);
            item3 = new OrderDetails(bag, 1);

            order0 = new Order("00000", customer1, "Wuhan", item0);
            order1 = new Order("00001", customer2, "Nanchang", item2);
            order2 = new Order("00002", customer1, "Shanghai", item1);
            order3 = new Order("00003", customer2, "Beijing", item3);

            orderService = new OrderService();
            orderService.Add(order0);
            orderService.Add(order1);
            orderService.Add(order2);
        }
示例#2
0
 public void InitializeOrderList()
 {
     service = OrderService.Instance();
     service.OrderList.Clear();
     service.Add(order1);
     service.Add(order2);
 }
示例#3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            textBox_query.DataBindings.Add("Text", this, "QueryString");
            comboBox_query.DataSource = selectList;

            customer1 = new Customer("00001", "LiuFeifan", "18812345678");
            customer2 = new Customer("00002", "Liuxia", "18202939333");

            pc     = new Goods("computer", "Lenovo 16G 512G i5", 4325.99, 1000);
            guitar = new Goods("guitar", "Mesopotamia S200 41", 2680, 2000);
            shirt  = new Goods("T-Shirt", "Li-Ning 2021", 129.98, 50);
            bag    = new Goods("handbag", "Dior Latest", 10000, 500);

            item0 = new OrderDetails(pc, 1);
            item1 = new OrderDetails(guitar, 2);
            item2 = new OrderDetails(shirt, 3);
            item3 = new OrderDetails(bag, 1);

            order0 = new Order("00000", customer1, "Wuhan", item0);
            order1 = new Order("00001", customer2, "Nanchang", item2);
            order2 = new Order("00002", customer1, "Shanghai", item1);
            order3 = new Order("00003", customer2, "Beijing", item3);

            orderService = new OrderService();
            orderService.Add(order0);
            orderService.Add(order1);
            orderService.Add(order2);
            orderService.Add(order3);
            orderbindingSource.DataSource = orderService.OrderList;
        }
        public void Intialize()
        {
            order1.OrderID      = 1 + 100;
            order1.Customername = "客户" + 1;
            for (int j = 0; j < 3; j++)
            {
                OrderItem item = new OrderItem();
                item.Amount   = 3;
                item.Price    = 9;
                item.Itemname = "商品" + j;
                item.ItemID   = 100 + j;
                order1.AddOrderItem(item);
            }

            order1.CountTotal();
            service.Add(order1);



            order2.OrderID      = 1 + 100;
            order2.Customername = "客户" + 2;
            for (int j = 0; j < 3; j++)
            {
                OrderItem item = new OrderItem();
                item.Amount   = 3;
                item.Price    = 9;
                item.Itemname = "商品" + j;
                item.ItemID   = 100 + j;
                order2.AddOrderItem(item);
            }

            order2.CountTotal();
        }
示例#5
0
        public void RemoveTest()
        {
            OrderService os = new OrderService();

            os.Add("zzq", "hubei", "矿泉水", 20);
            os.Add("xxx", "hunan", "面包", 2);
            os.Remove(2);
            Assert.IsTrue(os.orderlist.Count == 1);
        }
 public void AddTest1()
 {
     Assert.AreEqual(orderService.OrderList.Count, 3);
     orderService.Add(order3);
     Assert.AreEqual(orderService.OrderList.Count, 4);
     CollectionAssert.AreEqual(orderService.OrderList, new List <Order> {
         order0, order1, order2, order3
     });
 }
        public void Order_TestService_AddOrder_ShouldBeOk()
        {
            _mockRepository.Setup(or => or.Save(_order)).Returns(_order);

            Order resultadoEncontrado = _service.Add(_order);

            _mockRepository.Verify(or => or.Save(_order));
            resultadoEncontrado.Id.Should().BeGreaterThan(0);
        }
示例#8
0
        public void ModifyTest()
        {
            OrderService service = new OrderService();

            service.Add(new Order(1));
            service.Add(new Order(2));

            // 提供的订单号和要修改的不一样
            service.Modify(2, order2);
        }
示例#9
0
        public void ModifyTest1()
        {
            OrderService service = new OrderService();

            service.Add(new Order(1));
            service.Add(new Order(2));

            Order ori = service.Modify(2, order4);

            Assert.AreEqual(new Order(2), ori);
            Assert.AreEqual(service.SearchByNumber(2), order4);
        }
示例#10
0
        public void DeleteTest1()
        {
            OrderService service = new OrderService();

            service.Add(new Order(1));
            service.Add(new Order(2));
            service.Add(new Order(3));

            service.Delete(2);

            Assert.AreEqual(service.orderList.Count, 2);
        }
示例#11
0
        public void SortTest()
        {
            OrderService os = new OrderService();

            os.Add("zzq", "hubei", "矿泉水", 20);
            os.Add("txy", "hunan", "面包", 1);
            os.Add("abc", "beijing", "卫龙", 100);
            bool TestSum = true;

            os.Sort("Sum");
            for (int i = 0; i < os.orderlist.Count - 1; i++)
            {
                if (os.orderlist[i].Sum > os.orderlist[i + 1].Sum)
                {
                    TestSum = false;
                }
            }
            bool TestName = true;

            os.Sort("Name");
            for (int i = 0; i < os.orderlist.Count - 1; i++)
            {
                if (os.orderlist[i].client.ClientName[i] > os.orderlist[i].client.ClientName[i + 1])
                {
                    TestName = false;
                }
            }
            bool TestTime = true;

            os.Sort("Time");
            for (int i = 0; i < os.orderlist.Count - 1; i++)
            {
                if (os.orderlist[i].DT > os.orderlist[i].DT)
                {
                    TestTime = false;
                }
            }
            bool TestDefault = true;

            os.Sort();
            for (int i = 0; i < os.orderlist.Count - 1; i++)
            {
                if (os.orderlist[i].Ordernum > os.orderlist[i + 1].Ordernum)
                {
                    TestDefault = false;
                }
            }
            Assert.IsTrue(TestSum && TestName && TestTime && TestDefault);
        }
        public ActionResult Add()
        {
            if (Session["sepet"] == null)
            {
                return(Redirect("/Home/Index"));
            }

            ProductCart cart = Session["sepet"] as ProductCart;
            Order       o    = new Order();
            AppUser     user = _appUserService.FindByUserName(HttpContext.User.Identity.Name);

            o.AppUserID = user.ID;
            o.AppUser   = user;
            _appUserService.DetachEntity(user);

            Product p = new Product();

            foreach (var item in cart.CartProductList)
            {
                p = _productService.GetByID(item.ID);

                o.OrderDetails.Add(new OrderDetail
                {
                    ProductID = p.ID,
                    Quantity  = item.Quantity,
                    UnitPrice = item.UnitPrice
                });
                _productService.DetachEntity(p);
            }
            _orderService.Add(o);

            return(Redirect("/Home/Index"));
        }
示例#13
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (lstOrderDetail != null && lstOrderDetail.Count > 0)
     {
         ORDER order = new ORDER();
         var   cmd   = new OrderService(order);
         order.Action             = ActionEnum.Create;
         order.ORDER_CODE         = "";
         order.ORDER_DATE         = System.DateTime.Now;
         order.ORDER_STEP         = "1";
         order.ORDER_TOTAL        = Convert.ToDecimal(lblPrice.Text);
         order.ORDER_APPROVE      = "2";
         order.STORE_ID           = ((STORE)ViewState["store"]).STORE_ID;
         order.SYE_DEL            = true;
         order.CREATE_DATE        = System.DateTime.Now;
         order.CREATE_EMPLOYEE_ID = 0;
         order.UPDATE_DATE        = System.DateTime.Now;
         order.UPDATE_EMPLOYEE_ID = 0;
         int i = 1;
         foreach (ORDER_DETAIL od in lstOrderDetail)
         {
             od.PRODUCT_SEQ = i++;
         }
         order.ORDER_DETAIL = lstOrderDetail;
         cmd.Add();
         order.ORDER_CODE = "IV" + order.ORDER_ID;
         cmd.Edit();
         Response.Redirect("MainAdmin.aspx");
     }
 }
示例#14
0
 public void Add()
 {
     if (IsEdit == true)
     {
         toEdit.OrderItem        = OrderItem;
         toEdit.ItemQuantity     = ItemQuantity;
         toEdit.RecipientCompany = RecipientCompany;
         toEdit.CityTown         = CityTown;
         toEdit.PostalCode       = string.Format("{0}-{1}", PostalCode1, PostalCode2);
         toEdit.StreetAddress    = StreetAddress;
         toEdit.Weight           = Weight;
         toEdit.Description      = Description;
         OrderService.Edit(toEdit);
     }
     else
     {
         var newOrder = new OrderDTO();
         newOrder.OrderItem        = OrderItem;
         newOrder.ItemQuantity     = ItemQuantity;
         newOrder.RecipientCompany = RecipientCompany;
         newOrder.CityTown         = CityTown;
         newOrder.PostalCode       = string.Format("{0}-{1}", PostalCode1, PostalCode2);
         newOrder.StreetAddress    = StreetAddress;
         newOrder.Weight           = Weight;
         newOrder.Description      = Description;
         OrderService.Add(newOrder);
     }
     TryClose();
 }
示例#15
0
        public void AddTest()
        {
            OrderService     orderService1 = new OrderService();
            List <OrderItem> orderItems1   = new List <OrderItem>
            {
                new OrderItem(200, "apple1", 100, 1),
            };
            List <OrderItem> orderItems2 = new List <OrderItem>
            {
                new OrderItem(100, "apple1", 100, 1),
            };

            orderService1.Add(new Order(1, "zhangsan", "20000316", orderItems1));
            orderService1.Add(new Order(1, "zhangsan", "20000316", orderItems2));
            //Assert.Fail();
        }
        public ActionResult PlaceOrder(List <OrderedProduct> OrderedProducts)
        {
            var     uid        = User.Identity.GetUserId();
            decimal vTotalCost = 0;

            foreach (var a in OrderedProducts)
            {
                vTotalCost += a.Price * a.ProductQuantity;
            }
            Order order = new Order()
            {
                OrderDate = DateTime.Now,
                state     = 1,
                UserID    = uid,
                CompanyID = OrderedProducts[0].CompanyID,
                TotalCost = vTotalCost,
            };

            var createdOrder = OrderService.Add(order);

            foreach (var op in OrderedProducts)
            {
                op.OrderID = createdOrder.ID;
                OrderedProductService.Add(op);
            }

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
        public ActionResult Insert(Order item, Sepet item1)
        {
            List <Sepet> sepetim = (List <Sepet>)Session["sepetim"];

            if (Session["LoginUser"] != null)
            {
                kullanici = (AppUser)Session["LoginUser"];
                Order siparis = new Order();
                siparis.AppUserID       = kullanici.ID;
                siparis.OrderDate       = DateTime.Now;
                siparis.SendingDate     = DateTime.Now.AddMinutes(30);
                siparis.CustomerAddress = item.CustomerAddress;
                foreach (Sepet x in (List <Sepet>)Session["sepetim"])
                {
                    siparis.RestaurantID = x.RestaurantID;
                }

                os.Add(siparis);

                foreach (Sepet item3 in sepetim)
                {
                    OrderDetail detay = new OrderDetail();
                    detay.OrderID  = siparis.ID;
                    detay.MealID   = item3.MealID;
                    detay.Price    = item3.Price;
                    detay.Quantity = (short)item3.Quantity;

                    ods.Add(detay);
                    siparis.OrderDetails.Add(detay);
                }
                //Session["sepetim"] = null;
                return(RedirectToAction("SiparisDetay", "Order"));
            }
            return(View());
        }
示例#18
0
      public Form1()
      {
          InitializeComponent();
          Random random = new Random();

          service = new OrderService();
          for (int i = 0; i < 3; i++)
          {
              Order order = new Order();
              order.OrderID      = Convert.ToString(i) + 100;
              order.Customername = "客户" + i;
              for (int j = 0; j < 3; j++)
              {
                  OrderItem item = new OrderItem();
                  item.Amount   = random.Next(9) + 1;
                  item.Price    = random.Next(100) + 9;
                  item.Itemname = "商品" + j;
                  item.ItemID   = 100 + j;
                  order.AddOrderItem(item);
              }

              order.CountTotal();
              service.Add(order);
          }
          bindingSource1.DataSource = service.lists;
          textBox2.DataBindings.Add("Text", this, "CustomName");
          textBox1.DataBindings.Add("Text", this, "ID1");
          textBox3.DataBindings.Add("Text", this, "ID2");
      }
示例#19
0
        public TResult PayOrder(OrderCreateModel order)
        {
            var result = new TResult();

            if (order.TicketItem.Count <= 0)
            {
                return(result.ErrorResult("请选择您要购买的产品"));
            }

            var userInfo  = _enterpriseUserService.LoginForSession();
            var orderInfo = new OrderInfoCreateModel
            {
                PayType        = order.PayType,
                UserId         = userInfo.UserId,
                ValidityDate   = order.ValidityDate,
                Mobile         = "",
                Linkman        = "",
                TicketCategory = (int)TicketCategoryStatus.QrCodePrintTicket,
                TicketSource   = (int)TicketSourceStatus.ScenicSpot,
                TicketItem     = order.TicketItem
            };

            List <int> productIds       = orderInfo.TicketItem.Select(a => a.TicketId).ToList();
            var        tbl_Tickets      = _ticketService.GetTickets(productIds);
            var        tbl_Order        = _orderService.AddOrder(orderInfo);
            var        tbl_OrderDetails = _orderDetailService.AddOrderDetails(orderInfo, tbl_Order);

            _orderService.UpdateOrder(tbl_Order, tbl_OrderDetails);
            var tbl_Ticket_Testings = _ticketTestingService.addTicketTestings(tbl_Order, tbl_OrderDetails);

            _ticketService.UpdateTicketBySellCount(tbl_Tickets, tbl_OrderDetails);
            try
            {
                _orderService.BeginTran();
                _orderService.Add(tbl_Order);
                _orderDetailService.Add(tbl_OrderDetails);
                _ticketTestingService.Add(tbl_Ticket_Testings);
                _saleLogService.Add(tbl_Order);
                _ticketService.Update(tbl_Tickets);
                //提交事物
                _orderService.CommitTran();
            }
            catch
            {
                _orderService.RollbackTran();
                return(result.ErrorResult());
            }

            //打印机打印
            if (order.IsPrint && !string.IsNullOrEmpty(order.PrintKey))
            {
                var isPrint = _printService.Print(tbl_Order.OrderNo, order.PrintKey);
                if (!isPrint.Success)
                {
                    return(result.ErrorResult("门票创建成功," + isPrint.Message));
                }
            }

            return(result.SuccessResult());
        }
示例#20
0
        public ActionResult Add()
        {
            if (Session["sepet"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            ProductCart cart = Session["sepet"] as ProductCart;

            Order newOrder = new Order();

            AppUser currentUser = _appUserService.FindByEmail(HttpContext.User.Identity.Name);

            newOrder.AppUserID = currentUser.ID;

            foreach (var item in cart.CartProductList)
            {
                Product nextCartProduct = _productService.GetById(item.ID);
                newOrder.OrderDetails.Add(new OrderDetail
                {
                    ProductID = nextCartProduct.ID,
                    Quantity  = item.Quantity,
                    UnitPrice = item.UnitPrice
                });
            }

            _orderService.Add(newOrder);


            return(RedirectToAction("Index", "Home"));
        }
示例#21
0
        public void CreateOrder_ShouldMapProperties_To_DbOrder()
        {
            // Arrange
            var dateToTest = DateTime.Now;
            var inputDto   = new NewOrderDto()
            {
                Total = 100, CreatedDate = dateToTest
            };

            var mockOrderRepository = new Mock <IOrderRepository>();
            var orderForPersistance = default(Order);

            mockOrderRepository.Setup(r => r.Create(It.IsAny <Order>())).Callback <Order>(o => orderForPersistance = o);

            // Act
            var orderService = new OrderService(mockOrderRepository.Object);

            orderService.Add(inputDto);

            // Assert
            var dbOrder = new Order {
                Total = 100, UserId = -1, OrderItems = new List <OrderItem>(), CreatedDate = dateToTest.ToUniversalTime()
            };

            mockOrderRepository.Verify(moqRepo => moqRepo.Create(It.IsAny <Order>()), Times.Once);
            dbOrder.Should().BeEquivalentTo(orderForPersistance);
        }
示例#22
0
        public ViewResult CheckOut(Cart cart, Order order)
        {
            if (cart.Lines.Count() == 0)
            {
                ModelState.AddModelError("", "Sorry, your cart isempty!");
            }

            if (ModelState.IsValid)
            {
                ApplicationUser user = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(User.Identity.GetUserId());
                if (user != null)
                {
                    order.UserID = user.Id;
                }
                else
                {
                    order.UserID = "online";
                }
                OrderService.Add(cart, order);
                ProductService.Update(order);

                EmailHelper.SendMail(order.Email, "New order submitted!", CommonHelpers.FormatCart(cart, order));
                cart.Clear();
                return(View("Completed"));
            }
            return(View(order));
        }
示例#23
0
        /// <summary>
        /// 学员下订单
        /// </summary>
        public int MakeOrder(int studentId, int courseId)
        {
            CourseBll courseBll = new CourseBll();
            SchoolBll schoolBll = new SchoolBll();

            Yw_Course course = courseBll.GetCourse(courseId);
            if (course == null || course.Ycs_Status != (int)CourseStatusEnum.已上架)
            {
                throw new AbhsException(ErrorCodeEnum.CourseCanNotBuy, AbhsErrorMsg.ConstCourseCanNotBuy);
            }

            Bas_School school = schoolBll.GetSchoolByStudent(studentId);
            if (school == null)
            {
                throw new AbhsException(ErrorCodeEnum.StudentNotBindSchool, AbhsErrorMsg.ConstStudentNotBindSchool);
            }

            Yw_CoursePrice price = courseBll.GetCoursePrice(courseId, school.Bsl_Level);
            Yw_StudentOrder order = new Yw_StudentOrder();
            order.Yod_CourseId = courseId;
            order.Yod_OrderNo = GenerateOrderNo(courseId, studentId);
            order.Yod_OrderTime = DateTime.Now;
            order.Yod_OrderType = (int)OrderTypeEnum.订单;
            order.Yod_PayBatchId = 0;
            order.Yod_ReferOrderId = 0;
            order.Yod_PayTime = new DateTime(1900, 1, 1);
            order.Yod_Status = (int)StudentOrderStatus.待支付;
            order.Yod_StudentId = studentId;
            order.Yod_UpdateTime = DateTime.Now;
            order.Yod_Amount = price.Yce_Price;
            OrderService.Add(order);
            return order.Yod_Id;
        }
示例#24
0
        public ActionResult OrderCreate(Product data)//Kasa Satış ve Mobil satış için sipariş oluşturma sayfası
        {
            //Sepet boşsa ana sayfaya yönlendir.
            if (Session["sepet"] == null)
            {
                return(RedirectToAction("Index", "Cart", new { area = "Member" }));
            }
            //Sepeti yakalıyoruz.
            ProductCart cart = Session["sepet"] as ProductCart;

            //Yeni sipariş oluşturuyoruz.
            Order order = new Order();

            //Siparişin sahibi olan kullanıcının idsini yakaladık.
            order.AppUserID = _appUserService.GetByDefault(x => x.UserName == HttpContext.User.Identity.Name).ID;

            //Sepettki tüm ürünlerde geziyoruz, her ürün için bir sipariş detay oluşturuyoruz(Northwind örneğindeki gibi) ve bu her sipariş detayını siparişe ekliyoruz.
            foreach (var item in cart.CartProductList)
            {
                order.OrderDetails.Add(new OrderDetail
                {
                    ProductID = item.ID,
                    Quantity  = item.Quantity,
                });
            }
            //Deponun onaylayabilmesi için false yapıyoruz.
            order.IsConfirmed = false;

            _orderService.Add(order);

            return(RedirectToAction("OrderList", "Order", new { area = "Member" }));
        }
示例#25
0
        public void SearchTest()
        {
            OrderService os = new OrderService();

            os.Add("zzq", "hubei", "矿泉水", 20);
            Assert.IsTrue(os.Search("zzq").Equals("[1 " + DateTime.Now + " zzq hubei [[矿泉水,1.5],20,30] 30]"));
        }
示例#26
0
        public async Task <IHttpActionResult> PostOrder(AddOrderRequest dto)
        {
            await orderService.Add(dto);

            Uow.Commit();
            return(await Task.FromResult(Ok()));
        }
示例#27
0
        public RedirectToRouteResult Checkout()
        {
            //Sepet boşsa kategori listesine döndür.
            if (Session["sepet"] == null)
            {
                return(RedirectToAction("Index", "Category", new { area = "Member" }));
            }
            //Sepeti yakalıyoruz.
            ProductCart cart = Session["sepet"] as ProductCart;

            //Yeni sipariş oluşturuyoruz.
            Order o = new Order();

            //Siparişi yapacak kişinin id'sini yakalıyoruz ve siparişe ekliyoruz.
            o.AppUserID = _appUserService.FindByUserName(HttpContext.User.Identity.Name).ID;


            //Sepetteki tüm ürünlerde geziyoruz. Her ürün için siparişimizin ürün detay listesine yeni bir sipariş detay oluşturuyoruz.
            foreach (var item in cart.CartProductList)
            {
                o.OrderDetails.Add(new OrderDetail
                {
                    ProductID = item.Id,
                    Quantity  = item.Quantity,
                    UnitPrice = item.UnitPrice
                });
            }

            //Adminden onay bekleyececği için false yapıyoruz.
            o.isConfirmed = false;

            _orderService.Add(o);

            return(RedirectToAction("Index", "Category", new { area = "Member" }));
        }
示例#28
0
        public ActionResult ShoppingCartSave(OrderViewModel orderViewModel)
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <OrderViewModel, Order>();
            });
            IMapper mapper = config.CreateMapper();
            var     order  = mapper.Map <OrderViewModel, Order>(orderViewModel);

            try
            {
                var orderId = _orderService.Add(order);
                return(Json(new
                {
                    success = true,
                    redirectUrl = Url.Action("OrderDetails", "Order", new { id = orderId })
                }));
            }catch (Exception ex)
            {
                return(Json(new
                {
                    success = false,
                    errors = new { ex.Message }
                }));
            }
        }
示例#29
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var model = new Model.reception.Order1
            {
                Order_Name       = this.txtName.Text,
                Order_Price      = int.Parse(this.txtPrice.Text),
                Order_Content    = this.txtContent.Text,
                Order_WebMenusId = Guid.Parse(this.ddlWebMenuId.SelectedValue)
            };
            var res = os.Add(model);
            var rm  = res > 0 ? new ReturnMsg()
            {
                Code    = StatusCode.Ok,
                Message = "新增优化信息成功",
                Data    = null
            } : new ReturnMsg()
            {
                Code    = StatusCode.Error,
                Message = "新增优化信息失败",
                Data    = null
            };

            Session["Msg"] = rm;
            Response.Redirect("Seos_List.aspx");
        }
示例#30
0
        public void SelectByNumberTest()
        {
            OrderService     orderService1 = new OrderService();
            List <OrderItem> orderItems1   = new List <OrderItem>
            {
                new OrderItem(200, "apple1", 100, 1),
            };
            List <OrderItem> orderItems2 = new List <OrderItem>
            {
                new OrderItem(100, "apple1", 100, 1),
            };

            orderService1.Add(new Order(1, "zhangsan", "20000316", orderItems1));
            orderService1.Add(new Order(1, "zhangsan", "20000316", orderItems2));
            orderService1.SelectByNumber(1);
        }