public ActionResult updateTeacher(edu_course.Models.Teacher tea, int id) { try { int schoolid = Convert.ToInt32(Session["school"]); ClassDBHandle gc = new ClassDBHandle(); List <tbl_ClassValidation> list = gc.GetClass(schoolid); ViewBag.school = new SelectList(list, "Class_Id", "Name"); var data = db.Teachers.Where(x => x.Id == id).First(); if (data != null) { data.Name = tea.Name; data.Contact = tea.Contact; data.Email = tea.Email; data.Address = tea.Address; data.Class_Id = tea.Class_Id; db.Entry(data).State = EntityState.Modified; db.SaveChanges(); ViewBag.Message = "Data Successfully Updated"; ModelState.Clear(); } } catch (Exception ex) { ViewBag.Message = "Not Submitted"; return(View()); } return(RedirectToAction("viewsteacher", "Home")); }
public ActionResult addteacher() { if (Session["school"] == null) { return(RedirectToAction("Login", "Account", new { area = "" })); } int schoolid = Convert.ToInt32(Session["school"]); ClassDBHandle gc = new ClassDBHandle(); List <tbl_ClassValidation> list = gc.GetClass(schoolid); ViewBag.school = new SelectList(list, "Class_Id", "Name"); return(View()); }
public ActionResult courseAsssignation(CourseAssignToTeacher c) { int schoolid = Convert.ToInt32(Session["school"]); ClassDBHandle gc = new ClassDBHandle(); List <tbl_ClassValidation> list = gc.GetClass(schoolid); ViewData["class_name"] = new SelectList(list, "Class_Id", "Name"); return(View()); }
public ActionResult coursestatistic() { if (Session["school"] == null) { return(RedirectToAction("login", "Home", new { area = "" })); } int schoolid = Convert.ToInt32(Session["school"]); ClassDBHandle gc = new ClassDBHandle(); List <tbl_ClassValidation> list = gc.GetClass(schoolid); ViewData["class_name"] = new SelectList(list, "Class_Id", "Name"); return(View()); }
public ActionResult addstudent() { int schoolid = Convert.ToInt32(Session["school"]); ClassDBHandle gc = new ClassDBHandle(); List <tbl_ClassValidation> list = gc.GetClass(schoolid); ViewBag.schoolclass = new SelectList(list, "Class_Id", "Name"); SectionDBHandle section = new SectionDBHandle(); List <tbl_SectionValidation> sectionlist = section.GetSection(schoolid); ViewBag.schoolsection = new SelectList(sectionlist, "SectionID", "SectionName"); return(View()); }
public ActionResult updateTeacher(int id) { if (Session["school"] == null) { return(RedirectToAction("Login", "Account", new { area = "" })); } int schoolid = Convert.ToInt32(Session["school"]); ClassDBHandle gc = new ClassDBHandle(); List <tbl_ClassValidation> list = gc.GetClass(schoolid); ViewBag.school = new SelectList(list, "Class_Id", "Name"); var data = db.Teachers.Where(x => x.Id == id).First(); Session["imgPath"] = data.Image; return(View(data)); }
public ActionResult AddCourse(tbl_coursevalidation cou) { int schoolid = Convert.ToInt32(Session["school"]); ClassDBHandle gc = new ClassDBHandle(); List <tbl_ClassValidation> list = gc.GetClass(schoolid); ViewBag.school = new SelectList(list, "Class_Id", "Name"); Course cc = new Course(); try { cou.Role_Id = Convert.ToInt32(Session["RoleID"]); cc.User_Id = schoolid; cc.Role_Id = cou.Role_Id; cc.CreatedDate = DateTime.Now; cc.courseDescription = cou.courseDescription; cc.courseName = cou.courseName; cc.courseType = cou.courseType; cc.Class_Id = cou.Class_Id; cc.Code = cou.Code; //cc.longDes = cou.longDes; //cc.duration = cou.duration; db.Courses.Add(cc); db.SaveChanges(); ViewBag.Message = "Data Submitted"; ModelState.Clear(); } catch (Exception ex) { ViewBag.Message = "Not Submitted"; return(View()); } return(View()); }
public ActionResult updateStudent(int id) { if (Session["school"] == null) { return(RedirectToAction("login", "Home", new { area = "" })); } int schoolid = Convert.ToInt32(Session["school"]); ClassDBHandle gc = new ClassDBHandle(); List <tbl_ClassValidation> list = gc.GetClass(schoolid); ViewBag.schoolclass = new SelectList(list, "Class_Id", "Name"); SectionDBHandle section = new SectionDBHandle(); List <tbl_SectionValidation> sectionlist = section.GetSection(schoolid); ViewBag.schoolsection = new SelectList(sectionlist, "SectionID", "SectionName"); var data = db.Students.Where(x => x.Id == id).First(); return(View(data)); }
public ActionResult courseAsssignation() { if (Session["school"] == null) { return(RedirectToAction("Login", "Account", new { area = "" })); } //Tbl_Class c = new Tbl_Class(); //ViewBag.schoolclass = db.Tbl_Class.ToList(); int schoolid = Convert.ToInt32(Session["school"]); ClassDBHandle gc = new ClassDBHandle(); List <tbl_ClassValidation> list = gc.GetClass(schoolid); ViewData["class_name"] = new SelectList(list, "Class_Id", "Name"); return(View()); }
public ActionResult updateStudent(edu_course.Models.Student stu, int id) { try { int schoolid = Convert.ToInt32(Session["school"]); ClassDBHandle gc = new ClassDBHandle(); List <tbl_ClassValidation> list = gc.GetClass(schoolid); ViewBag.schoolclass = new SelectList(list, "Class_Id", "Name"); SectionDBHandle section = new SectionDBHandle(); List <tbl_SectionValidation> sectionlist = section.GetSection(schoolid); ViewBag.schoolsection = new SelectList(sectionlist, "SectionID", "SectionName"); var data = db.Students.Where(x => x.Id == id).First(); if (data != null) { data.Name = stu.Name; data.ContactNo = stu.ContactNo; data.Email = stu.Email; data.Address = stu.Address; data.Class_Id = data.Class_Id; data.Section_Id = data.Section_Id; db.Entry(data).State = EntityState.Modified; db.SaveChanges(); ViewBag.Message = "Data Successfully Updated"; ModelState.Clear(); } } catch (Exception ex) { ViewBag.Message = "Not Submitted"; return(View()); } return(RedirectToAction("viewstudent", "Home")); }
public ActionResult addteacher(tbl_TeacherValidation teacher) { try { int schoolid = Convert.ToInt32(Session["school"]); ClassDBHandle gc = new ClassDBHandle(); List <tbl_ClassValidation> list = gc.GetClass(schoolid); ViewBag.school = new SelectList(list, "Class_Id", "Name"); teacher.Reg_No = RegNo(teacher); digital_School.Models.Teacher a = new digital_School.Models.Teacher(); var userWithSameEmail = db.Teachers.Where(m => m.Email == teacher.Email).SingleOrDefault(); //checking if the emailid already exits for any user if (userWithSameEmail == null) { string filename = Path.GetFileNameWithoutExtension(teacher.UserImageFIle.FileName); string extension = Path.GetExtension(teacher.UserImageFIle.FileName); filename = DateTime.Now.ToString("yymmssff") + extension; a.Image = "~/FrontEnd/Images/TeacherImage/" + filename; //image ko folder me save krwanay ke leye filename = Path.Combine(Server.MapPath("~/FrontEnd/Images/TeacherImage/"), filename); teacher.UserImageFIle.SaveAs(filename); a.Class_Id = teacher.Class_Id; a.School_Id = Convert.ToInt32(Session["school"]); a.Name = teacher.Name; a.Reg_No = teacher.Reg_No; a.Address = teacher.Address; a.Email = teacher.Email; a.Contact = teacher.Contact; a.Password = teacher.Password; a.JoiningDate = DateTime.Now; db.Teachers.Add(a); db.SaveChanges(); } else { ViewBag.Message = "User with this Email Already Exist"; return(View()); } int teacherlatestid = a.Id; loginTable l = new loginTable(); l.UserId = teacherlatestid; l.Name = a.Name; l.Password = a.Password; l.RoleID = 3; l.Email = a.Email; db.loginTables.Add(l); db.SaveChanges(); ModelState.Clear(); ViewBag.Message = "Data Submitted"; } catch (Exception ex) { ViewBag.Message = "Not Submitted"; return(View()); } return(View()); }
public ActionResult updateTeacher(tbl_TeacherValidation tea, int id) { int schoolid = Convert.ToInt32(Session["school"]); ClassDBHandle gc = new ClassDBHandle(); List <tbl_ClassValidation> list = gc.GetClass(schoolid); ViewBag.school = new SelectList(list, "Class_Id", "Name"); tea.Reg_No = RegNo(tea); try { digital_School.Models.Teacher a = new digital_School.Models.Teacher(); //int userid = Convert.ToInt32((Session["Ad"])); //var l = db.loginTables.FirstOrDefault(t => t.UserId == userid); if (tea.UserImageFIle != null) { //if (l != null) //{ // l.UserId = userid; // l.Name = sa.ad_name; // l.Password = sa.password; // l.Email = sa.ad_email; // l.RoleID = 1; // db.Entry(l).State = EntityState.Modified; // db.SaveChanges(); //} string filename = Path.GetFileNameWithoutExtension(tea.UserImageFIle.FileName); string extension = Path.GetExtension(tea.UserImageFIle.FileName); filename = DateTime.Now.ToString("yymmssff") + extension; a.Image = "~/FrontEnd/Images/TeacherImage/" + filename; a.Id = id; a.Class_Id = tea.Class_Id; a.School_Id = Convert.ToInt32(Session["school"]); a.Name = tea.Name; a.Reg_No = tea.Reg_No; a.Address = tea.Address; a.Email = tea.Email; a.Contact = tea.Contact; a.Password = tea.Password; a.JoiningDate = DateTime.Now; if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png") { if (tea.UserImageFIle.ContentLength <= 1000000) { db.Entry(a).State = EntityState.Modified; string oldImgPath = Request.MapPath(Session["imgPath"].ToString()); if (db.SaveChanges() > 0) { filename = Path.Combine(Server.MapPath("~/FrontEnd/Images/TeacherImage/"), filename); tea.UserImageFIle.SaveAs(filename); if (System.IO.File.Exists(oldImgPath)) { System.IO.File.Delete(oldImgPath); } ViewBag.Message = "Data Updated"; return(RedirectToAction("viewsteacher")); } } else { ViewBag.msg = "File Size must be Equal or less than 1mb"; } } else { ViewBag.msg = "Inavlid File Type"; } } //} else { a.Image = Session["imgPath"].ToString(); //if (l != null) //{ // Session["name"] = sa.ad_name; // l.UserId = userid; // l.Name = sa.ad_name; // l.Password = sa.password; // l.Email = sa.ad_email; // l.RoleID = 1; // db.Entry(l).State = EntityState.Modified; // db.SaveChanges(); //} //superadmin.ad_name = sa.ad_name; //superadmin.ad_email = sa.ad_email; //superadmin.ad_password = sa.password; //superadmin.ad_Id = userid; a.Id = id; a.Class_Id = tea.Class_Id; a.School_Id = Convert.ToInt32(Session["school"]); a.Name = tea.Name; a.Reg_No = tea.Reg_No; a.Address = tea.Address; a.Email = tea.Email; a.Contact = tea.Contact; a.Password = tea.Password; a.JoiningDate = DateTime.Now; db.Entry(a).State = EntityState.Modified; if (db.SaveChanges() > 0) { ViewBag.Message = "Data Updated"; return(RedirectToAction("viewsteacher")); } } } catch (Exception ex) { ViewBag.Message = "Not Updated"; return(View()); } return(View()); }
public ActionResult addstudent(edu_course.Models.tbl_StudentValidation s) { try { int schoolid = Convert.ToInt32(Session["school"]); ClassDBHandle gc = new ClassDBHandle(); List <tbl_ClassValidation> list = gc.GetClass(schoolid); ViewBag.schoolclass = new SelectList(list, "Class_Id", "Name"); SectionDBHandle section = new SectionDBHandle(); List <tbl_SectionValidation> sectionlist = section.GetSection(schoolid); ViewBag.schoolsection = new SelectList(sectionlist, "SectionID", "SectionName"); edu_course.Models.Student a = new edu_course.Models.Student(); var userWithSameEmail = db.Students.Where(m => m.Email == s.Email).SingleOrDefault(); //checking if the emailid already exits for any user if (userWithSameEmail == null) { s.RegNo = StudentRegNo(s, s.Name); string filename = Path.GetFileNameWithoutExtension(s.UserImageFIle.FileName); string extension = Path.GetExtension(s.UserImageFIle.FileName); filename = DateTime.Now.ToString("yymmssff") + extension; a.ImagePath = "~/Content/img/users/" + filename; //image ko folder me save krwanay ke leye filename = Path.Combine(Server.MapPath("~/Content/img/users/"), filename); s.UserImageFIle.SaveAs(filename); a.Class_Id = s.Class_Id; a.Section_Id = s.Section_Id; a.School_Id = Convert.ToInt32(Session["school"]); a.Name = s.Name; a.RegNo = s.RegNo; a.Address = s.Address; a.Email = s.Email; a.ContactNo = s.ContactNo; a.Password = s.Password; a.RegisterationDate = DateTime.Now; db.Students.Add(a); db.SaveChanges(); } else { ViewBag.Message = "User with this Email Already Exist"; return(View()); } int studentlatestid = a.Id; loginTable l = new loginTable(); l.UserId = studentlatestid; l.Name = a.Name; l.Password = a.Password; l.RoleID = 4; l.Email = a.Email; db.loginTables.Add(l); db.SaveChanges(); ModelState.Clear(); ViewBag.Message = "Data Submitted"; } catch (Exception ex) { ViewBag.Message = "Not Submitted"; return(View()); } return(View()); }