public async Task <IActionResult> Edit(short id, [Bind("JobRoleId,Title,Description,TotalCredits,Id")] LeaveTypes leaveTypes) { if (id != leaveTypes.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(leaveTypes); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LeaveTypesExists(leaveTypes.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["JobRoleId"] = new SelectList(_context.JobRole, "Id", "Title", leaveTypes.JobRoleId); return(View(leaveTypes)); }
private void Page_Loaded(object sender, RoutedEventArgs e) { if ((baseControl as MainPage).UserRole == "USER") { mainGrid.Visibility = System.Windows.Visibility.Collapsed; lb_message2.Visibility = System.Windows.Visibility.Visible; return; } MainPage mainPage = baseControl as MainPage; Stack <Page> jobStack = mainPage.JobStack; if (!mainPage.UserIsLoggedIn) { (mainPage.BaseControl as MainWindow).Frame.Navigate(new LoginPage(baseControl)); } if (jobStack.Count != 0 && jobStack.Peek( ) != mainPage.LeaveAssignmentPage) { jobStack.Clear( ); } icb_employees.Data = Employees.GetSpecificEmployeeInfo("DISTINCT EmployeeName"); icb_leaveTypes.Data = LeaveTypes.GetLeaveTypes( ); icb_entitlementType.Data = EntitlementTypes.GetEntitlementTypes( ); icb_validFrom.Data = LeavePeriods.GetStartingDate( ); icb_validTo.Data = LeavePeriods.GetEndingDate( ); }
public IEnumerable <LeaveTypeAmount> GetRemainingLeave(Employee e) { List <LeaveTypeAmount> startingLeave = LeaveTypes.Select(lt => new LeaveTypeAmount { LeaveType = lt, Days = (lt.IsInheritable ? ((DateTime.Now.Year - AppSettings.StartingYear) + 1) * lt.YearlyLeave : lt.YearlyLeave) }).ToList(); List <LeaveTypeAmount> manualAllotments = e.EmployeeLeaveManualAllotments.GroupBy(ea => ea.LeaveType).Select(ea => new LeaveTypeAmount { LeaveType = ea.Key, Days = ea.Sum( l => ea.Key.IsInheritable ? l.Days : (l.DateTime.Year == DateTime.Now.Year ? l.Days : 0)) }).ToList(); foreach (LeaveTypeAmount leaveTypeAmount in startingLeave) { IEnumerable <EmployeeLeaveRequest> leaveRequests = e.EmployeeLeaveRequests.Where( elr => elr.LeaveTypeID == leaveTypeAmount.LeaveType.ID && (elr.EmployeeLeaveRequestStatusChanges.OrderByDescending(elrsc => elrsc.DateTime) .FirstOrDefault() == null || elr.EmployeeLeaveRequestStatusChanges.OrderByDescending(elrsc => elrsc.DateTime) .FirstOrDefault() .LeaveStatusID == 2)); if (!leaveTypeAmount.LeaveType.IsInheritable) { leaveRequests = leaveRequests.Where(lr => lr.DateTime.Year == DateTime.Now.Year); } LeaveTypeAmount manualAllotment = manualAllotments.SingleOrDefault(ma => ma.LeaveType == leaveTypeAmount.LeaveType); if (manualAllotment != null) { leaveTypeAmount.Days += manualAllotment.Days; } leaveTypeAmount.Days -= leaveRequests.Sum( lr => lr.EmployeeLeaveRequestDates.Count(d => d.IsFullDay) + (lr.EmployeeLeaveRequestDates.Count(d => !d.IsFullDay) / 2)); } return(startingLeave); }
public async Task <IActionResult> Create([Bind("JobRoleId,Title,Description,TotalCredits,Id")] LeaveTypes leaveTypes) { if (ModelState.IsValid) { _context.Add(leaveTypes); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["JobRoleId"] = new SelectList(_context.JobRole, "Id", "Title", leaveTypes.JobRoleId); return(View(leaveTypes)); }
public static Tabstrip GetConfigurationTabs <T>() { return(new Tabstrip { CurrentTab = typeof(T).GetFormId(), Tabs = new List <Tab> { ActivityTypes.Button("Activity types").AsTab(), LeaveTypes.Button("Leave types").AsTab() } }); }
private void RetrieveLeaveTypes() { if (LeaveTypes.Count != 0) { LeaveTypes.Clear(); } var leaveTypes = _leaveService.GetAllLeavesTypes(); foreach (var leaveType in leaveTypes) { LeaveTypes.Add(leaveType); } }
public ActionResult DeleteLeaveType(LeaveTypes lt) { Employee e1 = (Employee)Session["Employee"]; if (Session["EmpID"] != null && e1.isAdmin == true) { lt.DeleteLeaveType(); return(RedirectToAction("LeaveType")); } else { return(RedirectToAction("Index", "LogIn")); } }
public ActionResult UpdateLeaveType() { Employee e1 = (Employee)Session["Employee"]; if (Session["EmpID"] != null && e1.isAdmin == true) { LeaveTypes lt = new LeaveTypes() { LeaveTypeID = int.Parse(Request.Form["id"].ToString()), LeaveType = Request.Form["edittxt"].ToString() }; lt.updateLeaveType(); return(RedirectToAction("LeaveType")); } else { return(RedirectToAction("Index", "LogIn")); } }
public List <LeaveTypes> LeaveList(int PageNo, int RowsPerPage, string SearchText) { IDbConnection conn = null; IDbCommand cmd = null; IDataReader reader = null; Int64 TotalRecords = 0; List <LeaveTypes> objleavetypes = new List <LeaveTypes>(); LeaveTypes objlist = null; using (conn = DataFactory.CreateConnection()) { conn.Open(); cmd = conn.CreateCommand(); using (cmd = DataFactory.CreateCommand("SP_LeaveTypeMaster_Search", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(DataFactory.CreateParameter("@PageNo", PageNo)); cmd.Parameters.Add(DataFactory.CreateParameter("@RowsPerPage", RowsPerPage)); cmd.Parameters.Add(DataFactory.CreateParameter("@SearchText", SearchText)); reader = cmd.ExecuteReader(); while (reader.Read()) { TotalRecords = Convert.ToInt64(reader["TotalRecords"]); } if (reader.NextResult()) { while (reader.Read()) { objlist = new LeaveTypes(); objlist.LTypeID = Convert.ToInt64(reader["LTypeID"]); objlist.LeaveType = Convert.ToString(reader["LeaveType"]); objlist.Description = Convert.ToString(reader["Description"]); objlist.TotalRecords1 = TotalRecords; objleavetypes.Add(objlist); } } reader.Close(); } return(objleavetypes); } }
public async Task <IActionResult> UpdateLeaveType(string Leavecode, [FromBody] LeaveTypes leaveType) { APIResponse apiResponse = null; if (leaveType == null) { return(BadRequest($"{nameof(leaveType)} cannot be null")); } try { if (leaveType == null) { return(BadRequest($"{nameof(leaveType)} cannot be null")); } int rs = LeaveTypeHelper.UpdateLeaveType(leaveType); if (rs > 0) { apiResponse = new APIResponse() { status = APIStatus.PASS.ToString(), response = rs }; } else { apiResponse = new APIResponse() { status = APIStatus.FAIL.ToString(), response = "Updation Failed." }; } return(Ok(apiResponse)); } catch (Exception ex) { return(Ok(new APIResponse() { status = APIStatus.FAIL.ToString(), response = ex.Message })); } }
public string Create(LeaveTypes objLeaveType) { string LTypeID = string.Empty; IDbConnection con = null; IDbCommand cmd = null; int RecordAffected; using (con = DataFactory.CreateConnection()) { con.Open(); cmd = con.CreateCommand(); using (cmd = DataFactory.CreateCommand("sp_LeaveTypeMaster_Insert", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(DataFactory.CreateParameter("IsSave", 1)); cmd.Parameters.Add(DataFactory.CreateParameter("LTypeID", DBNull.Value)); cmd.Parameters.Add(DataFactory.CreateParameter("LeaveType", objLeaveType.LeaveType)); cmd.Parameters.Add(DataFactory.CreateParameter("Description", objLeaveType.Description)); cmd.Parameters.Add(DataFactory.CreateParameter("Createdby", objLeaveType.Createdby)); IDbDataParameter param = DataFactory.CreateParameter("@@guid", DBNull.Value); param.DbType = DbType.Int64; param.Direction = ParameterDirection.Output; cmd.Parameters.Add(param); RecordAffected = cmd.ExecuteNonQuery(); LTypeID = param.Value.ToString(); } } if (RecordAffected > 0) { return(Convert.ToString(objLeaveType.LTypeID)); } else { return("Error"); } }
public bool Update(LeaveTypes entity) { _db.LeaveTypes.Update(entity); return(Save()); }
public bool Delete(LeaveTypes entity) { _db.LeaveTypes.Remove(entity); return(Save()); }
public bool Create(LeaveTypes entity) { _db.LeaveTypes.Add(entity); return(Save()); }
public string Update(LeaveTypes objLeaveType) { LeaveTypesMasterDBO objleavedbo = new LeaveTypesMasterDBO(); return(objleavedbo.Update(objLeaveType)); }
private void Page_Loaded(object sender, RoutedEventArgs e) { icb_leaveType.Data = LeaveTypes.GetLeaveTypes( ); }
public ActionResult Create() { #region if (!_context.Roles.Any(x => x.Name == "Supervisor")) { _context.Roles.Add(new IdentityRole("Supervisor")); _context.SaveChanges(); } if (!_context.Roles.Any(x => x.Name == "Employee")) { _context.Roles.Add(new IdentityRole("Employee")); _context.SaveChanges(); } if (!_context.Roles.Any(x => x.Name == "Manager")) { _context.Roles.Add(new IdentityRole("Manager")); _context.SaveChanges(); } if (!_context.LeaveTypes.Any(x => x.LeaveTypeCode == "A0001")) { var annualLeaveType = new LeaveTypes { LeaveTypeCode = "A0001", LeaveTypeDescription = "Annual" }; _context.LeaveTypes.Add(annualLeaveType); _context.SaveChanges(); } if (!_context.LeaveTypes.Any(x => x.LeaveTypeCode == "C0001")) { var casualLeaveType = new LeaveTypes { LeaveTypeCode = "C0001", LeaveTypeDescription = "Casual" }; _context.LeaveTypes.Add(casualLeaveType); _context.SaveChanges(); } if (!_context.LeaveTypes.Any(x => x.LeaveTypeCode == "S0001")) { var sickLeaveType = new LeaveTypes { LeaveTypeCode = "S0001", LeaveTypeDescription = "Sick" }; _context.LeaveTypes.Add(sickLeaveType); _context.SaveChanges(); } if (!_context.EmployeeMaster.Any(x => x.EmployeeCode == "E0001")) { var employeeMaster = new EmployeeMaster { EmployeeCode = "E0001", EmployeeName = "Test Supervisor", EmployeeLeavePacakge = LeavePacakge.Wages, EmployeeType = EmployeeType.Supervisor, EmployeeSupervisorCode = "E0001" }; _context.EmployeeMaster.Add(employeeMaster); _context.SaveChanges(); var annualLeaveForOffice = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "A0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 10, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 10 }; _context.LeaveAllocation.Add(annualLeaveForOffice); _context.SaveChanges(); var casualLeaveForOffice = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "C0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 10, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 10 }; _context.LeaveAllocation.Add(casualLeaveForOffice); _context.SaveChanges(); var sickLeaveForOffice = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "S0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 10, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 10 }; _context.LeaveAllocation.Add(sickLeaveForOffice); _context.SaveChanges(); var newUser = new User { Username = employeeMaster.EmployeeCode, Password = employeeMaster.EmployeeCode }; _context.User.Add(newUser); _context.SaveChanges(); var userId = _context.User.ToList().Where(e => e.Username == employeeMaster.EmployeeCode).FirstOrDefault().UserId; var newUserRole = new UserRole { UserId = userId, Role = EmployeeType.Supervisor.ToString() }; _context.UserRole.Add(newUserRole); _context.SaveChanges(); } if (!_context.EmployeeMaster.Any(x => x.EmployeeCode == "E0002")) { var employeeMaster = new EmployeeMaster { EmployeeCode = "E0002", EmployeeName = "Test Employee", EmployeeLeavePacakge = LeavePacakge.Office, EmployeeType = EmployeeType.Employee, EmployeeSupervisorCode = "E0001" }; _context.EmployeeMaster.Add(employeeMaster); _context.SaveChanges(); var annualLeaveForOffice = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "A0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 14, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 14 }; _context.LeaveAllocation.Add(annualLeaveForOffice); _context.SaveChanges(); var casualLeaveForOffice = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "C0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 7, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 7 }; _context.LeaveAllocation.Add(casualLeaveForOffice); _context.SaveChanges(); var sickLeaveForOffice = new LeaveAllocation { EmployeeCode = employeeMaster.EmployeeCode, LeaveTypeCode = "S0001", Year = DateTime.Now.Year.ToString(), EntitledLeaveAmount = 21, UtilizedLeaveAmount = 0, RemainingLeaveAmount = 21 }; _context.LeaveAllocation.Add(sickLeaveForOffice); _context.SaveChanges(); var newUser = new User { Username = employeeMaster.EmployeeCode, Password = employeeMaster.EmployeeCode }; _context.User.Add(newUser); _context.SaveChanges(); var userId = _context.User.ToList().Where(e => e.Username == employeeMaster.EmployeeCode).FirstOrDefault().UserId; var newUserRole = new UserRole { UserId = userId, Role = EmployeeType.Employee.ToString() }; _context.UserRole.Add(newUserRole); _context.SaveChanges(); } #endregion return(View()); }
/// <summary> /// There are no comments for LeaveTypes in the schema. /// </summary> public void AddToLeaveTypes(LeaveTypes leaveTypes) { base.AddObject("LeaveTypes", leaveTypes); }
/// <summary> /// Create a new LeaveTypes object. /// </summary> /// <param name="leaveTypeId">Initial value of LeaveTypeId.</param> public static LeaveTypes CreateLeaveTypes(int leaveTypeId) { LeaveTypes leaveTypes = new LeaveTypes(); leaveTypes.LeaveTypeId = leaveTypeId; return leaveTypes; }
private void ComboBox_LeaveType_Selected(object sender, EventArgs e) { dataManager.Data = LeaveTypes.GetLeaveTypes(); ViewMatches((ComboBox)sender, dataManager, "LeaveType", 0); }