Exemple #1
0
        public string SaveStock(AddExtraStock Model1)
        {
            tbl_KitchenStock tb = new tbl_KitchenStock();
            var duplicate       = _entities.tbl_KitchenStock.Where(o => o.RawMaterialId.Equals(Model1.RawId) && o.Quantity.Equals(Model1.currentstock)).SingleOrDefault();

            if (duplicate == null)
            {
                try
                {
                    if (Model1.RawMaterial != null)
                    {
                        tb          = _entities.tbl_KitchenStock.Where(x => x.RawMaterialId == Model1.RawId).SingleOrDefault();
                        tb.Quantity = Model1.currentstock;
                        _entities.SaveChanges();
                        return("Record Updated Successfully...");
                    }
                    else
                    {
                        tb.Quantity = Model1.currentstock;
                        _entities.tbl_KitchenStock.Add(tb);
                        _entities.SaveChanges();
                        return("Record Saved Successfully...");
                    }
                }
                catch
                {
                    return("something Wrong try Agian !");
                }
            }
            else
            {
                return(Model1.RawId + " Already Exits");
            }
        }
Exemple #2
0
        public string SaveRawMaterial(RawMaterialsModel model)
        {
            tbl_RawMaterials tb  = new tbl_RawMaterials();
            tblOpStckRate    tb1 = new tblOpStckRate();
            tbl_KitchenStock tb2 = new tbl_KitchenStock();
            var duplicate        = _entities.tbl_RawMaterials.Where(o => o.Name.Equals(model.Name) && o.units.Equals(model.Units) && o.rawcategoryId.Equals(model.RawCategoryId)).SingleOrDefault();

            if (duplicate == null)
            {
                try
                {
                    if (model.RawMaterialId != 0)
                    {
                        tb               = _entities.tbl_RawMaterials.Where(x => x.RawMaterialId == model.RawMaterialId).SingleOrDefault();
                        tb2              = _entities.tbl_KitchenStock.Where(x => x.RawMaterialId == model.RawMaterialId).SingleOrDefault();
                        tb.Name          = model.Name;
                        tb.units         = model.Units;
                        tb.reorder       = model.reorder;
                        tb.rawcategoryId = model.RawCategoryId;
                        tb2.Unit         = model.Units;
                        _entities.SaveChanges();
                        return("Record Updated Successfully...");
                    }
                    else
                    {
                        tb.Name           = model.Name;
                        tb.units          = model.Units;
                        tb.reorder        = model.reorder;
                        tb.rawcategoryId  = model.RawCategoryId;
                        tb1.MaterialId    = model.RawMaterialId;
                        tb2.RawMaterialId = model.RawMaterialId;
                        tb1.Rate          = Convert.ToDecimal("0.00");
                        tb1.Date          = Convert.ToDateTime("2017/09/30");
                        tb1.Qty           = Convert.ToDecimal("0.00");
                        tb1.IssQty        = Convert.ToDecimal("0.00");
                        tb2.Quantity      = Convert.ToDecimal("0.00");
                        tb2.Unit          = model.Units;
                        tb2.OutletId      = Convert.ToInt32("99");
                        _entities.tbl_RawMaterials.Add(tb);
                        _entities.tblOpStckRates.Add(tb1);
                        _entities.tbl_KitchenStock.Add(tb2);
                        _entities.SaveChanges();
                        return("Record Saved Successfully...");
                    }
                }
                catch
                {
                    return("something Wrong try Agian !");
                }
            }
            else
            {
                return(model.Name + " Already Exits");
            }
        }
        public void AutoInventory(int ItemId, int FullQty, int HalfQty, int OutletId)
        {
            bool data = entities.AutoInventories.Where(a => a.OutletId == OutletId).Select(a => a.IsInventory.Value).FirstOrDefault();

            if (data)
            {
                var     Ingredient   = (from p in entities.tbl_KitchenRawIndent where p.ItemId == ItemId select p).ToList();
                decimal expenseStock = 0;
                decimal remaining    = 0;
                foreach (var item in Ingredient)
                {
                    //tbl_KitchenStock tb = new tbl_KitchenStock();
                    //tb = (from p in entities.tbl_KitchenStock
                    //      where p.OutletId == OutletId
                    //      && p.RawMaterialId == item.RawMaterialId
                    //      select p).FirstOrDefault();
                    //var expenseStock = item.Quantity * FullQty;
                    //var remaining = tb.Quantity - expenseStock;

                    //tb.Quantity = remaining;
                    //entities.SaveChanges();
                    tbl_KitchenStock tb = new tbl_KitchenStock();
                    tb = (from p in entities.tbl_KitchenStock
                          where p.OutletId == OutletId &&
                          p.RawMaterialId == item.RawMaterialId
                          select p).FirstOrDefault();
                    if (item.Unit == "kg" || item.Unit == "ltr")
                    {
                        expenseStock = (item.Quantity * 1000) * FullQty;
                        remaining    = tb.Quantity - expenseStock;
                    }

                    else
                    {
                        expenseStock = item.Quantity * FullQty;
                        remaining    = tb.Quantity - expenseStock;
                    }
                    tb.Quantity = remaining;
                    entities.SaveChanges();
                }
            }
        }