Exemplo n.º 1
0
        public void SetEmployeeTimeSheetValue(HREmployeeTimeSheetsInfo objEmployeeTimeSheetsInfo)
        {
            HRTimeSheetsInfo timeSheet = (HRTimeSheetsInfo)MainObject;
            List <string>    employeeTimeSheetValueList = new List <string> {
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                string.Empty
            };

            foreach (HRTimeSheetEntrysInfo timeSheetEntry in objEmployeeTimeSheetsInfo.HRTimeSheetEntrysList)
            {
                if (timeSheetEntry.HRTimeSheetEntryDate.Date >= timeSheet.HRTimeSheetFromDate.Date &&
                    timeSheetEntry.HRTimeSheetEntryDate.Date <= timeSheet.HRTimeSheetToDate.Date)
                {
                    int    index            = (int)(timeSheetEntry.HRTimeSheetEntryDate.Date - timeSheet.HRTimeSheetFromDate.Date).TotalDays + 1;
                    string timeSheetParamNo = string.Empty;
                    HRTimeSheetParamsInfo objTimeSheetParamsInfo = TimeSheetParams.Where(t => t.HRTimeSheetParamID == timeSheetEntry.FK_HRTimeSheetParamID).FirstOrDefault();
                    if (objTimeSheetParamsInfo != null)
                    {
                        timeSheetParamNo = objTimeSheetParamsInfo.HRTimeSheetParamNo;
                    }
                    if (!string.IsNullOrEmpty(timeSheetParamNo))
                    {
                        if (string.IsNullOrEmpty(employeeTimeSheetValueList[index - 1].Trim()))
                        {
                            employeeTimeSheetValueList[index - 1] = timeSheetParamNo;
                        }
                        else
                        {
                            employeeTimeSheetValueList[index - 1] += String.Format(", {0}", timeSheetParamNo);
                        }
                    }
                }
            }

            VinaDbUtil dbUtil  = new VinaDbUtil();
            int        numDays = ((TimeSheetModule)Module).NumOfDayInMonth();

            if (numDays > 31)
            {
                numDays = 31;
            }
            for (int i = 1; i <= numDays; i++)
            {
                String propertyName = String.Format("{0}{1}", "HREmployeeTimeSheetDate", i.ToString());
                dbUtil.SetPropertyValue(objEmployeeTimeSheetsInfo, propertyName, employeeTimeSheetValueList[i - 1]);
            }
        }
