public ActionResult Delete(PrimarySchoolStaff model) { try { // TODO: Add delete logic here string firstName = model.FirstName; string lastName = model.LastName; PrimarySchoolStaff theStaff = work.PrimarySchoolStaffRepository.GetByID(model.PersonID); work.PrimarySchoolStaffRepository.Delete(theStaff); Membership.DeleteUser(Convert.ToString(theStaff.UserID)); work.Save(); if (User.Identity.Name != "5000001") { AuditTrail audit = new AuditTrail { Date = DateTime.Now, Action = "Staff was Deleted, First Name:-" + firstName + " Last Name:-" + lastName, UserID = User.Identity.Name }; work.AuditTrailRepository.Insert(audit); work.Save(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public SalaryPaymentHistory ContributionsOrDeductions(SalaryPaymentHistory model) { int theStaffID = model.StaffID; PrimarySchoolStaff theStaff = work.PrimarySchoolStaffRepository.Get(a => a.UserID == theStaffID).First(); //get deductions out String[] theContributionId;// = new StringBuilder(); List <Deduction> theDeductiong = new List <Deduction>(); if (!(string.IsNullOrEmpty(theStaff.ContributionIDs))) { theContributionId = theStaff.ContributionIDs.Split(' '); foreach (var c in theContributionId) { if (!(string.IsNullOrEmpty(c))) { int theContributionID = Convert.ToInt16(c); Deduction thed = work.DeductionRepository.GetByID(theContributionID); if (thed != null) { theDeductiong.Add(thed); } } } } model.TheDeduction = theDeductiong; return(model); }
public RedirectToRouteResult AddToRole(Guid id, string role) { var user = _userService.Get(id); string theUSerName = user.UserName; Int32 theUserNameInt = Convert.ToInt32(theUSerName); PrimarySchoolStaff model = work.PrimarySchoolStaffRepository.Get(a => a.UserID == theUserNameInt).First(); string[] RoleList = Roles.GetAllRoles(); // Roles.RemoveUserFromRoles(model.UserID.ToString(), RoleList); foreach (var role1 in RoleList) { if (Roles.IsUserInRole(model.UserID.ToString(), role1)) { Roles.RemoveUserFromRole(model.UserID.ToString(), role1); } } Roles.AddUserToRole(model.UserID.ToString(), role); model.Role = role; work.PrimarySchoolStaffRepository.Update(model); work.Save(); // _rolesService.RemoveFromAllRoles(user); // _rolesService.AddToRole(_userService.Get(id), role); // user = _userService.Get(id); Tweaker.AdjustTimer(user.UserName); return RedirectToAction("UsersRoles", new { id }); }
public ActionResult Delete(string id) { Int32 theId = Convert.ToInt32(Models.Encript.DecryptString(id, true)); PrimarySchoolStaff theStaff = work.PrimarySchoolStaffRepository.GetByID(theId); return(View(theStaff)); }
public SalaryPaymentHistory Lateness(SalaryPaymentHistory model) { // model.TotalLatenessDeduction model.TotalLatenessDeduction = 0; DateTime theTime = DateHelper.NigeriaTime(DateTime.Now); List <LatenessDeduction> theLatenessDeduction = new List <LatenessDeduction>(); theLatenessDeduction = work.LatenessDeductionRepository.Get().ToList(); // List<AttendanceStaff> theAttendanceFortheMonth = work.AttendanceStaffRepository.Get(a =>a.DateTaken.Month == theTime.Month && a.DateTaken.Year == theTime.Month).OrderByDescending(a=>a.DateTaken).ToList(); PrimarySchoolStaff theCurrentStaff = work.PrimarySchoolStaffRepository.Get(a => a.UserID == model.StaffID).First(); if (theLatenessDeduction.Count > 0 && theCurrentStaff.LatenessDeduction == true) { // int numberOfAbsentDays = 0; for (int k = 1; k < 31; k++) { List <AttendanceStaff> theAttendanceFortheMonth = work.AttendanceStaffRepository.Get(a => a.DateTaken.Month == theTime.Month && a.DateTaken.Year == theTime.Year).OrderByDescending(a => a.DateTaken).ToList(); theAttendanceFortheMonth = theAttendanceFortheMonth.Where(a => a.DateTaken.Day == k).ToList(); if (theAttendanceFortheMonth.Count > 0) { theAttendanceFortheMonth = theAttendanceFortheMonth.Where(a => a.StaffID == Convert.ToString(model.StaffID)).ToList(); if (theAttendanceFortheMonth.Count > 0) { AttendanceStaff theStaffAttendance = theAttendanceFortheMonth[0]; if (theStaffAttendance.Present == true) { AttendanceStaff attendanceForthisDay = theAttendanceFortheMonth[0]; int theHour = Convert.ToInt16(theLatenessDeduction[0].Hour); int theMinute = Convert.ToInt16(theLatenessDeduction[0].Minute); double setTime = Convert.ToDouble(theHour + "." + theMinute); double timeTaken = Convert.ToDouble(attendanceForthisDay.DateTaken.Hour + "." + attendanceForthisDay.DateTaken.Minute); if (timeTaken > setTime) // if (setTime < timeTaken ) { model.TotalLatenessDeduction = model.TotalLatenessDeduction + theLatenessDeduction[0].AmountToBeDeducted; } } else { // model.TotalLatenessDeduction = model.TotalLatenessDeduction + 100; } } } } return(model); } else { return(model); } }
public ActionResult Index(int?page, string sortOrder, string currentFilter) { int pageSize = 40; int pageNumber = (page ?? 1); Int32 theUserName = Convert.ToInt32(User.Identity.Name); Person theStudent = work.PersonRepository.Get(a => a.UserID == theUserName).First(); if (theStudent is PrimarySchoolStudent) { PrimarySchoolStudent theStudent1 = work.PrimarySchoolStudentRepository.Get(a => a.UserID == theUserName).First(); List <Post> thePost = work.PostRepository.Get(a => a.Class == theStudent1.LevelType).ToList(); //List<Post> thePost = work.PostRepository.Get(a => a.Level.Equals(theStudent1.PresentLevel) || a.Class == theStudent1.PresentLevel).ToList(); // return View(); // List<Post> thePost = work.PostRepository.Get(a =>a.Class.Equals(theStudent1.PresentLevel)).ToList(); return(View(thePost.OrderByDescending(a => a.DateCreated).ToPagedList(pageNumber, pageSize))); // return View(thePost.OrderByDescending(a => a.DateCreated)); } if (theStudent is PrimarySchoolStaff) { PrimarySchoolStaff staff = work.PrimarySchoolStaffRepository.Get(a => a.UserID == theUserName).First(); // List<Post> thePostStudent = new List<Post>(); // staff. List <Post> thePost = work.PostRepository.Get(a => a.Level.Equals("Non-Student")).ToList(); //if (staff.ClassTeacherOf != null) //{ // string[] theClass = staff.ClassTeacherOf.Split(':'); // if (theClass[0] != null) // { // string teacherClass = theClass[0]; // List<Post> thePostStudent = work.PostRepository.Get(a => a.Level.Equals(teacherClass)).ToList(); // thePost.AddRange(thePostStudent); // // ViewBag.Delete = "True"; // } //} // List<Post> thePostStudent = work.PostRepository.Get(a => a.Level).ToList(); // return View(); return(View(thePost.OrderByDescending(a => a.DateCreated).ToPagedList(pageNumber, pageSize))); // return View(thePost.OrderByDescending(a => a.DateCreated)); } return(View()); }
// // GET: /PrimarySchoolStaff/Details/5 //public ActionResult Details(int id) //{ // return View(); //} public ActionResult Details(string id, int tracker = 0) { //if (tracker == 419) //{ // ViewData["Success"] = "Show the Dialog"; //} Int32 theId = Convert.ToInt32(Models.Encript.DecryptString(id, true)); PrimarySchoolStaff theStaff = work.PrimarySchoolStaffRepository.GetByID(theId); // PrimarySchoolStaff theStaff = db.PrimarySchoolStaff.Include("TheDeduction").Where(a => a.PersonID == theId).First(); Salary theSalary = work.SalaryRepository.GetByID(theStaff.SalaryID); // PrimarySchoolStaff theStaff = work.PrimarySchoolStaffRepository.GetByID(theId); if (theSalary != null) { ViewBag.Salary = theSalary.SalaryDescription + " Amount per Month NGN: " + theSalary.Amount; } //get deductions out String[] theContributionId;// = new StringBuilder(); List <Deduction> theDeductiong = new List <Deduction>(); if (!(string.IsNullOrEmpty(theStaff.ContributionIDs))) { theContributionId = theStaff.ContributionIDs.Split(' '); foreach (var c in theContributionId) { if (!(string.IsNullOrEmpty(c))) { int theContributionID = Convert.ToInt16(c); Deduction thed = work.DeductionRepository.GetByID(theContributionID); if (thed != null) { theDeductiong.Add(thed); } } } } theStaff.TheDeduction = theDeductiong; return(View("Details", theStaff)); }
public SalaryPaymentHistory Abscent(SalaryPaymentHistory model) { model.TotalAbscentDeduction = 0; DateTime theTime = DateHelper.NigeriaTime(DateTime.Now); List <LatenessDeduction> theLatenessDeduction = work.LatenessDeductionRepository.Get().ToList(); // List<AttendanceStaff> theAttendanceFortheMonth = work.AttendanceStaffRepository.Get(a =>a.DateTaken.Month == theTime.Month && a.DateTaken.Year == theTime.Month).OrderByDescending(a=>a.DateTaken).ToList(); List <AbscentDeduction> theAbscentDeduction = new List <AbscentDeduction>(); theAbscentDeduction = work.AbscentDeductionRepository.Get().ToList(); // List<AttendanceStaff> theAttendanceFortheMonth = work.AttendanceStaffRepository.Get(a =>a.DateTaken.Month == theTime.Month && a.DateTaken.Year == theTime.Month).OrderByDescending(a=>a.DateTaken).ToList(); PrimarySchoolStaff theCurrentStaff = work.PrimarySchoolStaffRepository.Get(a => a.UserID == model.StaffID).First(); if (theAbscentDeduction.Count > 0 && theCurrentStaff.AbscentDeduction == true) { // int numberOfAbsentDays = 0; for (int k = 1; k < 31; k++) { List <AttendanceStaff> theAttendanceFortheMonth = work.AttendanceStaffRepository.Get(a => a.DateTaken.Month == theTime.Month && a.DateTaken.Year == theTime.Year).OrderByDescending(a => a.DateTaken).ToList(); theAttendanceFortheMonth = theAttendanceFortheMonth.Where(a => a.DateTaken.Day == k).ToList(); if (theAttendanceFortheMonth.Count > 0) { theAttendanceFortheMonth = theAttendanceFortheMonth.Where(a => a.StaffID == Convert.ToString(model.StaffID)).ToList(); if (theAttendanceFortheMonth.Count > 0) { AttendanceStaff theStaffAttendance = theAttendanceFortheMonth[0]; if (theStaffAttendance.Present == true || theStaffAttendance.NotPresentButTookPermission == true) { } else { model.TotalAbscentDeduction = model.TotalAbscentDeduction + theAbscentDeduction[0].AmountToBeDeducted; } } } } } return(model); }
public ActionResult StaffSubjectView(string arm) { //List<Level> theLevels = work.LevelRepository.Get().ToList(); //List<SelectListItem> theItem = new List<SelectListItem>(); //theItem.Add(new SelectListItem() { Text = "None", Value = "" }); //foreach (var level in theLevels) //{ // theItem.Add(new SelectListItem() { Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type }); //} //ViewData["arm"] = theItem; int userId = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStaff> theStaff = work.PrimarySchoolStaffRepository.Get(a => a.UserID == userId).ToList(); PrimarySchoolStaff theRealStaff = theStaff[0]; List <List <TimeTable> > theTimeTable = TimeTableCollisionAviodance.DisplayTimeTableCustomisedForStaff(theRealStaff.PersonID); ViewBag.TimeTable = theTimeTable; ViewBag.Name = theRealStaff.LastName + " " + theRealStaff.FirstName; return(View("StaffSubjectView")); }
public ActionResult Edit(string arm) { List <Level> theLevels = work.LevelRepository.Get().ToList(); if (User.IsInRole("Subject Teacher") || User.IsInRole("Class Teacher")) { List <SelectListItem> theItemClasses = new List <SelectListItem>(); theItemClasses.Add(new SelectListItem() { Text = "None", Value = "" }); string theUserName = User.Identity.Name; Int32 theUserName1 = Convert.ToInt32(theUserName); PrimarySchoolStaff theStaff = work.PrimarySchoolStaffRepository.Get(a => a.UserID == theUserName1).First(); string theTeachersClass = theStaff.ClassTeacherOf; string[] splitClasses = theTeachersClass.Split('-'); List <string> listOfClasses = new List <string>(); listOfClasses = splitClasses.ToList(); foreach (var c in theLevels) { foreach (var cla in listOfClasses) { string classType = c.LevelName + ":" + c.Type; if (classType == cla) { theItemClasses.Add(new SelectListItem() { Text = classType, Value = classType }); } } } ViewData["arm"] = theItemClasses; } if (User.IsInRole("SuperAdmin")) { List <SelectListItem> theItem = new List <SelectListItem>(); theItem.Add(new SelectListItem() { Text = "None", Value = "" }); foreach (var level in theLevels) { theItem.Add(new SelectListItem() { Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type }); } ViewData["arm"] = theItem; } List <PrimarySchoolStudent> theStudents = new List <PrimarySchoolStudent>(); AttendanceViewModel theStudentsAttendace = new AttendanceViewModel(); List <Attendance> theAttendance = new List <Attendance>(); // ViewBag.Arm = arm; if (!(string.IsNullOrEmpty(arm))) { // List<Attendance> takenAttendance = work.AttendanceRepository.Get(a => a.DateTaken.Date ==DateTime.Now.Date && a.arm == arm).ToList(); List <Attendance> takenAttendance = work.AttendanceRepository.Get().OrderByDescending(a => a.DateTaken).ToList(); takenAttendance = takenAttendance.Where(s => s.DateTaken.Date == DateTime.Now.Date && s.arm == arm).ToList(); if (takenAttendance.Count() > 0) { ModelState.AddModelError("", "Attendance has already been taken for this Class Today!"); return(View("Edit", theStudentsAttendace)); } // ViewBag.Arm = "Attendance for " + arm; theStudents = work.PrimarySchoolStudentRepository.Get(a => a.LevelType == arm).ToList(); foreach (PrimarySchoolStudent p in theStudents) { theAttendance.Add(new Attendance() { arm = p.LevelType, DateTaken = DateTime.Now, StudentID = p.UserID.ToString(), Present = false, FirstName = p.FirstName, MiddleName = p.Middle, SurName = p.LastName }); } } theStudentsAttendace.TheAttendance = theAttendance; return(View("Edit", theStudentsAttendace)); }
public ActionResult Edit(SalaryPaymentHistoryViewModel model) { try { // TODO: Add update logic here List <SalaryPaymentHistory> thePaymentNow = new List <SalaryPaymentHistory>(); if (model != null) { List <SalaryPaymentHistory> theSalaryHistory = new List <SalaryPaymentHistory>(); theSalaryHistory = work.SalaryPaymentHistoryRepository.Get(a => a.DatePaid.Month == DateTime.Now.Month && a.DatePaid.Year == DateTime.Now.Year).ToList(); foreach (var staffPayment in model.TheSalaryPaymentHistory) { //check if there are payments logged aready // staffPayment. if (staffPayment.PaySalary == true) // { SalaryPaymentHistory individualPayment = new SalaryPaymentHistory(); individualPayment = new SalaryHelper().Lateness(staffPayment); individualPayment = new SalaryHelper().Abscent(staffPayment); individualPayment = new SalaryHelper().Loan(staffPayment); individualPayment = new SalaryHelper().ContributionsOrDeductions(staffPayment); thePaymentNow.Add(individualPayment); } } StringWriter oStringWriter1 = new StringWriter(); Document itextDoc = new Document(PageSize.LETTER); itextDoc.Open(); Response.ContentType = "application/pdf"; PrintResult print = new PrintResult(); // Set up the document and the MS to write it to and create the PDF writer instance MemoryStream ms = new MemoryStream(); //Document document = new Document(PageSize.A3.Rotate()); Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.GetInstance(document, ms); // Open the PDF document document.Open(); Document thedoc = new SalaryPrinting().PrintPaySlip(thePaymentNow, ref oStringWriter1, ref document); iTextSharp.text.pdf.draw.VerticalPositionMark seperator = new iTextSharp.text.pdf.draw.LineSeparator(); seperator.Offset = -6f; document.Close(); // Hat tip to David for his code on stackoverflow for this bit // http://stackoverflow.com/questions/779430/asp-net-mvc-how-to-get-view-to-generate-pdf byte[] file = ms.ToArray(); MemoryStream output = new MemoryStream(); output.Write(file, 0, file.Length); output.Position = 0; if (theSalaryHistory.Count == 0) { //log payment decimal totalDeduction = 0; // decimal totalSalarytobeDeducted = 0; foreach (var m in thePaymentNow) { // m.ActualSalary // work.SalaryPaymentHistoryRepository.Insert(m); if (m.TotalLatenessDeduction > 0) { DeductionHistory theLateness = new DeductionHistory(); theLateness.AmountDeducted = Convert.ToDecimal(m.TotalLatenessDeduction); theLateness.DatePaid = DateTime.Now; theLateness.Description = "Lasteness Deduction for the Month " + string.Format("{0:MMMM-yyyy}", DateTime.Now); theLateness.StaffID = m.StaffID.ToString(); totalDeduction = totalDeduction + theLateness.AmountDeducted; work.DeductionHistoryRepository.Insert(theLateness); // theLateness. } if (m.TotalAbscentDeduction > 0) { DeductionHistory theLateness = new DeductionHistory(); theLateness.AmountDeducted = Convert.ToDecimal(m.TotalAbscentDeduction); theLateness.DatePaid = DateTime.Now; theLateness.Description = "Abscent Deduction for the Month " + string.Format("{0:MMMM-yyyy}", DateTime.Now); theLateness.StaffID = m.StaffID.ToString(); totalDeduction = totalDeduction + theLateness.AmountDeducted; work.DeductionHistoryRepository.Insert(theLateness); // theLateness. } if (m.TotalLoan > 0) { DeductionHistory theLateness = new DeductionHistory(); theLateness.AmountDeducted = Convert.ToDecimal(m.TotalLoan); theLateness.DatePaid = DateTime.Now; theLateness.Description = "Loan Deduction for the Month " + string.Format("{0:MMMM-yyyy}", DateTime.Now); theLateness.StaffID = m.StaffID.ToString(); totalDeduction = totalDeduction + theLateness.AmountDeducted; work.DeductionHistoryRepository.Insert(theLateness); // theLateness. } // other subscibed deductions foreach (var subscibed in m.TheDeduction) { if (subscibed != null) { DeductionHistory theLateness = new DeductionHistory(); theLateness.AmountDeducted = Convert.ToDecimal(subscibed.Amount); theLateness.DatePaid = DateTime.Now; theLateness.Description = subscibed.DeductionDescription + " Deduction for the Month " + string.Format("{0:MMMM-yyyy}", DateTime.Now); theLateness.StaffID = m.StaffID.ToString(); totalDeduction = totalDeduction + theLateness.AmountDeducted; work.DeductionHistoryRepository.Insert(theLateness); // work.Save(); } } //save the actual salary payment PrimarySchoolStaff theStaf = work.PrimarySchoolStaffRepository.Get(a => a.UserID == m.StaffID).First(); Salary theStaffSalary = work.SalaryRepository.GetByID(theStaf.SalaryID); m.ActualSalary = theStaffSalary.Amount; m.Description = "Salary Payment for the Month of " + string.Format("{0:MMMM-yyyy}", DateTime.Now); m.AmountPaid = theStaffSalary.Amount - totalDeduction; m.DatePaid = DateTime.Now; work.SalaryPaymentHistoryRepository.Insert(m); work.Save(); totalDeduction = 0; // SalaryPaymentHistory theHistory = new SalaryPaymentHistory{ AmountPaid = m.AmountPaid, ActualSalary = m.ActualSalary, DatePaid = DateTime.Now, Description = "Salary Payment for "+ DateTime.Now.Month, FirstName = m.FirstName} } } // work.DeductionHistoryRepository HttpContext.Response.AddHeader("content-disposition", "attachment; filename=form.pdf"); return(new FileStreamResult(output, "application/pdf")); //new FileStreamResult(output, "application/pdf"); //return RedirectToAction("Index", new FileStreamResult(output, "application/pdf")); // return new ActionAsPdf // } } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(string id) { Int32 theId = Convert.ToInt32(Models.Encript.DecryptString(id, true)); PrimarySchoolStaff theStudent = work.PrimarySchoolStaffRepository.GetByID(theId); string thKeyRole = theStudent.Role; string theClasses = theStudent.ClassTeacherOf; //StringBuilder theContributionId = new StringBuilder(); // work.PrimarySchoolStaffRepository.GetByID string[] teacherClasses = new string[4]; teacherClasses = theClasses.Split('-'); List <string> theteacherClasses = teacherClasses.ToList(); int counter = theteacherClasses.Count(); if (counter == 1) { theteacherClasses.Add("Not Applicable"); theteacherClasses.Add("Not Applicable"); theteacherClasses.Add("Not Applicable"); theteacherClasses.Add("Not Applicable"); } if (counter == 2) { theteacherClasses.Add("Not Applicable"); theteacherClasses.Add("Not Applicable"); theteacherClasses.Add("Not Applicable"); } if (counter == 3) { theteacherClasses.Add("Not Applicable"); theteacherClasses.Add("Not Applicable"); } if (counter == 4) { theteacherClasses.Add("Not Applicable"); } teacherClasses = theteacherClasses.ToArray(); List <SelectListItem> theItem3 = new List <SelectListItem>(); List <MyRole> theRoles = work.MyRoleRepository.Get().ToList(); theItem3.Add(new SelectListItem() { Text = thKeyRole, Value = thKeyRole }); foreach (var role in theRoles) { if (role.RoleName != null && role.RoleName != "Student") { string thRole = role.RoleName.Trim(); //theItem3.Add(new SelectListItem() { Text = role.RoleName, Value = role.RoleName }); theItem3.Add(new SelectListItem() { Text = thRole, Value = thRole }); // } } } ViewBag.Role = theItem3; // ViewData["Role"] = theItem3; List <Level> theLevels = work.LevelRepository.Get().ToList(); List <SelectListItem> theItem = new List <SelectListItem>(); List <SelectListItem> class1 = new List <SelectListItem>(); List <SelectListItem> class2 = new List <SelectListItem>(); List <SelectListItem> class3 = new List <SelectListItem>(); List <SelectListItem> class4 = new List <SelectListItem>(); theItem.Add(new SelectListItem() { Text = teacherClasses[0], Value = teacherClasses[0] }); theItem.Add(new SelectListItem() { Text = "Not Applicable", Value = "Not Applicable" }); class1.Add(new SelectListItem() { Text = teacherClasses[1], Value = teacherClasses[1] }); class1.Add(new SelectListItem() { Text = "Not Applicable", Value = "Not Applicable" }); class2.Add(new SelectListItem() { Text = teacherClasses[2], Value = teacherClasses[1] }); class2.Add(new SelectListItem() { Text = "Not Applicable", Value = "Not Applicable" }); class3.Add(new SelectListItem() { Text = teacherClasses[3], Value = teacherClasses[3] }); class3.Add(new SelectListItem() { Text = "Not Applicable", Value = "Not Applicable" }); class4.Add(new SelectListItem() { Text = teacherClasses[4], Value = teacherClasses[4] }); class4.Add(new SelectListItem() { Text = "Not Applicable", Value = "Not Applicable" }); foreach (var level in theLevels) { theItem.Add(new SelectListItem() { Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type }); } ViewData["Level"] = theItem; foreach (var level in theLevels) { class1.Add(new SelectListItem() { Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type }); } ViewData["Level1"] = class1; foreach (var level in theLevels) { class2.Add(new SelectListItem() { Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type }); } ViewData["Level2"] = class2; foreach (var level in theLevels) { class3.Add(new SelectListItem() { Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type }); } ViewData["Level3"] = class3; foreach (var level in theLevels) { class4.Add(new SelectListItem() { Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type }); } ViewData["Level4"] = class4; List <SelectListItem> theSubjectList = new List <SelectListItem>(); List <Subject> theSubject = work.SubjectRepository.Get().ToList(); theSubjectList.Add(new SelectListItem() { Text = "Not Applicable", Value = "Not Applicable" }); foreach (var subject in theSubject) { theSubjectList.Add(new SelectListItem() { Text = subject.Name, Value = subject.Name }); } ViewData["Subject"] = theSubjectList; //List<LatenessDeduction> theLatenessDeduction = work.LatenessDeductionRepository.Get().ToList(); List <SelectListItem> theLatenessDeductionListItem = new List <SelectListItem>(); theLatenessDeductionListItem.Add(new SelectListItem() { Text = "None", Value = "" }); theLatenessDeductionListItem.Add(new SelectListItem() { Text = "YES", Value = "true" }); theLatenessDeductionListItem.Add(new SelectListItem() { Text = "NO", Value = "false" }); ViewData["LatenessDeduction"] = theLatenessDeductionListItem; List <SelectListItem> theAbscentDeductionListItem = new List <SelectListItem>(); theAbscentDeductionListItem.Add(new SelectListItem() { Text = "None", Value = "" }); theAbscentDeductionListItem.Add(new SelectListItem() { Text = "YES", Value = "true" }); theAbscentDeductionListItem.Add(new SelectListItem() { Text = "NO", Value = "false" }); ViewData["AbscentDeduction"] = theAbscentDeductionListItem; //salary List <SelectListItem> theSalaryList = new List <SelectListItem>(); List <Salary> theSalary = work.SalaryRepository.Get().ToList(); theSalaryList.Add(new SelectListItem() { Text = "Select", Value = "" }); foreach (var s in theSalary) { theSalaryList.Add(new SelectListItem() { Text = s.SalaryDescription + " Amount(NGN) " + s.Amount, Value = Convert.ToString(s.SalaryID) }); } ViewData["salary"] = theSalaryList; StaffViewModel theStaff = new StaffViewModel(); List <Deduction> theDeductions = work.DeductionRepository.Get().ToList(); theStaff.Deductions = theDeductions; theStaff.PrimarySchoolStaff = theStudent; string[] theContributionId; //= theStudent.ContributionIDs; List <Deduction> theDeductiong = new List <Deduction>(); if (!(string.IsNullOrEmpty(theStudent.ContributionIDs))) { theContributionId = theStudent.ContributionIDs.Split(' '); foreach (var c in theContributionId) { if (!(string.IsNullOrEmpty(c))) { int theContributionID = Convert.ToInt16(c); Deduction thed = work.DeductionRepository.GetByID(theContributionID); if (thed != null) { thed.Selected = true; theDeductiong.Add(thed); } } } } List <Deduction> allSubscribedDeductions = new List <Deduction>(); List <Deduction> allNonSubscribedandSubDeductions = new List <Deduction>(); List <Deduction> allDeductions = work.DeductionRepository.Get().ToList(); List <Deduction> allNonSubscribedDeductions = work.DeductionRepository.Get().ToList(); foreach (var d in theDeductiong) { allNonSubscribedDeductions = allNonSubscribedDeductions.Where(a => a.DeductionID != d.DeductionID).ToList(); } allNonSubscribedandSubDeductions.AddRange(theDeductiong); allNonSubscribedandSubDeductions.AddRange(allNonSubscribedDeductions); theStaff.Deductions = allNonSubscribedandSubDeductions; ViewBag.Staff = 5000000 + theStudent.PersonID; return(View(theStaff)); // return View(); }
public ViewResult Index(string sortOrder, string currentFilter, string ApprovedString, string searchString, string SexString, string role, string StudentIDString, int?page) { //get the list of class types Dictionary <string, string> theDic = new Dictionary <string, string>(); List <SelectListItem> theItem = new List <SelectListItem>(); // List<Level> theLevels = work.LevelRepository.Get().ToList(); // List<SelectListItem> theItem3 = new List<SelectListItem>(); List <MyRole> theRoles = work.MyRoleRepository.Get().ToList(); theItem.Add(new SelectListItem() { Text = "Choose...", Value = "" }); foreach (var role1 in theRoles) { if (!(string.IsNullOrEmpty(role1.RoleName)) && role1.RoleName != "Student") { theItem.Add(new SelectListItem() { Text = role1.RoleName, Value = role1.RoleName }); } } // theItem.Add(new SelectListItem() { Text = "PRIMART 1A", Value = "PRIMART 1A" }); ViewData["Level"] = theItem; ViewBag.CurrentSort = sortOrder; ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "Name desc" : ""; ViewBag.DateSortParm = sortOrder == "Date" ? "Date desc" : "Date"; ViewBag.ClassSortParm = sortOrder == "class" ? "class desc" : "class"; ViewBag.GenderSortParm = sortOrder == "gender" ? "gender desc" : "gender"; if (Request.HttpMethod == "GET") { // searchString = currentFilter; } else { page = 1; } ViewBag.CurrentFilter = searchString; var students = from s in work.PrimarySchoolStaffRepository.Get() select s; students = students.Where(s => s.UserID != 5000001); students = students.Where(s => s.UserID != 5000052); if (!String.IsNullOrEmpty(searchString)) { students = students.Where(s => s.LastName.ToUpper().Contains(searchString.ToUpper()) || s.FirstName.ToUpper().Contains(searchString.ToUpper()) || s.Middle.ToUpper().Contains(searchString.ToUpper())); } if (!String.IsNullOrEmpty(SexString)) { students = students.Where(s => s.Sex.Equals(SexString)); } if (!String.IsNullOrEmpty(role)) { students = students.Where(s => s.Role.Equals(role)); } if (!String.IsNullOrEmpty(StudentIDString)) { int theID = Convert.ToInt32(StudentIDString); students = students.Where(s => s.UserID == theID); } if (!String.IsNullOrEmpty(SexString)) { students = students.Where(s => s.Sex.Equals(SexString)); } if (!String.IsNullOrEmpty(ApprovedString)) { bool theValue = Convert.ToBoolean(ApprovedString); students = students.Where(s => s.IsApproved == theValue); } switch (sortOrder) { case "Name desc": students = students.OrderByDescending(s => s.LastName); break; case "Date": students = students.OrderBy(s => s.EnrollmentDate); break; case "Date desc": students = students.OrderByDescending(s => s.EnrollmentDate); break; case "class": students = students.OrderBy(s => s.ClassTeacherOf); break; case "class desc": students = students.OrderByDescending(s => s.ClassTeacherOf); break; case "gender": students = students.OrderBy(s => s.Sex); break; case "gender desc": students = students.OrderByDescending(s => s.Sex); break; default: students = students.OrderBy(s => s.LastName); break; } int pageSize = 40; int pageNumber = (page ?? 1); ViewBag.Count = students.Count(); if (!(User.IsInRole("SuperAdmin"))) { int UserName = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStaff> theStaff = work.PrimarySchoolStaffRepository.Get(a => a.UserID == UserName).ToList(); PrimarySchoolStaff theStaf = theStaff[0]; students = students.Where(a => a.UserID == UserName && a.IsApproved == true); ViewBag.Count = students.Count(); return(View(students.ToPagedList(pageNumber, pageSize))); } else { return(View(students.ToPagedList(pageNumber, pageSize))); } }
//public ActionResult Create(PrimarySchoolStaff model, string classteacher1, string classteacher2, string classteacher3, string classteacher4) public ActionResult Create(StaffViewModel viewmodel, string[] PrimarySchoolStaff, string classteacher1, string classteacher2, string classteacher3, string classteacher4) { try { // viewmodel.Deductions PrimarySchoolStaff model = viewmodel.PrimarySchoolStaff; model.EnrollmentDate = DateTime.Now; StringBuilder theContributionId = new StringBuilder(); if (viewmodel.Deductions.Count > 0) { List <Deduction> theDec = new List <Deduction>(); foreach (Deduction d in viewmodel.Deductions) { if (d.Selected == true) { // List<PrimarySchoolStaff> theS = new List<PrimarySchoolStaff>(); // theS.Add(model); // d.ThePrimarySchoolStaff = theS; theDec.Add(d); theContributionId.Append(d.DeductionID); theContributionId.Append(' '); } } model.TheDeduction = theDec; model.ContributionIDs = theContributionId.ToString(); } if (!(ModelState.IsValid)) { List <SelectListItem> theItem3 = new List <SelectListItem>(); List <MyRole> theRoles = work.MyRoleRepository.Get().ToList(); foreach (var role in theRoles) { if (!(string.IsNullOrEmpty(role.RoleName)) && role.RoleName != "Student") { theItem3.Add(new SelectListItem() { Text = role.RoleName, Value = role.RoleName }); } } ViewData["Role"] = theItem3; Dictionary <string, string> theDic = new Dictionary <string, string>(); List <SelectListItem> theItem = new List <SelectListItem>(); List <Level> theLevels = work.LevelRepository.Get().ToList(); theItem.Add(new SelectListItem() { Text = "Not Applicable", Value = "Not Applicable" }); foreach (var level in theLevels) { theItem.Add(new SelectListItem() { Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type }); } // theItem.Add(new SelectListItem() { Text = "PRIMART 1A", Value = "PRIMART 1A" }); ViewData["Level"] = theItem; List <SelectListItem> theSubjectList = new List <SelectListItem>(); List <Subject> theSubject = work.SubjectRepository.Get().ToList(); theSubjectList.Add(new SelectListItem() { Text = "Not Applicable", Value = "Not Applicable" }); foreach (var subject in theSubject) { theSubjectList.Add(new SelectListItem() { Text = subject.Name, Value = subject.Name }); } // theItem.Add(new SelectListItem() { Text = "PRIMART 1A", Value = "PRIMART 1A" }); ViewData["Subject"] = theSubjectList; //List<LatenessDeduction> theLatenessDeduction = work.LatenessDeductionRepository.Get().ToList(); List <SelectListItem> theLatenessDeductionListItem = new List <SelectListItem>(); theLatenessDeductionListItem.Add(new SelectListItem() { Text = "None", Value = "" }); theLatenessDeductionListItem.Add(new SelectListItem() { Text = "YES", Value = "true" }); theLatenessDeductionListItem.Add(new SelectListItem() { Text = "NO", Value = "false" }); ViewData["LatenessDeduction"] = theLatenessDeductionListItem; List <SelectListItem> theAbscentDeductionListItem = new List <SelectListItem>(); theAbscentDeductionListItem.Add(new SelectListItem() { Text = "None", Value = "" }); theAbscentDeductionListItem.Add(new SelectListItem() { Text = "YES", Value = "true" }); theAbscentDeductionListItem.Add(new SelectListItem() { Text = "NO", Value = "false" }); ViewData["AbscentDeduction"] = theAbscentDeductionListItem; //salary List <SelectListItem> theSalaryList = new List <SelectListItem>(); List <Salary> theSalary = work.SalaryRepository.Get().ToList(); theSalaryList.Add(new SelectListItem() { Text = "Select", Value = "" }); foreach (var s in theSalary) { theSalaryList.Add(new SelectListItem() { Text = s.SalaryDescription + " Amount " + s.Amount, Value = Convert.ToString(s.Amount) }); } ViewData["salary"] = theSalaryList; StaffViewModel theStaff = new StaffViewModel(); List <Deduction> theDeductions = work.DeductionRepository.Get().ToList(); theStaff.Deductions = theDeductions; theStaff.PrimarySchoolStaff = model; return(View(theStaff)); // return View(model); } model.ClassTeacherOf = model.ClassTeacherOf + "-" + classteacher1 + "-" + classteacher2 + "-" + classteacher3 + "-" + classteacher4; // TODO: Add insert logic here model.IsApproved = false; model.EnrollmentDate = DateTime.Now; // model .da.DateEntered = DateTime.Today; // model.DateApproved = DateTime.Now; work.PrimarySchoolStaffRepository.Insert(model); work.Save(); return(RedirectToAction("Create", "Photo", new { id = SchoolManagement.Models.Encript.EncryptString(model.PersonID.ToString(), true) })); // return RedirectToAction("Create", "Photo", new { id = model.PersonID }); } catch { return(View()); } }
// // GET: /PractiseSave/ public ActionResult Index(string studentID, string level = "", string term = "", int id = 0) { if (User.IsInRole("Parent")) { Int32 theUser = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> thSchoolStudents; // string userid = User.Identity.Name; List <Parent> theP = work.ParentRepository.Get(a => a.UserID == theUser).ToList(); Parent theRealParent = theP[0]; int idParent = theRealParent.ParentID; thSchoolStudents = work.PrimarySchoolStudentRepository.Get(a => a.ParentID == idParent).ToList(); List <SelectListItem> theItem = new List <SelectListItem>(); foreach (var s in thSchoolStudents) { theItem.Add(new SelectListItem() { Text = s.LastName + " " + s.FirstName, Value = s.PersonID.ToString() }); ViewData["Students"] = theItem; } } if (User.IsInRole("Student")) { Membership.GetUser(true); string theUser = User.Identity.Name.ToString(); ViewBag.Level = "Student ID -" + theUser + " Class -" + level + "Term -" + term; List <PractiseSave> thePractiseExam = work.PractiseSaveRepository.Get(a => a.Level.Equals(level) && a.Term.Equals(term) && a.StudentID.Equals(theUser)).ToList(); return(View(thePractiseExam)); } if (User.IsInRole("Parent")) { // int userID = Convert.ToInt32(User.Identity.Name); Int32 theUser = Convert.ToInt32(User.Identity.Name); Parent theP = work.ParentRepository.Get(a => a.UserID == theUser).First(); if (studentID != null) { int ids = Convert.ToInt32(studentID); PrimarySchoolStudent theStudents = work.PrimarySchoolStudentRepository.GetByID(ids); if (theStudents != null) { string userID = Convert.ToString(theStudents.UserID); ViewBag.Level = "Student ID -" + userID + " Class -" + level + "Term -" + term; List <PractiseSave> thePractiseExam = work.PractiseSaveRepository.Get(a => a.Level.Equals(level) && a.Term.Equals(term) && a.StudentID.Equals(userID)).ToList(); return(View(thePractiseExam)); } else { string userID = Convert.ToString(theStudents.UserID); ViewBag.Level = "Student ID -" + userID + " Class -" + level + "Term -" + term; List <PractiseSave> thePractiseExam = work.PractiseSaveRepository.Get(a => a.Level.Equals(level) && a.Term.Equals(term) && a.StudentID == "0").ToList(); return(View(thePractiseExam)); } } else { //string userID = "0";// Convert.ToString(theStudents.UserID); // ViewBag.Level = "Student ID -" + theUser + " Class -" + level + "Term -" + term; ViewBag.Level = "Student ID -" + " " + " Class -" + level + "Term -" + term; List <PractiseSave> thePractiseExam = work.PractiseSaveRepository.Get(a => a.Level.Equals(level) && a.Term.Equals(term) && a.StudentID == "0").ToList(); return(View(thePractiseExam)); } } if (User.IsInRole("Teacher")) { Membership.GetUser(true); ViewBag.ID = id; PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.GetByID(id); string StudentID = Convert.ToString(id); List <PractiseSave> thePractiseExam = new List <PractiseSave>(); if (theStudent != null) { Int32 theTeacher = Convert.ToInt32(User.Identity.Name); PrimarySchoolStaff theStaff = work.PrimarySchoolStaffRepository.Get(a => a.UserID == theTeacher).First(); string theStudentID = theStudent.UserID.ToString(); thePractiseExam = work.PractiseSaveRepository.Get(a => a.LevelType.Equals(theStaff.ClassTeacherOf) && a.Term.Equals(term) && a.StudentID.Equals(theStudentID)).ToList(); } return(View(thePractiseExam)); } else { Membership.GetUser(true); ViewBag.ID = id; PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.GetByID(id); string StudentID = Convert.ToString(id); List <PractiseSave> thePractiseExam = new List <PractiseSave>(); if (theStudent != null) { Int32 theTeacher = Convert.ToInt32(User.Identity.Name); PrimarySchoolStaff theStaff = work.PrimarySchoolStaffRepository.Get(a => a.UserID == theTeacher).First(); string theStudentID = theStudent.UserID.ToString(); thePractiseExam = work.PractiseSaveRepository.Get(a => a.Level.Equals(theStudent.PresentLevel) && a.Term.Equals(term) && a.StudentID.Equals(theStudentID)).ToList(); } return(View(thePractiseExam)); } }
public ActionResult Edit(StaffViewModel viewmodel, string classteacher1, string classteacher2, string classteacher3, string classteacher4) { PrimarySchoolStaff model = viewmodel.PrimarySchoolStaff; try { // TODO: Add update logic here // model.EnrollmentDate = DateTime.Now; StringBuilder theContributionId = new StringBuilder(); if (viewmodel.Deductions.Count > 0) { List <Deduction> theDec = new List <Deduction>(); foreach (Deduction d in viewmodel.Deductions) { if (d.Selected == true) { // List<PrimarySchoolStaff> theS = new List<PrimarySchoolStaff>(); // theS.Add(model); // d.ThePrimarySchoolStaff = theS; theContributionId.Append(d.DeductionID); theContributionId.Append(' '); theDec.Add(d); } } model.ContributionIDs = theContributionId.ToString(); model.TheDeduction = theDec; // theDec[0]. // TheDeduction[0]. // model.TheDeduction } // PrimarySchoolStaff model = viewmodel.PrimarySchoolStaff; if (ModelState.IsValid) { model.ClassTeacherOf = model.ClassTeacherOf + "-" + classteacher1 + "-" + classteacher2 + "-" + classteacher3 + "-" + classteacher4; // PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.GetByID(model.PersonID); if (model.IsApproved == true) { MembershipUser user = Membership.GetUser(Convert.ToString(5000000 + model.PersonID), false);; if (user == null) { //if (Membership.FindUsersByName(Convert.ToString(5000000 + model.PersonID)) == null) //{ model.UserID = 5000000 + model.PersonID; // model.level model.DateApproved = DateTime.Now; model.IsApproved = true; string password = PaddPassword.Padd(model.FirstName.ToLower() + model.Middle.ToLower() + model.LastName.ToLower()); Membership.CreateUser(model.UserID.ToString(), password, model.Email); // var user = _userService.Get(id); Tweaker.AdjustTimer(model.UserID.ToString()); Roles.AddUserToRole(model.UserID.ToString(), model.Role); } else { PrimarySchoolStaff staff = work2.PrimarySchoolStaffRepository.GetByID(model.PersonID); string[] RoleList = Roles.GetAllRoles(); // Roles.RemoveUserFromRoles(model.UserID.ToString(), RoleList); foreach (var role in RoleList) { if (Roles.IsUserInRole(model.UserID.ToString(), role)) { Roles.RemoveUserFromRole(model.UserID.ToString(), role); } } Roles.AddUserToRole(model.UserID.ToString(), model.Role); work.PrimarySchoolStaffRepository.Update(model); Tweaker.AdjustTimer(model.UserID.ToString()); } } //foreach (Deduction d in model.TheDeduction) //{ // work.DeductionRepository.Update(d); //} // work.DeductionRepository. work.PrimarySchoolStaffRepository.Update(model); work.Save(); if (User.Identity.Name != "5000001") { AuditTrail audit = new AuditTrail { Date = DateTime.Now, Action = "Staff Information Updated, Staff ID:-" + model.UserID, UserID = User.Identity.Name }; work.AuditTrailRepository.Insert(audit); work.Save(); } } return(RedirectToAction("Index")); } catch { PrimarySchoolStudent theStudent = work.PrimarySchoolStudentRepository.GetByID(model.PersonID); string thKeyRole = theStudent.Role; List <SelectListItem> theItem3 = new List <SelectListItem>(); List <MyRole> theRoles = work.MyRoleRepository.Get().ToList(); theItem3.Add(new SelectListItem() { Text = thKeyRole, Value = thKeyRole }); foreach (var role in theRoles) { // if (theStudent.Role.Equals(role.RoleName)) // { // theItem3.Add(new SelectListItem() { Selected = true, Text = role.RoleName, Value = role.RoleName }); // } // else // { if (role.RoleName != null && role.RoleName != "Student") { string thRole = role.RoleName.Trim(); //theItem3.Add(new SelectListItem() { Text = role.RoleName, Value = role.RoleName }); theItem3.Add(new SelectListItem() { Text = thRole, Value = thRole }); // } } } ViewBag.Role = theItem3; // ViewData["Role"] = theItem3; List <Level> theLevels = work.LevelRepository.Get().ToList(); List <SelectListItem> theItem = new List <SelectListItem>(); theItem.Add(new SelectListItem() { Text = "Not Applicable", Value = "Not Applicable" }); theItem.Add(new SelectListItem() { Text = "Proprietor", Value = "Proprietor" }); theItem.Add(new SelectListItem() { Text = "Principal", Value = "Principal" }); theItem.Add(new SelectListItem() { Text = "Bursar", Value = "Bursar" }); theItem.Add(new SelectListItem() { Text = "Admin Secretary", Value = "Admin Secretary" }); theItem.Add(new SelectListItem() { Text = "Supervisor", Value = "Supervisor" }); theItem.Add(new SelectListItem() { Text = "Vice Principal", Value = "Vice Principal" }); theItem.Add(new SelectListItem() { Text = "Head Teacher", Value = "Head Teache" }); theItem.Add(new SelectListItem() { Text = "Administrator", Value = "Administrator" }); theItem.Add(new SelectListItem() { Text = "Store Man", Value = "Store Man" }); theItem.Add(new SelectListItem() { Text = "Librarian", Value = "Librarian" }); theItem.Add(new SelectListItem() { Text = "Lab Attendant", Value = "Lab Attendant" }); theItem.Add(new SelectListItem() { Text = "Subject Teacher", Value = "Subject Teacher" }); theItem.Add(new SelectListItem() { Text = "Clerk", Value = "Clerk" }); theItem.Add(new SelectListItem() { Text = "Receptionist", Value = "Receptionist" }); theItem.Add(new SelectListItem() { Text = "Caregiver", Value = "Caregiver" }); theItem.Add(new SelectListItem() { Text = "Minder", Value = "Minder" }); theItem.Add(new SelectListItem() { Text = "Cleaner", Value = "Cleaner" }); theItem.Add(new SelectListItem() { Text = "Class Assistant", Value = "Class Assistant" }); foreach (var level in theLevels) { theItem.Add(new SelectListItem() { Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type }); } ViewData["Level"] = theItem; List <SelectListItem> theSubjectList = new List <SelectListItem>(); List <Subject> theSubject = work.SubjectRepository.Get().ToList(); theSubjectList.Add(new SelectListItem() { Text = "Not Applicable", Value = "Not Applicable" }); foreach (var subject in theSubject) { theSubjectList.Add(new SelectListItem() { Text = subject.Name, Value = subject.Name }); } ViewData["Subject"] = theSubjectList; //List<LatenessDeduction> theLatenessDeduction = work.LatenessDeductionRepository.Get().ToList(); List <SelectListItem> theLatenessDeductionListItem = new List <SelectListItem>(); theLatenessDeductionListItem.Add(new SelectListItem() { Text = "None", Value = "" }); theLatenessDeductionListItem.Add(new SelectListItem() { Text = "YES", Value = "true" }); theLatenessDeductionListItem.Add(new SelectListItem() { Text = "NO", Value = "false" }); ViewData["LatenessDeduction"] = theLatenessDeductionListItem; List <SelectListItem> theAbscentDeductionListItem = new List <SelectListItem>(); theAbscentDeductionListItem.Add(new SelectListItem() { Text = "None", Value = "" }); theAbscentDeductionListItem.Add(new SelectListItem() { Text = "YES", Value = "true" }); theAbscentDeductionListItem.Add(new SelectListItem() { Text = "NO", Value = "false" }); ViewData["AbscentDeduction"] = theAbscentDeductionListItem; //salary List <SelectListItem> theSalaryList = new List <SelectListItem>(); List <Salary> theSalary = work.SalaryRepository.Get().ToList(); theSalaryList.Add(new SelectListItem() { Text = "Select", Value = "" }); foreach (var s in theSalary) { theSalaryList.Add(new SelectListItem() { Text = s.SalaryDescription + " Amount(NGN) " + s.Amount, Value = Convert.ToString(s.SalaryID) }); } ViewData["salary"] = theSalaryList; StaffViewModel theStaff = new StaffViewModel(); List <Deduction> theDeductions = work.DeductionRepository.Get().ToList(); theStaff.Deductions = theDeductions; return(View(theStaff)); } }
public SalaryPaymentHistory Loan(SalaryPaymentHistory model) { List <Loan> theLoan = new List <Model.Loan>(); PrimarySchoolStaff theStaff = work.PrimarySchoolStaffRepository.Get(a => a.UserID == model.StaffID).First(); theLoan = work.LoanRepository.Get(a => a.StaffID == model.StaffID).ToList(); // theLoan[0]. model.TheLoan = theLoan; model.TotalLoan = 0; if (theLoan.Count > 0) { foreach (var l in theLoan) { DateTime theTime = DateHelper.NigeriaTime(DateTime.Now); if (l.FirstMonthPayment != null) { if (l.FirstMonthPayment.Value.Month == theTime.Month && l.FirstMonthPayment.Value.Year == theTime.Year) { if (l.FirstAmountPayment != null) { model.TotalLoan = l.FirstAmountPayment + model.TotalLoan; } } } if (l.SecondMonthPayment != null) { if (l.SecondMonthPayment.Value.Month == theTime.Month && l.SecondMonthPayment.Value.Year == theTime.Year) { if (l.SecondAmountPayment != null) { model.TotalLoan = l.SecondAmountPayment + model.TotalLoan; } } } if (l.ThirdMonthPayment != null) { if (l.ThirdMonthPayment.Value.Month == theTime.Month && l.ThirdMonthPayment.Value.Year == theTime.Year) { if (l.ThirdAmountPayment != null) { model.TotalLoan = l.ThirdAmountPayment + model.TotalLoan; } } } if (l.ForthMonthPayment != null) { if (l.ForthMonthPayment.Value.Month == theTime.Month && l.ForthMonthPayment.Value.Year == theTime.Year) { if (l.ForthAmountPayment != null) { model.TotalLoan = l.ForthAmountPayment + model.TotalLoan; } } } if (l.FifthMonthPayment != null) { if (l.FifthMonthPayment.Value.Month == theTime.Month && l.FifthMonthPayment.Value.Year == theTime.Year) { if (l.FifthAmountPayment != null) { model.TotalLoan = l.FifthAmountPayment + model.TotalLoan; } } } if (l.SixthMonthPayment != null) { if (l.SixthMonthPayment.Value.Month == theTime.Month && l.SixthMonthPayment.Value.Year == theTime.Year) { if (l.SixthAmountPayment != null) { model.TotalLoan = l.SixthAmountPayment + model.TotalLoan; } } } if (l.SeventhMonthPayment != null) { if (l.SeventhMonthPayment.Value.Month == theTime.Month && l.SeventhMonthPayment.Value.Year == theTime.Year) { if (l.SeventhAmountPayment != null) { model.TotalLoan = l.SeventhAmountPayment + model.TotalLoan; } } } //if (l.EighthMonthPayment != null) //{ // if (l.EighthMonthPayment.Value.Month == theTime.Month && l.EighthMonthPayment.Value.Year == theTime.Year) // { // if (l.EightAmountPayment != null) // { // model.TotalLoan = l.EightAmountPayment + model.TotalLoan; // } // } //} if (l.NinthMonthPayment != null) { if (l.NinthMonthPayment.Value.Month == theTime.Month && l.NinthMonthPayment.Value.Year == theTime.Year) { if (l.NinthAmountPayment != null) { model.TotalLoan = l.NinthAmountPayment + model.TotalLoan; } } } if (l.TenthMonthPayment != null) { if (l.TenthMonthPayment.Value.Month == theTime.Month && l.TenthMonthPayment.Value.Year == theTime.Year) { if (l.TenthAmountPayment != null) { model.TotalLoan = l.TenthAmountPayment + model.TotalLoan; } } } if (l.EleventhMonthPayment != null) { if (l.EleventhMonthPayment.Value.Month == theTime.Month && l.EleventhMonthPayment.Value.Year == theTime.Year) { if (l.EleventhAmountPayment != null) { model.TotalLoan = l.EleventhAmountPayment + model.TotalLoan; } } } if (l.TwelfthMonthPayment != null) { if (l.TwelfthMonthPayment.Value.Month == theTime.Month && l.TwelfthMonthPayment.Value.Year == theTime.Year) { if (l.TwelfthAmountPayment != null) { model.TotalLoan = l.TwelfthAmountPayment + model.TotalLoan; } } } } } return(model); }
public ViewResult Index(string arm, string sortOrder, string currentFilter, string ApprovedString, string searchString, string SexString, string LevelString, string StudentIDString, int?page) { ViewBag.CurrentSort = sortOrder; ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "Name desc" : ""; ViewBag.DateSortParm = sortOrder == "Date" ? "Date desc" : "Date"; ViewBag.ClassSortParm = sortOrder == "class" ? "class desc" : "class"; ViewBag.GenderSortParm = sortOrder == "gender" ? "gender desc" : "gender"; List <Level> theLevels = work.LevelRepository.Get().ToList(); List <SelectListItem> theItem = new List <SelectListItem>(); theItem.Add(new SelectListItem() { Text = "None", Value = "" }); foreach (var level in theLevels) { theItem.Add(new SelectListItem() { Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type }); } //theItem.Add(new SelectListItem() { Text = "Graduated", Value = "Graduated" }); //theItem.Add(new SelectListItem() { Text = "Withdraw", Value = "Withdraw" }); //theItem.Add(new SelectListItem() { Text = "Left", Value = "Left" }); ViewData["arm"] = theItem; if (Request.HttpMethod == "GET") { searchString = currentFilter; } else { page = 1; } ViewBag.CurrentFilter = searchString; var students = from s in work.PrimarySchoolStudentRepository.Get() select s; students = students.Where(s => s.LevelType != "Graduated"); students = students.Where(s => s.LevelType != "Withdraw"); students = students.Where(s => s.LevelType != "Left"); if (!String.IsNullOrEmpty(SexString)) { students = students.Where(s => s.Sex == (SexString)); } if (!String.IsNullOrEmpty(LevelString)) { students = students.Where(s => s.PresentLevel == (LevelString)); } if (!String.IsNullOrEmpty(arm)) { //students = students.Where(s => s.PresentLevel.Equals(LevelString) && s.PresentLevel !=null); students = students.Where(s => s.LevelType == arm); } if (!String.IsNullOrEmpty(searchString)) { students = students.Where(s => s.LastName.ToUpper().Contains(searchString.ToUpper()) || s.FirstName.ToUpper().Contains(searchString.ToUpper()) || s.Middle.ToUpper().Contains(searchString.ToUpper())); } if (!String.IsNullOrEmpty(StudentIDString)) { int theID = Convert.ToInt32(StudentIDString); students = students.Where(s => s.UserID == theID); } //if (!String.IsNullOrEmpty(SexString)) //{ // students = students.Where(s => s.Sex.Equals(SexString)); //} switch (sortOrder) { case "Name desc": students = students.OrderByDescending(s => s.LastName); break; case "Date": students = students.OrderBy(s => s.EnrollmentDate); break; case "Date desc": students = students.OrderByDescending(s => s.EnrollmentDate); break; case "class": students = students.OrderBy(s => s.PresentLevel); break; case "class desc": students = students.OrderByDescending(s => s.PresentLevel); break; case "gender": students = students.OrderBy(s => s.Sex); break; case "gender desc": students = students.OrderByDescending(s => s.Sex); break; default: students = students.OrderBy(s => s.LastName); break; } int pageSize = 100; int pageNumber = (page ?? 1); if (User.IsInRole("Teacher")) { int UserName = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStaff> theStaff = work.PrimarySchoolStaffRepository.Get(a => a.UserID == UserName).ToList(); PrimarySchoolStaff theStaf = theStaff[0]; students = students.Where(a => a.LevelType == theStaf.ClassTeacherOf && a.IsApproved == true); return(View(students.ToPagedList(pageNumber, pageSize))); } else { return(View(students.ToPagedList(pageNumber, pageSize))); } }
public Document PrintPaySlip(List <SalaryPaymentHistory> thePaymentNow, ref StringWriter sw, ref Document itextDoc) { // thePaymentNow. // PdfPTable table = new PdfPTable(2); // PdfPTable alphabet = new PdfPTable(11); iTextSharp.text.Font font_heading_3 = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, iTextSharp.text.Font.BOLD); PdfPTable table1 = new PdfPTable(2); table1.DefaultCell.Border = iTextSharp.text.Rectangle.BOX; table1.AddCell("WEXFORD COLLEGE"); table1.AddCell("FIRST GATE OBA ILE HOUSING ESTATE, AKURE, AKURE NORTH L.G.A"); table1.AddCell("MOTTO:"); table1.AddCell("INTELLIGENCE, INTEGRITY & INDUSTRY"); table1.AddCell("."); table1.AddCell("."); itextDoc.Add(table1); itextDoc.Add(new Paragraph(" ")); itextDoc.Add(new Paragraph(" ")); BaseFont bfTimes = BaseFont.CreateFont(FontFactory.TIMES_ROMAN, BaseFont.CP1252, false); // iTextSharp.text.Font font_heading_1 = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 19, iTextSharp.text.Font.BOLD); iTextSharp.text.Font times = new iTextSharp.text.Font(bfTimes, 12, iTextSharp.text.Font.NORMAL, BaseColor.RED); foreach (var s in thePaymentNow) { PdfPTable table = new PdfPTable(2); PdfPTable wexford = new PdfPTable(1); table.DefaultCell.Border = iTextSharp.text.Rectangle.BOX; decimal toTalDeduction = 0; toTalDeduction = Convert.ToDecimal(s.TotalLatenessDeduction) + toTalDeduction; toTalDeduction = Convert.ToDecimal(s.TotalLoan) + toTalDeduction; toTalDeduction = Convert.ToDecimal(s.TotalAbscentDeduction) + toTalDeduction; itextDoc.Add(new Paragraph("========================================================================== ")); // work.SalaryRepository.GetByID(s.) wexford.AddCell(new Paragraph("WexFord Akure, Pay Slip", font_heading_3)); itextDoc.Add(wexford); table.AddCell(new Paragraph("SALARY FOR THE MONTH OF :", font_heading_3)); table.AddCell(new Paragraph(string.Format("{0:MMMM-yyyy}", DateTime.Now), font_heading_3)); //table.AddCell(" "); table.AddCell(new Paragraph("NAME :", font_heading_3)); table.AddCell(new Paragraph(s.LastName + " " + s.FirstName, font_heading_3)); table.AddCell(new Paragraph("Staff ID", font_heading_3)); table.AddCell(new Paragraph(Convert.ToString(s.StaffID), font_heading_3)); table.AddCell(new Paragraph("Lateness Surcharge (NGN)", font_heading_3)); table.AddCell(new Paragraph(Convert.ToString(s.TotalLatenessDeduction), font_heading_3)); table.AddCell(new Paragraph("Abscent Surcharge (NGN)", font_heading_3)); table.AddCell(new Paragraph(Convert.ToString(s.TotalAbscentDeduction), font_heading_3)); table.AddCell(new Paragraph("Loan Repayment (NGN)", font_heading_3)); table.AddCell(new Paragraph(Convert.ToString(s.TotalLoan), font_heading_3)); foreach (var c in s.TheDeduction) { toTalDeduction = Convert.ToDecimal(c.Amount) + toTalDeduction; table.AddCell(new Paragraph(Convert.ToString(c.DeductionDescription + " (NGN)"), font_heading_3)); table.AddCell(new Paragraph(Convert.ToString(c.Amount), font_heading_3)); } table.AddCell(new Paragraph("ACTUAL SALARY (NGN)", font_heading_3)); table.AddCell(new Paragraph(Convert.ToString(s.ActualSalary), font_heading_3)); table.AddCell(new Paragraph("TOTAL DEDUCTION (NGN) ", font_heading_3)); table.AddCell(new Paragraph(Convert.ToString(toTalDeduction), font_heading_3)); table.AddCell(new Paragraph("NET PAY (NGN)", font_heading_3)); table.AddCell(new Paragraph(Convert.ToString(s.ActualSalary - toTalDeduction), font_heading_3)); itextDoc.Add(table); } // return itextDoc; //check for the student in exam2 // new SalaryPrinting().PrintPaySlip(thePaymentNow, ref oStringWriter1, ref document); // itextDoc.Add(new Paragraph("============================================================================================================================================================== ")); // account to bank itextDoc.NewPage(); PdfPTable table3 = new PdfPTable(2); table3.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER; iTextSharp.text.Image imgPDF = iTextSharp.text.Image.GetInstance(HttpRuntime.AppDomainAppPath + "\\Images\\wexford.jpg"); imgPDF.ScaleToFit(128, 100); // imgPDF.ScaleToFit(200, 200); PdfPCell theImage = new PdfPCell(imgPDF); theImage.Border = iTextSharp.text.Rectangle.NO_BORDER; table3.AddCell(theImage); iTextSharp.text.Font font_heading_1 = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12, iTextSharp.text.Font.BOLD); iTextSharp.text.Font font_heading_2 = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 11, iTextSharp.text.Font.BOLD); // iTextSharp.text.Font font_heading_3 = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, iTextSharp.text.Font.BOLD); PdfPTable theSchoolNameTable = new PdfPTable(1); PdfPCell theWexFord = new PdfPCell(new Paragraph("WEXFORD COLLEGE", font_heading_1)); theWexFord.Border = iTextSharp.text.Rectangle.NO_BORDER; // theWexFord.w PdfPCell theWexFordFirstGate = new PdfPCell(new Paragraph(new Paragraph("FIRST GATE OBA ILE HOUSING ESTATE, AKURE, AKURE NORTH L.G.A, ", font_heading_1))); theWexFordFirstGate.Border = iTextSharp.text.Rectangle.NO_BORDER; PdfPCell theWexFordMoto = new PdfPCell(new Paragraph("MOTTO: INTELLIGENCE, INTEGRITY & INDUSTRY", font_heading_1)); theWexFordMoto.Border = iTextSharp.text.Rectangle.NO_BORDER; theSchoolNameTable.AddCell(theWexFord); theSchoolNameTable.AddCell(theWexFordFirstGate); theSchoolNameTable.AddCell(theWexFordMoto); table3.AddCell(theSchoolNameTable); itextDoc.Add(table3); itextDoc.Add(new Paragraph(" ")); itextDoc.Add(new Paragraph(" Date Generated - " + (string.Format("{0:dd MMM-yyyy}", DateTime.Now)))); itextDoc.Add(new Paragraph(" ")); itextDoc.Add(new Paragraph(" The Manager", font_heading_2)); itextDoc.Add(new Paragraph(" EcoBank Nig Plc,", font_heading_2)); itextDoc.Add(new Paragraph(" Alagbaka,", font_heading_2)); itextDoc.Add(new Paragraph(" Akure, Ondo State,", font_heading_2)); // itextDoc.Add(new Paragraph(" REPORT SHEET ", font_heading_1)); itextDoc.Add(new Paragraph(" ")); // itextDoc.Add(table1); itextDoc.Add(new Paragraph(" ")); itextDoc.Add(new Paragraph(" ")); // BaseFont bfTimes = BaseFont.CreateFont(FontFactory.TIMES_ROMAN, BaseFont.CP1252, false); // iTextSharp.text.Font font_heading_1 = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 19, iTextSharp.text.Font.BOLD); // iTextSharp.text.Font times = new iTextSharp.text.Font(bfTimes, 12, iTextSharp.text.Font.NORMAL, BaseColor.RED); PdfPTable table4 = new PdfPTable(6); table4.AddCell((new Paragraph("s/n", font_heading_3))); table4.AddCell((new Paragraph("Staff Name", font_heading_3))); table4.AddCell((new Paragraph("Account Name", font_heading_3))); table4.AddCell((new Paragraph("Account No", font_heading_3))); table4.AddCell((new Paragraph("Bank", font_heading_3))); table4.AddCell((new Paragraph("Amount (NGN)", font_heading_3))); int counter = 1; foreach (var s in thePaymentNow) { //PdfPTable table = new PdfPTable(2); PrimarySchoolStaff theStaff = work.PrimarySchoolStaffRepository.Get(a => a.UserID == s.StaffID).First(); table4.DefaultCell.Border = iTextSharp.text.Rectangle.BOX; decimal toTalDeduction = 0; toTalDeduction = Convert.ToDecimal(s.TotalLatenessDeduction) + toTalDeduction; toTalDeduction = Convert.ToDecimal(s.TotalLoan) + toTalDeduction; toTalDeduction = Convert.ToDecimal(s.TotalAbscentDeduction) + toTalDeduction; table4.AddCell(new Paragraph(Convert.ToString(counter), font_heading_3)); table4.AddCell(new Paragraph(s.LastName + " " + s.FirstName, font_heading_3)); table4.AddCell(new Paragraph(theStaff.AccountName, font_heading_3)); table4.AddCell(new Paragraph(theStaff.AccountNumber, font_heading_3)); table4.AddCell(new Paragraph(theStaff.BankName, font_heading_3)); // table.AddCell(theStaff.BankName); foreach (var c in s.TheDeduction) { toTalDeduction = Convert.ToDecimal(c.Amount) + toTalDeduction; } counter = counter + 1; table4.AddCell(new Paragraph(Convert.ToString(s.ActualSalary - toTalDeduction), font_heading_3)); } itextDoc.Add(table4); return(itextDoc); }