public void XoaBangCap(string maBangCap) { try { BangCapDAO BangCap = new BangCapDAO(); BangCap.XoaBangCap(maBangCap); } catch (Exception) { throw; } }
public void SuaBangCap(string tenBangCap, string maBangCap) { try { BangCapDAO BangCap = new BangCapDAO(); BangCap.SuaBangCap(tenBangCap, maBangCap); } catch (Exception) { throw; } }
public DataTable LayDanhSachBangCap() { try { BangCapDAO dsBangCap = new BangCapDAO(); DataTable table = dsBangCap.LayDanhSachBangCap(); return(table); } catch (SqlException ex) { throw ex; } }
public void ThemBangCap(string tenBangCap) { try { BangCapDAO BangCap = new BangCapDAO(); DataTable dsBangCap = BangCap.LayDanhSachBangCap(); string maBangCap = "BC" + (int.Parse(dsBangCap.Rows[dsBangCap.Rows.Count - 1][0].ToString().Substring(2, 2)) + 1).ToString("00"); BangCap.ThemBangCap(tenBangCap, maBangCap); } catch (Exception) { throw; } }
private void btnXoa_Click(object sender, EventArgs e) { try { int idbangcap = Convert.ToInt32(grvBangCap.GetFocusedDataRow()["BANGCAPID"].ToString()); int idnv = (int)cboBangCap.SelectedValue; if (BangCapDAO.DeleteBangCap(idbangcap) == 1) { MessageBox.Show("thành công"); } else { MessageBox.Show("thất bại"); } LoadBangCap(idnv); } catch { return; } }
private void btnThem_Click(object sender, EventArgs e) { try { int idnv = (int)cboBangCap.SelectedValue; string trinhdohocvan = txbTrinhDoHocvan.Text; DateTime thoigian = dtpThoiGian.DateTime; string chitiet = txbBangCap.Text; if (BangCapDAO.InsertBangCap(idnv, trinhdohocvan, thoigian, chitiet) == 1) { MessageBox.Show("thành công"); } else { MessageBox.Show("thất bại"); } LoadBangCap(idnv); } catch { return; } }
private void btnSua_Click(object sender, EventArgs e) { try { int idbangcap = Convert.ToInt32(grvBangCap.GetFocusedDataRow()["BANGCAPID"].ToString()); int idnv = (int)cboBangCap.SelectedValue; string trinhdohocvan = txbTrinhDoHocvan.Text; DateTime thoigian = dtpThoiGian.DateTime; string chitiet = txbBangCap.Text; if (BangCapDAO.UpdateBangCap(idbangcap, idnv, trinhdohocvan, thoigian, chitiet) == 1) { MessageBox.Show("thành công"); } else { MessageBox.Show("thất bại"); } LoadBangCap(idnv); } catch { return; } }
void LoadBangCap(int idnv) { list.DataSource = BangCapDAO.LoadBangCap(idnv); }