Exemplo n.º 2
0
        public void SaveLeaveDays(DateTime dateFrom, DateTime dateTo)
        {
            VinaDbUtil                  dbUtil = new VinaDbUtil();
            LeaveDayEntities            entity = (LeaveDayEntities)CurrentModuleEntity;
            HRTimeSheetParamsController objTimeSheetParamsController = new HRTimeSheetParamsController();

            commonParams = objTimeSheetParamsController.GetTimeSheetParamsByTimeSheetType(TimeSheetParamType.Common.ToString());
            HRLeaveDaysController objLeaveDaysController = new HRLeaveDaysController();

            foreach (HRLeaveDaysInfo employeeLeaveDay in entity.LeaveDaysList)
            {
                //objLeaveDaysController.DeleteByEmployeeIDAndDate(employeeLeaveDay.FK_HREmployeeID, employeeLeaveDay.HRLeaveDayDate);
                for (int i = 1; i <= 31; i++)
                {
                    string[] paramNumbers = dbUtil.GetPropertyStringValue(employeeLeaveDay, string.Format("HRLeaveDayDate{0}", i)).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    if (dateFrom.Date.AddDays(i - 1) <= dateTo.Date)
                    {
                        objLeaveDaysController.DeleteByEmployeeIDAndDate(employeeLeaveDay.FK_HREmployeeID, dateFrom.Date.AddDays(i - 1));
                    }
                    for (int j = 0; j < paramNumbers.Length; j++)
                    {
                        string paramNo = paramNumbers[j].Trim();
                        //string paramNo = dbUtil.GetPropertyStringValue(employeeLeaveDay, string.Format("HRLeaveDayDate{0}", i));
                        if (!string.IsNullOrEmpty(paramNo))
                        {
                            HRTimeSheetParamsInfo param = commonParams.Where(p => p.HRTimeSheetParamNo == paramNo).FirstOrDefault();
                            if (param != null)
                            {
                                HRLeaveDaysInfo leaveDay = new HRLeaveDaysInfo();
                                leaveDay.FK_HREmployeeID       = employeeLeaveDay.FK_HREmployeeID;
                                leaveDay.FK_HRTimeSheetParamID = param.HRTimeSheetParamID;
                                //leaveDay.HRLeaveDayDate = new DateTime(employeeLeaveDay.HRLeaveDayDate.Year, employeeLeaveDay.HRLeaveDayDate.Month, i);
                                leaveDay.HRLeaveDayDate = dateFrom.Date.AddDays(i - 1);
                                //objLeaveDaysController.DeleteByEmployeeIDAndDate(employeeLeaveDay.FK_HREmployeeID, leaveDay.HRLeaveDayDate);
                                objLeaveDaysController.CreateObject(leaveDay);
                            }
                        }
                        //else
                        //{
                        //    objLeaveDaysController.DeleteByEmployeeIDAndDate(employeeLeaveDay.FK_HREmployeeID, dteFrom.DateTime.Date.AddDays(i - 1));
                        //}
                    }
                }
            }

            MessageBox.Show("Lưu thành công",
                            "Thông báo",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
        }
Exemplo n.º 3
0
        protected override void GridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            base.GridView_CellValueChanged(sender, e);
            GridView gridView = (GridView)MainView;
            HRTimeSheetParamsInfo objTimeSheetParamsInfo = (HRTimeSheetParamsInfo)gridView.GetRow(gridView.FocusedRowHandle);

            if (objTimeSheetParamsInfo == null)
            {
                return;
            }

            if (objTimeSheetParamsInfo.HRTimeSheetParamID == 0 && String.IsNullOrEmpty(objTimeSheetParamsInfo.HRTimeSheetParamType))
            {
                objTimeSheetParamsInfo.HRTimeSheetParamType = TimeSheetParamType.Hour.ToString();
            }
        }
Exemplo n.º 4
0
 private void gridView_CustomColumnDisplayText(object sender, CustomColumnDisplayTextEventArgs e)
 {
     if (e.Column.FieldName == "FK_HRTimeSheetParamID")
     {
         if (e.Value != null)
         {
             HRTimeSheetParamsController objTimeSheetParamsController = new HRTimeSheetParamsController();
             HRTimeSheetParamsInfo       objTimeSheetParamsInfo       = new HRTimeSheetParamsInfo();
             objTimeSheetParamsInfo = (HRTimeSheetParamsInfo)objTimeSheetParamsController.GetObjectByID(Int32.Parse(e.Value.ToString()));
             if (objTimeSheetParamsInfo != null)
             {
                 e.DisplayText = objTimeSheetParamsInfo.HRTimeSheetParamNo;
             }
         }
     }
 }
