public bool InsertAcademicStudentClassSection(ACD_StudentClassSection stdclassSection) { string sql = " Insert into ACD_StudentClassSection (StudentId,ClassId,SectionId,AcademicYear,AssignedDate,AssignedDateBS,EnteredBy, EnteredDate,LastUpdatedBy,LastUpdatedDate,IsDeleted,DeletedBy,DeletedDate) " + " values " + "(@StudentId,@ClassId,@SectionId,@AcademicYear,@AssignedDate,@AssignedDateBS,@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, stdclassSection); trsn.Complete(); db.Close(); if (lst > 0) { return(true); } else { return(false); } } } }
public ActionResult AssignSection(FormCollection form, string[] a) { var ses = sesrepo.GetSessionById((User as CustomPrincipal).UserId); int orgid = ses.OrganizationId; try { ACD_StudentClassSection classSection; ACD_Student student; DateTime time = DateTime.Now; if (a != null && a.Count() > 0) { foreach (var stid in a) { classSection = new ACD_StudentClassSection(); classSection.StudentId = Convert.ToInt32(stid); classSection.ClassId = Convert.ToInt32(form["ClassId"]); classSection.SectionId = Convert.ToInt32(form["SectionId"]); classSection.AcademicYear = form["AcademicYear"]; classSection.AssignedDate = time; classSection.EnteredBy = (User as CustomPrincipal).UserId; classSection.EnteredDate = DateTime.Now; dbst.InsertAcademicStudentClassSection(classSection); student = db.GetAcademicStudentById(Convert.ToInt32(stid)); student.CurrentClassId = classSection.ClassId; student.CurrentSectionId = classSection.SectionId; student.LastUpdatedBy = (User as CustomPrincipal).UserId; student.LastUpdatedDate = DateTime.Now; db.UpdateAcademicStudent(student); } } } catch (Exception ex) { ViewBag.AcademicYear = new SelectList(ddl.GetYearList(), "Id", "Name"); ViewBag.BatchId = new SelectList(ddl.GetBatchList(orgid), "Id", "Name"); ViewBag.ClassId = new SelectList(ddl.GetClassList(orgid), "Id", "Name"); ViewBag.SectionId = new SelectList(ddl.GetSectionList(orgid), "Id", "Name"); return(View()); } return(RedirectToAction("Index")); }