public ActionResult EmployeeLeaveAllocation(EmployeeLeaveAllocation employeeLeave) { if (ModelState.IsValid) { try { if (superadminManager.IsLeaveAllocated(employeeLeave)) { ViewBag.ShowMsg = "Leave Allocated Was Already Set!"; } else { int message = superadminManager.EmployeeLeaveAllocation(employeeLeave); if (message > 0) { ViewBag.ShowMsg = "Employee Leave Allocation Saved Successfully"; } else { ViewBag.ShowMsg = "Sorry!, Data Not Saved! Please Try Again"; } } } catch (Exception exception) { ViewBag.ShowMsg = exception.Message; } } ViewBag.leavetype = superadminManager.GetLeaveType(); ViewBag.designations = superadminManager.GetDesignationList(); return(View()); }
public Result <bool> ApprovedEmployeeRequest(int id) { if (id > 0) { try { var data = _unitOfWork.employeeLeaveRequestRepository.GetFirstOrDefault(u => u.Id == id); if (data != null) { EmployeeLeaveAllocation createModel = new EmployeeLeaveAllocation(); createModel.DateCreated = DateTime.Now; createModel.EmployeeId = data.RequestingEmployeeId; createModel.EmployeeLeaveTypeId = data.EmployeeLeaveTypeId; var day = (data.EndDate.Day - data.StartDate.Day); createModel.NumberOfDays = day < 0 ? -day : day; createModel.Period = 1; _unitOfWork.employeeLeaveAllocation.Add(createModel); } data.Approved = (int)EnumEmployeeLeaveRequestStatus.Approved; _unitOfWork.employeeLeaveRequestRepository.Update(data); _unitOfWork.Save(); return(new Result <bool>(true, ResultConstant.RecordCreateSuccessfully)); } catch (Exception ex) { return(new Result <bool>(false, ResultConstant.RecordCreateNotSuccessfully + "=>" + ex.Message.ToString())); } } else { return(new Result <bool>(false, "Parametre Olarak Geçilen Data Boş Olamaz!")); } }
public bool IsLeaveAllocated(EmployeeLeaveAllocation leaveAllocation) { try { const string query = "select * from EmployeeLeaveAllocation where (DesignationId = @DesignationId and LeaveTypeId = @LeaveTypeId)"; var command = new SqlCommand(query, Connection); Connection.Open(); command.Parameters.Clear(); command.Parameters.Add("DesignationId", SqlDbType.Int); command.Parameters["DesignationId"].Value = leaveAllocation.DesignationId; command.Parameters.Add("LeaveTypeId", SqlDbType.Int); command.Parameters["LeaveTypeId"].Value = leaveAllocation.LeaveTypeId; SqlDataReader reader = command.ExecuteReader(); reader.Read(); bool isExist = reader.HasRows; reader.Close(); return(isExist); } catch (Exception exception) { throw new Exception("Unable to connect Server", exception); } finally { Connection.Close(); } }
public List <EmployeeLeaveAllocation> TotalCasualLeave(int employeeId) { string query = @"select e.Id, a.LeaveTypeId, a.TotalLeave from Employee e inner join EmployeeLeaveAllocation a on e.DesignationId = a.DesignationId where e.Id = '" + employeeId + "' and a.LeaveTypeId = '" + 2 + "'"; try { var com = new SqlCommand(query, Connection); Connection.Open(); SqlDataReader dr = com.ExecuteReader(); var totalLeave = new List <EmployeeLeaveAllocation>(); while (dr.Read()) { EmployeeLeaveAllocation leave = new EmployeeLeaveAllocation(); leave.Id = (int)dr["Id"]; leave.TotalLeave = (int)dr["TotalLeave"]; totalLeave.Add(leave); } dr.Close(); return(totalLeave.ToList()); } catch (Exception exception) { throw new Exception("Unable to connect Server", exception); } finally { Connection.Close(); } }
public int EmployeeLeaveAllocation(EmployeeLeaveAllocation employeeLeave) { string query = "INSERT INTO EmployeeLeaveAllocation (DesignationId,LeaveTypeId,TotalLeave) VALUES ('" + employeeLeave.DesignationId + "','" + employeeLeave.LeaveTypeId + "','" + employeeLeave.TotalLeave + "')"; try { var command = new SqlCommand(query, Connection); Connection.Open(); int rowAffected = command.ExecuteNonQuery(); return(rowAffected); } catch (Exception exception) { throw new Exception("Unable to connect Server", exception); } finally { Connection.Close(); } }
public int EmployeeLeaveAllocation(EmployeeLeaveAllocation employeeLeave) { return(_superadminGateway.EmployeeLeaveAllocation(employeeLeave)); }
public bool IsLeaveAllocated(EmployeeLeaveAllocation leaveAllocation) { return(_superadminGateway.IsLeaveAllocated(leaveAllocation)); }