public ActionResult CourseRegister(RegisteredCours obj) { // try { // string message; DB49Entities db = new DB49Entities(); List <Course> co = db.Courses.ToList(); ViewBag.courseList = new SelectList(co, "CourseID", "CourseName"); List <Student> students = db.Students.ToList(); ViewBag.StudentList = new SelectList(students, "StudentID", "Name"); List <Sectionss> sections = db.Sectionsses.ToList(); ViewBag.SectionList = new SelectList(sections, "SectionID", "SectionName"); Student s = new Student(); Course t = new Course(); Sectionss d = new Sectionss(); RegisteredCours r = new RegisteredCours(); r.StudentID = obj.StudentID; r.CourseID = obj.CourseID; r.SectionID = obj.SectionID; r.Semester = obj.Semester; db.RegisteredCourses.Add(r); db.SaveChanges(); // Student s = new Student(); // var p = db.Employees.Where(d => d.Type == "emp" && d.EmailID == l.Email).ToList(); var p = db.RegisteredCourses.Where(n => n.StudentID == obj.StudentID).ToList(); foreach (var item in p) { // var k = db.Students.Select(new Student { EmailId = l.Email }).ToList(); if (item != null) { Session["RegisteredCourseID"] = r.RegisteredCourseID.ToString(); Session["Semester"] = r.Semester.ToString(); Session["SectionID"] = r.SectionID.ToString(); Session["CourseID"] = r.CourseID.ToString(); Session["StudentID"] = r.CourseID.ToString(); return(RedirectToAction("ShowRegisteredCourses", "ShowRegisteredCourses")); // message = " Course Registered Successfully.\\nRegisteredCourse Id:" + r.RegisteredCourseID.ToString(); //ViewBag.Message = message; } } } catch (DbEntityValidationException e) { Console.WriteLine(e.ToString()); } return(View(obj)); }
public ActionResult AddScholarship(Scholar obj) { try { string message; DB49Entities k = new DB49Entities(); List <Student> students = k.Students.ToList(); ViewBag.StudentList = new SelectList(students, "StudentID", "Name"); List <Scholarshipss> scholarships = k.Scholarshipsses.ToList(); ViewBag.ScholarshipList = new SelectList(scholarships, "ScholarshipID", "Scholarship"); Student s = new Student(); Scholarshipss t = new Scholarshipss(); Scholar d = new Scholar(); d.StudentID = obj.StudentID; d.ScholarshipID = obj.ScholarshipID; d.ScholarID = obj.ScholarID; k.Scholars.Add(d); k.SaveChanges(); } catch (DbEntityValidationException e) { Console.WriteLine(e.ToString()); } return(View(obj)); }
public ActionResult EditCourse(Course obj, int id) { using (DB49Entities db = new DB49Entities()) { List <Department> departments = db.Departments.ToList(); ViewBag.DepartmentList = new SelectList(departments, "DepartmentID", "DepartmentName"); List <Session> sessions = db.Sessions.ToList(); ViewBag.SessionList = new SelectList(sessions, "SessionID", "Session1"); Course user = db.Courses.Where(a => a.CourseID == id).FirstOrDefault(); user.CourseName = obj.CourseName; user.DepartmentID = obj.DepartmentID; user.SessionID = obj.SessionID; user.CreditHours = obj.CreditHours; // k.Complain.StatusID = obj.StatusID; //db.Comments.Add(k); db.SaveChanges(); } return(View(obj)); }
public ActionResult AddFee(Fee obj) { try { string message; DB49Entities db = new DB49Entities(); // Student l = new Student(); Fee c = new Fee(); c.Fees = obj.Fees; c.Semester = obj.Semester; c.Date = obj.Date; db.Fees.Add(c); db.SaveChanges(); // Session[" CourseID"] = c.CourseID.ToString(); message = " Fee Added Successfully.\\nFee Id:" + c.FeeId.ToString(); ViewBag.Message = message; } catch (DbEntityValidationException e) { Console.WriteLine(e.ToString()); } return(View(obj)); }
public ActionResult Result(Result obj) { try { DB49Entities db = new DB49Entities(); Course f = new Course(); int y = f.CourseID; List <RegisteredCours> q = db.RegisteredCourses.ToList(); ViewBag.r = new SelectList(q, "RegisteredCourseID", "CourseID"); List <Student> b = db.Students.ToList(); ViewBag.u = new SelectList(b, "StudentId", "Name"); Result r = new Result(); r.Grade = obj.Grade; r.CreditHours = obj.CreditHours; r.Date = obj.Date; r.RegisteredCourseID = obj.RegisteredCourseID; r.StudentID = obj.StudentID; db.Results.Add(r); db.SaveChanges(); var m = db.Results.Where(n => n.StudentID == obj.StudentID).ToList(); foreach (var item in m) { // var k = db.Students.Select(new Student { EmailId = l.Email }).ToList(); if (item != null) { Session["ResultID"] = r.ResultID.ToString(); Session["Grade"] = r.Grade.ToString(); Session["CreditHours"] = r.CreditHours.ToString(); Session["Date"] = r.Date.ToString(); Session["RegisteredCourseID"] = r.RegisteredCourseID.ToString(); Session["StudentID"] = r.StudentID.ToString(); return(RedirectToAction("ShowStuResult", "Student")); // message = " Course Registered Successfully.\\nRegisteredCourse Id:" + r.RegisteredCourseID.ToString(); //ViewBag.Message = message; } } } catch (DbEntityValidationException e) { Console.WriteLine(e.ToString()); } return(View(obj)); }
public ActionResult Courses(Course obj) { try { string message; DB49Entities db = new DB49Entities(); List <Department> departments = db.Departments.ToList(); ViewBag.DepartmentList = new SelectList(departments, "DepartmentID", "DepartmentName"); List <Session> sessions = db.Sessions.ToList(); ViewBag.SessionList = new SelectList(sessions, "SessionID", "Session1"); // Student l = new Student(); Course c = new Course(); Department s = new Department(); Session n = new Session(); //c.StatusID = 1; // s.Date = DateTime.Now; db.Sessions.Add(n); db.Departments.Add(s); db.SaveChanges(); c.CourseName = obj.CourseName; c.DepartmentID = obj.DepartmentID; c.SessionID = obj.SessionID; c.CreditHours = obj.CreditHours; c.Semester = obj.Semester; db.Courses.Add(c); db.SaveChanges(); Session[" CourseID"] = c.CourseID.ToString(); message = " Course Added Successfully.\\nCourse Id:" + c.CourseID.ToString(); ViewBag.Message = message; } catch (DbEntityValidationException e) { Console.WriteLine(e.ToString()); } return(View(obj)); }
public ActionResult Editemp(Login obj, int id) { using (DB49Entities db = new DB49Entities()) { Login user = db.Logins.Where(a => a.LoginID == id).FirstOrDefault(); user.LoginID = obj.LoginID; // k.Complain.StatusID = obj.StatusID; //db.Comments.Add(k); db.SaveChanges(); } return(View(obj)); }
public ActionResult Exam(Exam obj) { try { string message; DB49Entities r = new DB49Entities(); List <Course> co = r.Courses.ToList(); ViewBag.courseList = new SelectList(co, "CourseID", "CourseName"); List <Session> sessions = r.Sessions.ToList(); ViewBag.SessionList = new SelectList(sessions, "SessionID", "Session1"); List <Department> departments = r.Departments.ToList(); ViewBag.DepartmentList = new SelectList(departments, "DepartmentId", "DepartmentName"); Exam ex = new Exam(); Course c = new Course(); Session n = new Session(); ex.ExamDate = obj.ExamDate; ex.CourseID = obj.CourseID; ex.SessionID = obj.SessionID; ex.DepartmentId = obj.DepartmentId; r.Exams.Add(ex); r.SaveChanges(); Session[" ExamID"] = ex.ExamID.ToString(); message = " Course Added Successfully.\\nExam Id:" + ex.ExamID.ToString(); ViewBag.Message = message; } catch (DbEntityValidationException e) { Console.WriteLine(e.ToString()); } return(View(obj)); }
public ActionResult markatt(ClassAttendance c) { DB49Entities db = new DB49Entities(); List <Department> departments = db.Departments.ToList(); ViewBag.DepartmentList = new SelectList(departments, "DepartmentID", "DepartmentName"); List <Sectionss> sections = db.Sectionsses.ToList(); ViewBag.sectionlist = new SelectList(sections, "SectionID", "SectionName"); List <status> statuses = db.status.ToList(); ViewBag.statuslist = new SelectList(statuses, "ID", "Status1"); List <Student> student = db.Students.ToList(); ViewBag.studnetlist = new SelectList(student, "StudentId", "RegistrationNumber"); List <Course> courses = db.Courses.ToList(); ViewBag.course = new SelectList(courses, "CourseID", "CourseName"); List <Session> sessions = db.Sessions.ToList(); ViewBag.SessionList = new SelectList(sessions, "SessionID", "Session1"); ClassAttendance k = new ClassAttendance(); k.StudentID = c.StudentID; k.statusid = c.statusid; k.Department = c.Department; k.CourseId = c.CourseId; k.Session = c.Session; k.SectionID = c.SectionID; k.Semester = c.Semester; k.Date = DateTime.Now; db.ClassAttendances.Add(k); db.SaveChanges(); return(View()); }
public ActionResult UpdateFee(Fe obj) { try { DB49Entities k = new DB49Entities(); List <Student> students = k.Students.ToList(); ViewBag.StudentList = new SelectList(students, "StudentID", "Name"); List <Scholarshipss> scholarships = k.Scholarshipsses.ToList(); ViewBag.ScholarshipList = new SelectList(scholarships, "ScholarshipID", "Scholarship"); List <Lookup> lookups = k.Lookups.ToList(); ViewBag.LookupList = new SelectList(lookups, "LookupID", "Name"); Student s = new Student(); Scholarshipss t = new Scholarshipss(); Lookup p = new Lookup(); Fe d = new Fe(); d.StudentID = obj.StudentID; d.ScholarshipID = obj.ScholarshipID; d.LookupID = obj.LookupID; d.LookupID = obj.LookupID; d.NewFee = obj.NewFee; k.Fes.Add(d); k.SaveChanges(); var m = k.Fes.Where(n => n.StudentID == obj.StudentID).ToList(); foreach (var item in m) { // var k = db.Students.Select(new Student { EmailId = l.Email }).ToList(); if (item != null) { Session["FeeID"] = d.FeeID.ToString(); Session["ScholarshipID"] = d.ScholarshipID.ToString(); Session["LookupID"] = d.LookupID.ToString(); Session["NewFee"] = d.NewFee.ToString(); Session["StudentID"] = d.StudentID.ToString(); return(RedirectToAction("UpFeeChallan", "Student")); // message = " Course Registered Successfully.\\nRegisteredCourse Id:" + r.RegisteredCourseID.ToString(); //ViewBag.Message = message; } } } catch (DbEntityValidationException e) { Console.WriteLine(e.ToString()); } return(View(obj)); }
public ActionResult Reg(Employee obj) { try { DB49Entities db = new DB49Entities(); Employee k = new Employee(); Login site = new Login(); site.Email = obj.EmailID; site.Password = obj.Password; site.Type = "emp"; string message = string.Empty; // using (HMSEntities k = new HMSEntities()) if (db.Logins.Any(x => x.Email == obj.EmailID)) { //{ // ViewData["error"] = "User Already exits"; message = "Email is already taken register with another EmailID"; // // return View("StuRegister",) // return RedirectToAction("Login"); // ViewBag.ErrorMessage = "Email not found or matched" //return View(); } else { db.Logins.Add(site); db.SaveChanges(); k.Name = obj.Name; k.EmailID = obj.EmailID; k.Password = obj.Password; k.FatherName = obj.FatherName; k.Address = obj.Address; k.ContactNumber = obj.ContactNumber; k.DOB = obj.DOB; k.MonthlySalary = obj.MonthlySalary; k.Designation = obj.Designation; k.CNIC = obj.CNIC; k.Type = "emp"; // k.Login.Type = "stu"; k.LoginID = obj.LoginID; int latestid = site.LoginID; k.LoginID = site.LoginID; db.Employees.Add(k); db.SaveChanges(); message = "Registration successful.\\nUser Id: " + site.LoginID.ToString(); // return RedirectToAction("Login"); //// int lateststuID = k.StudentID; // } ViewBag.Message = message; } } catch (DbEntityValidationException e) { Console.WriteLine(e.ToString()); } return(View(obj)); }
public ActionResult RegisterStudent(Student obj) { try { DB49Entities db = new DB49Entities(); List <Department> list = db.Departments.ToList(); ViewBag.DepartmentList = new SelectList(list, "DepartmentID", "DepartmentName"); List <Session> list2 = db.Sessions.ToList(); ViewBag.SessionList = new SelectList(list2, "SessionID", "Session1"); Student k = new Student(); Login site = new Login(); site.Email = obj.EmailId; site.Password = obj.Password; site.Type = "stu"; string message = string.Empty; // using (HMSEntities k = new HMSEntities()) if (db.Logins.Any(x => x.Email == obj.EmailId)) { //{ // ViewData["error"] = "User Already exits"; message = "Email is already taken register with another EmailID"; } else { db.Logins.Add(site); db.SaveChanges(); k.Name = obj.Name; k.EmailId = obj.EmailId; k.Password = obj.Password; k.FatherName = obj.FatherName; k.Address = obj.Address; k.PhoneNumber = obj.PhoneNumber; k.DOB = obj.DOB; k.DepartmentID = obj.DepartmentID; k.PhoneNumber = obj.PhoneNumber; k.RegistrationNumber = obj.RegistrationNumber; k.CNIC = obj.CNIC; k.Type = "stu"; // k.Login.Type = "stu"; k.LoginID = obj.LoginID; int latestid = site.LoginID; k.LoginID = site.LoginID; k.Address = obj.Address; // k.DOB = obj.Address; k.SessionId = obj.SessionId; // k.Designation = obj.Designation; // k.Login.LoginID = obj.LoginID; //k.StudentID = latestid; db.Students.Add(k); db.SaveChanges(); message = "Registration successful.\\nUser Id: " + site.LoginID.ToString(); // return RedirectToAction("Login"); //// int lateststuID = k.StudentID; // } ViewBag.Message = message; } } catch (DbEntityValidationException e) { Console.WriteLine(e.ToString()); } return(View(obj)); }