public ActionResult CreateStudentOtherDetails(Student_Other_Details Student_Other_Detail) { string sReturn_Text = string.Empty; Student_Other_Details newStudentOtherDetailsToBeAdded = new Student_Other_Details(); newStudentOtherDetailsToBeAdded = Student_Other_Detail; newStudentOtherDetailsToBeAdded.Mother_Occupation_Id = Student_Other_Detail.Mother_Occupation_Id; newStudentOtherDetailsToBeAdded.Father_Occupation_Id = Student_Other_Detail.Father_Occupation_Id; newStudentOtherDetailsToBeAdded.Is_Active = true; newStudentOtherDetailsToBeAdded.Created_By = 5; //newStudentOtherDetailsToBeAdded.Student_Id = 113; newStudentOtherDetailsToBeAdded.Student_Id = Convert.ToInt64(TempData.Peek("Student_Id")); newStudentOtherDetailsToBeAdded.Created_On = DateTime.Now; try { using (var dbcontext = new SchoolERPDBContext()) { dbcontext.Student_Other_Details.Add(newStudentOtherDetailsToBeAdded); dbcontext.SaveChanges(); sReturn_Text = "Student Other Details Saved Successfully"; } } catch (Exception ex) { sReturn_Text = "Error"; } return(Json(sReturn_Text, JsonRequestBehavior.AllowGet)); }
public ActionResult EditStudentOtherDetails(string sStudent_Id) { long nStudent_Id = Convert.ToInt64(sStudent_Id); Student_Other_Details student_OtherDetails_ToBeEdited = new Student_Other_Details(); GetCategory(); GetSecondLanguage(); GetOccupation(); using (var dbcontext = new SchoolERPDBContext()) { if (dbcontext.Student_Other_Details.Where(x => x.Student_Id == nStudent_Id).Count() == 1) { var id = dbcontext.Student_Other_Details.Where(x => x.Student_Id == nStudent_Id).FirstOrDefault().StudentDetail_Id; var studen_OtherDetailsTotEdit = dbcontext.Student_Other_Details.Find(id); //GetSectionForClass(Convert.ToString(studentEdited.Class_Id)); //GetStatesForCountry(Convert.ToString(studentEdited.Country_Id)); //GetCitiesForState(Convert.ToString(studentEdited.State_Id)); student_OtherDetails_ToBeEdited = studen_OtherDetailsTotEdit; } else { student_OtherDetails_ToBeEdited.Student_Id = nStudent_Id; } } return(View(student_OtherDetails_ToBeEdited)); // return View(); }
public async Task <ActionResult> CreateStudentOther([Bind(Include = "StudentDetail_Id,Identification_Mark1,Identification_Mark2,Is_Allergic,Allergy_Details,Father_Occupation_Id,Father_Annual_Income,Mother_Occupation_Id,Mother_Annual_Income,Caste,Religion,Languages_Known,Second_Language_Opted_Id,Birth_Certificate,Upload_Document1,UpLoad_Document2,Academic_Year,Category_Id")] Student_Other_Details student_Other_Details, string command) { var userId = LoggedInUser.Id; if (ModelState.IsValid) { int Student_Id = Convert.ToInt32(Request.Form["Student_Id"]); student_Other_Details.Student_Id = Student_Id; student_Other_Details.Created_On = DateTime.Now; student_Other_Details.Created_By = userId; db.Student_Other_Details.Add(student_Other_Details); await db.SaveChangesAsync(); switch (command) { case "Save & Back To List": return(RedirectToAction("Index")); case "Save & Continue": TempData["SiblingForStudentId"] = student_Other_Details.Student_Id; return(RedirectToAction("SaveAndContiune")); default: return(RedirectToAction("Index")); } } ViewBag.Father_Occupation_Id = new SelectList(db.Father_Occu, "Id", "Occupation"); ViewBag.Mother_Occupation_Id = new SelectList(db.Mother_Occu, "Id", "Occupation"); ViewBag.Second_Language_Opted_Id = new SelectList(db.Languag, "Id", "Name"); ViewBag.Category_Id = new SelectList(db.Categories, "Id", "Name"); return(View(student_Other_Details)); }
public ActionResult EditAndSaveStudentOtherDetails(Student_Other_Details Student_Other_Detail) { long nStudent_Id = Convert.ToInt64(Student_Other_Detail.Student_Id); Student_Other_Details student_OtherDetails_ToBeEdited = new Student_Other_Details(); string sReturn_Text = string.Empty; try { using (var dbcontext = new SchoolERPDBContext()) { //var id = dbcontext.Student_Other_Details.Where(x => x.Student_Id == nStudent_Id).FirstOrDefault().StudentDetail_Id; if (dbcontext.Student_Other_Details.Where(x => x.Student_Id == nStudent_Id).Count() == 1) { var studen_OtherDetailsTotEdit = dbcontext.Student_Other_Details.Find(Student_Other_Detail.StudentDetail_Id); studen_OtherDetailsTotEdit.Identification_Mark1 = Student_Other_Detail.Identification_Mark1; studen_OtherDetailsTotEdit.Identification_Mark2 = Student_Other_Detail.Identification_Mark2; studen_OtherDetailsTotEdit.Is_Allergic = Student_Other_Detail.Is_Allergic; studen_OtherDetailsTotEdit.Allergy_Details = Student_Other_Detail.Allergy_Details; studen_OtherDetailsTotEdit.Father_Occupation_Id = Student_Other_Detail.Father_Occupation_Id; studen_OtherDetailsTotEdit.Father_Designation = Student_Other_Detail.Father_Designation; studen_OtherDetailsTotEdit.Father_Company_Name = Student_Other_Detail.Father_Company_Name; studen_OtherDetailsTotEdit.Father_Office_Address = Student_Other_Detail.Father_Office_Address; studen_OtherDetailsTotEdit.Father_Annual_Income = Student_Other_Detail.Father_Annual_Income; studen_OtherDetailsTotEdit.Mother_Occupation_Id = Student_Other_Detail.Mother_Occupation_Id; studen_OtherDetailsTotEdit.Mother_Designation = Student_Other_Detail.Mother_Designation; studen_OtherDetailsTotEdit.Mother_Company_Name = Student_Other_Detail.Mother_Company_Name; studen_OtherDetailsTotEdit.Mother_Office_Address = Student_Other_Detail.Mother_Office_Address; studen_OtherDetailsTotEdit.Mother_Annual_Income = Student_Other_Detail.Mother_Annual_Income; studen_OtherDetailsTotEdit.Medical_History_Details = Student_Other_Detail.Medical_History_Details; studen_OtherDetailsTotEdit.Second_Language_Opted_Id = Student_Other_Detail.Second_Language_Opted_Id; studen_OtherDetailsTotEdit.Updated_On = DateTime.Now; dbcontext.Entry(studen_OtherDetailsTotEdit).State = EntityState.Modified; dbcontext.SaveChanges(); } else { Student_Other_Detail.Created_On = DateTime.Now; Student_Other_Detail.Created_By = 5; dbcontext.Student_Other_Details.Add(Student_Other_Detail); dbcontext.SaveChanges(); } TempData["Student_Id"] = nStudent_Id; TempData.Keep("Student_Id"); sReturn_Text = "OK"; } } catch (Exception ex) { sReturn_Text = ex.InnerException.Message.ToString(); } return(Json(sReturn_Text, JsonRequestBehavior.AllowGet)); // return View(); }
public async Task <ActionResult> DeleteConfirmed(long id) { Student_Other_Details student_Other_Details = await db.Student_Other_Details.FindAsync(id); db.Student_Other_Details.Remove(student_Other_Details); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "StudentDetail_Id,Student_Id,Identification_Mark1,Identification_Mark2,Is_Allergic,Allergy_Details,Father_Occupation_Id,Father_Annual_Income,Mother_Occupation_Id,Mother_Annual_Income,Caste,Religion,Languages_Known,Second_Language_Opted_Id,Birth_Certificate,Upload_Document1,UpLoad_Document2,Academic_Year,Is_Active,Is_Deleted,Created_On,Created_By,Deleted_On,Deleted_By")] Student_Other_Details student_Other_Details) { if (ModelState.IsValid) { db.Entry(student_Other_Details).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(student_Other_Details)); }
public ActionResult CreateStudentOther() { int Student_Id = Convert.ToInt32(TempData["Student_Id"].ToString()); Student_Other_Details student_Other_Details = new Student_Other_Details(); student_Other_Details.Student_Id = Student_Id; ViewBag.Father_Occupation_Id = new SelectList(db.Father_Occu, "Id", "Occupation"); ViewBag.Mother_Occupation_Id = new SelectList(db.Mother_Occu, "Id", "Occupation"); ViewBag.Second_Language_Opted_Id = new SelectList(db.Languag, "Id", "Name"); ViewBag.Category_Id = new SelectList(db.Categories, "Id", "Name"); return(View(student_Other_Details)); }
// GET: Lab/Student_Other_Details/Delete/5 public async Task <ActionResult> Delete(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Student_Other_Details student_Other_Details = await db.Student_Other_Details.FindAsync(id); if (student_Other_Details == null) { return(HttpNotFound()); } return(View(student_Other_Details)); }
// GET: Lab/Student_Other_Details/Edit/5 public async Task <ActionResult> EditOther() { int id = Convert.ToInt32(TempData["Student_Id"].ToString()); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Student_Other_Details student_Other_Details = await db.Student_Other_Details.Where(a => a.Student_Id == id).FirstAsync(); if (student_Other_Details == null) { return(HttpNotFound()); } ViewBag.Father_Occupation_Id = new SelectList(db.Father_Occu, "Id", "Occupation", student_Other_Details.Father_Occupation_Id); ViewBag.Mother_Occupation_Id = new SelectList(db.Mother_Occu, "Id", "Occupation", student_Other_Details.Mother_Occupation_Id); ViewBag.Second_Language_Opted_Id = new SelectList(db.Languag, "Id", "Name", student_Other_Details.Second_Language_Opted_Id); ViewBag.Category_Id = new SelectList(db.Categories, "Id", "Name", student_Other_Details.Category_Id); return(View(student_Other_Details)); }