public JsonResult GetCostSetting(int chosenMonth)
        {
            _cmcOmtSqlDb.Configuration.ProxyCreationEnabled = false;
            CostSetting costSetting = _cmcOmtSqlDb.CostSettings.Where(s => s.MonthID == chosenMonth).FirstOrDefault();

            return(Json(costSetting, JsonRequestBehavior.AllowGet));
        }
        // GET: Cost
        public ActionResult Setting()
        {
            if (Session["user"] == null)
            {
                Response.Redirect("/Reports/Login", true);
            }

            int         currentMonth   = System.DateTime.Now.Month;
            CostSetting curCostSetting = _cmcOmtSqlDb.CostSettings.Where(s => s.MonthID == currentMonth).FirstOrDefault();

            return(View(curCostSetting));
        }
        public ActionResult Setting(int?month, string productionCost, string bargeCost, string totalSiteCost)
        {
            if (Session["user"] == null)
            {
                Response.Redirect("/Reports/Login", true);
            }

            CostSetting updatedSetting = _cmcOmtSqlDb.CostSettings.Where(s => s.MonthID == month).FirstOrDefault();;

            if (updatedSetting != null)
            {
                System.Diagnostics.Debug.WriteLine("Raw: " + productionCost + " | Converted: " + Convert.ToDecimal(productionCost.Replace(",", "")));
                updatedSetting.ProductionCost   = Convert.ToDecimal(productionCost.Replace(",", ""));
                updatedSetting.BargeloadingCost = Convert.ToDecimal(bargeCost.Replace(",", ""));
                updatedSetting.TotalSiteCost    = Convert.ToDecimal(totalSiteCost.Replace(",", ""));

                _cmcOmtSqlDb.Entry(updatedSetting).State = System.Data.Entity.EntityState.Modified;
                _cmcOmtSqlDb.SaveChanges();
            }

            return(View(updatedSetting));
        }