private void btnXoaBM_Click(object sender, EventArgs e) { if (btnXoaBM.Enabled == true) { DialogResult r = MessageBox.Show(null, "Bạn có chắc xóa bộ môn " + txtTenBM.Text + " không!", "Cân nhắc", MessageBoxButtons.YesNo); if (r == DialogResult.Yes) { XepThoiKhoaBieuEntities et = new XepThoiKhoaBieuEntities(); BoMon bmdel = new BoMon(); bmdel.MaBM = Int32.Parse(txtMaBM.Text); et.Entry(bmdel).State = EntityState.Deleted; et.SaveChanges(); MessageBox.Show("Đã xóa!"); QLBoMon_Load(sender, e); } } }
private void btnReload_Click(object sender, EventArgs e) { if (k == 1) { try { if (t == 1) { XepThoiKhoaBieuEntities et = new XepThoiKhoaBieuEntities(); Lop lop = new Lop(); lop.MaLop = Int32.Parse(txtMaLH.Text); lop.TenLop = txtTenLH.Text; lop.SoHocSinh = Int32.Parse(txtSoHS.Text); lop.MaBan = Int32.Parse(txtMaBan.Text); et.Entry(lop).State = EntityState.Added; et.SaveChanges(); MessageBox.Show("Thêm thành công!"); } else { XepThoiKhoaBieuEntities et = new XepThoiKhoaBieuEntities(); Lop lop = new Lop(); lop.MaLop = Int32.Parse(txtMaLH.Text); lop.TenLop = txtTenLH.Text; lop.SoHocSinh = Int32.Parse(txtSoHS.Text); lop.MaBan = Int32.Parse(txtMaBan.Text); et.Entry(lop).State = EntityState.Modified; et.SaveChanges(); MessageBox.Show("Sửa thành công!"); } QLLop_Load(sender, e); } catch (Exception ex) { MessageBox.Show("Lỗi " + ex.Message); } } else { QLLop_Load(sender, e); } }
private void btnReload_Click(object sender, EventArgs e) { if (k == 1) { try { if (t == 1) { XepThoiKhoaBieuEntities et = new XepThoiKhoaBieuEntities(); PhongHoc ph = new PhongHoc(); ph.MaPH = Int32.Parse(txtMaPH.Text); ph.TenPH = txtTenPH.Text; ph.DungLuong = Int32.Parse(txtDungLuong.Text); et.Entry(ph).State = EntityState.Added; et.SaveChanges(); MessageBox.Show("Đã xóa!"); } else { XepThoiKhoaBieuEntities et = new XepThoiKhoaBieuEntities(); PhongHoc ph = new PhongHoc(); ph.MaPH = Int32.Parse(txtMaPH.Text); ph.TenPH = txtTenPH.Text; ph.DungLuong = Int32.Parse(txtDungLuong.Text); et.Entry(ph).State = EntityState.Modified; et.SaveChanges(); MessageBox.Show("Đã xóa!"); } } catch (Exception ex) { MessageBox.Show("Lỗi " + ex.Message); } QLPhongHoc_Load(sender, e); } else { QLPhongHoc_Load(sender, e); } }
private void btnReload_Click(object sender, EventArgs e) { if (k == 1) { try { if (t == 1) { XepThoiKhoaBieuEntities et = new XepThoiKhoaBieuEntities(); Ban b = new Ban(); b.MaBan = Int32.Parse(txtMaBan.Text); b.TenBan = txtTenBan.Text; et.Entry(b).State = EntityState.Added; et.SaveChanges(); MessageBox.Show("Thêm thành công!"); } else { XepThoiKhoaBieuEntities et = new XepThoiKhoaBieuEntities(); Ban bnew = new Ban(); bnew.MaBan = Int32.Parse(txtMaBan.Text); bnew.TenBan = txtTenBan.Text; et.Entry(bnew).State = EntityState.Modified; et.SaveChanges(); MessageBox.Show("Sửa thành công!"); } } catch (Exception ex) { MessageBox.Show("Lỗi " + ex.Message); } QLBan_Load(sender, e); } else { QLBan_Load(sender, e); } }
private void btnXoaLop_Click(object sender, EventArgs e) { if (btnXoaLop.Enabled == true) { DialogResult r = MessageBox.Show(null, "Bạn có chắc xóa lớp " + txtTenLH.Text + " không!", "Cân nhắc", MessageBoxButtons.YesNo); if (r == DialogResult.Yes) { try { XepThoiKhoaBieuEntities et = new XepThoiKhoaBieuEntities(); Lop lop = new Lop(); lop.MaLop = Int32.Parse(txtMaLH.Text); et.Entry(lop).State = EntityState.Deleted; et.SaveChanges(); MessageBox.Show("Đã xóa!"); } catch (Exception ex) { MessageBox.Show("Lỗi " + ex.Message); } QLLop_Load(sender, e); } } }
private void btnReload_Click(object sender, EventArgs e) { if (k == 1) { try { if (t == 1) { XepThoiKhoaBieuEntities et = new XepThoiKhoaBieuEntities(); MonHoc mh = new MonHoc(); mh.MaMH = Int32.Parse(txtMaMH.Text); mh.TenMH = txtTenMH.Text; et.Entry(mh).State = EntityState.Added; et.SaveChanges(); } else { XepThoiKhoaBieuEntities et = new XepThoiKhoaBieuEntities(); MonHoc mh = new MonHoc(); mh.MaMH = Int32.Parse(txtMaMH.Text); mh.TenMH = txtTenMH.Text; et.Entry(mh).State = EntityState.Modified; et.SaveChanges(); } } catch (Exception ex) { MessageBox.Show("Lỗi " + ex.Message); } QLMonHoc_Load(sender, e); } else { QLMonHoc_Load(sender, e); } }