Ejemplo n.º 1
0
        public void AddDefaulArrangementShiftEntries(HREmployeeArrangementShiftsInfo objEmployeeArrangementShiftsInfo, HREmployeesInfo objEmployeesInfo)
        {
            objEmployeeArrangementShiftsInfo.HRArrangementShiftEntrysList.Clear();

            ArrangementShiftEntities   entity = (ArrangementShiftEntities)CurrentModuleEntity;
            HRArrangementShiftsInfo    objArrangementShiftsInfo   = (HRArrangementShiftsInfo)entity.MainObject;
            ADWorkingShiftsController  objWorkingShiftsController = new ADWorkingShiftsController();
            List <ADWorkingShiftsInfo> workingShifts = entity.WorkingShifts;
            ADWorkingShiftsInfo        defaultParam  = (ADWorkingShiftsInfo)workingShifts.Where(o => o.ADWorkingShiftID == objEmployeesInfo.FK_ADWorkingShiftID).FirstOrDefault();

            if (defaultParam != null)
            {
                VinaDbUtil dbUtil  = new VinaDbUtil();
                int        numDays = NumOfDayInMonth();
                for (int i = 1; i <= numDays; i++)
                {
                    DateTime currentDate = objArrangementShiftsInfo.HRArrangementShiftFromDate.Date.AddDays(i - 1);
                    HRArrangementShiftEntrysInfo entry = new HRArrangementShiftEntrysInfo();
                    entry.FK_HREmployeeID                 = objEmployeeArrangementShiftsInfo.FK_HREmployeeID;
                    entry.FK_HRArrangementShiftID         = objEmployeeArrangementShiftsInfo.FK_HRArrangementShiftID;
                    entry.FK_HREmployeeArrangementShiftID = objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftID;
                    entry.HRArrangementShiftEntryDate     = currentDate;
                    entry.FK_ADWorkingShiftID             = defaultParam.ADWorkingShiftID;

                    //String propertyName = String.Format("{0}{1}", "HREmployeeArrangementShiftDate", i);
                    objEmployeeArrangementShiftsInfo.HRArrangementShiftEntrysList.Add(entry);
                }
            }
        }
Ejemplo n.º 2
0
        public void SetEmployeeArrangementShiftValue(HREmployeeArrangementShiftsInfo objEmployeeArrangementShiftsInfo)
        {
            HRArrangementShiftsInfo arrangementShift = (HRArrangementShiftsInfo)MainObject;
            List <string>           employeeArrangementShiftValueList = 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 (HRArrangementShiftEntrysInfo arrangementShiftEntry in objEmployeeArrangementShiftsInfo.HRArrangementShiftEntrysList)
            {
                if (arrangementShiftEntry.HRArrangementShiftEntryDate.Date >= arrangementShift.HRArrangementShiftFromDate.Date &&
                    arrangementShiftEntry.HRArrangementShiftEntryDate.Date <= arrangementShift.HRArrangementShiftToDate.Date)
                {
                    int index = (int)(arrangementShiftEntry.HRArrangementShiftEntryDate.Date - arrangementShift.HRArrangementShiftFromDate.Date).TotalDays + 1;
                    if (index > 31)
                    {
                        MessageBox.Show("Bạn không thể chọn thời gian xếp ca quá 31 ngày!", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    string workingShifId = string.Empty;
                    ADWorkingShiftsInfo objWorkingShiftsInfo = WorkingShifts.Where(o => o.ADWorkingShiftID == arrangementShiftEntry.FK_ADWorkingShiftID).FirstOrDefault();
                    if (objWorkingShiftsInfo != null)
                    {
                        workingShifId = objWorkingShiftsInfo.ADWorkingShiftName;
                    }
                    if (!string.IsNullOrEmpty(workingShifId))
                    {
                        if (string.IsNullOrEmpty(employeeArrangementShiftValueList[index - 1].Trim()))
                        {
                            employeeArrangementShiftValueList[index - 1] = workingShifId;
                        }
                        else
                        {
                            employeeArrangementShiftValueList[index - 1] += String.Format(", {0}", workingShifId);
                        }
                    }
                }
            }

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

            if (numDays > 31)
            {
                numDays = 31;
            }
            for (int i = 1; i <= numDays; i++)
            {
                String propertyName = String.Format("{0}{1}", "HREmployeeArrangementShiftDate", i.ToString());
                dbUtil.SetPropertyValue(objEmployeeArrangementShiftsInfo, propertyName, employeeArrangementShiftValueList[i - 1]);
            }
        }
Ejemplo n.º 3
0
 private void gridView_CustomColumnDisplayText(object sender, CustomColumnDisplayTextEventArgs e)
 {
     if (e.Column.FieldName == "FK_ADWorkingShiftID")
     {
         if (e.Value != null)
         {
             int id = int.Parse(e.Value.ToString());
             ADWorkingShiftsController objWorkingShiftsController = new ADWorkingShiftsController();
             ADWorkingShiftsInfo       objWorkingShiftsInfo       = (ADWorkingShiftsInfo)objWorkingShiftsController.GetObjectByID(id);
             if (objWorkingShiftsInfo != null)
             {
                 e.DisplayText = objWorkingShiftsInfo.ADWorkingShiftName;
             }
         }
     }
 }
Ejemplo n.º 4
0
        public void UpdateWorkingShift()
        {
            EmployeePayRollFormulaEntities entity = (EmployeePayRollFormulaEntities)CurrentModuleEntity;
            HRWorkingShiftsInfo            objHRWorkingShiftsInfo = (HRWorkingShiftsInfo)entity.WorkingShiftsList[entity.WorkingShiftsList.CurrentIndex];

            if (objHRWorkingShiftsInfo.FK_ADWorkingShiftID > 0)
            {
                ADWorkingShiftsController objADWorkingShiftsController = new ADWorkingShiftsController();
                ADWorkingShiftsInfo       objADWorkingShiftsInfo       = (ADWorkingShiftsInfo)objADWorkingShiftsController.GetObjectByID(objHRWorkingShiftsInfo.FK_ADWorkingShiftID);
                if (objADWorkingShiftsInfo != null)
                {
                    objHRWorkingShiftsInfo.HRWorkingShiftDayOffWeek  = objADWorkingShiftsInfo.ADWorkingShiftDayOffWeek;
                    objHRWorkingShiftsInfo.HRWorkingShiftDesc        = objADWorkingShiftsInfo.ADWorkingShiftDesc;
                    objHRWorkingShiftsInfo.HRWorkingShiftFromTime    = objADWorkingShiftsInfo.ADWorkingShiftFromTime;
                    objHRWorkingShiftsInfo.HRWorkingShiftIsDefault   = objADWorkingShiftsInfo.ADWorkingShiftIsDefault;
                    objHRWorkingShiftsInfo.HRWorkingShiftNight       = objADWorkingShiftsInfo.ADWorkingShiftNight;
                    objHRWorkingShiftsInfo.HRWorkingShiftTimeBreak   = objADWorkingShiftsInfo.ADWorkingShiftTimeBreak;
                    objHRWorkingShiftsInfo.HRWorkingShiftToTime      = objADWorkingShiftsInfo.ADWorkingShiftToTime;
                    objHRWorkingShiftsInfo.HRWorkingShiftWorkingTime = objADWorkingShiftsInfo.ADWorkingShiftWorkingTime;
                }
            }
            entity.WorkingShiftsList.GridControl.RefreshDataSource();
        }
Ejemplo n.º 5
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();
        }