public bool AddMaterial(string materialName, string materialUnit,int materialSQuantity)
 {
     ProductMaterial productMaterial = new ProductMaterial();
     productMaterial.ProductMaterialName = materialName;
     productMaterial.ProductMaterialUnit = materialUnit;
     productMaterial.CurrentQuantity = 0;
     productMaterial.StandardQuantity = materialSQuantity;
     productMaterial.IsActive = true;
     db.ProductMaterials.Add(productMaterial);
     db.SaveChanges();
     return true;
 }
예제 #2
0
 public static bool CheckProductMaterial(int productMaterialId, int importQuantity, int inputMaterialId)
 {
     ProductMaterial productMaterial = new ProductMaterial();
     if (inputMaterialId == 0)
     {
         productMaterial = db.ProductMaterials.SingleOrDefault(n => n.ProductMaterialId == productMaterialId && (n.CurrentQuantity + importQuantity) < n.StandardQuantity);
     }
     else
     {
         InputMaterial inputMaterialDetail = db.InputMaterials.SingleOrDefault(n => n.InputMaterialId == inputMaterialId);
         int changeInputMaterialQuantity = importQuantity - inputMaterialDetail.RemainQuantity;
         productMaterial = db.ProductMaterials.SingleOrDefault(n => n.ProductMaterialId == productMaterialId && (n.CurrentQuantity + changeInputMaterialQuantity) < n.StandardQuantity);
     }
     if (productMaterial != null)
     {
         return true;
     }
     return false;
 }