// 1 class nữa #endregion #endregion #region MH private void btnLuu_MH_Click(object sender, EventArgs e) { if (flag == "thêm") { DTO_mh.MonHoc_MaMonHoc = txtMaMH.Text; DTO_mh.MonHoc_TenMonHoc = txtTenMh.Text; DTO_mh.MonHoc_MaKhoa = cmbMaKhoa_MH.SelectedValue.ToString(); DTO_mh.MonHoc_TinChiLyThuyet = (int)numSoTietLT.Value; DTO_mh.MonHoc_TinChiThucHanh = (int)numSoTietTH.Value; bool hinhthuc = false; if (rdMonbatbuoc.Checked == true) { hinhthuc = true; } else if (rdMontuchon.Checked == true) { hinhthuc = false; } DTO_mh.MonHoc_LoaiMonHoc = hinhthuc; BUS_mh.ThemMonHoc(DTO_mh.MonHoc_MaMonHoc, DTO_mh.MonHoc_TenMonHoc, DTO_mh.MonHoc_LoaiMonHoc, DTO_mh.MonHoc_TinChiLyThuyet, DTO_mh.MonHoc_TinChiThucHanh, DTO_mh.MonHoc_MaKhoa); dgvMonhoc.DataSource = BUS_mh.LoadDLMonHoc(); BUS_xuly.ClearAllTextBox(groupBox3); int i; for (i = 0; i < dgvMonhoc.RowCount - 1; i++) { if (dgvMonhoc.Rows[i].Cells[1].Value.ToString() == dgvMonhoc.Text) { break; } } dgvMonhoc.CurrentCell = dgvMonhoc[0, i]; DisEnable_MH(); dgvMonhoc.Enabled = true; btnSua_MH.Enabled = true; btnCancel_MH.Enabled = true; btnThem_MH.Visible = true; } else if (flag == "sửa") { DTO_mh.MonHoc_MaMonHoc = txtMaMH.Text; DTO_mh.MonHoc_TenMonHoc = txtTenMh.Text; DTO_mh.MonHoc_MaKhoa = cmbMaKhoa_MH.SelectedValue.ToString(); DTO_mh.MonHoc_TinChiLyThuyet = (int)numSoTietLT.Value; DTO_mh.MonHoc_TinChiThucHanh = (int)numSoTietTH.Value; bool hinhthuc = false; if (rdMonbatbuoc.Checked == true) { hinhthuc = true; } else if (rdMontuchon.Checked == true) { hinhthuc = false; } DTO_mh.MonHoc_LoaiMonHoc = hinhthuc; BUS_mh.CapNhatMonHoc(DTO_mh.MonHoc_MaMonHoc, DTO_mh.MonHoc_TenMonHoc, DTO_mh.MonHoc_LoaiMonHoc, DTO_mh.MonHoc_TinChiLyThuyet, DTO_mh.MonHoc_TinChiThucHanh, DTO_mh.MonHoc_MaKhoa); dgvMonhoc.DataSource = BUS_mh.LoadDLMonHoc(); BUS_xuly.ClearAllTextBox(groupBox3); int i; for (i = 0; i < dgvMonhoc.RowCount - 1; i++) { if (dgvMonhoc.Rows[i].Cells[1].Value.ToString() == dgvMonhoc.Text) { break; } } dgvMonhoc.CurrentCell = dgvMonhoc[0, i]; DisEnable_MH(); dgvMonhoc.Enabled = true; btnSua_MH.Enabled = true; btnCancel_MH.Enabled = true; btnThem_MH.Visible = true; } }