コード例 #1
0
        public void AddItem(ProductSkuInfo productSkuInfo, decimal quantity, decimal weight, decimal price, string productNumber, Guid positionID, string remark = "", Guid?purchaseOrderItemID = null)
        {
            if (productNumber == null)
            {
                productNumber = string.Empty;
            }
            MaterialRequisitionItem newMaterialRequisitionItem = new MaterialRequisitionItem();

            newMaterialRequisitionItem.MaterialRequisition   = this;
            newMaterialRequisitionItem.MaterialRequisitionID = this.ID;
            newMaterialRequisitionItem.Remark         = remark;
            newMaterialRequisitionItem.ProductSkuInfo = productSkuInfo;
            newMaterialRequisitionItem.Quantity       = quantity;
            newMaterialRequisitionItem.Weight         = weight;
            newMaterialRequisitionItem.Price          = price;
            if (productSkuInfo.PricingMethod == PricingMethod.PricingByQuantity)
            {
                newMaterialRequisitionItem.Amount = quantity * price;
            }
            else
            {
                newMaterialRequisitionItem.Amount = weight * price;
            }
            newMaterialRequisitionItem.ProductNumber = productNumber;
            newMaterialRequisitionItem.PositionID    = positionID;
            RefreshAmount(newMaterialRequisitionItem);
            Items.Add(newMaterialRequisitionItem);
        }
コード例 #2
0
        public void UpdateItem(Guid itemID, ProductSkuInfo productSkuInfo, decimal quantity, decimal weight, decimal price, string productNumber, Guid positionID, string remark = "")
        {
            MaterialRequisitionItem item = this.Items.FirstOrDefault(p => p.ID == itemID);

            if (item != null)
            {
                if (productNumber == null)
                {
                    productNumber = string.Empty;
                }
                //item.Product = product;
                item.ProductSkuInfo = productSkuInfo;
                item.Remark         = remark;
                item.Quantity       = quantity;
                item.Weight         = weight;
                item.ProductNumber  = productNumber;
                item.PositionID     = positionID;
                item.Price          = price;
                RefreshAmount(item);
            }
            else
            {
                throw new DomainException("无此ID");
            }
        }
コード例 #3
0
        public void RemoveItem(Guid itemID)
        {
            MaterialRequisitionItem item = Items.FirstOrDefault(p => p.ID == itemID);

            if (item == null)
            {
                throw new DomainException("无此ID");
            }
            Items.Remove(item);
        }
コード例 #4
0
 private void RefreshAmount(MaterialRequisitionItem item)
 {
     this.TotalAmount = this.TotalAmount - item.Amount;
     if (item.ProductSkuInfo.PricingMethod == PricingMethod.PricingByQuantity)
     {
         item.Amount = item.Quantity * item.Price;
     }
     else
     {
         item.Amount = item.Weight * item.Price;
     }
     this.TotalAmount = this.TotalAmount + item.Amount;
 }