public int Insert(Core.Domain.RefillTank model)
        {
            int ID = 0;

            db = new SqlConnection(ConfigurationManager.ConnectionStrings["cnConsumption"].ConnectionString);
            string sql = " INSERT INTO tblRefillTank(TankId,FillingDate,Quantity) " +
                         " VALUES (@TankId,@FillingDate,@Quantity)" +
                         " Select Cast(SCOPE_IDENTITY() AS int)";

            try
            {
                ID = db.Query <int>(sql, new
                {
                    model.TankId,
                    model.FillingDate,
                    model.Quantity
                }).SingleOrDefault();
            }
            catch (Exception e)
            {
                db.Close();
                return(0);
            }
            db.Close();
            return(ID);
        }
Exemple #2
0
        public ActionResult Add(Core.Domain.RefillTank model)
        {
            _RefillService = new RefillTankService();
            int RecordID = _RefillService.Insert(model);

            if (RecordID > 0)
            {
                Stock.UpdateStockTank("DC", 1, RecordID, model.TankId, "tblRefillTank", "ID", false);
                if (TempData["ConfimationMsg"] == null)
                {
                    TempData["ConfimationMsg"] = "Tank Refill Successfully";
                }
            }
            return(RedirectToAction("Add"));
        }