Ejemplo n.º 1
0
        public static int Insert(int RefundGoodsID, int AgentID, int OrderID, string ProductName, int CustomerID, string SKU, double Quantity, double QuantityMax,
                                 string PriceNotFeeRefund, int ProductType, bool IsCount, int RefundType, string RefundFeePerProduct, string TotalRefundFee, string GiavonPerProduct,
                                 string DiscountPricePerProduct, string SoldPricePerProduct, string TotalPriceRow, DateTime CreatedDate, string CreatedBy)
        {
            using (var con = new inventorymanagementEntities())
            {
                #region Cập nhật thôn tin giá vốn
                Nullable <double> cogs = null;

                #region Sản phẩm đơn gian
                if (ProductType == 1)
                {
                    cogs = con.tbl_Product
                           .Where(x => x.ProductSKU == SKU)
                           .Select(x => x.CostOfGood.HasValue ? x.CostOfGood.Value : 0)
                           .SingleOrDefault();
                }
                #endregion

                #region Sản phẩm biến thể
                if (ProductType == 2)
                {
                    cogs = con.tbl_ProductVariable
                           .Where(x => x.SKU == SKU)
                           .Select(x => x.CostOfGood.HasValue ? x.CostOfGood.Value : 0)
                           .SingleOrDefault();
                }
                #endregion
                #endregion

                tbl_RefundGoodsDetails a = new tbl_RefundGoodsDetails();
                a.RefundGoodsID           = RefundGoodsID;
                a.AgentID                 = AgentID;
                a.OrderID                 = OrderID;
                a.ProductName             = ProductName;
                a.CustomerID              = CustomerID;
                a.SKU                     = SKU;
                a.Quantity                = Quantity;
                a.QuantityMax             = QuantityMax;
                a.PriceNotFeeRefund       = PriceNotFeeRefund;
                a.ProductType             = ProductType;
                a.IsCount                 = true;
                a.RefundType              = RefundType;
                a.RefundFeePerProduct     = RefundFeePerProduct;
                a.TotalRefundFee          = TotalRefundFee;
                a.GiavonPerProduct        = GiavonPerProduct;
                a.DiscountPricePerProduct = DiscountPricePerProduct;
                a.SoldPricePerProduct     = SoldPricePerProduct;
                a.TotalPriceRow           = TotalPriceRow;
                a.CreatedDate             = CreatedDate;
                a.CreatedBy               = CreatedBy;
                a.ModifiedDate            = CreatedDate;
                a.ModifiedBy              = CreatedBy;
                a.CostOfGood              = cogs.HasValue ? Convert.ToDecimal(cogs.Value) : 0;
                con.tbl_RefundGoodsDetails.Add(a);
                con.SaveChanges();
                int kq = a.ID;
                return(kq);
            }
        }
 public static int Insert(int RefundGoodsID, int AgentID, int OrderID, string ProductName, int CustomerID, string SKU, double Quantity, double QuantityMax,
                          string PriceNotFeeRefund, int ProductType, bool IsCount, int RefundType, string RefundFeePerProduct, string TotalRefundFee, string GiavonPerProduct,
                          string DiscountPricePerProduct, string SoldPricePerProduct, string TotalPriceRow, DateTime CreatedDate, string CreatedBy)
 {
     using (var dbe = new inventorymanagementEntities())
     {
         tbl_RefundGoodsDetails a = new tbl_RefundGoodsDetails();
         a.RefundGoodsID           = RefundGoodsID;
         a.AgentID                 = AgentID;
         a.OrderID                 = OrderID;
         a.ProductName             = ProductName;
         a.CustomerID              = CustomerID;
         a.SKU                     = SKU;
         a.Quantity                = Quantity;
         a.QuantityMax             = QuantityMax;
         a.PriceNotFeeRefund       = PriceNotFeeRefund;
         a.ProductType             = ProductType;
         a.IsCount                 = true;
         a.RefundType              = RefundType;
         a.RefundFeePerProduct     = RefundFeePerProduct;
         a.TotalRefundFee          = TotalRefundFee;
         a.GiavonPerProduct        = GiavonPerProduct;
         a.DiscountPricePerProduct = DiscountPricePerProduct;
         a.SoldPricePerProduct     = SoldPricePerProduct;
         a.TotalPriceRow           = TotalPriceRow;
         a.CreatedDate             = CreatedDate;
         a.CreatedBy               = CreatedBy;
         dbe.tbl_RefundGoodsDetails.Add(a);
         dbe.SaveChanges();
         int kq = a.ID;
         return(kq);
     }
 }
 public static int Insert(tbl_RefundGoodsDetails refundDetail)
 {
     using (var con = new inventorymanagementEntities())
     {
         con.tbl_RefundGoodsDetails.Add(refundDetail);
         con.SaveChanges();
         int kq = refundDetail.ID;
         return(kq);
     }
 }