コード例 #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);
                }
            }
        }
コード例 #2
0
        public override void SetDefaultMainObject()
        {
            base.SetDefaultMainObject();
            HRArrangementShiftsInfo objArrangementShiftsInfo = (HRArrangementShiftsInfo)MainObject;

            objArrangementShiftsInfo.HRArrangementShiftFromDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            objArrangementShiftsInfo.HRArrangementShiftToDate   = DateTime.Now;
        }
コード例 #3
0
        public int NumOfDayInMonth()
        {
            ArrangementShiftEntities entity = (ArrangementShiftEntities)CurrentModuleEntity;
            HRArrangementShiftsInfo  objArrangementShiftsInfo = (HRArrangementShiftsInfo)entity.MainObject;
            int numDays = (int)(objArrangementShiftsInfo.HRArrangementShiftToDate.Date - objArrangementShiftsInfo.HRArrangementShiftFromDate.Date).TotalDays + 1;

            return(numDays);
        }
コード例 #4
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]);
            }
        }
コード例 #5
0
        public void InitializeArrangementShiftEntryGridControl()
        {
            ArrangementShiftEntities entity = (ArrangementShiftEntities)CurrentModuleEntity;
            HRArrangementShiftsInfo  objArrangementShiftsInfo  = (HRArrangementShiftsInfo)entity.MainObject;
            HREmployeeArrangementShiftsGridControl gridControl = (HREmployeeArrangementShiftsGridControl)Controls["fld_dgcHREmployeeArrangementShifts"];

            gridControl.InitializeControl();
            InitColumnRepository();
        }
コード例 #6
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();
        }
コード例 #7
0
        protected override void AddColumnsToGridView(string strTableName, DevExpress.XtraGrid.Views.Grid.GridView gridView)
        {
            base.AddColumnsToGridView(strTableName, gridView);
            GridColumn column = new GridColumn();

            column.Caption   = "Mã nhân viên";
            column.FieldName = "HREmployeeNo";
            gridView.Columns.Add(column);

            column           = new GridColumn();
            column.Caption   = "Mã ID";
            column.FieldName = "HREmployeeCardNumber";
            gridView.Columns.Add(column);

            column           = new GridColumn();
            column.Caption   = "Bộ phận";
            column.FieldName = "HRDepartmentRoomName";
            gridView.Columns.Add(column);

            column           = new GridColumn();
            column.Caption   = "Phòng ban";
            column.FieldName = "HRDepartmentName";
            gridView.Columns.Add(column);

            column           = new GridColumn();
            column.Caption   = "Tên nhân viên";
            column.FieldName = "HREmployeeName";
            gridView.Columns.Add(column);

            column           = new GridColumn();
            column.Caption   = "Tổ";
            column.FieldName = "HRDepartmentRoomGroupName";
            gridView.Columns.Add(column);

            int numDays = ((ArrangementShiftModule)Screen.Module).NumOfDayInMonth();
            ArrangementShiftEntities entity = (ArrangementShiftEntities)((BaseModuleERP)Screen.Module).CurrentModuleEntity;
            HRArrangementShiftsInfo  objArrangementShiftsInfo = (HRArrangementShiftsInfo)entity.MainObject;

            for (int i = 1; i <= numDays; i++)
            {
                GridColumn columnDays = new GridColumn();
                DateTime   dt         = objArrangementShiftsInfo.HRArrangementShiftFromDate.Date.AddDays(i - 1);
                columnDays.Caption   = dt.ToString("dd/MM");
                columnDays.FieldName = String.Format("{0}{1}", "HREmployeeArrangementShiftDate", i.ToString());
                gridView.Columns.Add(columnDays);
            }
        }
コード例 #8
0
        public List <string> GetColumnFieldNameByTypeEndOfWeek()
        {
            ArrangementShiftEntities entity = (ArrangementShiftEntities)CurrentModuleEntity;
            HRArrangementShiftsInfo  objArrangementShiftsInfo = (HRArrangementShiftsInfo)entity.MainObject;
            List <string>            list = new List <string>();
            int numDays = NumOfDayInMonth();

            for (int i = 1; i <= numDays; i++)
            {
                DateTime dt          = objArrangementShiftsInfo.HRArrangementShiftFromDate.Date.AddDays(i - 1);
                bool     isDayOfWeek = (VinaApp.IsEndOfWeek(objArrangementShiftsInfo.HRArrangementShiftFromDate.Date.AddDays(i - 1).DayOfWeek));
                if (isDayOfWeek)
                {
                    string columnName = String.Format("{0}{1}", "HREmployeeArrangementShiftDate", i.ToString());
                    list.Add(columnName);
                }
            }
            return(list);
        }
コード例 #9
0
        public void UpdateEmployeeArrangementShift()
        {
            ArrangementShiftEntities entity = (ArrangementShiftEntities)CurrentModuleEntity;
            HRArrangementShiftsInfo  objArrangementShiftsInfo = (HRArrangementShiftsInfo)entity.MainObject;
            HREmployeesController    objEmployeesController   = new HREmployeesController();
            HREmployeesInfo          objEmployeesInfo;

            entity.EmployeeArrangementShiftsList.ForEach(o =>
            {
                objEmployeesInfo = (HREmployeesInfo)objEmployeesController.GetObjectByID(o.FK_HREmployeeID);
                if (objEmployeesInfo != null)
                {
                    AddDefaulArrangementShiftEntries(o, objEmployeesInfo);
                    List <HRArrangementShiftEntrysInfo> arrangementShiftEntrys = o.HRArrangementShiftEntrysList.Where(i => i.FK_HREmployeeID == o.FK_HREmployeeID).ToList();
                    o.HRArrangementShiftEntrysList = arrangementShiftEntrys;
                    entity.SetEmployeeArrangementShiftValue(o);
                }
            });
            entity.EmployeeArrangementShiftsList.GridControl.RefreshDataSource();
        }
コード例 #10
0
        public override void SaveModuleObjects()
        {
            HRArrangementShiftsInfo arrangementShift = (HRArrangementShiftsInfo)MainObject;

            //Save employee time sheet list
            EmployeeArrangementShiftsList.SaveItemObjects();
            //Create entry for time sheet
            HRArrangementShiftEntrysController objArrangementShiftEntrysController = new HRArrangementShiftEntrysController();

            foreach (HREmployeeArrangementShiftsInfo objEmployeeArrangementShiftsInfo in EmployeeArrangementShiftsList)
            {
                objArrangementShiftEntrysController.DeleteByForeignColumn("FK_HREmployeeArrangementShiftID", objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftID);
                foreach (HRArrangementShiftEntrysInfo entry in objEmployeeArrangementShiftsInfo.HRArrangementShiftEntrysList)
                {
                    if (entry.FK_ADWorkingShiftID == 0)
                    {
                        continue;
                    }
                    entry.FK_HRArrangementShiftID         = arrangementShift.HRArrangementShiftID;
                    entry.FK_HREmployeeArrangementShiftID = objEmployeeArrangementShiftsInfo.HREmployeeArrangementShiftID;
                    objArrangementShiftEntrysController.CreateObject(entry);
                }
            }
        }
コード例 #11
0
 public override void InitMainObject()
 {
     MainObject   = new HRArrangementShiftsInfo();
     SearchObject = new HRArrangementShiftsInfo();
 }
コード例 #12
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();
        }