//Add new record public static int AddUpdateRecord(etblAdditionalCommission eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { SqlParameter[] parameters = { new SqlParameter("@iAdditionalCommisionId", eobj.iAdditionalCommisionId), new SqlParameter("@dtCommisionStartDate", eobj.dtCommisionStartDate), new SqlParameter("@dtCommisionEndDate", eobj.dtCommisionEndDate), new SqlParameter("@bActive", eobj.bActive), new SqlParameter("@dCommission", eobj.dCommission), new SqlParameter("@iPropId", eobj.iPropId), new SqlParameter("@iActionBy", eobj.iActionBy) }; retval = db.Database.SqlQuery <int>("uspSetAdditionalCommision @iAdditionalCommisionId, @dtCommisionStartDate,@dtCommisionEndDate, @bActive, @dCommission, @iPropId, @iActionBy", parameters).SingleOrDefault(); //OneFineRate.tblAdditionalCommision dbstate = (OneFineRate.tblAdditionalCommision)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblAdditionalCommision()); //db.tblAdditionalCommisions.Add(dbstate); //db.SaveChanges(); //retval = 1; } catch (Exception) { throw; } } return(retval); }
public ActionResult AddEditCommission(etblAdditionalCommission model) { if (ModelState.IsValid) { try { string sStartDate = model.dtCommisionStartDate; string sEndDate = model.dtCommisionEndDate; model.iPropId = Convert.ToInt32(Session["PropId"].ToString()); model.iActionBy = ((OneFineRateBLL.BL_Login.UserDetails)(Session["UserDetails"])).iUserId; model.dtCommisionStartDate = clsUtils.ConvertddmmyyyytommDDyyyy(model.dtCommisionStartDate); model.dtCommisionEndDate = clsUtils.ConvertddmmyyyytommDDyyyy(model.dtCommisionEndDate); var startDate = DateTime.ParseExact(model.dtCommisionStartDate, "mm/dd/yyyy", null); var endDate = DateTime.ParseExact(model.dtCommisionEndDate, "mm/dd/yyyy", null); if (startDate > endDate) { return(Json(new { status = -1, msg = "Start Date must be less than End Date ! " }, JsonRequestBehavior.AllowGet)); } string statusMessage = string.Empty; int status = BL_AdditionalCommission.AddUpdateRecord(model); if (status == 0) { statusMessage = "Commission already exist between " + sStartDate + " and " + sEndDate; } else if (model.iAdditionalCommisionId != 0 && status == 1) { statusMessage = "Commission updated successfully"; } else { statusMessage = "Commission added successfully"; } return(Json(new { status = status, msg = statusMessage }, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new { status = -1, msg = "Some unknown error has occurred ! Please try after some time." }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { status = -1, msg = "Valiation error..." }, JsonRequestBehavior.AllowGet)); } }
//Get Single Record public static etblAdditionalCommission GetSingleRecordById(int iCommissionId) { etblAdditionalCommission eobj = new etblAdditionalCommission(); using (OneFineRateEntities db = new OneFineRateEntities()) { var dbobj = db.tblAdditionalCommisions.SingleOrDefault(u => u.iAdditionalCommisionId == iCommissionId); if (dbobj != null) { eobj.iAdditionalCommisionId = dbobj.iAdditionalCommisionId; eobj.bActive = dbobj.bActive; eobj.dCommission = dbobj.dCommission; eobj.dtActionDate = dbobj.dtActionDate; eobj.dtCommisionEndDate = dbobj.dtCommisionEndDate.Value.ToString("dd/MM/yyyy"); eobj.dtCommisionStartDate = dbobj.dtCommisionStartDate.Value.ToString("dd/MM/yyyy"); eobj.iActionBy = dbobj.iActionBy; eobj.iPropId = dbobj.iPropId; } } return(eobj); }
public ActionResult AddEditCommission(int?commissionId) { var PropId = Convert.ToInt32(Session["PropId"].ToString()); decimal value = BL_AdditionalCommission.GetPropertyCommission(PropId); if (commissionId.HasValue && commissionId != 0) { etblAdditionalCommission obj = BL_AdditionalCommission.GetSingleRecordById(commissionId.Value); obj.baseDCommission = value; ViewBag.HeaderText = "Edit Commission"; return(PartialView("_AddCommission", obj)); } else { ViewBag.HeaderText = "Add Commission"; return(PartialView("_AddCommission", new etblAdditionalCommission() { baseDCommission = value })); } }