Ejemplo n.º 1
0
        /// <summary>
        /// New event one employee
        /// </summary>
        /// <param name="timeSheetEvent"></param>
        /// <param name="timeSymbol"></param>
        private void CreateNewTimeSheetEvent(hr_TimeSheetEvent timeSheetEvent, cat_TimeSheetSymbol timeSymbol)
        {
            try
            {
                //create new event
                timeSheetEvent.StatusId    = EventStatus.Active;
                timeSheetEvent.WorkConvert = timeSymbol.WorkConvert;
                timeSheetEvent.Symbol      = timeSymbol.Code;
                timeSheetEvent.Description = timeSymbol.Name;
                timeSheetEvent.TypeGroup   = timeSymbol.Group;
                hr_TimeSheetEventServices.Create(timeSheetEvent);


                var timeSheet = hr_TimeSheetServices.GetById(timeSheetEvent.TimeSheetId);

                if (timeSymbol.Group == ConstLeave)
                {
                    //create history
                    var useDate = new DateTime(Convert.ToInt32(hdfYear.Text), Convert.ToInt32(hdfMonth.Text),
                                               Convert.ToInt32(hdfDay.Text));
                    var annual = new hr_AnnualLeaveHistory()
                    {
                        RecordId         = Convert.ToInt32(hdfRecordId.Text),
                        TimeSheetEventId = timeSheetEvent.Id,
                        UsedLeaveDate    = useDate,
                        UsedLeaveDay     = timeSymbol.WorkConvert,
                        CreatedDate      = DateTime.Now,
                        CreatedBy        = CurrentUser.User.UserName,
                    };

                    hr_AnnualLeaveHistoryServices.Create(annual);
                    //Update
                    UpdateAnnualLeaveConfig(timeSheet, annual);
                }

                //Adjust timesheet
                if (!string.IsNullOrEmpty(hdfTimeSheetCode.Text) && !string.IsNullOrEmpty(hdfDay.Text))
                {
                    var timeAdjust = new hr_TimeSheetAdjustment()
                    {
                        RecordId          = Convert.ToInt32(hdfRecordId.Text),
                        TimeSheetCode     = hdfTimeSheetCode.Text,
                        TimeSheetEventIds = timeSheetEvent.Id.ToString(),
                        TimeSheetReportId = timeSheet.TimeSheetReportId,
                        Day                         = Convert.ToInt32(hdfDay.Text),
                        Month                       = hdfMonth.Text != null?Convert.ToInt32(hdfMonth.Text) : 0,
                                               Year = hdfYear.Text != null?Convert.ToInt32(hdfYear.Text) : DateTime.Now.Year,
                                                          Reason      = timeSymbol.Name,
                                                          CreatedDate = DateTime.Now,
                                                          CreatedBy   = CurrentUser.User.UserName,
                    };

                    hr_TimeSheetAdjustmentServices.Create(timeAdjust);
                }
            }
            catch (Exception e)
            {
                Dialog.ShowNotification("Có lỗi xảy ra" + e.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static TimeSheetEventModel Update(TimeSheetEventModel model)
        {
            var entity = new hr_TimeSheetEvent();

            model.FillEntity(ref entity);
            entity.EditedDate = DateTime.Now;
            return(new TimeSheetEventModel(hr_TimeSheetEventServices.Update(entity)));
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static TimeSheetEventModel Create(TimeSheetEventModel model)
        {
            var entity = new hr_TimeSheetEvent();

            // fill
            model.FillEntity(ref entity);

            // create entity
            return(new TimeSheetEventModel(hr_TimeSheetEventServices.Create(entity)));
        }
Ejemplo n.º 4
0
        private void CreatNewTimeSheetEvent(int id, string typeDay)
        {
            var timeSheetEvent = new hr_TimeSheetEvent
            {
                TimeSheetId = id,
                StatusId    = EventStatus.Active,
                CreatedDate = DateTime.Now,
                CreatedBy   = CurrentUser.User.UserName
            };

            AddNewTimeSheetEventAllEmployee(timeSheetEvent, typeDay);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Chấm công theo ngày
        /// </summary>
        private void SaveTimeSheetForDay(object sender, DirectEventArgs e)
        {
            try
            {
                var timeSheetEvent = new hr_TimeSheetEvent();
                var timeSheetId    = 0;//Id bang cham cong
                if (!string.IsNullOrEmpty(hdfTimeSheetId.Text))
                {
                    timeSheetId = Convert.ToInt32(hdfTimeSheetId.Text);
                    if (timeSheetId == 0)
                    {
                        var timeSheet = new hr_TimeSheet();
                        if (!string.IsNullOrEmpty(hdfDay.Text))
                        {
                            timeSheet.Day = Convert.ToInt32(hdfDay.Text);
                        }
                        if (!string.IsNullOrEmpty(hdfMonth.Text))
                        {
                            timeSheet.Month = Convert.ToInt32(hdfMonth.Text);
                        }
                        if (!string.IsNullOrEmpty(hdfYear.Text))
                        {
                            timeSheet.Year = Convert.ToInt32(hdfYear.Text);
                        }
                        timeSheet.CreatedDate = DateTime.Now;
                        timeSheet.Detail      = " ";
                        if (!string.IsNullOrEmpty(hdfRecordId.Text))
                        {
                            timeSheet.RecordId = Convert.ToInt32(hdfRecordId.Text);
                        }
                        timeSheet.TimeSheetCode = hdfTimeSheetCode.Text;
                        hr_TimeSheetServices.Create(timeSheet);
                        timeSheetEvent.TimeSheetId = timeSheet.Id;
                        timeSheetId = timeSheet.Id;
                    }
                    else
                    {
                        timeSheetEvent.TimeSheetId = timeSheetId;
                    }
                }
                timeSheetEvent.CreatedDate = DateTime.Now;
                //Add moi event
                AddNewTimeSheetEvent(timeSheetEvent);

                var timeSheetEdit = hr_TimeSheetServices.GetById(timeSheetId);
                //update timesheet
                UpdateTimeSheet(timeSheetEdit);
            }
            catch (Exception ex)
            {
                Dialog.ShowNotification("Có lỗi xảy ra" + ex.Message);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// New event one employee
        /// </summary>
        /// <param name="timeSheetEvent"></param>
        /// <param name="timeSymbol"></param>
        private void CreateNewTimeSheetEvent(hr_TimeSheetEvent timeSheetEvent, cat_TimeSheetSymbol timeSymbol)
        {
            timeSheetEvent.WorkConvert = timeSymbol.WorkConvert;
            timeSheetEvent.TimeConvert = timeSymbol.TimeConvert;
            timeSheetEvent.Symbol      = timeSymbol.Code;
            timeSheetEvent.Description = timeSymbol.Name;
            timeSheetEvent.TypeGroup   = timeSymbol.Group;
            hr_TimeSheetEventServices.Create(timeSheetEvent);

            TimeSheetEventIds         = TimeSheetEventIds + "," + timeSheetEvent.Id;
            hdfTimeSheetEventIds.Text = TimeSheetEventIds;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// New event one employee
        /// </summary>
        /// <param name="timeSheetEvent"></param>
        /// <param name="timeSymbol"></param>
        private void CreateNewTimeSheetEvent(hr_TimeSheetEvent timeSheetEvent, cat_TimeSheetSymbol timeSymbol)
        {
            try
            {
                timeSheetEvent.WorkConvert = timeSymbol.WorkConvert;
                timeSheetEvent.Symbol      = timeSymbol.Code;
                timeSheetEvent.Description = timeSymbol.Name;
                timeSheetEvent.TypeGroup   = timeSymbol.Group;
                hr_TimeSheetEventServices.Create(timeSheetEvent);

                if (timeSymbol.Group == ConstLeave)
                {
                    //create history
                    var useDate = new DateTime(Convert.ToInt32(hdfYear.Text), Convert.ToInt32(hdfMonth.Text),
                                               Convert.ToInt32(hdfDay.Text));
                    var annual = new hr_AnnualLeaveHistory()
                    {
                        RecordId      = Convert.ToInt32(hdfRecordId.Text),
                        UsedLeaveDate = useDate,
                        UsedLeaveDay  = timeSymbol.WorkConvert,
                        CreatedDate   = DateTime.Now,
                        CreatedBy     = CurrentUser.User.UserName,
                    };

                    hr_AnnualLeaveHistoryServices.Create(annual);

                    //update nguoc lai bang phep
                    var leaveConfig =
                        hr_AnnualLeaveConfigureServices.GetAnnualLeaveConfigByRecordId(
                            Convert.ToInt32(hdfRecordId.Text), Convert.ToInt32(hdfYear.Text));
                    if (leaveConfig != null)
                    {
                        leaveConfig.UsedLeaveDay = annual.UsedLeaveDay + leaveConfig.UsedLeaveDay;
                        if (leaveConfig.AnnualLeaveDay > 0)
                        {
                            leaveConfig.RemainLeaveDay = leaveConfig.AnnualLeaveDay - leaveConfig.UsedLeaveDay;
                        }

                        leaveConfig.EditedDate = DateTime.Now;
                        leaveConfig.EditedBy   = CurrentUser.User.UserName;
                    }

                    hr_AnnualLeaveConfigureServices.Update(leaveConfig);
                }
            }
            catch (Exception e)
            {
                Dialog.ShowNotification("Có lỗi xảy ra" + e.Message);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// New event one employee
        /// </summary>
        /// <param name="timeSheetEvent"></param>
        /// <param name="timeSymbol"></param>
        private void CreateNewTimeSheetEvent(hr_TimeSheetEvent timeSheetEvent, cat_TimeSheetSymbol timeSymbol)
        {
            try
            {
                timeSheetEvent.WorkConvert = timeSymbol.WorkConvert;
                timeSheetEvent.Symbol      = timeSymbol.Code;
                timeSheetEvent.Description = timeSymbol.Name;
                timeSheetEvent.TypeGroup   = timeSymbol.Group;
                hr_TimeSheetEventServices.Create(timeSheetEvent);

                TimeSheetEventIds         = TimeSheetEventIds + "," + timeSheetEvent.Id;
                hdfTimeSheetEventIds.Text = TimeSheetEventIds;
            }
            catch (Exception e)
            {
                Dialog.ShowNotification("Có lỗi xảy ra" + e.Message);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Add moi timeSheetEvent
        /// </summary>
        /// <param name="timeSheetEvent"></param>
        private void AddNewTimeSheetEvent(hr_TimeSheet timeSheet, hr_TimeSheetEvent timeSheetEvent, int recordId)
        {
            var rowSelecteds = RowSelectionModel2.SelectedRows;

            if (rowSelecteds != null && rowSelecteds.Count > 0)
            {
                //Lay thong tin tu bang ky hieu cham cong cat_TimeSheetSymbol
                foreach (var item in rowSelecteds)
                {
                    var timeSymbol = cat_TimeSheetSymbolServices.GetById(int.Parse("0" + item.RecordID));
                    if (timeSymbol != null)
                    {
                        timeSheetEvent.SymbolDisplay = "<span class='badge badge-normal' title='{1}' >{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                        timeSheet.OverTimeConvert += timeSymbol.TimeConvert;
                    }
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="recordId"></param>
        /// <param name="workShiftId"></param>
        /// <param name="groupSymbolId"></param>
        /// <param name="symbolId"></param>
        /// <param name="description"></param>
        /// <param name="workConvert"></param>
        /// <param name="timeConvert"></param>
        private void CreateTimeSheetEvent(int recordId, int workShiftId, int groupSymbolId, int symbolId, double workConvert, double timeConvert, string description)
        {
            var timeSheetEvent = new hr_TimeSheetEvent()
            {
                RecordId      = recordId,
                WorkShiftId   = workShiftId,
                Description   = description,
                GroupSymbolId = groupSymbolId,
                SymbolId      = symbolId,
                WorkConvert   = workConvert,
                TimeConvert   = timeConvert,
                Status        = EventStatus.Active,
                IsDeleted     = false,
                CreatedDate   = DateTime.Now,
                EditedDate    = DateTime.Now,
            };

            //Create
            hr_TimeSheetEventServices.Create(timeSheetEvent);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Tạo bảng chấm công theo đơn vị lựa chọn
        /// </summary>
        /// <param name="timeReportId"></param>
        private void CreateTimeSheetByDepartment(int timeReportId)
        {
            var timeSheets = hr_TimeSheetServices.GetAllTimeSheets(Convert.ToInt32(hdfMonth.Text),
                                                                   Convert.ToInt32(hdfYear.Text), ConstTypeTimeSheet, null);

            if (!string.IsNullOrEmpty(hdfDepartmentId.Text))
            {
                var rootId       = 0;
                var rootParentId = 0;
                int parseId;
                var selectedDepartment = "{0},".FormatWith(hdfDepartmentId.Text);
                if (int.TryParse(hdfDepartmentId.Text, out parseId))
                {
                    rootId = parseId;
                }

                var objDept = CurrentUser.RootDepartment;
                if (objDept != null)
                {
                    rootParentId = objDept.Id;
                }

                var lstDepartment = cat_DepartmentServices.GetTree(rootId).Select(d => d.Id).ToList();
                if (lstDepartment.Count > 0)
                {
                    selectedDepartment = lstDepartment.Aggregate(selectedDepartment, (current, d) => current + "{0},".FormatWith(d));
                }

                if (rootId != rootParentId)
                {
                    selectedDepartment = "{0}".FormatWith(selectedDepartment.TrimEnd(','));
                }
                else
                {
                    selectedDepartment = "{0}".FormatWith(selectedDepartment.TrimEnd(',').Remove(0, 2));
                }

                //Get list employee by department selected
                var listEmp = hr_RecordServices.GetAllEmployee(selectedDepartment, null, null, null).Select(d => d.Id).ToList();

                if (listEmp.Count > 0)
                {
                    foreach (var item in timeSheets)
                    {
                        if (listEmp.Contains(item.RecordId))
                        {
                            var newTimeSheet = new hr_TimeSheet();
                            newTimeSheet = item;
                            newTimeSheet.TimeSheetReportId = timeReportId;
                            newTimeSheet.CreatedDate       = DateTime.Now;

                            //Create
                            hr_TimeSheetServices.Create(newTimeSheet);

                            var objEvent = JSON.Deserialize <List <TimeSheetEventModel> >(newTimeSheet.Detail);
                            //Create timeSheetEvent
                            foreach (var itemEvent in objEvent)
                            {
                                var timeEvent = new hr_TimeSheetEvent()
                                {
                                    StatusId      = EventStatus.Active,
                                    TypeGroup     = itemEvent.TypeGroup,
                                    Description   = itemEvent.Description,
                                    WorkConvert   = itemEvent.WorkConvert,
                                    MoneyConvert  = itemEvent.MoneyConvert,
                                    TimeConvert   = itemEvent.TimeConvert,
                                    Symbol        = itemEvent.Symbol,
                                    SymbolDisplay = itemEvent.SymbolDisplay,
                                };

                                timeEvent.TimeSheetId = newTimeSheet.Id;
                                timeEvent.CreatedDate = DateTime.Now;
                                timeEvent.CreatedBy   = CurrentUser.User.UserName;

                                hr_TimeSheetEventServices.Create(timeEvent);
                            }

                            //update timesheet
                            UpdateTimeSheet(newTimeSheet);
                        }
                    }
                }
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Nhóm ký hiệu mặc định
 /// </summary>
 /// <param name="timeSymbol"></param>
 /// <param name="timeSheetEvent"></param>
 private void CreateGroupTimeSheetDefault(cat_TimeSheetSymbol timeSymbol, hr_TimeSheetEvent timeSheetEvent)
 {
     if (timeSymbol.Group == ConstDefault1)
     {
         timeSheetEvent.SymbolDisplay = "<span class='badge badge-default1' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
     }
     if (timeSymbol.Group == ConstDefault2)
     {
         timeSheetEvent.SymbolDisplay = "<span class='badge badge-default2' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
     }
     if (timeSymbol.Group == ConstDefault3)
     {
         timeSheetEvent.SymbolDisplay = "<span class='badge badge-default3' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
     }
     if (timeSymbol.Group == ConstDefault4)
     {
         timeSheetEvent.SymbolDisplay = "<span class='badge badge-default4' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
     }
     if (timeSymbol.Group == ConstDefault5)
     {
         timeSheetEvent.SymbolDisplay = "<span class='badge badge-default5' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
     }
     if (timeSymbol.Group == ConstDefault6)
     {
         timeSheetEvent.SymbolDisplay = "<span class='badge badge-default6' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
     }
     if (timeSymbol.Group == ConstDefault7)
     {
         timeSheetEvent.SymbolDisplay = "<span class='badge badge-default7' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
     }
     if (timeSymbol.Group == ConstDefault8)
     {
         timeSheetEvent.SymbolDisplay = "<span class='badge badge-default8' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
     }
     if (timeSymbol.Group == ConstDefault9)
     {
         timeSheetEvent.SymbolDisplay = "<span class='badge badge-default9' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
     }
     if (timeSymbol.Group == ConstDefault10)
     {
         timeSheetEvent.SymbolDisplay = "<span class='badge badge-default10' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
     }
     if (timeSymbol.Group == ConstDefault11)
     {
         timeSheetEvent.SymbolDisplay = "<span class='badge badge-default11' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
     }
     if (timeSymbol.Group == ConstDefault12)
     {
         timeSheetEvent.SymbolDisplay = "<span class='badge badge-default12' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
     }
     if (timeSymbol.Group == ConstDefault13)
     {
         timeSheetEvent.SymbolDisplay = "<span class='badge badge-default13' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
     }
     if (timeSymbol.Group == ConstDefault14)
     {
         timeSheetEvent.SymbolDisplay = "<span class='badge badge-default14' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Add moi timeSheetEvent
 /// </summary>
 /// <param name="timeSheetEvent"></param>
 private void AddNewTimeSheetEvent(hr_TimeSheetEvent timeSheetEvent)
 {
     try
     {
         //var description = string.Empty;
         var rowSelecteds = RowSelectionModel2.SelectedRows;
         if (rowSelecteds != null && rowSelecteds.Count > 0)
         {
             //Lay thong tin tu bang ky hieu cham cong cat_TimeSheetSymbol
             foreach (var item in rowSelecteds)
             {
                 var timeSymbol = cat_TimeSheetSymbolServices.GetById(int.Parse("0" + item.RecordID));
                 if (timeSymbol != null)
                 {
                     //Nhóm ký hiệu công tác
                     if (timeSymbol.Group == ConstWork)
                     {
                         timeSheetEvent.SymbolDisplay = "<span class='badge badge-work' title='{1}' >{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                     }
                     //Nhóm ký hiệu hưởng lương
                     if (timeSymbol.Group == ConstPaySalary)
                     {
                         timeSheetEvent.SymbolDisplay = "<span class='badge badge-normal' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                     }
                     //Nhóm ký hiệu không hưởng lương
                     if (timeSymbol.Group == ConstNotPaySalary)
                     {
                         timeSheetEvent.SymbolDisplay = "<span class='badge badge-red' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                     }
                     //Nhóm ký hiệu muộn
                     if (timeSymbol.Group == ConstLate)
                     {
                         timeSheetEvent.SymbolDisplay = "<span class='badge badge-late' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                     }
                     //Nhóm ký hiệu nghỉ lễ
                     if (timeSymbol.Group == ConstHoliday)
                     {
                         timeSheetEvent.SymbolDisplay = "<span class='badge badge-holiday' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                     }
                     //Nhóm ký hiệu nghỉ phép
                     if (timeSymbol.Group == ConstLeave)
                     {
                         timeSheetEvent.SymbolDisplay = "<span class='badge badge-leave' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                     }
                     //Nhóm ký hiệu không phép
                     if (timeSymbol.Group == ConstNotLeave)
                     {
                         timeSheetEvent.SymbolDisplay = "<span class='badge badge-notleave' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                         CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                     }
                     //Nhóm ký hiệu mặc định
                     CreateGroupTimeSheetDefault(timeSymbol, timeSheetEvent);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Dialog.ShowNotification("Có lỗi xảy ra" + ex.Message);
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Add moi timeSheetEvent
        /// </summary>
        /// <param name="timeSheetEvent"></param>
        private void AddNewTimeSheetEvent(hr_TimeSheetEvent timeSheetEvent)
        {
            try
            {
                //var description = string.Empty;
                var rowSelecteds = RowSelectionModel2.SelectedRows;
                if (rowSelecteds != null && rowSelecteds.Count > 0)
                {
                    //Lay thong tin tu bang ky hieu cham cong cat_TimeSheetSymbol
                    foreach (var item in rowSelecteds)
                    {
                        var timeSymbol = cat_TimeSheetSymbolServices.GetById(int.Parse("0" + item.RecordID));
                        if (timeSymbol != null)
                        {
                            timeSheetEvent.SymbolDisplay = "<span class='badge' title='{0}' style='background:{1}'>{2}</span>".FormatWith(timeSymbol.Name, timeSymbol.SymbolColor, timeSymbol.Code);
                            CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                            ////Nhóm ký hiệu công tác
                            //if (timeSymbol.Group == Constant.Timesheet_Work)
                            //{
                            //    timeSheetEvent.SymbolDisplay = "<span class='badge badge-{0}' title='{1}' >{2}</span>".FormatWith(timeSymbol.Group, timeSymbol.Code, timeSymbol.Name);
                            //    CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                            //}
                            ////Nhóm ký hiệu hưởng lương
                            //if (timeSymbol.Group == Constant.TimesheetPaySalary)
                            //{
                            //    timeSheetEvent.SymbolDisplay = "<span class='badge badge-normal' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                            //    CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                            //}
                            ////Nhóm ký hiệu không hưởng lương
                            //if (timeSymbol.Group == Constant.TimesheetNotPaySalary)
                            //{
                            //    timeSheetEvent.SymbolDisplay = "<span class='badge badge-red' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                            //    CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                            //}
                            ////Nhóm ký hiệu muộn
                            //if (timeSymbol.Group == Constant.TimesheetLate)
                            //{
                            //    timeSheetEvent.SymbolDisplay = "<span class='badge badge-late' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                            //    CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                            //}
                            ////Nhóm ký hiệu nghỉ lễ
                            //if (timeSymbol.Group == Constant.TimesheetHoliday)
                            //{
                            //    timeSheetEvent.SymbolDisplay = "<span class='badge badge-holiday' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                            //    CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                            //}
                            ////Nhóm ký hiệu nghỉ phép
                            //if (timeSymbol.Group == Constant.TimesheetLeave)
                            //{
                            //    timeSheetEvent.SymbolDisplay = "<span class='badge badge-leave' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                            //    CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                            //}
                            ////Nhóm ký hiệu không phép
                            //if (timeSymbol.Group == Constant.TimesheetNotLeave)
                            //{
                            //    timeSheetEvent.SymbolDisplay = "<span class='badge badge-notleave' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                            //    CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                            //}
                            ////Nhóm ký hiệu thêm giờ
                            //if (timeSymbol.Group == Constant.TimesheetOverTime)
                            //{
                            //    timeSheetEvent.SymbolDisplay = "<span class='badge badge-overtime' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                            //    CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                            //}
                            ////Nhóm ký hiệu tăng ca ngày
                            //if (timeSymbol.Group == Constant.TimesheetOverTimeDay)
                            //{
                            //    timeSheetEvent.SymbolDisplay = "<span class='badge badge-overtimeday' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                            //    CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                            //}
                            ////Nhóm ký hiệu tăng ca đêm
                            //if (timeSymbol.Group == Constant.TimesheetOverTimeNight)
                            //{
                            //    timeSheetEvent.SymbolDisplay = "<span class='badge badge-overtimenight' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                            //    CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                            //}
                            ////Nhóm ký hiệu tăng ca ngày lễ
                            //if (timeSymbol.Group == Constant.TimesheetOverTimeHoliday)
                            //{
                            //    timeSheetEvent.SymbolDisplay = "<span class='badge badge-overtimeholiday' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                            //    CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                            //}
                            ////Nhóm ký hiệu tăng ca ngày nghỉ
                            //if (timeSymbol.Group == Constant.TimesheetOverTimeWeekend)
                            //{
                            //    timeSheetEvent.SymbolDisplay = "<span class='badge badge-overtimeweekend' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                            //    CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                            //}

                            //Nhóm ký hiệu mặc định
                            CreateGroupTimeSheetDefault(timeSymbol, timeSheetEvent);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Dialog.ShowNotification("Có lỗi xảy ra" + ex.Message);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Nhóm ký hiệu mặc định
        /// </summary>
        /// <param name="timeSymbol"></param>
        /// <param name="timeSheetEvent"></param>
        private void CreateGroupTimeSheetDefault(cat_TimeSheetSymbol timeSymbol, hr_TimeSheetEvent timeSheetEvent)
        {
            timeSheetEvent.SymbolDisplay = "<span class='badge' title='{0}' style='background:{1}'>{2}</span>".FormatWith(timeSymbol.Name, timeSymbol.SymbolColor, timeSymbol.Code);
            CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
            //switch (timeSymbol.Group)
            //{

            //    case Constant.TimeSheetDefault1:
            //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-default1' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
            //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
            //        break;
            //    case Constant.TimesheetDefault2:
            //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-default2' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
            //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
            //        break;
            //    case Constant.TimesheetDefault3:
            //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-default3' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
            //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
            //        break;
            //    case Constant.TimesheetDefault4:
            //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-default4' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
            //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
            //        break;
            //    case Constant.TimesheetDefault5:
            //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-default5' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
            //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
            //        break;
            //    case Constant.TimesheetDefault6:
            //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-default6' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
            //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
            //        break;
            //    case Constant.TimesheetDefault7:
            //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-default7' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
            //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
            //        break;
            //    case Constant.TimesheetDefault8:
            //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-default8' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
            //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
            //        break;
            //    case Constant.TimesheetDefault9:
            //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-default9' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
            //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
            //        break;
            //    case Constant.TimesheetDefault10:
            //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-default10' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
            //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
            //        break;
            //    case Constant.TimesheetDefault11:
            //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-default11' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
            //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
            //        break;
            //    case Constant.TimesheetDefault12:
            //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-default12' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
            //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
            //        break;
            //    case Constant.TimesheetDefault13:
            //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-default13' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
            //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
            //        break;
            //    case Constant.TimesheetDefault14:
            //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-default14' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
            //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
            //        break;
            //}
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Add moi timeSheetEvent all employee
        /// TODO : phần này sao lại fix cứng ??
        /// </summary>
        /// <param name="timeSheetEvent"></param>
        /// <param name="typeDaySaturdayOrSunday"></param>
        private void AddNewTimeSheetEventAllEmployee(hr_TimeSheetEvent timeSheetEvent, string typeDaySaturdayOrSunday)
        {
            try
            {
                var description = string.Empty;
                if (typeDaySaturdayOrSunday == "Saturday")
                {
                    if (cbxSaturday.SelectedItem.Value == "1")
                    {
                        description = "Một ngày công";
                        timeSheetEvent.WorkConvert   = 1;
                        timeSheetEvent.Symbol        = "1";
                        timeSheetEvent.SymbolDisplay = "<span class='badge badge-normal' title='{0}'>1</span>".FormatWith(description);
                    }
                    else
                    {
                        description = "Nửa ngày công";
                        timeSheetEvent.WorkConvert   = 0.5;
                        timeSheetEvent.Symbol        = "0.5";
                        timeSheetEvent.SymbolDisplay = "<span class='badge badge-normal' title='{0}'>0.5</span>".FormatWith(description);
                    }
                    timeSheetEvent.Description = description;
                    timeSheetEvent.TypeGroup   = "HuongLuong";
                    hr_TimeSheetEventServices.Create(timeSheetEvent);
                    return;
                }
                if (typeDaySaturdayOrSunday == "Sunday")
                {
                    if (cbxSunday.SelectedItem.Value == "1")
                    {
                        description = "Một ngày công";
                        timeSheetEvent.WorkConvert   = 1;
                        timeSheetEvent.Symbol        = "1";
                        timeSheetEvent.SymbolDisplay = "<span class='badge badge-normal' title='{0}'>1</span>".FormatWith(description);
                    }
                    else
                    {
                        description = "Nửa ngày công";
                        timeSheetEvent.WorkConvert   = 0.5;
                        timeSheetEvent.Symbol        = "0.5";
                        timeSheetEvent.SymbolDisplay = "<span class='badge badge-normal' title='{0}'>0.5</span>".FormatWith(description);
                    }
                    timeSheetEvent.Description = description;
                    timeSheetEvent.TypeGroup   = "HuongLuong";
                    hr_TimeSheetEventServices.Create(timeSheetEvent);
                    return;
                }

                //Nhóm ký hiệu hưởng lương
                if (groupPaySalaryAllEmp.CheckedItems.Count <= 0)
                {
                    return;
                }
                foreach (var item in groupPaySalaryAllEmp.CheckedItems)
                {
                    if (item.ID == "chkFullDayAllEmp")
                    {
                        description = "Một ngày công";
                        timeSheetEvent.WorkConvert   = 1;
                        timeSheetEvent.Symbol        = "1";
                        timeSheetEvent.SymbolDisplay = "<span class='badge badge-normal' title='{0}'>1</span>".FormatWith(description);
                    }

                    if (item.ID != "chkHalfDayAllEmp")
                    {
                        continue;
                    }
                    description = "Nửa ngày công";
                    timeSheetEvent.WorkConvert   = 0.5;
                    timeSheetEvent.Symbol        = "0.5";
                    timeSheetEvent.SymbolDisplay = "<span class='badge badge-normal' title='{0}'>0.5</span>".FormatWith(description);
                }

                timeSheetEvent.Description = description;
                timeSheetEvent.TypeGroup   = "HuongLuong";
                hr_TimeSheetEventServices.Create(timeSheetEvent);
            }
            catch (Exception ex)
            {
                Dialog.ShowNotification("Có lỗi xảy ra" + ex.Message);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Chấm công theo ngày
        /// </summary>
        private void SaveTimeSheetForDay(object sender, DirectEventArgs e)
        {
            try
            {
                var listId = e.ExtraParams["ListRecordId"].Split(',');

                if (startDate.SelectedValue == null)
                {
                    ExtNet.Msg.Alert("Thông báo", "Bạn chưa chọn ngày cần hiệu chỉnh").Show();
                    return;
                }

                var day   = startDate.SelectedDate.Day;
                var month = startDate.SelectedDate.Month;
                var year  = startDate.SelectedDate.Year;

                for (var i = 0; i < listId.Length - 1; i++)
                {
                    var recordId = listId[i];
                    //Lay ma cham cong theo recordId
                    var timeSheetCode = GetTimeSheetCode(recordId);

                    if (timeSheetCode != null)
                    {
                        var timeSheet = hr_TimeSheetServices.GetTimeSheetByCondition(day, month, year, Convert.ToInt32(recordId), Convert.ToInt32(hdfTimeSheetReport.Text), TypeTimeSheet);
                        if (timeSheet != null)
                        {
                            var timeSheetEvent = new hr_TimeSheetEvent
                            {
                                TimeSheetId = timeSheet.Id,
                                StatusId    = EventStatus.Active,
                                CreatedDate = DateTime.Now,
                                CreatedBy   = CurrentUser.User.UserName
                            };
                            //Add moi event
                            AddNewTimeSheetEvent(timeSheetEvent, Convert.ToInt32(recordId));
                            var events = hr_TimeSheetEventServices.GetAllEventsByTimeSheetId(timeSheet.Id, EventStatus.Active);
                            //update timesheet
                            timeSheet.Detail = events.ToJson();
                            hr_TimeSheetServices.Update(timeSheet);
                        }
                        else
                        {
                            //create new timesheet by day selected
                            var newTimeSheet = new hr_TimeSheet()
                            {
                                RecordId      = Convert.ToInt32(recordId),
                                TimeSheetCode = timeSheetCode.Code,
                                Month         = month,
                                Year          = year,
                                Day           = day,
                                Detail        = " ",
                                CreatedDate   = DateTime.Now,
                                CreatedBy     = CurrentUser.User.UserName,
                                Type          = TypeTimeSheet,
                            };
                            hr_TimeSheetServices.Create(newTimeSheet);

                            var timeSheetEvent = new hr_TimeSheetEvent()
                            {
                                TimeSheetId = newTimeSheet.Id,
                                StatusId    = EventStatus.Active,
                                CreatedDate = DateTime.Now,
                                CreatedBy   = CurrentUser.User.UserName
                            };

                            //Add moi event
                            AddNewTimeSheetEvent(timeSheetEvent, Convert.ToInt32(recordId));
                            var events = hr_TimeSheetEventServices.GetAllEventsByTimeSheetId(newTimeSheet.Id, EventStatus.Active);
                            //update timesheet
                            newTimeSheet.Detail = events.ToJson();
                            hr_TimeSheetServices.Update(newTimeSheet);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Dialog.ShowNotification("Có lỗi xảy ra" + ex.Message);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Add moi timeSheetEvent
        /// </summary>
        /// <param name="timeSheetEvent"></param>
        private void AddNewTimeSheetEvent(hr_TimeSheetEvent timeSheetEvent)
        {
            try
            {
                //var description = string.Empty;
                var rowSelecteds = RowSelectionModel2.SelectedRows;
                if (rowSelecteds != null && rowSelecteds.Count > 0)
                {
                    //Lay thong tin tu bang ky hieu cham cong cat_TimeSheetSymbol
                    foreach (var item in rowSelecteds)
                    {
                        var timeSymbol = cat_TimeSheetSymbolServices.GetById(int.Parse("0" + item.RecordID));
                        // if(timeSymbol == null) continue;
                        timeSheetEvent.SymbolDisplay = "<span class='badge' title='{0}' style='background:{1}'>{2}</span>".FormatWith(timeSymbol.Name, timeSymbol.SymbolColor, timeSymbol.Code);
                        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);

                        //switch(timeSymbol.Group)
                        //{
                        //    //Nhóm ký hiệu công tác
                        //    case ConstWork:
                        //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-work' title='{1}' >{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                        //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                        //        break;
                        //    //Nhóm ký hiệu hưởng lương
                        //    case ConstPaySalary:
                        //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-normal' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                        //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                        //        break;
                        //    //Nhóm ký hiệu không hưởng lương
                        //    case ConstNotPaySalary:
                        //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-red' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                        //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                        //        break;
                        //    //Nhóm ký hiệu muộn
                        //    case ConstLate:
                        //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-late' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                        //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                        //        break;
                        //    //Nhóm ký hiệu nghỉ lễ
                        //    case ConstHoliday:
                        //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-holiday' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                        //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                        //        break;
                        //    //Nhóm ký hiệu nghỉ phép
                        //    case ConstLeave:
                        //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-leave' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                        //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                        //        break;
                        //    //Nhóm ký hiệu không phép
                        //    case ConstNotLeave:
                        //        timeSheetEvent.SymbolDisplay = "<span class='badge badge-notleave' title='{1}'>{0}</span>".FormatWith(timeSymbol.Code, timeSymbol.Name);
                        //        CreateNewTimeSheetEvent(timeSheetEvent, timeSymbol);
                        //        break;
                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                Dialog.ShowNotification("Có lỗi xảy ra" + ex.Message);
            }
        }