Пример #1
0
        public void ChangeArrangementShiftTime()
        {
            ArrangementShiftEntities entity = (ArrangementShiftEntities)CurrentModuleEntity;
            HRArrangementShiftsInfo  objArrangementShiftsInfo = (HRArrangementShiftsInfo)entity.MainObject;
            int numDays = NumOfDayInMonth();

            if (numDays > 31)
            {
                MessageBox.Show("Bạn không thể chọn thời gian xếp ca quá 31 ngày!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                objArrangementShiftsInfo.HRArrangementShiftToDate = objArrangementShiftsInfo.HRArrangementShiftFromDate;
                entity.UpdateMainObjectBindingSource();
            }
            InvalidateArrangementShiftValues();
            InitializeArrangementShiftEntryGridControl();
            UpdateEmployeeArrangementShift();
        }
Пример #2
0
        public void UpdateArrangementShift(HREmployeeArrangementShiftsInfo objEmployeeArrangementShiftsInfo)
        {
            ArrangementShiftEntities entity = (ArrangementShiftEntities)CurrentModuleEntity;
            HRArrangementShiftsInfo  objArrangementShiftsInfo          = (HRArrangementShiftsInfo)entity.MainObject;
            List <string>            employeeArrangementShiftValueList = new List <string> {
                objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate1, objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate2,
                objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate3, objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate4,
                objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate5, objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate6,
                objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate7, objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate8,
                objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate9, objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate10,
                objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate11, objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate12,
                objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate13, objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate14,
                objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate15, objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate16,
                objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate17, objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate18,
                objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate19, objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate20,
                objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate21, objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate22,
                objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate23, objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate24,
                objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate25, objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate26,
                objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate27, objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate28,
                objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate29, objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate30,
                objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftDate31
            };

            objEmployeeArrangementShiftsInfo.HRArrangementShiftEntrysList.ForEach(o => o.FK_HRArrangementShiftID = 0);
            objEmployeeArrangementShiftsInfo.HRArrangementShiftEntrysList.Clear();
            int numDays = NumOfDayInMonth();

            for (int i = 0; i < numDays; i++)
            {
                string[] paramNumbers = employeeArrangementShiftValueList[i].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                DateTime currentDate    = objArrangementShiftsInfo.HRArrangementShiftFromDate.AddDays(i);
                decimal  mainEntryValue = 0;

                for (int j = 0; j < paramNumbers.Length; j++)
                {
                    string paramNo            = paramNumbers[j].Trim();
                    ADWorkingShiftsInfo param = entity.WorkingShifts.Where(o => o.ADWorkingShiftName == paramNo).FirstOrDefault();
                    if (param != null)
                    {
                        HRArrangementShiftEntrysInfo arrangementShiftEntrys = objEmployeeArrangementShiftsInfo.HRArrangementShiftEntrysList.Where(o => o.HRArrangementShiftEntryDate.Date == currentDate.Date &&
                                                                                                                                                  o.FK_ADWorkingShiftID == param.ADWorkingShiftID &&
                                                                                                                                                  objEmployeeArrangementShiftsInfo.FK_HREmployeeID == o.FK_HREmployeeID)
                                                                              .FirstOrDefault();
                        if (arrangementShiftEntrys == null)
                        {
                            arrangementShiftEntrys = new HRArrangementShiftEntrysInfo();
                            arrangementShiftEntrys.FK_HREmployeeArrangementShiftID = objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftID;
                            arrangementShiftEntrys.FK_HRArrangementShiftID         = objEmployeeArrangementShiftsInfo.FK_HRArrangementShiftID;
                            arrangementShiftEntrys.FK_HREmployeeID             = objEmployeeArrangementShiftsInfo.FK_HREmployeeID;
                            arrangementShiftEntrys.HRArrangementShiftEntryDate = currentDate;

                            arrangementShiftEntrys.FK_ADWorkingShiftID = param.ADWorkingShiftID;
                            objEmployeeArrangementShiftsInfo.HRArrangementShiftEntrysList.Add(arrangementShiftEntrys);
                        }
                        else
                        {
                            arrangementShiftEntrys.FK_HREmployeeArrangementShiftID = objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftID;
                            arrangementShiftEntrys.FK_HRArrangementShiftID         = objEmployeeArrangementShiftsInfo.FK_HRArrangementShiftID;
                            arrangementShiftEntrys.FK_HREmployeeID             = objEmployeeArrangementShiftsInfo.FK_HREmployeeID;
                            arrangementShiftEntrys.FK_ADWorkingShiftID         = param.ADWorkingShiftID;
                            arrangementShiftEntrys.HRArrangementShiftEntryDate = currentDate;
                        }
                    }
                }
            }
            entity.EmployeeArrangementShiftsList.GridControl.RefreshDataSource();
            entity.UpdateMainObjectBindingSource();
        }