public bool InsertAcademicStudent(ACD_Student student) { string sql = " Insert into ACD_Student (StudentName, StudentCode, StudentRegNo,Gender,OrganizationId,BatchId, " + "ClassId , SectionId, CurrentClassId, CurrentSectionId, AdmissionYear ," + " TemporaryAddress, PermanentAddress, Phone, DOB, DOBBS, FatherName , FatherContact," + " MotherName, MotherContact, EnteredBy ," + " EnteredDate, LastUpdatedBy , LastUpdatedDate, IsDeleted, DeletedBy, DeletedDate) " + " values " + "(@StudentName, @StudentCode, @StudentRegNo,@Gender,@OrganizationId,@BatchId," + " @ClassId , @SectionId, @CurrentClassId, @CurrentSectionId, @AdmissionYear ," + " @TemporaryAddress, @PermanentAddress, @Phone, @DOB, @DOBBS, @FatherName , @FatherContact," + " @MotherName, @MotherContact, @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, student); trsn.Complete(); db.Close(); if (lst > 0) { return(true); } else { return(false); } } } }
public bool UpdateAcademicStudent(ACD_Student aclass) { string sql = " Update ACD_Student set StudentName=@StudentName, StudentCode=@StudentCode, StudentRegNo=@StudentRegNo,Gender=@Gender,OrganizationId=@OrganizationId,BatchId=@BatchId, " + " ClassId=@ClassId , SectionId=@SectionId, CurrentClassId=@CurrentClassId, CurrentSectionId=@CurrentSectionId, AdmissionYear=@AdmissionYear ," + " TemporaryAddress=@TemporaryAddress, PermanentAddress=@PermanentAddress, Phone=@Phone, DOB=@DOB, DOBBS=@DOBBS, FatherName=@FatherName , FatherContact=@FatherContact," + " MotherName=@MotherName, MotherContact=@MotherContact, LastUpdatedBy=@LastUpdatedBy , LastUpdatedDate=@LastUpdatedDate" + " where StudentId=@StudentId"; using (var db = DbHelper.GetDBConnection()) { using (var trsn = new TransactionScope()) { //db.Execute(sql); var lst = db.Execute(sql, aclass); trsn.Complete(); db.Close(); if (lst > 0) { return(true); } else { return(false); } } } }
// GET: AcademicStudent/Details/5 public ActionResult Details(int?id) { var ses = sesrepo.GetSessionById((User as CustomPrincipal).UserId); int orgid = ses.OrganizationId; if (id == null || id == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ACD_Student obj = db.GetAcademicStudentById((int)id); if (obj == null) { return(HttpNotFound()); } ViewBag.OrganizationId = new SelectList(ddl.GetOrganizationList(), "Id", "Name", obj.OrganizationId); ViewBag.BatchId = new SelectList(ddl.GetBatchList(orgid), "Id", "Name", obj.BatchId); ViewBag.ClassId = new SelectList(ddl.GetClassList(orgid), "Id", "Name", obj.ClassId); ViewBag.SectionId = new SelectList(ddl.GetSectionList(orgid), "Id", "Name", obj.SectionId); ViewBag.CurrentClassId = new SelectList(ddl.GetClassList(orgid), "Id", "Name", obj.CurrentClassId); ViewBag.CurrentSectionId = new SelectList(ddl.GetSectionList(orgid), "Id", "Name", obj.CurrentSectionId); return(View(obj)); }
public ActionResult Create(FormCollection frm) { var ses = sesrepo.GetSessionById((User as CustomPrincipal).UserId); int orgid = ses.OrganizationId; ACD_Student obj = new ACD_Student(); obj.StudentName = frm["StudentName"]; obj.StudentCode = frm["StudentCode"]; obj.StudentRegNo = frm["StudentRegNo"]; //obj.Gender = frm["Gender"]; //if(!string.IsNullOrEmpty(frm["OrganizationId"])) obj.OrganizationId = orgid;// Convert.ToInt32(frm["OrganizationId"]); if (!string.IsNullOrEmpty(frm["BatchId"])) { obj.BatchId = Convert.ToInt32(frm["BatchId"]); } if (!string.IsNullOrEmpty(frm["ClassId"])) { obj.ClassId = Convert.ToInt32(frm["ClassId"]); } if (!string.IsNullOrEmpty(frm["SectionId"])) { obj.SectionId = Convert.ToInt32(frm["SectionId"]); } if (!string.IsNullOrEmpty(frm["CurrentClassId"])) { obj.CurrentClassId = Convert.ToInt32(frm["CurrentClassId"]); } if (!string.IsNullOrEmpty(frm["CurrentSectionId"])) { obj.CurrentSectionId = Convert.ToInt32(frm["CurrentSectionId"]); } if (!string.IsNullOrEmpty(frm["AdmissionYear"])) { obj.AdmissionYear = DateTime.ParseExact(frm["AdmissionYear"], "yyyy-MM-dd", null); } obj.TemporaryAddress = frm["TemporaryAddress"]; obj.PermanentAddress = frm["PermanentAddress"]; obj.Phone = frm["Phone"]; if (!string.IsNullOrEmpty(frm["DOB"])) { obj.DOB = DateTime.ParseExact(frm["DOB"], "yyyy-MM-dd", null); } obj.DOBBS = frm["DOBBS"]; obj.FatherName = frm["FatherName"]; obj.FatherContact = frm["FatherContact"]; obj.MotherName = frm["MotherName"]; obj.MotherContact = frm["MotherContact"]; obj.EnteredBy = (User as CustomPrincipal).UserId; obj.EnteredDate = DateTime.Now; if (ModelState.IsValid) { db.InsertAcademicStudent(obj); return(RedirectToAction("Index")); } ViewBag.OrganizationId = new SelectList(ddl.GetOrganizationList(), "Id", "Name", obj.OrganizationId); ViewBag.BatchId = new SelectList(ddl.GetBatchList(orgid), "Id", "Name", obj.BatchId); ViewBag.ClassId = new SelectList(ddl.GetClassList(orgid), "Id", "Name", obj.ClassId); ViewBag.SectionId = new SelectList(ddl.GetSectionList(orgid), "Id", "Name", obj.SectionId); ViewBag.CurrentClassId = new SelectList(ddl.GetClassList(orgid), "Id", "Name", obj.CurrentClassId); ViewBag.CurrentSectionId = new SelectList(ddl.GetSectionList(orgid), "Id", "Name", obj.CurrentSectionId); return(View(obj)); }