public List <EmployeeMaster> GetEmployeeList(int IsActive, int SchoolID)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GetEmployeeList(IsActive, SchoolID));
        }
        public EmployeeAttendance GetEmployeeAttendance(EmployeeAttendance model, string EmployeeID = "")
        {
            EmployeeSalary                  _EmployeeSalaryModel = new EmployeeSalary();
            EmployeeSalary                  _EmployeeSalary      = new EmployeeSalary();
            DALFee                          dal           = new DALFee(ConStr);
            List <EmployeeMaster>           _employeeList = new List <EmployeeMaster>();
            List <EmployeeAttendanceRecord> ObjEmployeeAttendanceRecordList = new List <EmployeeAttendanceRecord>();
            EmployeeAttendanceRecord        objEmployeeAttendanceRecord     = null;
            EmployeeMaster                  objEmployeeMaster = null;
            AttendanceDetails               objAttendanceDetails = null;
            int Month = 0, Year = 0;

            try
            {
                #region SET properties to Get Employee Salary status
                _EmployeeSalaryModel.SchoolID      = model.SchoolID;
                _EmployeeSalaryModel.FinancialYear = model.FinancialYear;
                _EmployeeSalaryModel.MonthYear     = model.MonthYear;
                #endregion SET properties to Get Employee Salary status
                model.MonthYear = string.IsNullOrEmpty(model.MonthYear) ? DateTime.Now.ToString("MMM/yyyy") : model.MonthYear;
                Month           = Convert.ToInt32(Convert.ToDateTime(model.MonthYear).ToString("MM"));
                Year            = Convert.ToInt32(Convert.ToDateTime(model.MonthYear).ToString("yyyy"));
                _employeeList   = !string.IsNullOrEmpty(EmployeeID) ? dal.GetEmployeeList(1, model.SchoolID).Where(x => x.ISACTIVE == true && Convert.ToString(x.EMP_ID) == EmployeeID).ToList() : dal.GetEmployeeList(1, model.SchoolID).Where(x => x.ISACTIVE == true).ToList();
                foreach (var emp in _employeeList)
                {
                    objEmployeeAttendanceRecord = new EmployeeAttendanceRecord();
                    objEmployeeMaster           = new EmployeeMaster();
                    objAttendanceDetails        = new AttendanceDetails();



                    objEmployeeMaster = emp;
                    var dtEmployeeAttendance = dal.GetEmployeeAttendance(model.SchoolID, model.FinancialYear, emp.EMP_ID, Month, Year);

                    var startDate = !string.IsNullOrEmpty(Convert.ToString(emp.JOININGDATE)) ? Convert.ToDateTime(emp.JOININGDATE) : new DateTime(Year, Month, 1);
                    var endDate   = !string.IsNullOrEmpty(Convert.ToString(emp.LEAVINGDATE)) ? Convert.ToDateTime(emp.LEAVINGDATE) : new DateTime(Year, Month, DateTime.DaysInMonth(Year, Month));
                    model.TotalDaysInMonth = DateTime.DaysInMonth(Year, Month);
                    var ListDates = Enumerable.Range(1, DateTime.DaysInMonth(Year, Month)).Select(day => new DateTime(Year, Month, day)).ToList();
                    objAttendanceDetails.TotalWorkingDaysList = ListDates.Where(x => Convert.ToDateTime(x) >= startDate && Convert.ToDateTime(x) <= endDate).Select(x => x.ToString("dd/MM/yyyy")).ToList();
                    objAttendanceDetails.Attendance           = dtEmployeeAttendance;
                    //if (dtEmployeeAttendance.Rows.Count > 0)
                    //{
                    _EmployeeSalary = dal.GetEmployeeSalaryList(_EmployeeSalaryModel, emp.EMPCODE);

                    objAttendanceDetails.AbsentList          = dtEmployeeAttendance.Rows.OfType <DataRow>().Where(dr => dr.Field <string>("SalaryAttendance") == "A" && dr.Field <DateTime>("Attendancedate") >= startDate && dr.Field <DateTime>("Attendancedate") <= endDate).Select(dr => dr.Field <DateTime>("Attendancedate").ToString("dd/MM/yyyy")).ToList();
                    objAttendanceDetails.ActualTotalAbsent   = objAttendanceDetails.AbsentList.Count();
                    objAttendanceDetails.ModifiedTotalAbsent = objAttendanceDetails.AbsentList.Count();

                    objAttendanceDetails.PaidLeaveList          = dtEmployeeAttendance.Rows.OfType <DataRow>().Where(dr => dr.Field <string>("SalaryAttendance") == "PL" && dr.Field <DateTime>("Attendancedate") >= startDate && dr.Field <DateTime>("Attendancedate") <= endDate).Select(dr => dr.Field <DateTime>("Attendancedate").ToString("dd/MM/yyyy")).ToList();
                    objAttendanceDetails.ActualTotalPaidLeave   = objAttendanceDetails.PaidLeaveList.Count();
                    objAttendanceDetails.ModifiedTotalPaidLeave = objAttendanceDetails.PaidLeaveList.Count();


                    objAttendanceDetails.UnPaidLeaveList          = dtEmployeeAttendance.Rows.OfType <DataRow>().Where(dr => dr.Field <string>("SalaryAttendance") == "UPL" && dr.Field <DateTime>("Attendancedate") >= startDate && dr.Field <DateTime>("Attendancedate") <= endDate).Select(dr => dr.Field <DateTime>("Attendancedate").ToString("dd/MM/yyyy")).ToList();
                    objAttendanceDetails.ActualTotalUnPaidLeave   = objAttendanceDetails.UnPaidLeaveList.Count();
                    objAttendanceDetails.ModifiedTotalUnPaidLeave = objAttendanceDetails.UnPaidLeaveList.Count();

                    objAttendanceDetails.HolidayList          = dtEmployeeAttendance.Rows.OfType <DataRow>().Where(dr => dr.Field <string>("SalaryAttendance") == "H" && dr.Field <DateTime>("Attendancedate") >= startDate && dr.Field <DateTime>("Attendancedate") <= endDate).Select(dr => dr.Field <DateTime>("Attendancedate").ToString("dd/MM/yyyy")).ToList();
                    objAttendanceDetails.ActualTotalHoliday   = objAttendanceDetails.HolidayList.Count();
                    objAttendanceDetails.ModifiedTotalHoliday = objAttendanceDetails.HolidayList.Count();

                    objAttendanceDetails.WOList          = dtEmployeeAttendance.Rows.OfType <DataRow>().Where(dr => dr.Field <string>("SalaryAttendance") == "WO" && dr.Field <DateTime>("Attendancedate") >= startDate && dr.Field <DateTime>("Attendancedate") <= endDate).Select(dr => dr.Field <DateTime>("Attendancedate").ToString("dd/MM/yyyy")).ToList();
                    objAttendanceDetails.ActualTotalWO   = objAttendanceDetails.WOList.Count();
                    objAttendanceDetails.ModifiedTotalWO = objAttendanceDetails.WOList.Count();

                    objAttendanceDetails.PresentList          = dtEmployeeAttendance.Rows.OfType <DataRow>().Where(dr => dr.Field <string>("SalaryAttendance") == "P" && dr.Field <DateTime>("Attendancedate") >= startDate && dr.Field <DateTime>("Attendancedate") <= endDate).Select(dr => dr.Field <DateTime>("Attendancedate").ToString("dd/MM/yyyy")).ToList();
                    objAttendanceDetails.ActualTotalPresent   = objAttendanceDetails.PresentList.Count();
                    objAttendanceDetails.ModifiedTotalPresent = objAttendanceDetails.PresentList.Count();

                    objAttendanceDetails.MissingAttendenceList          = objAttendanceDetails.TotalWorkingDaysList.Where(y => !(dtEmployeeAttendance.Rows.OfType <DataRow>().Where(dr => dr.Field <DateTime>("Attendancedate") >= startDate && dr.Field <DateTime>("Attendancedate") <= endDate).Select(dr => dr.Field <DateTime>("Attendancedate").ToString("dd/MM/yyyy")).ToList()).Any(z => z == y)).ToList();
                    objAttendanceDetails.ActualTotalMissingAttendence   = objAttendanceDetails.MissingAttendenceList.Count();
                    objAttendanceDetails.ModifiedTotalMissingAttendence = objAttendanceDetails.MissingAttendenceList.Count();
                    objEmployeeAttendanceRecord.PaidSalary    = "N/G";
                    objEmployeeAttendanceRecord.PaymentStatus = false;
                    if (_EmployeeSalary != null)
                    {
                        if (_EmployeeSalary.SalaryDetailsList != null && _EmployeeSalary.SalaryDetailsList.Count > 0)
                        {
                            if (_EmployeeSalary.SalaryDetailsList.Where(x => x.EMP_ID == emp.EMP_ID && x.EMP_CODE == emp.EMPCODE).Any())
                            {
                                var empSal = _EmployeeSalary.SalaryDetailsList.Where(x => x.EMP_ID == emp.EMP_ID && x.EMP_CODE == emp.EMPCODE).FirstOrDefault();
                                objEmployeeAttendanceRecord.PaidSalary    = string.IsNullOrEmpty(Convert.ToString(empSal.PaidSalary)) ? objEmployeeAttendanceRecord.PaidSalary : Convert.ToString(empSal.PaidSalary);
                                objEmployeeAttendanceRecord.PaymentStatus = empSal.PaymentStatus;
                            }
                        }
                    }

                    //}
                    //else
                    //{

                    //    objAttendanceDetails.AbsentList = new List<string>();
                    //    objAttendanceDetails.ActualTotalAbsent = 0;
                    //    objAttendanceDetails.ModifiedTotalAbsent = 0;

                    //    objAttendanceDetails.PaidLeaveList = new List<string>();
                    //    objAttendanceDetails.ActualTotalPaidLeave = 0;
                    //    objAttendanceDetails.ModifiedTotalPaidLeave = 0;

                    //    objAttendanceDetails.UnPaidLeaveList = new List<string>();
                    //    objAttendanceDetails.ActualTotalUnPaidLeave = 0;
                    //    objAttendanceDetails.ModifiedTotalUnPaidLeave = 0;

                    //    objAttendanceDetails.HolidayList = new List<string>();
                    //    objAttendanceDetails.ActualTotalHoliday = 0;
                    //    objAttendanceDetails.ModifiedTotalHoliday = 0;

                    //    objAttendanceDetails.WOList = new List<string>();
                    //    objAttendanceDetails.ActualTotalWO = 0;
                    //    objAttendanceDetails.ModifiedTotalWO = 0;

                    //    objAttendanceDetails.PresentList = new List<string>();
                    //    objAttendanceDetails.ActualTotalPresent = 0;
                    //    objAttendanceDetails.ModifiedTotalPresent = 0;

                    //    objAttendanceDetails.MissingAttendenceList = ListDates.Select(x => x.ToString("dd/MM/yyyy")).ToList();
                    //    objAttendanceDetails.ActualTotalMissingAttendence = objAttendanceDetails.MissingAttendenceList.Count();
                    //    objAttendanceDetails.ModifiedTotalMissingAttendence = objAttendanceDetails.MissingAttendenceList.Count();
                    //    objEmployeeAttendanceRecord.PaidSalary = "N/G";
                    //}
                    objEmployeeAttendanceRecord.AttendanceDetail = objAttendanceDetails;
                    objEmployeeAttendanceRecord.EmployeeDetails  = objEmployeeMaster;

                    ObjEmployeeAttendanceRecordList.Add(objEmployeeAttendanceRecord);
                }
                model.EmployeeAttendanceList = ObjEmployeeAttendanceRecordList;
            }
            catch (Exception ex)
            {
            }

            return(model);
        }