public static List <EmployeeLeaveDays> GetEmployeeLeaveDaysList(int employeeId, int financialPeriodId)
        {
            List <EmployeeLeaveDays> list = new List <EmployeeLeaveDays>();

            Database  db         = DatabaseFactory.CreateDatabase("Spar-StoreRep");
            string    sqlCommand = "GetEmployeeLeaveDaysList";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "@EmployeeId", DbType.Int32, employeeId);
            db.AddInParameter(dbCommand, "@FinancialPeriodId", DbType.Int32, financialPeriodId);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    EmployeeLeaveDays employeeLeaveDays = new EmployeeLeaveDays();
                    employeeLeaveDays.EmployeeId          = employeeId;
                    employeeLeaveDays.FinancialPeriodId   = financialPeriodId;
                    employeeLeaveDays.EmployeeLeaveDaysId = Convert.ToInt32(dataReader["EmployeeLeaveDaysId"]);
                    employeeLeaveDays.EmployeeLeaveId     = Convert.ToInt32(dataReader["EmployeeLeaveId"]);
                    employeeLeaveDays.StartDate           = Convert.ToDateTime(dataReader["StartDate"]);
                    employeeLeaveDays.EndDate             = Convert.ToDateTime(dataReader["EndDate"]);
                    employeeLeaveDays.Days        = Convert.ToDecimal(dataReader["Days"]);
                    employeeLeaveDays.Comment     = dataReader["Comment"].ToString();
                    employeeLeaveDays.LeaveTypeId = Convert.ToInt32(dataReader["LeaveTypeId"]);
                    employeeLeaveDays.LeaveType   = dataReader["LeaveType"].ToString();
                    employeeLeaveDays.isApproved  = Convert.ToInt32(dataReader["isApproved"]);
                    employeeLeaveDays.Attachment  = dataReader["Attachment"].ToString();
                    list.Add(employeeLeaveDays);
                }
            }
            return(list);
        }
        public static EmployeeLeaveDays GetEmployeeLeaveDaysByEmployeeIdFinancialPeriodId(int employeeId, int financialPeriodId)
        {
            Database  db         = DatabaseFactory.CreateDatabase("Spar-StoreRep");
            string    sqlCommand = "GetEmployeeLeaveDaysByEmployeeIdFinancialPeriodId";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "@EmployeeId", DbType.Int32, employeeId);
            db.AddInParameter(dbCommand, "@FinancialPeriodId", DbType.Int32, financialPeriodId);
            db.AddOutParameter(dbCommand, "@EmployeeLeaveDaysId", DbType.Int32, 4);
            db.AddOutParameter(dbCommand, "@StartDate", DbType.DateTime, 8);
            db.AddOutParameter(dbCommand, "@EndDate", DbType.DateTime, 8);
            db.AddOutParameter(dbCommand, "@Days", DbType.Decimal, 8);
            db.AddOutParameter(dbCommand, "@Comment", DbType.String, 500);
            db.AddOutParameter(dbCommand, "@LeaveTypeId", DbType.Int32, 4);
            db.ExecuteNonQuery(dbCommand);
            EmployeeLeaveDays employeeLeaveDays = new EmployeeLeaveDays();

            employeeLeaveDays.EmployeeId          = employeeId;
            employeeLeaveDays.FinancialPeriodId   = financialPeriodId;
            employeeLeaveDays.EmployeeLeaveDaysId = Convert.ToInt32(db.GetParameterValue(dbCommand, "EmployeeLeaveDaysId"));
            employeeLeaveDays.StartDate           = Convert.ToDateTime(db.GetParameterValue(dbCommand, "StartDate"));
            employeeLeaveDays.EndDate             = Convert.ToDateTime(db.GetParameterValue(dbCommand, "EndDate"));
            employeeLeaveDays.Days        = Convert.ToDecimal(db.GetParameterValue(dbCommand, "Days"));
            employeeLeaveDays.Comment     = db.GetParameterValue(dbCommand, "Comment").ToString();
            employeeLeaveDays.LeaveTypeId = Convert.ToInt32(db.GetParameterValue(dbCommand, "LeaveTypeId"));
            return(employeeLeaveDays);
        }
        public static List <EmployeeLeaveDays> GetReportEmployeeLeaveHeader(/*int employeeId,*/ int financialPeriodId, int locationId, int leaveTypeId, DateTime dateFrom, DateTime dateTo, int isApproved)
        {
            List <EmployeeLeaveDays> list = new List <EmployeeLeaveDays>();

            Database  db         = DatabaseFactory.CreateDatabase("Spar-StoreRep");
            string    sqlCommand = "GetReportEmployeeLeaveHeader";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "@FinancialPeriodId", DbType.Int32, financialPeriodId);
            db.AddInParameter(dbCommand, "@LocationId", DbType.Int32, locationId);
            db.AddInParameter(dbCommand, "@LeaveTypeId", DbType.Int32, leaveTypeId);
            db.AddInParameter(dbCommand, "@DateFrom", DbType.DateTime, dateFrom);
            db.AddInParameter(dbCommand, "@DateTo", DbType.DateTime, dateTo);
            db.AddInParameter(dbCommand, "@IsApproved", DbType.Int32, isApproved);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    EmployeeLeaveDays employeeLeaveDays = new EmployeeLeaveDays();
                    employeeLeaveDays.EmployeeId      = Convert.ToInt32(dataReader["EmployeeId"]);
                    employeeLeaveDays.CurrentDays     = Convert.ToDecimal(dataReader["CurrentDays"]);
                    employeeLeaveDays.EntitledDays    = Convert.ToDecimal(dataReader["EntitledDays"]);
                    employeeLeaveDays.EmployeeNumber  = dataReader["EmployeeNumber"].ToString();
                    employeeLeaveDays.FirstName       = dataReader["FirstName"].ToString();
                    employeeLeaveDays.LastName        = dataReader["LastName"].ToString();
                    employeeLeaveDays.FinancialPeriod = dataReader["FinancialPeriod"].ToString();
                    //employeeLeaveDays.StartDate = Convert.ToDateTime(dataReader["StartDate"]);
                    //employeeLeaveDays.EndDate = Convert.ToDateTime(dataReader["EndDate"]);
                    //employeeLeaveDays.Days = Convert.ToDecimal(dataReader["Days"]);
                    employeeLeaveDays.TotalDays = Convert.ToDecimal(dataReader["TotalDays"]);
                    employeeLeaveDays.EmployeeLeaveProjection = Convert.ToDecimal(dataReader["EmployeeLeaveProjection"]);
                    employeeLeaveDays.Comment          = dataReader["Comment"].ToString();
                    employeeLeaveDays.ReportsToComment = dataReader["ReportsToComment"].ToString();
                    employeeLeaveDays.LeaveType        = dataReader["LeaveType"].ToString();
                    list.Add(employeeLeaveDays);
                }
            }
            return(list);
        }
        public static List <EmployeeLeaveDays> GetEmployeeListFilterByReportsToId(string searchValue, int accountId, int financialPeriodId)
        {
            List <EmployeeLeaveDays> list = new List <EmployeeLeaveDays>();

            Database  db         = DatabaseFactory.CreateDatabase("Spar-StoreRep");
            string    sqlCommand = "GetEmployeeListFilterByReportsToId";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "@SearchValue", DbType.String, searchValue);
            db.AddInParameter(dbCommand, "@AccountId", DbType.Int32, accountId);
            db.AddInParameter(dbCommand, "@FinancialPeriodId", DbType.Int32, financialPeriodId);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    EmployeeLeaveDays employeeLeaveDays = new EmployeeLeaveDays();
                    employeeLeaveDays.EmployeeId          = Convert.ToInt32(dataReader["EmployeeId"]);
                    employeeLeaveDays.EmployeeNumber      = dataReader["EmployeeNumber"].ToString();
                    employeeLeaveDays.FirstName           = dataReader["FirstName"].ToString();
                    employeeLeaveDays.LastName            = dataReader["LastName"].ToString();
                    employeeLeaveDays.Email               = dataReader["Email"].ToString();
                    employeeLeaveDays.ReportsToEmail      = dataReader["ReportsToEmail"].ToString();
                    employeeLeaveDays.EmployeeLeaveDaysId = Convert.ToInt32(dataReader["EmployeeLeaveDaysId"]);
                    employeeLeaveDays.EmploymentType      = dataReader["EmploymentType"].ToString();
                    employeeLeaveDays.StartDate           = Convert.ToDateTime(dataReader["StartDate"]);
                    employeeLeaveDays.EndDate             = Convert.ToDateTime(dataReader["EndDate"]);
                    employeeLeaveDays.Days            = Convert.ToDecimal(dataReader["Days"]);
                    employeeLeaveDays.isApproved      = Convert.ToInt32(dataReader["isApproved"]);
                    employeeLeaveDays.LeaveType       = dataReader["LeaveType"].ToString();
                    employeeLeaveDays.FinancialPeriod = dataReader["FinancialPeriod"].ToString();

                    list.Add(employeeLeaveDays);
                }
            }
            return(list);
        }