/// <summary> /// Action to view non-teaching staff /// </summary> /// <param name="page">page number</param> /// <param name="searchName">quesry to search by name</param> /// <param name="err">error flag</param> /// <returns></returns> public ActionResult ViewNonStaff(int?page, string searchName = "", bool err = false) { try { ViewBag.Error = err; ViewBag.SearchName = searchName; HttpCookie conString = Request.Cookies.Get("rwxgqlb"); List <ViewStaffViewModel> lstTeachers = new List <ViewStaffViewModel>(); foreach (var item in NonTeachingStaff.GetAllNonTeachingStaff(Cryptography.Decrypt(conString.Value), searchName)) { lstTeachers.Add(new ViewStaffViewModel { CNIC = item.CNIC, Id = item.StaffId, Name = item.Name, PNumber = item.PhoneNumber.GetLocalViewFormat() }); } if (lstTeachers.Count == 0) { ViewBag.Error = true; } PagedList <ViewStaffViewModel> model = new PagedList <ViewStaffViewModel>(lstTeachers, page ?? 1, 20); return(View(model)); } catch (Exception ex) { return(Content(ex.Message)); } }
public ActionResult GetStaff(int staffType) { try { HttpCookie conString = Request.Cookies.Get("rwxgqlb"); List <string> data = new List <string>(); data.Add("<option value = '' >Select Staff</option>"); if ((StaffTypes)staffType == StaffTypes.NonTeaching) { foreach (var item in NonTeachingStaff.GetAllNonTeachingStaff(Cryptography.Decrypt(conString.Value), "")) { data.Add("<option value='" + item.StaffId + "'>Name: " + item.Name + " CNIC: " + item.CNIC + "</option>"); } } else { foreach (var item in Teacher.GetAllTeachers(Cryptography.Decrypt(conString.Value), "")) { data.Add("<option value='" + item.StaffId + "'>Name: " + item.Name + " CNIC: " + item.CNIC + "</option>"); } } return(Content(string.Join("", data))); } catch (Exception) { return(Content("")); } }
/// <summary> /// View the list of Non-Teaching staff. /// </summary> /// <param name="id">unique id of the staff</param> /// <param name="s">success flag </param> /// <returns></returns> public ActionResult ViewNonStaffDetails(int id, bool s = false) { try { ViewBag.Success = s; HttpCookie conString = Request.Cookies.Get("rwxgqlb"); NonTeachingStaff nts = new NonTeachingStaff(id, Cryptography.Decrypt(conString.Value)); ViewNonStaffDetailsViewModel vnvm = new ViewNonStaffDetailsViewModel { Address = nts.Address, CNIC = nts.CNIC, Gender = nts.Gender + "", Id = nts.StaffId, JobType = nts.JobType, MNumber = nts.PhoneNumber.GetLocalViewFormat(), Name = nts.Name, Salary = decimal.Round(nts.Salary), JoiningDate = nts.Joiningdate.ToLongDateString() }; return(View(vnvm)); } catch (Exception ex) { return(Content(ex.Message)); } }
public List <NonTeachingStaff> getNonTeachingStaff(List <NonTeachingStaff> nt) { NonTeachingStaff t = new NonTeachingStaff(); List <NonTeachingStaff> p = t.GetAllNonTeachingStaffDetails(nt); return(p); }
/// <summary> /// Action to edit staff details /// </summary> /// <param name="id">Unique id of the staff.</param> /// <param name="t">Type of Staff</param> /// <returns>View showing staff details</returns> public ActionResult EditStaff(int id, StaffTypes t) { try { ViewBag.StaffId = id; HttpCookie conString = Request.Cookies.Get("rwxgqlb"); AddStaffViewModel asvm; if (t == StaffTypes.NonTeaching) { NonTeachingStaff s = new NonTeachingStaff(id, Cryptography.Decrypt(conString.Value)); asvm = new AddStaffViewModel { Address = s.Address, CNIC = s.CNIC, Gender = s.Gender, JobType = s.JobType, Salary = s.Salary, MCompanyCode = s.PhoneNumber.CompanyCode, MCountryCode = s.PhoneNumber.CountryCode, MNumber = s.PhoneNumber.Number, Name = s.Name, StaffType = t }; } else if (t == StaffTypes.Teacher) { Teacher s = new Teacher(id, Cryptography.Decrypt(conString.Value)); asvm = new AddStaffViewModel { Address = s.Address, CNIC = s.CNIC, Gender = s.Gender, Salary = s.Salary, MCompanyCode = s.PhoneNumber.CompanyCode, MCountryCode = s.PhoneNumber.CountryCode, MNumber = s.PhoneNumber.Number, Name = s.Name, StaffType = t }; } else { asvm = null; } return(View(asvm)); } catch (Exception ex) { return(Content(ex.Message)); } }
public ActionResult EditStaff(AddStaffViewModel model, int id) { try { HttpCookie conString = Request.Cookies.Get("rwxgqlb"); //getting the encrypted connection string from cookies if (!ModelState.IsValid) { //f the model state is not acorrding to the given format ViewBag.StaffId = id; //sending the staff id back to the view for again processing ViewBag.StaffType = model.StaffType; //sending staff type to the view via viewbag return(View()); } if (model.StaffType == StaffTypes.NonTeaching && model.JobType == null) { //if the staff type is non-teaching & job type is not selected ModelState.AddModelError("JobType", "This field is required"); //adding error meesage ViewBag.StaffId = id; //sending the staff id back to the view for again processing ViewBag.StaffType = model.StaffType; //sending staff type to the view via viewbag return(View()); } try { if (model.StaffType == StaffTypes.NonTeaching) { //if non-teachng staff is selected NonTeachingStaff s = new NonTeachingStaff(id, Cryptography.Decrypt(conString.Value)) { Address = model.Address, CNIC = model.CNIC, JobType = model.JobType, Name = model.Name, PhoneNumber = new MobileNumber(model.MCountryCode, model.MCompanyCode, model.MNumber), Salary = model.Salary }; } else if (model.StaffType == StaffTypes.Teacher) { //if teaching staff is selected Teacher s = new Teacher(id, Cryptography.Decrypt(conString.Value)) { Address = model.Address, CNIC = model.CNIC, Name = model.Name, PhoneNumber = new MobileNumber(model.MCountryCode, model.MCompanyCode, model.MNumber), Salary = model.Salary }; } } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View()); } if (model.StaffType == StaffTypes.Teacher) { return(RedirectToAction("ViewTeacherDetails", new { id = id, s = true })); } else { return(RedirectToAction("ViewNonStaffDetails", new { id = id, s = true })); } } catch (Exception ex) { return(Content(ex.Message)); } }
public ActionResult AddStaff(AddStaffViewModel model) { try { HttpCookie conString = Request.Cookies.Get("rwxgqlb"); //getting the connection string from cookies if (!ModelState.IsValid) { return(View()); } if (model.StaffType == StaffTypes.NonTeaching && model.JobType == null) { ModelState.AddModelError("JobType", "This field is required"); //adding model error which displayed on invalid entry return(View()); } NonTeachingStaff nts = null; Teacher t = null; try { if (model.StaffType == StaffTypes.NonTeaching) { nts = new NonTeachingStaff(model.Name, model.CNIC, model.Address, new Models.HelperModels.MobileNumber(model.MCountryCode, model.MCompanyCode, model.MNumber), model.Salary, model.Gender, model.JobType, Cryptography.Decrypt(conString.Value)); } else if (model.StaffType == StaffTypes.Teacher) { t = new Teacher(model.Name, model.CNIC, model.Address, new Models.HelperModels.MobileNumber(model.MCountryCode, model.MCompanyCode, model.MNumber), model.Salary, model.Gender, Cryptography.Decrypt(conString.Value)); } } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View()); } if (model.StaffType == StaffTypes.Teacher && t != null) { ViewTeacherDetailsViewModel vtdvm = new ViewTeacherDetailsViewModel { Address = t.Address, CNIC = t.CNIC, Gender = t.Gender + "", Id = t.StaffId, MNumber = t.PhoneNumber.GetLocalViewFormat(), Name = t.Name, Qualifications = new List <TeacherQualification>(), Salary = decimal.Round(t.Salary), Sections = new List <TeacherSection>(), JoiningDate = t.Joiningdate.ToLongDateString() }; foreach (var item in t.Qualifications) { vtdvm.Qualifications.Add(new TeacherQualification { Degree = item.Degree, Id = item.Id, Year = item.Year.ToString(), TeacherId = t.StaffId }); } foreach (var item in t.GetAssignedSections()) { vtdvm.Sections.Add(new TeacherSection { Class = item.Section.Class.Name, Section = item.Section.Name, SectionId = item.Section.SectionId, Subject = item.Subject.Name, SubjectId = item.Subject.SubjectId, TeacherId = t.StaffId }); } ViewBag.Success = true; return(View("ViewTeacherDetails", vtdvm)); } else if (model.StaffType == StaffTypes.NonTeaching && nts != null) { ViewNonStaffDetailsViewModel vnvm = new ViewNonStaffDetailsViewModel { Address = nts.Address, CNIC = nts.CNIC, Gender = nts.Gender + "", Id = nts.StaffId, JobType = nts.JobType, MNumber = nts.PhoneNumber.GetLocalViewFormat(), Name = nts.Name, Salary = decimal.Round(nts.Salary), JoiningDate = nts.Joiningdate.ToLongDateString() }; ViewBag.Success = true; return(View("ViewNonStaffDetails", vnvm)); } else { return(View()); } } catch (Exception ex) { return(Content(ex.Message)); } }
public void InsertStaff(List <TeachingStaff> t, List <NonTeachingStaff> nt) { string category = GetCategory(); if (category.Equals("Teaching")) { TeachingStaff staff = new TeachingStaff(); List <Subjects> subb = GetSubjects(); string n = getName(); Address ad = getAddress(); string tpe = GetStaffType(); int sal = GetSalary(); TeachingStaff t1 = new TeachingStaff() { address = ad, TeachingOrNonTeaching = category, name = n, salary = sal, sub = subb, type = tpe }; t.Add(t1); } else { NonTeachingStaff staff = new NonTeachingStaff(); string n = getName(); Address ad = getAddress(); string tpe = GetStaffType(); int sal = GetSalary(); string d = GetDepartment(); NonTeachingStaff ntt = new NonTeachingStaff() { address = ad, TeachingOrNonTeaching = category, name = n, salary = sal, dept = d, type = tpe }; nt.Add(ntt); } }