public List <StudentMaster> GetDueFeeList(int SchoolId, int FinancialYearID, int ClassID, int SectionID, int FromMonth, int ToMonth)
        {
            DALCommon            obj          = new DALCommon(ConStr);
            DALFee               dal          = new DALFee(ConStr);
            List <StudentMaster> Studentlist  = new List <StudentMaster>();
            List <FeeHeadList>   _FeeHeadList = new List <FeeHeadList>();

            try
            {
                Studentlist = obj.GetStudentList(SchoolId, FinancialYearID, ClassID, SectionID, 0, "");
                Studentlist.ToList().ForEach(p =>
                {
                    p.UnPaidMonth   = getUnPaidMonth(p.PaidMonths, FromMonth, ToMonth);
                    _FeeHeadList    = dal.GetFeeHeadListForFeeGroup(p.FeeGroup, SchoolId, p.Adminssionno, FinancialYearID);
                    p.PendingAmount = _FeeHeadList.Count() == 0 ? "N/A" : getTotalPaid(dal.GetFeeHeadListForFeeGroup(p.FeeGroup, SchoolId, p.Adminssionno, FinancialYearID), p.UnPaidMonth, FromMonth, ToMonth);
                });
            }
            catch (Exception ex)
            {
            }
            return(Studentlist.Where(x => !string.IsNullOrEmpty(x.UnPaidMonth)).ToList());
        }
        public List <StudentMaster> GetStudentList(int SectionID, int StudentID)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GetStudentList(SectionID, StudentID));
        }
        public List <selectList> GetDDList(string Module, int SchoolID)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GetDDList(Module, SchoolID));
        }
        public string SaveFeeGroup(FeeGroup FG)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.SaveFeeGroup(FG));
        }
        public DataTable GetFeeRefundList(FeeRefund Obj)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GetFeeRefundList(Obj));
        }
        public string DeleteFeeHead(string FeeID)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.DeleteFeeHead(FeeID));
        }
        public IndisciplineDetails GetIndisciplineFeeDepositByReceiptNo(IndisciplineDetails FeeDepositDetails)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GetIndisciplineFeeDepositByReceiptNo(FeeDepositDetails));
        }
        public List <IndisciplineDetails> GetIndisciplineList(int SchoolID, int FinancialYearID)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GetIndisciplineList(SchoolID, FinancialYearID));
        }
        public List <EmployeeMaster> GetEmployeeList(int IsActive, int SchoolID)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GetEmployeeList(IsActive, SchoolID));
        }
        public string SaveFeeHead(FeeHead FH)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.SaveFeeHead(FH));
        }
        public List <EmployeeMaster> SearchEmployeeList(string searchVal, int schoolID)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.SearchEmployeeList(searchVal, 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);
        }
        public bool InsertLedgerEntry(Ledger obj)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.InsertLedgerEntry(obj));
        }
        public List <Ledger> GerLedgerReport(Ledger obj)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GerLedgerReport(obj));
        }
        public List <ClassSectionMaster> GetClassSection(int ClassID, int SchoolID)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GetClassSection(ClassID, SchoolID));
        }
        public List <FeeHeadDescription> GetFeeHeadDescription(FeeHeadDescription FHD)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GetFeeHeadDescription(FHD));
        }
        public string DeleteFeeHeadDescription(FeeHeadDescription FHD)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.DeleteFeeHeadDescription(FHD));
        }
        public int InsertSalaryEntry(EmployeeSalary obj)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.InsertSalaryEntry(obj));
        }
        public string SaveIndiscipline(IndisciplineDetails ID)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.SaveIndiscipline(ID));
        }
        public EmployeeSalary GetEmployeeSalaryList(EmployeeSalary employeeSalary, string EmpCode)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GetEmployeeSalaryList(employeeSalary, EmpCode));
        }
        public DataTable GetFineConcessionList(FineConcession fineConcession)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GetFineConcessionList(fineConcession));
        }
        public List <FeeHead> GetFeeHeads(FeeHead FH)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GetFeeHeads(FH));
        }
        public string SaveFeeRefund(FeeRefund Obj)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.SaveFeeRefund(Obj));
        }
        public int UpdateSalary(EmployeeSalary employeeSalary)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.UpdateSalary(employeeSalary));
        }
        public List <FeeGroup> GetFeeGroup(FeeGroup FG)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GetFeeGroup(FG));
        }
        public int AssignFeeConcession(FeeConcessionDetails feeConcessionDetails)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.AssignFeeConcession(feeConcessionDetails));
        }
        public string DeleteFeeGroup(string FeeGroupID, string FeeGroupName)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.DeleteFeeGroup(FeeGroupID, FeeGroupName));
        }
        public FeeConcessionDetails GetAssignFeeConcession(FeeConcessionDetails model)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GetAssignFeeConcession(model));
        }
        public List <FeeHeadList> GetFeeHeadListForFeeGroup(string FeeGroupName, int SchoolID, string AdmissionNo, int FMid)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GetFeeHeadListForFeeGroup(FeeGroupName, SchoolID, AdmissionNo, FMid));
        }
        public List <ClassMaster> GetClassList(string SchoolID)
        {
            DALFee dal = new DALFee(ConStr);

            return(dal.GetClassList(SchoolID));
        }