private void btsua1_Click(object sender, EventArgs e) { int mahk, tinhtrang; string mamh, malh; DateTime tgbatdau, tgketthuc; malh = txtmalop.Text.Trim(); mamh = txtmh.Text.Trim(); mahk = int.Parse(txtmahk.Text.Trim()); tgbatdau = DateTime.Parse(txtBD.Text.Trim()); tgketthuc = DateTime.Parse(txtKT.Text.Trim()); tinhtrang = int.Parse(txttinhtrang.Text.Trim()); LopHoc LH = new LopHoc(malh, mamh, mahk, tgbatdau, tgketthuc, tinhtrang); try { int i = new LopHocBus().SuaLH(LH); if (i == -2) { throw new Exception(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } dgvLH.DataSource = GetLH(); }
public List <LopHoc> GetLH() { try { string sql = "Select * from LopHoc"; LopHocBus LH = new LopHocBus(); return(LH.GetLH(sql)); } catch (Exception ex) { throw ex; } }
private void btxoa1_Click(object sender, EventArgs e) { string malh; malh = txtmalop.Text.Trim(); try { int i = new LopHocBus().XoaLH(malh); //if (i == -2) //{ // throw new Exception(); //} } catch (Exception ex) { MessageBox.Show(ex.Message); } dgvLH.DataSource = GetLH(); }