private void Create(DirectEventArgs e) { try { var path = string.Empty; var util = new Util(); if (fufTepTinHangLoat.HasFile) { path = UploadFile(fufTepTinHangLoat, hdfTypePage.Text.Equals("KhenThuong") ? Constant.PathReward : Constant.PathDiscipline); } var listId = e.ExtraParams["ListId"].Split(','); if (listId.Length <= 1) { Dialog.Alert("Bạn chưa chọn cán bộ nào!"); return; } for (var i = 0; i < listId.Length - 1; i++) { var id = listId[i]; if (hdfTypePage.Text.Equals("KhenThuong")) { string reasonReward; if (hdfIsDanhMuc2.Text == @"0") { var reason = new cat_ReasonReward { Name = cbbLyDoHangLoat.Text }; cat_ReasonRewardServices.Create(reason); reasonReward = cbbLyDoHangLoat.Text; } else { reasonReward = cbbLyDoHangLoat.SelectedItem.Text; } if (string.IsNullOrEmpty(reasonReward)) { ExtNet.Msg.Alert("Thông báo", "Không tìm thấy lý do khen thưởng. Vui lòng thử lại!").Show(); return; } if (txtSoQuyetDinhHangLoat.Text == "") { GenerateRewardDecisionNumber(); } var record = new hr_Reward { RecordId = int.Parse(id), DecisionNumber = txtSoQuyetDinhHangLoat.Text.Trim(), DecisionMaker = tgfNguoiQuyetDinhHangLoat.Text.Trim(), FormRewardId = int.Parse(hdfHinhThucHangLoat.Text), LevelRewardId = int.Parse(hdfCapKhenThuongKyLuatHangLoat.Text), Reason = reasonReward, SourceDepartment = txtSourceDepartment.Text, Note = txtGhuChuHangLoat.Text.Trim() }; var makerPosition = hdfIsMakerPosition.Text == @"0" ? cbxMakerPosition.Text : cbxMakerPosition.SelectedItem.Text; record.MakerPosition = makerPosition; if (!string.IsNullOrEmpty(txtMoneyAmount.Text)) { record.MoneyAmount = decimal.Parse("0" + txtMoneyAmount.Text); } record.CreatedDate = DateTime.Now; if (!util.IsDateNull(dfNgayQuyetDinhHangLoat.SelectedDate)) { record.DecisionDate = dfNgayQuyetDinhHangLoat.SelectedDate; } if (!util.IsDateNull(dfNgayHieuLuc.SelectedDate)) { record.EffectiveDate = dfNgayHieuLuc.SelectedDate; } record.AttachFileName = path != "" ? path : hdfTepDinhKemHangLoat.Text; hr_RewardServices.Create(record); } else { string reasonDiscipline; if (hdfIsDanhMuc2.Text == @"0") { var reason = new cat_ReasonDiscipline() { Name = cbbLyDoHangLoat.Text }; cat_ReasonDisciplineServices.Create(reason); reasonDiscipline = cbbLyDoHangLoat.Text; } else { reasonDiscipline = cbbLyDoHangLoat.SelectedItem.Text; } if (string.IsNullOrEmpty(reasonDiscipline)) { ExtNet.Msg.Alert("Thông báo", "Không tìm thấy lý do khen thưởng. Vui lòng thử lại!").Show(); return; } if (txtSoQuyetDinhHangLoat.Text == "") { GenerateRewardDecisionNumber(); } var record = new hr_Discipline { RecordId = int.Parse(id), DecisionNumber = txtSoQuyetDinhHangLoat.Text.Trim(), DecisionMaker = tgfNguoiQuyetDinhHangLoat.Text.Trim(), FormDisciplineId = int.Parse(hdfHinhThucHangLoat.Text), LevelDisciplineId = int.Parse(hdfCapKhenThuongKyLuatHangLoat.Text), Reason = reasonDiscipline, SourceDepartment = txtSourceDepartment.Text, Note = txtGhuChuHangLoat.Text.Trim() }; var makerPosition = hdfIsMakerPosition.Text == @"0" ? cbxMakerPosition.Text : cbxMakerPosition.SelectedItem.Text; record.MakerPosition = makerPosition; record.CreatedDate = DateTime.Now; if (!util.IsDateNull(dfNgayQuyetDinhHangLoat.SelectedDate)) { record.DecisionDate = dfNgayQuyetDinhHangLoat.SelectedDate; } if (!util.IsDateNull(dfExpireDate.SelectedDate)) { record.ExpireDate = dfExpireDate.SelectedDate; } record.AttachFileName = path != "" ? path : hdfTepDinhKemHangLoat.Text; hr_DisciplineServices.Create(record); } } grp_KhenThuongKyLuat.Reload(); ResetForm(); wdKhenThuongKyLuatHangLoat.Hide(); } catch (Exception ex) { Dialog.Alert("Có lỗi xảy ra trong quá trình tạo quyết định: {0}".FormatWith(ex.Message)); } }
/// <summary> /// /// </summary> /// <param name="e"></param> private void Create(DirectEventArgs e) { try { var path = string.Empty; if (fufTepTinHangLoat.HasFile) { path = UploadFile(fufTepTinHangLoat, hdfTypePage.Text.Equals("KhenThuong") ? Constant.PathReward : Constant.PathDiscipline); } foreach (var itemRow in chkEmployeeRowSelection.SelectedRows) { if (hdfTypePage.Text.Equals("KhenThuong")) { string reasonReward; if (hdfIsDanhMuc2.Text == @"0") { var reason = new cat_ReasonReward { Name = cbbLyDoHangLoat.Text }; cat_ReasonRewardServices.Create(reason); reasonReward = cbbLyDoHangLoat.Text; } else { reasonReward = cbbLyDoHangLoat.SelectedItem.Text; } if (string.IsNullOrEmpty(reasonReward)) { Dialog.Alert("Thông báo", "Không tìm thấy lý do khen thưởng. Vui lòng thử lại!"); return; } if (txtSoQuyetDinhHangLoat.Text == "") { GenerateRewardDecisionNumber(); } var record = new RewardModel { RecordId = Convert.ToInt32(itemRow.RecordID), DecisionNumber = txtSoQuyetDinhHangLoat.Text.Trim(), DecisionMaker = tgfNguoiQuyetDinhHangLoat.Text.Trim(), FormRewardId = int.Parse(hdfHinhThucHangLoat.Text), LevelRewardId = int.Parse(hdfLevelManyId.Text), Reason = reasonReward, SourceDepartment = txtSourceDepartment.Text, Note = txtGhuChuHangLoat.Text.Trim() }; var makerPosition = hdfIsMakerPosition.Text == @"0" ? cbxMakerPosition.Text : cbxMakerPosition.SelectedItem.Text; record.MakerPosition = makerPosition; if (!string.IsNullOrEmpty(txtMoneyAmount.Text)) { record.MoneyAmount = decimal.Parse("0" + txtMoneyAmount.Text); } record.CreatedDate = DateTime.Now; record.CreatedBy = CurrentUser.User.UserName; record.EditedDate = DateTime.Now; record.EditedBy = CurrentUser.User.UserName; if (!DatetimeHelper.IsNull(dfNgayQuyetDinhHangLoat.SelectedDate)) { record.DecisionDate = dfNgayQuyetDinhHangLoat.SelectedDate; } if (!DatetimeHelper.IsNull(dfNgayHieuLuc.SelectedDate)) { record.EffectiveDate = dfNgayHieuLuc.SelectedDate; } record.AttachFileName = path != "" ? path : hdfTepDinhKemHangLoat.Text; RewardController.Create(record); } else { string reasonDiscipline; if (hdfIsDanhMuc2.Text == @"0") { var reason = new cat_ReasonDiscipline() { Name = cbbLyDoHangLoat.Text }; cat_ReasonDisciplineServices.Create(reason); reasonDiscipline = cbbLyDoHangLoat.Text; } else { reasonDiscipline = cbbLyDoHangLoat.SelectedItem.Text; } if (string.IsNullOrEmpty(reasonDiscipline)) { Dialog.Alert("Thông báo", "Không tìm thấy lý do khen thưởng. Vui lòng thử lại!"); return; } if (txtSoQuyetDinhHangLoat.Text == "") { GenerateRewardDecisionNumber(); } var record = new DisciplineModel { RecordId = Convert.ToInt32(itemRow.RecordID), DecisionNumber = txtSoQuyetDinhHangLoat.Text.Trim(), DecisionMaker = tgfNguoiQuyetDinhHangLoat.Text.Trim(), FormDisciplineId = int.Parse(hdfHinhThucHangLoat.Text), LevelDisciplineId = int.Parse(hdfLevelManyId.Text), Reason = reasonDiscipline, SourceDepartment = txtSourceDepartment.Text, Note = txtGhuChuHangLoat.Text.Trim() }; var makerPosition = hdfIsMakerPosition.Text == @"0" ? cbxMakerPosition.Text : cbxMakerPosition.SelectedItem.Text; record.MakerPosition = makerPosition; record.CreatedDate = DateTime.Now; record.CreatedBy = CurrentUser.User.UserName; record.EditedDate = DateTime.Now; record.EditedBy = CurrentUser.User.UserName; if (!DatetimeHelper.IsNull(dfNgayQuyetDinhHangLoat.SelectedDate)) { record.DecisionDate = dfNgayQuyetDinhHangLoat.SelectedDate; } if (!DatetimeHelper.IsNull(dfExpireDate.SelectedDate)) { record.ExpireDate = dfExpireDate.SelectedDate; } record.AttachFileName = path != "" ? path : hdfTepDinhKemHangLoat.Text; DisciplineController.Create(record); } } grp_KhenThuongKyLuat.Reload(); ResetForm(); wdKhenThuongKyLuatHangLoat.Hide(); } catch (Exception ex) { Dialog.Alert("Có lỗi xảy ra trong quá trình tạo quyết định: {0}".FormatWith(ex.Message)); } }