public bool InsertAcademicYear(MS_AcademicYear year) { string sql = " Insert into MS_AcademicYear (AcademicYearName,StartDate,EndDate,IsCurrent,EnteredBy,EnteredDate,LastUpdatedBy,LastUpdatedDate," + "IsDeleted,DeletedBy,DeletedDate) " + " values " + "(@AcademicYearName,@StartDate,@EndDate,@IsCurrent,@EnteredBy,@EnteredDate,0,null,0,0,null)"; using (var db = DbHelper.GetDBConnection()) { using (var trsn = new TransactionScope()) { //db.Execute(sql); var lst = db.Execute(sql, year); trsn.Complete(); db.Close(); if (lst > 0) { return(true); } else { return(false); } } } }
public ActionResult Create(FormCollection frm) { MS_AcademicYear obj = new MS_AcademicYear(); obj.AcademicYearName = frm["AcademicYearName"]; if (frm["IsCurrent"] == "Y") { obj.IsCurrent = true; } else { obj.IsCurrent = false; } var aaa = frm["StartDate"]; obj.StartDate = DateTime.ParseExact(frm["StartDate"], "yyyy-MM-dd", null); obj.EndDate = DateTime.ParseExact(frm["EndDate"], "yyyy-MM-dd", null); if (ModelState.IsValid) { db.InsertAcademicYear(obj); return(RedirectToAction("Index")); } return(View(obj)); }
// GET: AcademicYear/Edit/5 public ActionResult Edit(int?id) { if (id == null || id == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MS_AcademicYear mS_AcademicYear = db.GetAcademicYearById((int)id); if (mS_AcademicYear == null) { return(HttpNotFound()); } return(View(mS_AcademicYear)); }
public bool UpdateAcademicYear(MS_AcademicYear year) { if (year.IsCurrent != null && year.IsCurrent == true) { string sql1 = " Update MS_AcademicYear set IsCurrent=@IsCurrent"; //" IsDeleted,DeletedBy,DeletedDate" + //" where AcademicYearId=@AcademicYearId"; using (var db = DbHelper.GetDBConnection()) { using (var trsn = new TransactionScope()) { //db.Execute(sql); var lst = db.Execute(sql1); trsn.Complete(); db.Close(); } } } string sql = " Update MS_AcademicYear set AcademicYearName=@AcademicYearName,StartDate=@StartDate,EndDate=@EndDate,IsCurrent=@IsCurrent," + " LastUpdatedBy=@LastUpdatedBy,LastUpdatedDate=@LastUpdatedDate" + //" IsDeleted,DeletedBy,DeletedDate" + " where AcademicYearId=@AcademicYearId"; using (var db = DbHelper.GetDBConnection()) { using (var trsn = new TransactionScope()) { //db.Execute(sql); var lst = db.Execute(sql, year); trsn.Complete(); db.Close(); if (lst > 0) { return(true); } else { return(false); } } } }
public ActionResult Edit(FormCollection frm) { MS_AcademicYear obj = db.GetAcademicYearById(Convert.ToInt32(frm["AcademicYearId"])); obj.AcademicYearName = frm["AcademicYearName"]; if (frm["IsCurrent"] == "Y") { obj.IsCurrent = true; } else { obj.IsCurrent = false; } obj.StartDate = DateTime.ParseExact(frm["StartDate"], "yyyy-MM-dd", null); obj.EndDate = DateTime.ParseExact(frm["EndDate"], "yyyy-MM-dd", null); if (ModelState.IsValid) { db.UpdateAcademicYear(obj); return(RedirectToAction("Index")); } return(View(obj)); }