private void Insert(DirectEventArgs e) { try { //check validation choose employee if (string.IsNullOrEmpty(e.ExtraParams["ListRecordId"])) { ExtNet.Msg.Alert("Thông báo", "Bạn hãy chọn ít nhất 1 cán bộ").Show(); return; } var listId = e.ExtraParams["ListRecordId"].Split(','); for (var i = 0; i < listId.Length - 1; i++) { var recordId = listId[i]; var annual = new hr_AnnualLeaveConfigure(); EditDataAnnualLeave(annual); annual.RecordId = Convert.ToInt32(recordId); annual.CreatedDate = DateTime.Now; hr_AnnualLeaveConfigureServices.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)); } }
/// <summary> /// edit data before save DB /// </summary> /// <param name="annual"></param> private void EditDataAnnualLeave(hr_AnnualLeaveConfigure annual) { var util = new Util(); if (!string.IsNullOrEmpty(txtAnnualLeaveDay.Text)) { annual.AnnualLeaveDay = Convert.ToDouble(txtAnnualLeaveDay.Text); } if (!string.IsNullOrEmpty(txtDayAddedStep.Text)) { annual.DayAddedStep = Convert.ToDouble(txtDayAddedStep.Text); } if (!string.IsNullOrEmpty(txtYearStep.Text)) { annual.YearStep = Convert.ToInt32(txtYearStep.Text); } if (!string.IsNullOrEmpty(txtMaximumPerMonth.Text)) { annual.MaximumPerMonth = Convert.ToDouble(txtMaximumPerMonth.Text); } annual.AllowUseFirstYear = chk_AllowUseFirstYear.Checked; annual.AllowUsePreviousYear = chk_AllowUsePreviousYear.Checked; if (!util.IsDateNull(dfExpiredDate.SelectedDate)) { annual.ExpiredDate = dfExpiredDate.SelectedDate; } if (!string.IsNullOrEmpty(txtUsedLeaveDay.Text)) { annual.UsedLeaveDay = Convert.ToDouble(txtUsedLeaveDay.Text); } if (!string.IsNullOrEmpty(txtRemainLeaveDay.Text)) { annual.RemainLeaveDay = Convert.ToDouble(txtRemainLeaveDay.Text); } }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public static AnnualLeaveConfigureModel Create(AnnualLeaveConfigureModel model) { var entity = new hr_AnnualLeaveConfigure(); // fill data to entity model.FillEntity(ref entity); return(new AnnualLeaveConfigureModel(hr_AnnualLeaveConfigureServices.Create(entity))); }
public override void Excute(string args) { // create history var schedulerHistory = SchedulerHistoryServices.Create(Id, Name.ToUpper(), false, string.Empty, string.Empty, DateTime.Now, DateTime.MaxValue); // start process if (schedulerHistory == null) { return; } // log start SchedulerLogServices.Create(schedulerHistory.Id, "START"); // Chạy 0:05 ngày 1 hàng tháng var month = DateTime.Now.Month; var year = DateTime.Now.Year; //Tao ngay phep mac dinh cho tat ca nhan vien var condition = @"WorkStatusId = (select top 1 Id from cat_WorkStatus where Name like N'{0}')".FormatWith(ConstStatusWorking); var listRecords = hr_RecordServices.GetAll(condition); foreach (var item in listRecords) { //tạo mới bảng phép var leave = new hr_AnnualLeaveConfigure() { RecordId = item.Id, AnnualLeaveDay = ConstLeaveDay, CreatedDate = DateTime.Now, Year = DateTime.Now.Year, AllowUseFirstYear = false, AllowUsePreviousYear = false, ExpiredDate = null, }; hr_AnnualLeaveConfigureServices.Create(leave); } SchedulerLogServices.Create(schedulerHistory.Id, "END"); }