public ActionResult Edit(int?Id)
        {
            FillDropDowns();
            ServiceExpense model = repo.GetServiceExpense(Id ?? 0);

            return(View(model));
        }
        public ActionResult Create()
        {
            ServiceExpense model = new ServiceExpense();

            FillDropDowns();
            return(View(model));
        }
 public int Edit(ServiceExpense model)
 {
     using (IDbConnection connection = OpenConnection(sqlConnString))
     {
         string query        = @"UPDATE ServiceExpense SET
                         SerSAC = @SerSAC
                         ,SerName = @SerName
                         ,gstId = @gstId
                         ,SerOrExp = @SerOrExp
                         ,SerRemarks = @SerRemarks
                         WHERE SerId=@SerId";
         int    rowsAffected = connection.Execute(query, model);
         return(rowsAffected);
     }
 }
 public ActionResult Edit(ServiceExpense model)
 {
     if (ModelState.IsValid)
     {
         int rowsAffected = repo.Edit(model);
         if (rowsAffected > 0)
         {
             TempData["message"] = "Successfully Updated";
             return(RedirectToAction("Index"));
         }
         else
         {
             FillDropDowns();
             return(View(model));
         }
     }
     return(View(model));
 }
 public ActionResult Create(ServiceExpense model)
 {
     if (ModelState.IsValid)
     {
         int rowsAffected = repo.Create(model);
         if (rowsAffected > 0)
         {
             TempData["message"] = "Successfully Saved";
             return(RedirectToAction("Create"));
         }
         else
         {
             FillDropDowns();
             return(View(model));
         }
     }
     FillDropDowns();
     return(View(model));
 }
 public int Create(ServiceExpense model)
 {
     using (IDbConnection connection = OpenConnection(sqlConnString))
     {
         string query        = @"INSERT INTO ServiceExpense(
                         SerSAC
                         ,SerName
                         ,gstId
                         ,SerOrExp
                         ,SerRemarks
                         )
                         select 
                         @SerSAC
                         ,@SerName
                         ,@gstId
                         ,@SerOrExp
                         ,@SerRemarks";
         int    rowsAffected = connection.Execute(query, model);
         SetIdentity <int>(connection, id => model.SerId = id);
         return(rowsAffected);
     }
 }