private void Xoa() { try { if (vtIndex != -1) //khi click lên tiêu đề header của datagrid thì bỏ qua { if (MSG.BanCoChacChanMuonXoaKhong() == System.Windows.Forms.DialogResult.Yes) { ThietBi temp = Utils.DataGridViewRow_to_ThietBi(DataGridView.Rows[vtIndex]); int kq = ThietBiBiz.DeleteThietBi(temp); //if (kq > 0) MSG.XoaThanhCong(); //else MSG.XoaThatBai(); if (kq <= 0) { MSG.XoaThatBai(); } HienThi(); } } } catch (Exception ex) { MSG.Error(ex); } }
private void btnDongY_Click(object sender, EventArgs e) { if (Them) {//Thêm ThietBi temp = new ThietBi(); temp.MaThietBi = txtMa.Text; temp.TenThietBi = txtTen.Text; if (!CheckLoi(temp)) { return; } int kq = ThietBiBiz.AddThietBi(temp); if (kq > 0) { MSG.ThemThanhCong(); } else { MSG.ThemThatBai(); } } else {//Sửa ThietBi temp = new ThietBi(); temp.MaThietBi = txtMa.Text; temp.TenThietBi = txtTen.Text; int kq = ThietBiBiz.EditThietBi(temp); if (kq > 0) { MSG.SuaThanhCong(); } else { MSG.SuaThatBai(); } } this.Close(); }
private void HienThi() { Ldata = ThietBiBiz.getListThietBi(); DataGridView.DataSource = Ldata.ToArray(); FixDataGirdView(); }