bool AddFlag; // xac dinh thao tac add hay edit public QLNS_VanBang() { InitializeComponent(); vanbang = new VanBangChinhQuy(); trinhdo = new TrinhDo(); }
public NVTheo_HocHam_HocVi_GioiTinh() { InitializeComponent(); oDonVi = new Business.DonVi(); oBaoCao = new Business.BaoCao(); oChucDanh = new ChucDanh(); oVangBangChinhQuy = new VanBangChinhQuy(); }
private void RefreshDataSource() { vanbang = new VanBangChinhQuy(); DataTable dt = vanbang.GetVanBangList(); if (dt != null) { PrepareDataSource(dt); EditDtgInterface(); } }
private void btn_Xoa_Click(object sender, EventArgs e) { if (dtgv_DSVanBang.CurrentRow != null) { if (MessageBox.Show("Bạn thực sự muốn xoá văn bằng này?", "Hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //vanbang = ToDepartmentObject(dtg_DepartmentList.CurrentRow); vanbang = new VanBangChinhQuy(Convert.ToInt16(dtgv_DSVanBang.CurrentRow.Cells["id"].Value.ToString())); try { vanbang.Delete(); RefreshDataSource(); MessageBox.Show("Xoá thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } return; }
private void btn_Luu_Click(object sender, EventArgs e) { if (txt_Ten.Text != "") { #region thao tac them if (AddFlag) { if (MessageBox.Show("Bạn thực sự muốn thêm văn bằng này ?", "Hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //Department = ToDepartmentObject(); int?id = null; int?trinhdoid = null; if (comB_TrinhDo.Text != "") { trinhdoid = Convert.ToInt32(comB_TrinhDo.SelectedValue.ToString()); } try { vanbang = new VanBangChinhQuy(id, txt_Ten.Text, trinhdoid, rtb_MoTa.Text); vanbang.Add(); MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); ResetInterface(true); RefreshDataSource(); return; } catch { MessageBox.Show("Thao tác thêm thất bại.", "Lỗi", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } } } #endregion #region thao tac sua else // thao tac sua { if (MessageBox.Show("Bạn thực sự muốn sửa văn bằng này ?", "Hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int id = Convert.ToInt16(dtgv_DSVanBang.CurrentRow.Cells["id"].Value.ToString()); int?trinhdoid = null; if (comB_TrinhDo.Text != "") { trinhdoid = Convert.ToInt32(comB_TrinhDo.SelectedValue.ToString()); } try { vanbang = new VanBangChinhQuy(id, txt_Ten.Text, trinhdoid, rtb_MoTa.Text); vanbang.Update(); MessageBox.Show("Sửa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); ResetInterface(true); RefreshDataSource(); return; } catch { MessageBox.Show("Thao tác sửa thất bại.", "Lỗi", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } } } #endregion } else { MessageBox.Show("Tên văn bằng không được rỗng, xin vui lòng cung cấp tên văn bằng", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_Luu_Click(object sender, EventArgs e) { if (txt_Ten.Text != "") { #region thao tac them if (AddFlag) { if (MessageBox.Show("Bạn thực sự muốn thêm văn bằng này ?", "Hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //Department = ToDepartmentObject(); int? id = null; int? trinhdoid = null; if (comB_TrinhDo.Text != "") trinhdoid = Convert.ToInt32(comB_TrinhDo.SelectedValue.ToString()); try { vanbang = new VanBangChinhQuy(id, txt_Ten.Text, trinhdoid, rtb_MoTa.Text); vanbang.Add(); MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); ResetInterface(true); RefreshDataSource(); return; } catch { MessageBox.Show("Thao tác thêm thất bại.", "Lỗi", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } } } #endregion #region thao tac sua else // thao tac sua { if (MessageBox.Show("Bạn thực sự muốn sửa văn bằng này ?", "Hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int id = Convert.ToInt16(dtgv_DSVanBang.CurrentRow.Cells["id"].Value.ToString()); int? trinhdoid = null; if (comB_TrinhDo.Text != "") trinhdoid = Convert.ToInt32(comB_TrinhDo.SelectedValue.ToString()); try { vanbang = new VanBangChinhQuy(id, txt_Ten.Text, trinhdoid, rtb_MoTa.Text); vanbang.Update(); MessageBox.Show("Sửa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); ResetInterface(true); RefreshDataSource(); return; } catch { MessageBox.Show("Thao tác sửa thất bại.", "Lỗi", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } } } #endregion } else MessageBox.Show("Tên văn bằng không được rỗng, xin vui lòng cung cấp tên văn bằng", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); }