Beispiel #1
0
        public static void assignMaterialToItem(int itemId, int materialId, decimal quantity, int rate)
        {
            var instance     = Context.sharedInstance;
            int?locationId   = instance.Items.Find(itemId).LocationID;
            var materialItem = new MaterialItem();

            materialItem.ItemId     = itemId;
            materialItem.MaterialId = materialId;
            materialItem.Quantity   = quantity;
            materialItem.Rate       = rate;
            materialItem.LocationId = locationId;
            materialItem.IsDeleted  = false;
            materialItem.CreatedAt  = DateTime.Now;
            instance.MaterialItems.Add(materialItem);
            instance.SaveChanges();
            MaterialService.addQuantity(materialId, quantity * -1);
        }
        public static void addIndentMaterial(Indent indent, List <Material> list)
        {
            foreach (var material in  list)
            {
                var itemToAdd = new IndentMaterial();
                itemToAdd.IsDeleted  = false;
                itemToAdd.CreatedAt  = DateTime.Now;
                itemToAdd.IndentId   = indent.Id;
                itemToAdd.MaterialId = material.Id;
                itemToAdd.Quantity   = material.Quantity;

                var con = Context.sharedInstance;
                con.IndentMaterials.Add(itemToAdd);
                con.SaveChanges();

                MaterialService.addQuantity((int)itemToAdd.MaterialId, (Decimal)itemToAdd.Quantity);
            }
        }