Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        private void Insert(DirectEventArgs e)
        {
            try
            {
                foreach (var item in chkEmployeeRowSelection.SelectedRows)
                {
                    var recordId = item.RecordID;
                    var annual   = new AnnualLeaveConfigureModel();
                    EditDataAnnualLeave(annual);
                    annual.RecordId    = Convert.ToInt32(recordId);
                    annual.CreatedDate = DateTime.Now;
                    annual.CreatedBy   = CurrentUser.User.UserName;
                    annual.EditedDate  = DateTime.Now;
                    annual.EditedBy    = CurrentUser.User.UserName;
                    //create
                    AnnualLeaveConfigureController.Create(annual);
                }


                if (e.ExtraParams["Close"] == "True")
                {
                    wdAnnualLeave.Hide();
                    ResetForm();
                }
            }
            catch (Exception ex)
            {
                Dialog.Alert("Có lỗi xảy ra trong quá trình thêm mới: {0}".FormatWith(ex.Message));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void EditAnnualLeave_Click(object sender, DirectEventArgs e)
        {
            if (!int.TryParse(hdfKeyRecord.Text, out var id) || id <= 0)
            {
                return;
            }
            var annual = AnnualLeaveConfigureController.GetById(id);

            if (annual != null)
            {
                txtAnnualLeaveDay.Text           = annual.AnnualLeaveDay.ToString();
                txtDayAddedStep.Text             = annual.DayAddedStep.ToString();
                txtMaximumPerMonth.Text          = annual.MaximumPerMonth.ToString();
                txtYearStep.Text                 = annual.YearStep.ToString();
                chk_AllowUseFirstYear.Checked    = annual.AllowUseFirstYear;
                chk_AllowUsePreviousYear.Checked = annual.AllowUsePreviousYear;
                txtUsedLeaveDay.Text             = annual.UsedLeaveDay.ToString();
                txtRemainLeaveDay.Text           = annual.RemainLeaveDay.ToString();
                dfExpiredDate.SetValue(annual.ExpiredDate);
                txtFullName.Text = annual.FullName;
            }

            // show window
            btnUpdate.Show();
            btnUpdateClose.Hide();
            txtFullName.Hidden = false;
            grp_ListEmployee.Hide();
            ctnEmployee.Hide();
            wdAnnualLeave.Title = @"Cập nhật cấu hình ngày phép";
            wdAnnualLeave.Show();
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDeleteTime_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(hdfUpdateTimeSheetEventId.Text))
                {
                    return;
                }
                var id = int.Parse(hdfUpdateTimeSheetEventId.Text);

                // delete
                var deletedTimeSheetEvent = TimeSheetEventController.Delete(id);

                // get symbol group
                var timeSheetGroupSymbol = TimeSheetGroupSymbolController.GetById(deletedTimeSheetEvent.GroupSymbolId);

                // update annual leave
                if (timeSheetGroupSymbol.Group == Constant.TimesheetLeave)
                {
                    // get annual leave history by record id and event id
                    var annualLeaveHistorys = AnnualLeaveHistoryController.GetAll(null,
                                                                                  deletedTimeSheetEvent.RecordId.ToString(), deletedTimeSheetEvent.Id, false, null, 1);
                    if (annualLeaveHistorys != null && annualLeaveHistorys.Count > 0)
                    {
                        // delete annual leave history
                        var annualLeaveHistory = AnnualLeaveHistoryController.Delete(annualLeaveHistorys.First().Id);

                        // get annual leave config by record id and year
                        var annualLeaveConfigures = AnnualLeaveConfigureController.GetAll(null, annualLeaveHistory.RecordId.ToString(), null,
                                                                                          annualLeaveHistory.UsedLeaveDate.Year, false, null, 1);
                        if (annualLeaveConfigures != null && annualLeaveConfigures.Count > 0)
                        {
                            // get first item
                            var annualLeaveConfigure = annualLeaveConfigures.First();

                            // calc used and remain leave day
                            annualLeaveConfigure.UsedLeaveDay -= annualLeaveHistory.UsedLeaveDay;
                            if (annualLeaveConfigure.AnnualLeaveDay > 0)
                            {
                                annualLeaveConfigure.RemainLeaveDay =
                                    annualLeaveConfigure.AnnualLeaveDay - annualLeaveConfigure.UsedLeaveDay;
                            }
                            annualLeaveConfigure.EditedBy = CurrentUser.User.UserName;

                            // update annual leave configure
                            AnnualLeaveConfigureController.Update(annualLeaveConfigure);
                        }
                    }
                }

                gridUpdateTimeSheet.Reload();
                gridTimeSheet.Reload();
            }
            catch (Exception ex)
            {
                Dialog.ShowNotification("Có lỗi xảy ra" + ex.Message);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="directEventArgs"></param>
        protected void Delete(object sender, DirectEventArgs directEventArgs)
        {
            try
            {
                if (!string.IsNullOrEmpty(hdfKeyRecord.Text))
                {
                    AnnualLeaveConfigureController.Delete(Convert.ToInt32(hdfKeyRecord.Text));
                }

                gridAnnualLeave.Reload();
            }
            catch (Exception ex)
            {
                Dialog.Alert("Có lỗi xảy ra trong quá trình xóa: {0}".FormatWith(ex.Message));
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 private void Update()
 {
     try
     {
         if (string.IsNullOrEmpty(hdfKeyRecord.Text))
         {
             return;
         }
         var annual = AnnualLeaveConfigureController.GetById(Convert.ToInt32(hdfKeyRecord.Text));
         if (annual != null)
         {
             EditDataAnnualLeave(annual);
             annual.EditedDate = DateTime.Now;
             annual.EditedBy   = CurrentUser.User.UserName;
         }
         //update
         AnnualLeaveConfigureController.Update(annual);
     }
     catch (Exception ex)
     {
         Dialog.Alert("Có lỗi xảy ra trong quá trình cập nhật: {0}".FormatWith(ex.Message));
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAccept_Click(object sender, DirectEventArgs e)
        {
            try
            {
                foreach (var workShift in chkWorkShiftRowSelection.SelectedRows)
                {
                    foreach (var symbol in chkSelectionModelSymbol.SelectedRows)
                    {
                        var timeSheetSymbol      = TimeSheetSymbolController.GetById(int.Parse(symbol.RecordID));
                        var timeSheetGroupSymbol =
                            TimeSheetGroupSymbolController.GetById(timeSheetSymbol.GroupSymbolId);
                        var timeSheetEvent = new TimeSheetEventModel
                        {
                            RecordId      = int.Parse(hdfRecordId.Text),
                            WorkShiftId   = int.Parse(workShift.RecordID),
                            SymbolId      = timeSheetSymbol.Id,
                            GroupSymbolId = timeSheetSymbol.GroupSymbolId,
                            WorkConvert   = timeSheetSymbol.WorkConvert,
                            TimeConvert   = timeSheetSymbol.TimeConvert,
                            Type          = timeSheetGroupSymbol.Group == Constant.TimesheetOverTime
                                ? TimeSheetAdjustmentType.AdjustmentOverTime
                                : TimeSheetAdjustmentType.Adjustment,
                            Description = timeSheetGroupSymbol.Group == Constant.TimesheetOverTime
                                ? "Thêm giờ"
                                : "Hiệu chỉnh"
                        };
                        var newTimeSheetEvent = TimeSheetEventController.Create(timeSheetEvent);

                        // update annual leave
                        if (timeSheetGroupSymbol.Group == Constant.TimesheetLeave)
                        {
                            // update annual leave history
                            var annualLeaveHistory = new AnnualLeaveHistoryModel
                            {
                                RecordId         = newTimeSheetEvent.RecordId,
                                TimeSheetEventId = newTimeSheetEvent.Id,
                                UsedLeaveDate    = newTimeSheetEvent.StartDate,
                                UsedLeaveDay     = newTimeSheetEvent.WorkConvert,
                                CreatedBy        = CurrentUser.User.UserName
                            };
                            AnnualLeaveHistoryController.Create(annualLeaveHistory);

                            // get annual leave configure by record id and year
                            var annualLeaveConfigures = AnnualLeaveConfigureController.GetAll(null, annualLeaveHistory.RecordId.ToString(), null,
                                                                                              annualLeaveHistory.UsedLeaveDate.Year, false, null, 1);

                            if (annualLeaveConfigures == null || annualLeaveConfigures.Count == 0)
                            {
                                continue;
                            }

                            // get first item in list
                            var annualLeaveConfigure = annualLeaveConfigures.First();

                            // calc used and remain leave day
                            annualLeaveConfigure.UsedLeaveDay += annualLeaveHistory.UsedLeaveDay;
                            if (annualLeaveConfigure.AnnualLeaveDay > 0)
                            {
                                annualLeaveConfigure.RemainLeaveDay =
                                    annualLeaveConfigure.AnnualLeaveDay - annualLeaveConfigure.UsedLeaveDay;
                            }
                            annualLeaveConfigure.EditedBy = CurrentUser.User.UserName;

                            // update annual leave configure
                            AnnualLeaveConfigureController.Update(annualLeaveConfigure);
                        }
                    }
                }
                gridTimeSheet.Reload();
                gridUpdateTimeSheet.Reload();
            }
            catch (Exception ex)
            {
                Dialog.ShowNotification("Có lỗi xảy ra" + ex.Message);
            }
        }
Ejemplo n.º 7
0
        protected void Delete(object sender, DirectEventArgs e)
        {
            try
            {
                // init id
                var param = e.ExtraParams["Id"];
                // parse id
                if (!int.TryParse(param, out var id) || id <= 0)
                {
                    // parse error, show error
                    Dialog.ShowError("Có lỗi xảy ra trong quá trình xử lý");
                    return;
                }
                // delete
                var deletedTimeSheetEvent = TimeSheetEventController.Delete(id);

                // get symbol group
                var timeSheetGroupSymbol = TimeSheetGroupSymbolController.GetById(deletedTimeSheetEvent.GroupSymbolId);

                // update annual leave
                if (timeSheetGroupSymbol.Group == Constant.TimesheetLeave)
                {
                    // get annual leave history by record id and event id
                    var annualLeaveHistorys = AnnualLeaveHistoryController.GetAll(null,
                                                                                  deletedTimeSheetEvent.RecordId.ToString(), deletedTimeSheetEvent.Id, false, null, 1);
                    if (annualLeaveHistorys != null && annualLeaveHistorys.Count > 0)
                    {
                        // delete annual leave history
                        var annualLeaveHistory = AnnualLeaveHistoryController.Delete(annualLeaveHistorys.First().Id);

                        // get annual leave config by record id and year
                        var annualLeaveConfigures = AnnualLeaveConfigureController.GetAll(null, annualLeaveHistory.RecordId.ToString(), null,
                                                                                          annualLeaveHistory.UsedLeaveDate.Year, false, null, 1);
                        if (annualLeaveConfigures != null && annualLeaveConfigures.Count > 0)
                        {
                            // get first item
                            var annualLeaveConfigure = annualLeaveConfigures.First();

                            // calc used and remain leave day
                            annualLeaveConfigure.UsedLeaveDay -= annualLeaveHistory.UsedLeaveDay;
                            if (annualLeaveConfigure.AnnualLeaveDay > 0)
                            {
                                annualLeaveConfigure.RemainLeaveDay =
                                    annualLeaveConfigure.AnnualLeaveDay - annualLeaveConfigure.UsedLeaveDay;
                            }
                            annualLeaveConfigure.EditedBy = CurrentUser.User.UserName;

                            // update annual leave configure
                            AnnualLeaveConfigureController.Update(annualLeaveConfigure);
                        }
                    }
                }

                // reload data
                gridTimeAdjust.Reload();
            }
            catch (Exception exception)
            {
                Dialog.ShowError(exception);
            }
        }