コード例 #1
0
ファイル: OrderService.cs プロジェクト: nguyentu1982/inthudo
 public void UpdateOrderDetail(OrderItemlBO orderDetail)
 {
     orderDao.UpdateOrderDetail(orderDetail);
 }
コード例 #2
0
ファイル: OrderService.cs プロジェクト: nguyentu1982/inthudo
 public int InsertOrderDetail(OrderItemlBO orderDetail)
 {
     return orderDao.InsertOrderDetail(orderDetail);
 }
コード例 #3
0
ファイル: OrderDao.cs プロジェクト: nguyentu1982/inthudo
 public int InsertOrderDetail(OrderItemlBO orderDetail)
 {
     using (var context = new InThuDoEntities())
     {
         var entity = Mapper.Map<OrderItemlBO, OrderItem>(orderDetail);
         context.OrderItems.Add(entity);
         context.Entry(entity).State = System.Data.EntityState.Added;
         context.SaveChanges();
         return entity.OrderItemId;
     }
 }
コード例 #4
0
ファイル: OrderDao.cs プロジェクト: nguyentu1982/inthudo
        public void UpdateOrderDetail(OrderItemlBO orderDetail)
        {
            using (var context = new InThuDoEntities())
            {
                var entity = context.OrderItems.Where(od => od.OrderItemId == orderDetail.OrderItemId).FirstOrDefault();
                if (entity == null) return;
                entity.ProductId = orderDetail.ProductId;
                entity.Specification = orderDetail.Specification;
                entity.Quantity = orderDetail.Quantity;
                entity.Price = orderDetail.Price;
                entity.LastEditedBy = orderDetail.LastEditedBy;
                entity.LastEditedOn = orderDetail.LastEditedOn;
                entity.IsCustomerHasDesign = orderDetail.IsCustomerHasDesign;
                entity.PrintingTypeId = orderDetail.PrintingTypeId;

                context.SaveChanges();
            }
        }
コード例 #5
0
        public OrderItemlBO SaveInfo(int orderId)
        {
            if (txtProduct.Text == string.Empty)
            {
                throw new Exception("Bạn phải nhập sản phẩm");
            }

            //Add product if not exist
            int productId = 0;
            ProductBO product = this.ProductService.GetProductByName(txtProduct.Text);

            if (product == null)
            {
                productId = this.ProductService.InsertProduct(txtProduct.Text);
            }
            else
            {
                productId = product.ProductId;
            }

            OrderItemlBO orderDetail = this.OrderService.GetOrderDetailById(this.OrderDetailId);
            if (orderDetail != null)
            {
                orderDetail.ProductId = productId;
                orderDetail.Specification = txtProductRequirement.Text;
                orderDetail.Quantity = ctrltxtQuantity.Value;
                orderDetail.Price = ctrltxtPrice.Value;
                orderDetail.LastEditedOn = DateTime.Now;
                orderDetail.LastEditedBy = this.LoggedInUserId;
                orderDetail.IsCustomerHasDesign = cbIsCustomerHasDesign.Checked;
                orderDetail.PrintingTypeId = int.Parse(cblPrintingType.SelectedValue);

                this.OrderService.UpdateOrderDetail(orderDetail);
            }
            else
            {

                orderDetail = new OrderItemlBO()
                {
                     OrderId = orderId,
                     ProductId = productId,
                     Specification = txtProductRequirement.Text,
                     Quantity = ctrltxtQuantity.Value,
                     Price = ctrltxtPrice.Value,
                     CreatedBy = this.UserId,
                     CreatedOn = DateTime.Now,
                     IsCustomerHasDesign = cbIsCustomerHasDesign.Checked,
                     PrintingTypeId = int.Parse(cblPrintingType.SelectedValue)
                };

                orderDetail.OrderItemId = this.OrderService.InsertOrderDetail(orderDetail);
            }
            return orderDetail;
        }