Exemplo n.º 5
0
        public void InvalidateData()
        {
            ADConfigValuesController objConfigValuesController = new ADConfigValuesController();
            DataSet ds = objConfigValuesController.GetADConfigValuesByGroup(ConfigValueGroup.RewardType.ToString());

            RewardTypesList.Invalidate(ds);

            ds = objConfigValuesController.GetADConfigValuesByGroup(ConfigValueGroup.DisciplineType.ToString());
            DisciplineTypesList.Invalidate(ds);

            ADWorkingShiftGroupsController  objWorkingShiftGroupsController = new ADWorkingShiftGroupsController();
            List <ADWorkingShiftGroupsInfo> wsgList = objWorkingShiftGroupsController.GetAllWorkingShiftGroup();

            WorkingShiftGroupsList.Invalidate(wsgList);

            HRFormAllowancesController  objFormAllowancesController = new HRFormAllowancesController();
            List <HRFormAllowancesInfo> faList = objFormAllowancesController.GetAllFormAllowances();

            FormAllowancesList.Invalidate(faList);

            ADOTFactorsController  objOTFactorsController = new ADOTFactorsController();
            List <ADOTFactorsInfo> otfList = objOTFactorsController.GetAllOTFactors();

            OTFactorsList.Invalidate(otfList);

            HRTimesheetEmployeeLateConfigsController  objTimesheetEmployeeLateConfigsController = new HRTimesheetEmployeeLateConfigsController();
            List <HRTimesheetEmployeeLateConfigsInfo> telcList = objTimesheetEmployeeLateConfigsController.GetAllTimesheetEmployeeLateConfigs();

            TimesheetEmployeeLateConfigsList.Invalidate(telcList);

            ADTimesheetConfigsController objTimesheetConfigsController = new ADTimesheetConfigsController();

            ds = objTimesheetConfigsController.GetAllObjects();
            TimesheetConfigsList.Invalidate(ds);

            ADWorkingShiftsController objWorkingShiftsController = new ADWorkingShiftsController();

            ds = objWorkingShiftsController.GetAllObjects();
            WorkingShiftsList.Invalidate(ds);

            HRTimeSheetParamsController objTimeSheetParamsController = new HRTimeSheetParamsController();

            ds = objTimeSheetParamsController.GetAllObjects();
            List <HRTimeSheetParamsInfo> list = new List <HRTimeSheetParamsInfo>();

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                HRTimeSheetParamsInfo objTimeSheetParamsInfo = new HRTimeSheetParamsInfo();
                objTimeSheetParamsInfo = (HRTimeSheetParamsInfo)objTimeSheetParamsController.GetObjectFromDataRow(row);
                objTimeSheetParamsInfo.HRTimeSheetParamValue2 = objTimeSheetParamsInfo.HRTimeSheetParamValue2 * 100;
                if (!objTimeSheetParamsInfo.IsOTCalculated)
                {
                    list.Add(objTimeSheetParamsInfo);
                }
            }
            TimeSheetParamsList.Invalidate(list);

            List <HRTimeSheetParamsInfo> list2 = new List <HRTimeSheetParamsInfo>();
            List <HRTimeSheetParamsInfo> lst   = objTimeSheetParamsController.GetOTTimeSheetParamsList();

            foreach (HRTimeSheetParamsInfo info in lst)
            {
                info.HRTimeSheetParamValue2 = info.HRTimeSheetParamValue2 * 100;
                list2.Add(info);
            }
            TimeSheetParam2sList.Invalidate(list2);
        }
