private void button3_Click(object sender, EventArgs e) { string mamh, tenmh, sotinchi, sotiet, manganh; mamh = txtmamh.Text.Trim(); tenmh = txttenmh.Text.Trim(); sotinchi = txtsotinchi.Text.Trim(); sotiet = txtsotiet.Text.Trim(); manganh = txtmn.Text.Trim(); MonHoc MH = new MonHoc(mamh, tenmh, sotinchi, sotiet, manganh); try { int i = new MonHocBus().SuaMH(MH); if (i == -2) { throw new Exception(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } dgvMH.DataSource = GetMH(); }
public List <MonHoc> GetMH() { try { string sql = "select * from MonHoc"; MonHocBus mh = new MonHocBus(); return(mh.GetMH(sql)); } catch (Exception ex) { MessageBox.Show(ex.Message); return(null); } }
private void button2_Click(object sender, EventArgs e) { string mamh; mamh = txtmamh.Text.Trim(); try { int i = new MonHocBus().XoaMH(mamh); if (i == -2) { throw new Exception(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } dgvMH.DataSource = GetMH(); }