private void but_CreateJobtitle_Click(object sender, EventArgs e) { ChucVuDto _cvdDTO = new ChucVuDto(); _cvdDTO.TenChucVu = txt_JobtitleName.Text; _cvdDTO.TrangThai = true; NhanVienBus _nvBUS = new NhanVienBus(); string _qgdMessage = string.Empty; if (!_nvBUS.CreateJobtitle(_cvdDTO, out _qgdMessage)) { MessageBox.Show(_qgdMessage, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DialogResult dialogResult = MessageBox.Show(_qgdMessage + "\nBạn có tiếp tục tạo chức vụ", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.Yes) { txt_JobtitleName.Text = ""; } else if (dialogResult == DialogResult.No) { RenderForm(); HideControlSupportJobtitle(); but_CreateStaff.Enabled = true; but_CreatePermission.Enabled = false; but_CreatePaymentStore.Enabled = false; but_CreateJobtitle.Enabled = false; this.ClientSize = new System.Drawing.Size(500, 240); } } }
public async Task <int> CreateOrUpdate(ChucVuDto input) { if (input.Id > 0) { // update var updateData = await _chucVuRepos.GetAsync(input.Id); input.MapTo(updateData); await _chucVuRepos.UpdateAsync(updateData); return(updateData.Id); } else { try { var insertInput = input.MapTo <ChucVu>(); int newId = await _chucVuRepos.InsertAndGetIdAsync(insertInput); return(newId); } catch (Exception ex) { throw new Exception(ex.Message); } } }
public bool CreateJobtitle(ChucVuDto cvNhanVien, out string outMsg) { if (!NhanVienDao.CreateJobtitle(cvNhanVien)) { outMsg = "Tạo chức vụ không thành công"; return(false); } else { outMsg = "Tạo chức vụ thành công"; return(true); } }
public static bool CreateJobtitle(ChucVuDto cvNhanVien) { try { using (QLSoTietKiemDBContext ql = new QLSoTietKiemDBContext()) { ql.ChucVu.Add(cvNhanVien); ql.SaveChanges(); return(true); } } catch (Exception ex) { Logger.WriteLogError("NhanVienDao CreateNewStaff", ex.ToString()); return(false); } }