Exemplo n.º 6
0
        public void ViewLeaveDays(int branchID, int departmentID, int departmentRoomID, int departmentRoomGroupItemID, int employeeID, DateTime dateFrom, DateTime dateTo, string status)
        {
            VinaDbUtil                  dbUtil = new VinaDbUtil();
            HRLeaveDaysController       objLeaveDaysController       = new HRLeaveDaysController();
            HRTimeSheetParamsController objTimeSheetParamsController = new HRTimeSheetParamsController();
            List <HRLeaveDaysInfo>      leaveDays = objLeaveDaysController.GetLeaveDaysList(branchID, departmentID, departmentRoomID, departmentRoomGroupItemID, employeeID, dateFrom, dateTo);

            commonParams = objTimeSheetParamsController.GetTimeSheetParamsByTimeSheetType(TimeSheetParamType.Common.ToString());
            LeaveDayEntities entity = (LeaveDayEntities)CurrentModuleEntity;

            entity.LeaveDaysList.Clear();
            HREmployeesController  objEmployeesController = new HREmployeesController();
            List <HREmployeesInfo> employees = new List <HREmployeesInfo>();

            if (employeeID == 0)
            {
                employees = objEmployeesController.GetEmployeeList(branchID, departmentID, departmentRoomID, departmentRoomGroupItemID, status);
            }
            else
            {
                HREmployeesInfo employee = (HREmployeesInfo)objEmployeesController.GetObjectByID(employeeID);
                employees.Add(employee);
            }

            int numDays = (int)(dateTo.Date - dateFrom.Date).TotalDays + 1;

            foreach (HRLeaveDaysInfo leaveDay in leaveDays)
            {
                if (!employees.Exists(p => p.HREmployeeID == leaveDay.FK_HREmployeeID))
                {
                    continue;
                }
                HRLeaveDaysInfo employeeLeaveDay = entity.LeaveDaysList.Where(ld => ld.FK_HREmployeeID == leaveDay.FK_HREmployeeID).FirstOrDefault();
                if (employeeLeaveDay == null)
                {
                    employeeLeaveDay = new HRLeaveDaysInfo();
                    entity.LeaveDaysList.Add(employeeLeaveDay);
                }
                if (employeeLeaveDay != null)
                {
                    employeeLeaveDay.FK_HREmployeeID      = leaveDay.FK_HREmployeeID;
                    employeeLeaveDay.HREmployeeNo         = leaveDay.HREmployeeNo;
                    employeeLeaveDay.HREmployeeName       = leaveDay.HREmployeeName;
                    employeeLeaveDay.HRLeaveDayDate       = dateFrom;
                    employeeLeaveDay.HREmployeeCardNumber = leaveDay.HREmployeeCardNumber;
                    HRTimeSheetParamsInfo param = commonParams.Where(p => p.HRTimeSheetParamID == leaveDay.FK_HRTimeSheetParamID).FirstOrDefault();
                    for (int i = 1; i <= numDays; i++)
                    {
                        if (param != null)
                        {
                            //dbUtil.SetPropertyValue(employeeLeaveDay, string.Format("HRLeaveDayDate{0}", leaveDay.HRLeaveDayDate.Date.Day), param.HRTimeSheetParamNo);
                            if (dateFrom.Date.AddDays(i - 1) == leaveDay.HRLeaveDayDate.Date)
                            {
                                string paramTemp = dbUtil.GetPropertyStringValue(employeeLeaveDay, string.Format("HRLeaveDayDate{0}", leaveDay.HRLeaveDayDate.Date.Day));
                                if (string.IsNullOrEmpty(paramTemp))
                                {
                                    dbUtil.SetPropertyValue(employeeLeaveDay, string.Format("HRLeaveDayDate{0}", i), param.HRTimeSheetParamNo);
                                }
                                else
                                {
                                    dbUtil.SetPropertyValue(employeeLeaveDay, string.Format("HRLeaveDayDate{0}", i), paramTemp + ", " + param.HRTimeSheetParamNo);
                                }
                            }
                        }
                    }
                }
            }

            foreach (HREmployeesInfo employee in employees)
            {
                if (!entity.LeaveDaysList.Exists(ld => ld.FK_HREmployeeID == employee.HREmployeeID))
                {
                    HRLeaveDaysInfo leaveDay = new HRLeaveDaysInfo();
                    leaveDay.FK_HREmployeeID      = employee.HREmployeeID;
                    leaveDay.HREmployeeNo         = employee.HREmployeeNo;
                    leaveDay.HREmployeeName       = employee.HREmployeeName;
                    leaveDay.HRLeaveDayDate       = dateFrom;
                    leaveDay.HREmployeeCardNumber = employee.HREmployeeCardNumber;
                    entity.LeaveDaysList.Add(leaveDay);
                }
            }

            foreach (HRLeaveDaysInfo leaveDay in entity.LeaveDaysList)
            {
                UpdateTotalLeaveDays(leaveDay);
                leaveDay.BackupObject = (HRLeaveDaysInfo)leaveDay.Clone();
            }

            HRLeaveDaysGridControl gridControl = entity.LeaveDaysList.GridControl as HRLeaveDaysGridControl;

            gridControl.ViewDate = dateFrom;
            gridControl.FromDate = dateFrom;
            gridControl.ToDate   = dateTo;
            //gridControl.InitializeControl();

            foreach (var item in entity.LeaveDaysList)
            {
                HREmployeesInfo objEmployeesInfo = (HREmployeesInfo)objEmployeesController.GetObjectByID(item.FK_HREmployeeID);
                if (objEmployeesInfo != null)
                {
                    item.HREmployeeCardNumber = objEmployeesInfo.HREmployeeCardNumber;
                }
            }
            gridControl.RefreshDataSource();
        }