Đề tài Quản lý giảng dạy của giảng viên tại trường Đại học Công Nghiệp Hà Nội

Trong Solution QLGD, thêm 1 Form Timkiem, dùng Label, ComboBox, TabControl, DataGirdView, Button, GroupBox, Textbox tạo đƣợc giao diện:

pdf89 trang | Chia sẻ: lylyngoc | Lượt xem: 2553 | Lượt tải: 1download
Bạn đang xem trước 20 trang tài liệu Đề tài Quản lý giảng dạy của giảng viên tại trường Đại học Công Nghiệp Hà Nội, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
, Textbox, Label, Groupbox, DatagirdView: Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 44 Trong Form Main, tại Menu Nhập liệu -> Khoa, double click viết code load Form DsKhoa lên: private void khoaToolStripMenuItem_Click(object sender, EventArgs e) { dsKhoa f1 = new dsKhoa(); f1.Show(); } - Code load dữ liệu lên DataGirdView: private void dsKhoa_Load(object sender, EventArgs e) { dataGridView1.DataSource = bslg.laydsKhoa(); btnThem.Enabled = false; txtMakhoa.Enabled = false; } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { btnThem.Enabled = false; txtMakhoa.Enabled = false; } private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != dataGridView1.Rows.Count - 1) Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 45 { txtMakhoa.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); txtTenKhoa.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); } } - Các Button: Thêm khoa, Sửa, Ghi, Xóa, Thoát: private void btnThem_Click(object sender, EventArgs e) { try { bslg.themKhoa(txtMakhoa.Text, txtTenKhoa.Text); dsKhoa_Load(sender, e); MessageBox.Show("Thêm mới thành công!"); } catch (Exception ec) { MessageBox.Show("Có lỗi xảy ra:" + ec + ".\nThêm mới thất bại"); } } private void btnSua_Click(object sender, EventArgs e) { try { bslg.suaKhoa(txtMakhoa.Text, txtTenKhoa.Text); dsKhoa_Load(sender, e); MessageBox.Show("Cập nhật dữ liệu thành công!"); } catch (Exception ec) { MessageBox.Show("Có lỗi xảy ra: "+ec+"\n Cập nhật thất bại!"); } } private void btnXoa_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn thật sự muốn xóa khoa này?") == DialogResult.OK) { bslg.xoaKhoa(txtMakhoa.Text); dsKhoa_Load(sender, e); } } private void btnThoat_Click(object sender, EventArgs e) { txtMakhoa.ResetText(); txtTenKhoa.ResetText(); btnThem.Enabled = true; txtMakhoa.Enabled = true; } private void button1_Click(object sender, EventArgs e) { Close(); } Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 46  Button Ghi bị ẩn khi load Form lên, sau khi click vào Thêm Khoa thì mới hiển thị để ngƣời dùng thêm Khoa vào Cơ sở dữ liệu. - Trong Lớp Bussiness viết code tạo các truy vấn dữ liệu cho Form Khoa: public DataTable laydsKhoa() { string sql = "SELECT * FROM KHOA"; return condata.getTable(sql); } public void themKhoa(string makhoa,string tenkhoa) { condata.truyvan("INSERT INTO KHOA VALUES('"+makhoa+"',N'"+tenkhoa+"')"); } public void suaKhoa(string makhoa, string tenkhoa) { condata.truyvan("UPDATE KHOA SET tenKhoa=N'"+tenkhoa+"' WHERE maKhoa='"+makhoa+"'"); } public void xoaKhoa(string makhoa) { condata.truyvan("DELETE FROM KHOA WHERE maKhoa='"+makhoa+"'"); } Làm tƣơng tự với các Form của Ngành, Tổ môn, Chƣơng trình đào tạo, Phân công giảng dạy, Lớp, Môn học, Hồ sơ giảng viên, Khóa đào tạo. Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 47 b) Form Ngành +) Code cho các sự kiện trong Form: public partial class dsNganh : Form { public dsNganh() { InitializeComponent(); } BussinessLogic bslg = new BussinessLogic(); string dh = "False"; string cd = "False"; string tc = "False"; string trc = "False"; string nghe = "False"; public void kiemtra() { if (cbbDTDH.Checked) dh = "True"; else dh = "False"; if (cbbDTCD.Checked) cd = "True"; else cd = "False"; if (txtDTTC.Checked) tc = "True"; else tc = "False"; if (cbbDTTrC.Checked) trc = "True"; else trc = "False"; if (cbbDTNghe.Checked) nghe = "True"; else nghe = "False"; } private void dsNganh_Load(object sender, EventArgs e) { dataGridView1.DataSource = bslg.laydsNganh(); txtManganh.Enabled = false; btnThem.Enabled = false; cbbMakhoa.DataSource = bslg.maKhoa(); cbbMakhoa.DisplayMember = "maKhoa"; cbbMakhoa.ValueMember = "maKhoa"; } private void btnThem_Click(object sender, EventArgs e) { kiemtra(); if (txtManganh.Text != "") Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 48 { bslg.themNganh(txtManganh.Text, cbbMakhoa.Text, txtTenNganh.Text, dh,cd,tc,trc,nghe ); dsNganh_Load(sender, e); } } private void btnSua_Click(object sender, EventArgs e) { kiemtra(); try { bslg.suaNganh(txtManganh.Text, cbbMakhoa.Text, txtTenNganh.Text, dh, cd, tc, trc, nghe); dsNganh_Load(sender, e); MessageBox.Show("Cập nhật thành công!"); } catch (Exception ec) { MessageBox.Show("Có lỗi:\n" + ec + "\n\nCập nhật thất bại!"); } } private void btnXoa_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn thật sự muốn xóa?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { bslg.xoaNganh(txtManganh.Text); dsNganh_Load(sender, e); } } private void btnThoat_Click(object sender, EventArgs e) { this.Close(); } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { txtManganh.Enabled = false; btnThem.Enabled = false; } private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != dataGridView1.Rows.Count - 1) { txtManganh.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); txtTenNganh.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); cbbMakhoa.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); if (dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString() == "True") cbbDTDH.Checked = true; else cbbDTDH.Checked = false; if (dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString() == "True") cbbDTCD.Checked = true; else cbbDTCD.Checked = false; Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 49 if (dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString() == "True") txtDTTC.Checked = true; else txtDTTC.Checked = false; if (dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString() == "True") cbbDTTrC.Checked = true; else cbbDTTrC.Checked = false; if (dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString() == "True") cbbDTNghe.Checked = true; else cbbDTNghe.Checked = false; } } private void btnThemmoi_Click(object sender, EventArgs e) { cbbMakhoa.DataSource = bslg.maKhoa(); cbbMakhoa.DisplayMember = "KHOA"; cbbMakhoa.ValueMember = "maKhoa"; txtManganh.Enabled = true; btnThem.Enabled = true; txtManganh.ResetText(); txtTenNganh.ResetText(); cbbMakhoa.ResetText(); } +) Các câu truy vấn trong Form( Trong lớp BussinessLogicLayer): public DataTable laydsNganh() { string sql = "SELECT * FROM NGANH"; return condata.getTable(sql); } public void themNganh(string manganh,string makhoa,string tennganh,string daotaodh, string daotaocd, string daotaotc, string daotaotrc, string daotaonghe) { condata.truyvan("INSERT INTO NGANH VALUES('" + manganh + "','" + makhoa + "',N'" + tennganh + "'," +"'" + daotaodh + "','" + daotaocd + "','"+daotaotc+"','" + daotaotrc + "','" + daotaonghe + "')"); } public void suaNganh(string manganh, string makhoa, string tennganh, string daotaodh, string daotaocd,string daotaotc, string daotaotrc,string daotaonghe) { condata.truyvan("UPDATE NGANH SET maKhoa='" + makhoa + "',tenNganh=N'" + tennganh + "'," + "daotaoDH='" + daotaodh + "',daotaoCD='" + daotaocd + "',daotaoTC='"+daotaotc+"'," +"daotaoTrC='" + daotaotrc + "',daotaoNGHE='" + daotaonghe + "' WHERE maNganh='" + manganh + "'"); } public void xoaNganh(string manganh) Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 50 { condata.truyvan("DELETE FROM NGANH WHERE maNganh='"+manganh+"'"); } c) Form Tổ môn +) Code cho các sự kiện trong Form: public partial class dsToMon : Form { public dsToMon() { InitializeComponent(); } BussinessLogic bslg = new BussinessLogic(); private void btnThem_Click(object sender, EventArgs e) { if (txtMatomon.Text != null && cbbMaKhoa.Text != null) { try { bslg.themToMon(txtMatomon.Text, txtTentomon.Text, cbbMaKhoa.Text, txtSoSV.Text); Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 51 dsToMon_Load(sender, e); MessageBox.Show("Thêm mới thành công!"); } catch (Exception ec) { MessageBox.Show("Có lỗi:\n" + ec + "\n\n Thêm mới thất bại!"); } } } private void dsToMon_Load(object sender, EventArgs e) { dataGridView1.DataSource = bslg.laydsTOMON(); cbbMaKhoa.DataSource = bslg.maKhoa(); cbbMaKhoa.DisplayMember = "maKhoa"; cbbMaKhoa.ValueMember = "maKhoa"; txtMatomon.Enabled = false; btnThem.Enabled = false; } private void btnThemmoi_Click(object sender, EventArgs e) { txtMatomon.Enabled = true; btnThem.Enabled = true; } private void btnSua_Click(object sender, EventArgs e) { if (txtMatomon.Text != null && cbbMaKhoa.Text != null) { try { bslg.suaToMon(txtMatomon.Text, txtTentomon.Text, cbbMaKhoa.Text, txtSoSV.Text); dsToMon_Load(sender, e); MessageBox.Show("Cập nhật thành công!"); } catch (Exception ec) { MessageBox.Show("Có lỗi:\n" + ec + "\n\n Cập nhật thất bại!"); } } } private void btnXoa_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn thật sự muốn xóa?","",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning) == DialogResult.OK) { bslg.xoaToMon(txtMatomon.Text); dsToMon_Load(sender, e); } } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { txtMatomon.Enabled = false; Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 52 btnThem.Enabled = false; } private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e) { if(e.RowIndex!=dataGridView1.Rows.Count-1) { txtMatomon.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); txtTentomon.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); txtSoSV.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); cbbMaKhoa.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); } } private void btnThoat_Click(object sender, EventArgs e) { Close(); } } +) Các câu truy vấn trong Form: public DataTable laydsTOMON() { return condata.getTable("SELECT * FROM TOMON"); } public void themToMon(string matomon,string tenTomon,string maKhoa,string soGV) { condata.truyvan("INSERT INTO TOMON VALUES('"+matomon+"',N'"+tenTomon+"','"+soGV+"','"+maKhoa+"')"); } public void suaToMon(string matomon, string tenTomon, string maKhoa, string soGV) { condata.truyvan("UPDATE TOMON SET tenToMon=N'" + tenTomon + "',soGV='" + soGV + "',maKhoa='" + maKhoa + "' WHERE maToMon='"+matomon+"'"); } public void xoaToMon(string matomon) { condata.truyvan("DELETE FROM TOMON WHERE maToMon='"+matomon+"'"); } d) Chương trình đào tạo Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 53 +) Code cho các sự kiện trong Form: public partial class DsChuogtrinhDT : Form { public DsChuogtrinhDT() { InitializeComponent(); } BussinessLogic bslg = new BussinessLogic(); private void DsChuogtrinhDT_Load(object sender, EventArgs e) { txtMaHocphan.Enabled = false; btnGhi.Enabled = false; dataGridView1.DataSource = bslg.laydsCTDT(); txtmaKhoaDT.DataSource = bslg.maKhoaDT(); txtmaKhoaDT.DisplayMember = "KHOADAOTAO"; txtmaKhoaDT.ValueMember = "maKhoaDT"; txtMaMon.DataSource = bslg.maMon(); txtMaMon.DisplayMember = "MONHOC"; txtMaMon.ValueMember = "maMon"; } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { txtMaHocphan.Enabled = false; btnGhi.Enabled = false; } private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != dataGridView1.Rows.Count - 1) Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 54 { txtMaHocphan.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); txtmaKhoaDT.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); txtMaMon.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); txtsoTinChi.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); txtSoTCLT.Text = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); txtsoTCTH.Text = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString(); txthocKy.Text = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString(); } } private void btnThemmoi_Click(object sender, EventArgs e) { btnGhi.Enabled = true; txtMaHocphan.Enabled = true; } private void btnGhi_Click(object sender, EventArgs e) { try { bslg.themCTDT(txtMaHocphan.Text, txtmaKhoaDT.Text, txtMaMon.Text, txtsoTinChi.Text, txtSoTCLT.Text, txtsoTCTH.Text, txthocKy.Text); DsChuogtrinhDT_Load(sender, e); MessageBox.Show("Thêm mới thành công!"); } catch (Exception ec) { MessageBox.Show("Có lỗi xảy ra: "+ec+". Thêm mới thất bại!","",MessageBoxButtons.OK,MessageBoxIcon.Error); } } private void btnSua_Click(object sender, EventArgs e) { try { bslg.suaCTDT(txtMaHocphan.Text, txtmaKhoaDT.Text, txtMaMon.Text, txtsoTinChi.Text, txtSoTCLT.Text, txtsoTCTH.Text, txthocKy.Text); DsChuogtrinhDT_Load(sender, e); MessageBox.Show("Cập nhật dữ liệu thành công!"); } catch (Exception ec) { MessageBox.Show("Có lỗi xảy ra: " + ec + ". Cập nhật thất bại!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void btnXoa_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn thật sự muốn xóa?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 55 { bslg.xoaCTDT(txtMaHocphan.Text); DsChuogtrinhDT_Load(sender, e); } } private void buttonThoat_Click(object sender, EventArgs e) { this.Close(); } } +) Các câu truy vấn trong Form: public DataTable laydsCTDT() { return condata.getTable("SELECT * FROM CTDT"); } public void themCTDT(string maHocPhan,string maKhoaDT,string maMon,string soTinChi,string soTCLT,string soTCTH,string hocky) { condata.truyvan("INSERT INTO CTDT VALUES ('"+maHocPhan+"','"+maKhoaDT+"','"+maMon+"','"+soTinChi+"','"+soTCLT+"','"+ soTCTH+"','"+hocky+"')"); } public void suaCTDT(string maHocPhan, string maKhoaDT, string maMon, string soTinChi, string soTCLT, string soTCTH,string hocky) { condata.truyvan("update CTDT set maKhoaDT='" + maKhoaDT + "',maMon='" + maMon + "',soTinChi='" + soTinChi + "',soTCLT='" + soTCLT + "',soTCTH='" + soTCTH + "',hocKy='"+hocky+"' WHERE maHocPhan='"+maHocPhan+"'"); } public void xoaCTDT(string maHP) { condata.truyvan("delete from CTDT where maHocPhan='" + maHP + "'"); } Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 56 e) Phân công giảng dạy +) Code cho các sự kiện trong Form: public partial class dsPhanCongGD : Form { public dsPhanCongGD() { InitializeComponent(); } BussinessLogic bslg = new BussinessLogic(); private void dsPhanCongGD_Load(object sender, EventArgs e) { dataGridView1.DataSource = bslg.laydsPCGD(); btnThem.Enabled = false; txtMaPCGD.Enabled = false; txtMaLop.DataSource = bslg.maLop(); txtMaLop.DisplayMember = "LOP"; txtMaLop.ValueMember = "maLop"; txtMaGV.DataSource = bslg.maGV(); txtMaGV.DisplayMember = "HOSOGV"; txtMaGV.ValueMember = "maGV"; txtMahocphan.DataSource = bslg.maHocPhan(); txtMahocphan.DisplayMember = "CTDT"; txtMahocphan.ValueMember = "maHocPhan"; txtMaPhong.DataSource = bslg.maPhong(); txtMaPhong.DisplayMember = "PHONGHOC"; Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 57 txtMaPhong.ValueMember = "maPhong"; } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { btnThem.Enabled = false; txtMaPCGD.Enabled = false; } private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != dataGridView1.Rows.Count - 1) { txtMaPCGD.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); txtMaLop.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); txtMaGV.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); txtMahocphan.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); txtNgaybatdau.Text = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); txtNgayketthuc.Text = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString(); txtBuoiday.Text = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString(); txtMaPhong.Text = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString(); } } private void btnThemmoi_Click(object sender, EventArgs e) { btnThem.Enabled = true; txtMaPCGD.Enabled = true; } private void btnThem_Click(object sender, EventArgs e) { try { bslg.themPCGD(txtMaPCGD.Text, txtMaLop.Text, txtMaGV.Text, txtMahocphan.Text, txtNgaybatdau.Text, txtNgayketthuc.Text, txtBuoiday.Text, txtMaPhong.Text); dsPhanCongGD_Load(sender, e); MessageBox.Show("Thêm mới thành công!"); } catch (Exception ex) { MessageBox.Show("Có lỗi xảy ra: " + ex + " thêm mới thất bại"); } } private void btnSua_Click(object sender, EventArgs e) { try { bslg.suaPCGD(txtMaPCGD.Text, txtMaLop.Text, txtMaGV.Text, Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 58 txtMahocphan.Text, txtNgaybatdau.Text, txtNgayketthuc.Text, txtBuoiday.Text, txtMaPhong.Text); dsPhanCongGD_Load(sender, e); MessageBox.Show("Cập nhật thành công!"); } catch (Exception ec) { MessageBox.Show("Có lỗi xảy ra: "+ec+" cập thất bại!"); } } private void btnXoa_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn thật sự muốn xóa phân công này?")==DialogResult.OK) { bslg.xoaPCGD(txtMaPCGD.Text); dsPhanCongGD_Load(sender, e); } } private void btnThoat_Click(object sender, EventArgs e) { Close(); } } +) Các câu truy vấn trong Form: public DataTable laydsPCGD() { return condata.getTable("SELECT * FROM PCGD"); } public void themPCGD(string maPCGD,string maLop,string maGV,string mahocphan,string ngaybatdau,string ngayketthuc,string buoi,string maPhong) { condata.truyvan("INSERT INTO PCGD VALUES('"+maPCGD+"','"+maLop+"','"+maGV+"','"+mahocphan+"','"+ngaybatdau+"' ,'"+ngayketthuc+"',N'"+buoi+"','"+maPhong+"')"); } public void suaPCGD(string maPCGD, string maLop, string maGV, string mahocphan, string ngaybatdau, string ngayketthuc, string buoi,string maPhong) { condata.truyvan("UPDATE PCGD SET maLop='" + maLop + "',maHocPhan='" + mahocphan + "',maGV='"+maGV+"',ngayBatdau='"+ngaybatdau+"',ngayKetthuc='"+ngayketthuc+" ',tietDay=N'"+buoi+"',maPhong='"+maPhong+"' where maPCGD='"+maPCGD+"'"); } public void xoaPCGD(string maPCGD) { condata.truyvan("DELETE FROM PCGD WHERE maPCGD='"+maPCGD+"'"); } Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 59 f) Lớp +) Code cho các sự kiện trong Form: public partial class dsLop : Form { public dsLop() { InitializeComponent(); } BussinessLogic bslg = new BussinessLogic(); private void dsLop_Load(object sender, EventArgs e) { btnThemlop.Enabled = false; txtMalop.Enabled = false; dataGridView1.DataSource = bslg.laydsLop(); txtMakhoaDT.DataSource = bslg.maKhoaDT(); txtMakhoaDT.DisplayMember = "KHOADAOTAO"; txtMakhoaDT.ValueMember = "maKhoaDT"; } private void btnThemlop_Click(object sender, EventArgs e) { try { bslg.themLop(txtMalop.Text, txtTenLop.Text, txtMakhoaDT.Text, txtsoSV.Text); dsLop_Load(sender, e); MessageBox.Show("Thêm mới thành công!"); } Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 60 catch (Exception ec) { MessageBox.Show("Có lỗi: "+ec+"\nThêm mới thất bại!"); } } private void btnSuaLop_Click(object sender, EventArgs e) { try { bslg.sualop(txtMalop.Text, txtTenLop.Text, txtMakhoaDT.Text, txtsoSV.Text); dsLop_Load(sender, e); MessageBox.Show("Cập nhật thành công!"); } catch (Exception ec) { MessageBox.Show("Có lỗi: "+ec+"\n Thêm mới thất bại!"); } } private void btnXoalop_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn thật sự muốn xóa!") == DialogResult.OK) { bslg.xoalop(txtMalop.Text); dsLop_Load(sender, e); } } private void btnThemmoi_Click(object sender, EventArgs e) { txtMalop.Enabled = true; btnThemlop.Enabled = true; } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { btnThemlop.Enabled = false; txtMalop.Enabled = false; } private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != dataGridView1.Rows.Count - 1) { txtMalop.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); txtTenLop.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); txtMakhoaDT.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); txtsoSV.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); } } private void button1_Click(object sender, EventArgs e) { Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 61 Close(); } } +) Các câu truy vấn trong Form: public DataTable laydsLop() { string sql = "SELECT * FROM LOP"; return condata.getTable(sql); } public DataTable timLop(string timtheo,string tukhoa) { return condata.getTable("SELECT * FROM LOP WHERE "+timtheo+"=N'"+tukhoa+"'"); } public void themLop(string malop,string tenlop,string makhoadt,string sosv) { condata.truyvan("INSERT INTO LOP VALUES('"+malop+"',N'"+tenlop+"','"+makhoadt+"','"+sosv+"')"); } public void sualop(string malop, string tenlop, string makhoadt, string sosv) { condata.truyvan("UPDATE LOP SET tenLop=N'" + tenlop + "',maKhoaDT='" + makhoadt + "',soSV='" + sosv + "' where maLop='" + malop + "'"); } public void xoalop(string malop) { condata.truyvan("DELETE FROM LOP WHERE maLop='"+malop+"'"); } Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 62 g) Môn học +) Code cho các sự kiện trong Form: public partial class dsMonhoc : Form { public dsMonhoc() { InitializeComponent(); } BussinessLogic bslg = new BussinessLogic(); private void dsMonhoc_Load(object sender, EventArgs e) { dataGridView1.DataSource = bslg.laydsMonHoc(); btnThemmon.Enabled = false; txtMamon.Enabled = false; } private void btnThemmon_Click(object sender, EventArgs e) { if (txtMamon.Text != null && txtTenmon.Text != null) { try { bslg.themMonhoc(txtMamon.Text, txtTenmon.Text); dsMonhoc_Load(sender, e); MessageBox.Show("Thêm mới thành công!"); } Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 63 catch (Exception ec) { MessageBox.Show("Lỗi:\n" + ec + "Thêm mới thất bại"); } } else MessageBox.Show("Bạn phải điền đầy đủ thông tin!"); } private void btnsuamon_Click(object sender, EventArgs e) { if (txtMamon.Text != null && txtTenmon.Text != null) { try { bslg.suaMonhoc(txtMamon.Text, txtTenmon.Text); dsMonhoc_Load(sender, e); MessageBox.Show("Thêm mới thành công!"); } catch (Exception ec) { MessageBox.Show("Lỗi:\n" + ec ); } } else MessageBox.Show("Bạn phải điền đầy đủ thông tin!"); } private void btnxoamon_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn thật sự muôn xóa?", "", MessageBoxButtons.OKCancel) == DialogResult.OK) { bslg.xoaMonhoc(txtMamon.Text); dsMonhoc_Load(sender, e); } } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { btnThemmon.Enabled = false; txtMamon.Enabled = false; } private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != dataGridView1.Rows.Count - 1) { txtMamon.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); txtTenmon.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); } } private void btnThemmoi_Click(object sender, EventArgs e) { btnThemmon.Enabled = true; txtMamon.Enabled = true; } Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 64 private void btnThoat_Click(object sender, EventArgs e) { Close(); } } +) Các câu truy vấn trong Form: public DataTable laydsMonHoc() { string sql = "SELECT * FROM MONHOC"; return condata.getTable(sql); } public DataTable timMonhoc(string timtheo,string tukhoa) { return condata.getTable("SELECT * FROM MONHOC WHERE "+timtheo+"=N'"+tukhoa+"' "); } public void themMonhoc(string mamon, string tenmon) { condata.truyvan("insert into MONHOC values('" + mamon + "',N'" + tenmon + "')"); } public void suaMonhoc(string mamon, string tenmon) { condata.truyvan("UPDATE MONHOC SET tenMon=N'" + tenmon + "' where maMon='"+mamon+"'"); } public void xoaMonhoc(string mamon) { condata.truyvan("DELETE FROM MONHOC WHERE maMon='" + mamon + "'"); } Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 65 h) Hồ sơ giảng viên +) Code cho các sự kiện trong Form: public partial class dsGV : Form { public dsGV() { InitializeComponent(); } BussinessLogic bslg = new BussinessLogic(); private void dsGV_Load(object sender, EventArgs e) { dataGridView1.DataSource = bslg.laydsGV(); txtmaTomon.DataSource = bslg.maTomon(); txtmaTomon.DisplayMember = "TOMON"; txtmaTomon.ValueMember = "maToMon"; txtMaGV.Enabled = false; btnThem.Enabled = false; } private void btnThem_Click(object sender, EventArgs e) { if (txtMaGV.Text != "" && txtHoGV.Text != "" && txtTen.Text != "" && txtmaTomon.Text != "") { try { bslg.themGV(txtMaGV.Text, txtHoGV.Text, txtTen.Text, txtChucdanh.Text, txtChucVu.Text, txtNgaySinh.Text, txtGioiTinh.Text, txtDienThoai.Text, txtmaTomon.Text, txtDiaChi.Text); Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 66 dsGV_Load(sender, e); MessageBox.Show("Thêm mới thành công!"); } catch (Exception ec) { MessageBox.Show("Lỗi:\n" + ec); } } else MessageBox.Show("Bạn chưa điền đầy đủ thông tin!"); } private void btnSua_Click(object sender, EventArgs e) { try { bslg.suaGV(txtMaGV.Text, txtHoGV.Text, txtTen.Text, txtChucdanh.Text, txtChucVu.Text, txtNgaySinh.Text, txtGioiTinh.Text, txtDienThoai.Text, txtmaTomon.Text, txtDiaChi.Text); dsGV_Load(sender, e); MessageBox.Show("Cập nhật thành công!"); } catch (Exception ec) { MessageBox.Show("Lỗi:\n" + ec); } } private void btnXoa_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn thật sự muốn xóa?") == DialogResult.OK) { bslg.xoaGV(txtMaGV.Text); dsGV_Load(sender, e); } } private void btnThemmoi_Click(object sender, EventArgs e) { txtMaGV.Enabled = true; btnThem.Enabled = true; txtHoGV.ResetText(); txtTen.ResetText(); txtNgaySinh.ResetText(); txtGioiTinh.ResetText(); txtChucVu.ResetText(); txtChucdanh.ResetText(); txtDienThoai.ResetText(); txtMaGV.ResetText(); txtmaTomon.ResetText(); txtMaGV.Focus(); } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { txtMaGV.Enabled = false; btnThem.Enabled = false; } private void dataGridView1_RowEnter(object sender, Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 67 DataGridViewCellEventArgs e) { if(e.RowIndex!=dataGridView1.Rows.Count-1) { txtMaGV.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); txtHoGV.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); txtTen.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); txtNgaySinh.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); txtGioiTinh.Text = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); txtChucdanh.Text = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString(); txtDiaChi.Text = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString(); txtChucVu.Text = dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString(); txtDienThoai.Text = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString(); txtmaTomon.Text = dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString(); } } private void button1_Click(object sender, EventArgs e) { this.Close(); } } +) Các câu truy vấn trong Form: { string sql = "SELECT * FROM HSGV"; return condata.getTable(sql); } public void themGV(string magv,string hogv,string tengv,string chucDanh,string chucvu, string ngaysinh,string gioiting,string dienthoai,string matomon,string diachi) { condata.truyvan("INSERT INTO HSGV VALUES('" + magv + "',N'" + hogv + "',N'" + tengv + "'," + "N'" + ngaysinh + "',N'" + gioiting+ "',N'" + diachi + "',N'" + dienthoai + "'," +"N'" + chucDanh + "',N'"+chucvu+"','" + matomon + "')"); } public void suaGV(string magv, string hogv, string tengv, string chucdanh, string chucvu, string ngaysinh, string gioiting, string dienthoai,string matomon,string diachi) { condata.truyvan("UPDATE HSGV SET hoGV=N'" + hogv + "',tenGV=N'" + tengv + "'," +"chucDanh=N'"+chucdanh+"',chucVu=N'"+chucvu+"',ngaySinh='" + ngaysinh + Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 68 "'," +"gioiTinh=N'" + gioiting + "',diaChi=N'"+diachi+"',dienThoai='" + dienthoai + "',maTomon='"+matomon+"'" +"where maGV='"+magv+"'"); } public void xoaGV(string magv) { condata.truyvan("DELETE FROM HSGV WHERE maGV='"+magv+"'"); } i) Khóa đào tạo +) Code cho các sự kiện trong Form: public partial class dsKhoadaotao : Form { public dsKhoadaotao() { InitializeComponent(); } BussinessLogic bslg = new BussinessLogic(); private void dsKhoadaotao_Load(object sender, EventArgs e) { txtMaKhoaDT.Enabled = false; btnThem.Enabled = false; dataGridView1.DataSource = bslg.laydsKhoaDT(); cbbMaNganh.DataSource = bslg.maNganh(); cbbMaNganh.DisplayMember = "NGANH"; cbbMaNganh.ValueMember = "maNganh"; } private void btnThemmoi_Click(object sender, EventArgs e) { Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 69 txtMaKhoaDT.Enabled = true; btnThem.Enabled = true; } private void btnThem_Click(object sender, EventArgs e) { try { bslg.themKhoaDT(txtMaKhoaDT.Text, txtTenKhoaDT.Text, txtNamnhap.Text, txtSoNamDT.Text, cbbMaNganh.Text); dsKhoadaotao_Load(sender, e); MessageBox.Show("Thêm mới thành công!"); } catch (Exception ec) { MessageBox.Show("Có lỗi xảy ra: "+ec+"\nThêm mới thất bại!"); } } private void btnSua_Click(object sender, EventArgs e) { try { bslg.suaKhoaDT(txtMaKhoaDT.Text, txtTenKhoaDT.Text, txtNamnhap.Text, txtSoNamDT.Text, cbbMaNganh.Text); dsKhoadaotao_Load(sender, e); MessageBox.Show("Cập nhật thành công!"); } catch (Exception ec) { MessageBox.Show("Có lỗi xảy ra: " + ec + "\nCập nhật thất bại"); } } private void btnXoa_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn thậ sự muốn xóa?") == DialogResult.OK) { bslg.xoaKhoaDT(txtMaKhoaDT.Text); dsKhoadaotao_Load(sender, e); } } private void btnThoat_Click(object sender, EventArgs e) { this.Close(); } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { txtMaKhoaDT.Enabled = false; btnThem.Enabled = false; } private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != dataGridView1.Rows.Count - 1) { txtMaKhoaDT.Text = Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 70 dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); txtTenKhoaDT.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); txtNamnhap.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); txtSoNamDT.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); cbbMaNganh.Text = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); } } } +) Các câu truy vấn trong Form: public DataTable laydsCTDT() { return condata.getTable("SELECT * FROM CTDT"); } public void themCTDT(string maHocPhan,string maKhoaDT,string maMon,string soTinChi,string soTCLT,string soTCTH,string hocky) { condata.truyvan("INSERT INTO CTDT VALUES ('"+maHocPhan+"','"+maKhoaDT+"','"+maMon+"','"+soTinChi+"','"+soTCLT+"','"+ soTCTH+"','"+hocky+"')"); } public void suaCTDT(string maHocPhan, string maKhoaDT, string maMon, string soTinChi, string soTCLT, string soTCTH,string hocky) { condata.truyvan("update CTDT set maKhoaDT='" + maKhoaDT + "',maMon='" + maMon + "',soTinChi='" + soTinChi + "',soTCLT='" + soTCLT + "',soTCTH='" + soTCTH + "',hocKy='"+hocky+"' WHERE maHocPhan='"+maHocPhan+"'"); } public void xoaCTDT(string maHP) { condata.truyvan("delete from CTDT where maHocPhan='" + maHP + "'"); } Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 71 j) Giám sát giảng dạy +) Code cho các sự kiện trong Form: public partial class giamsatGD : Form { public giamsatGD() { InitializeComponent(); } BussinessLogic bslg = new BussinessLogic(); private void btnThem_Click(object sender, EventArgs e) { txtMaGV.Enabled = true; btnGhi.Enabled = true; } private void btnGhi_Click(object sender, EventArgs e) { try { bslg.themgiamsat(txtMaGV.Text, txtSoTietNghi.Text, txtNgayNghi.Text, txtSotietBu.Text, txtNgayBu.Text); giamsatGD_Load(sender, e); MessageBox.Show("Thêm mới thành công!"); } catch (Exception ec) { MessageBox.Show("Lỗi:\n" + ec + "\n Thêm mới thất bại"); } } Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 72 private void btnSua_Click(object sender, EventArgs e) { try { bslg.suagiamsat(txtMaGV.Text, txtSoTietNghi.Text, txtNgayNghi.Text, txtSotietBu.Text, txtNgayBu.Text); giamsatGD_Load(sender, e); MessageBox.Show("Cập nhật thành công!"); } catch (Exception ec) { MessageBox.Show("Lỗi:\n"+ec+"\n Cập nhật thất bại"); } } private void btnXoa_Click(object sender, EventArgs e) { if(MessageBox.Show("Bạn thật sự muốn xóa?","",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning)==DialogResult.O K) { bslg.xoagiamsat(txtMaGV.Text); } } private void button5_Click(object sender, EventArgs e) { Close(); } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { txtMaGV.Enabled = false; btnGhi.Enabled = false; } private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex!=dataGridView1.Rows.Count - 1) { txtMaGV.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); txtSoTietNghi.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); txtNgayNghi.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); txtSotietBu.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); txtNgayBu.Text = dataGridView1.Rows[e.RowIndex].Cells[04].Value.ToString(); } } private void giamsatGD_Load(object sender, EventArgs e) { txtMaGV.Enabled = false; btnGhi.Enabled = false; dataGridView1.DataSource = bslg.dsgiamsat(); txtMaGV.DataSource = bslg.maGV(); txtMaGV.DisplayMember = "HSGV"; Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 73 txtMaGV.ValueMember = "maGV"; } } +) Các câu truy vấn trong Form: public DataTable dsgiamsat() { return condata.getTable("SELECT * FROM giamsatgiangday"); } public void themgiamsat(string magv,string sotietnghi,string ngaynghi,string sotietbu,string ngaybu) { condata.truyvan("INSERT INTO giamsatgiangday Values ('"+magv+"','"+sotietnghi+"','"+ngaynghi+"','"+sotietbu+"','"+ngaybu+"')"); } public void suagiamsat(string magv, string sotietnghi, string ngaynghi, string sotietbu, string ngaybu) { condata.truyvan("UPDATE giamsatgiangday SET soTietnghi='" + sotietnghi + "',ngayNghi='" + ngaynghi + "',sotietbu='" + sotietbu + "',ngaybu='" + ngaybu + "' where magv='"+magv+"'"); } public void xoagiamsat(string magv) { condata.truyvan("DELETE FROM giamsatgiangday where magv='"+magv+"'"); } k) Danh sách phòng học Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 74 +) Code cho các sự kiện trong Form: public partial class dsPhonghoc : Form { public dsPhonghoc() { InitializeComponent(); } BussinessLogic bslg = new BussinessLogic(); private void btnThemmoi_Click(object sender, EventArgs e) { btnGhi.Enabled = true; txtMaPhong.Enabled = true; } private void btnGhi_Click(object sender, EventArgs e) { try { bslg.themPhong(txtMaPhong.Text, txtTenPhong.Text, txtSoban.Text, txtDiaDiem.Text); MessageBox.Show("Thêm mới phòng " + txtTenPhong.Text + " thành công"); dsPhonghoc_Load(sender, e); } catch(Exception ex) { MessageBox.Show(ex+"\nCó lỗi xảy ra. Thêm mới thất bại!"); } Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 75 } private void btnSua_Click(object sender, EventArgs e) { try { bslg.suaphong(txtMaPhong.Text, txtTenPhong.Text, txtSoban.Text, txtDiaDiem.Text); dsPhonghoc_Load(sender, e); } catch (Exception ex) { MessageBox.Show(ex+"\nCó lỗi xảy ra. Sửa dữ liệu thất bại!"); } } private void btnXoa_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn thật sự muốn xóa phòng: "+ txtTenPhong.Text+" khỏi danh sách?","Xác nhận",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning) == DialogResult.OK) { bslg.xoaPhong(txtMaPhong.Text); dsPhonghoc_Load(sender, e); } } private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { txtMaPhong.Enabled = false; btnGhi.Enabled = false; } private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e) { if(e.RowIndex!=dataGridView1.Rows.Count-1) { txtMaPhong.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); txtTenPhong.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); txtSoban.Text = dataGridView1.Rows[e.RowIndex].Cells[02].Value.ToString(); txtDiaDiem.Text = dataGridView1.Rows[e.RowIndex].Cells[03].Value.ToString(); } } private void dsPhonghoc_Load(object sender, EventArgs e) { dataGridView1.DataSource = bslg.dsPhonghoc(); txtMaPhong.Enabled = false; btnGhi.Enabled = false; } private void btnThoat_Click(object sender, EventArgs e) { Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 76 Close(); } } +) Các câu truy vấn trong Form: public DataTable dsPhonghoc() { return condata.getTable("SELECT * from PHONGHOC"); } public DataTable maPhong() { return condata.getTable("SELECT maPhong From PHONGHOC"); } public void themPhong(string maphong,string tenphong,string soban,string diadiem) { condata.truyvan("INSERT INTO PHONGHOC VALUES ('"+maphong+"',N'"+tenphong+"','"+soban+"','"+diadiem+"')"); } public void suaphong(string maphong, string tenphong, string soban, string diadiem) { condata.truyvan("UPDATE PHONGHOC SET tenPhong=N'"+tenphong+"',soBan='"+soban+"',diaDiem='"+diadiem+"' WHERE maPhong='"+maphong+"'"); } public void xoaPhong(string maphong) { condata.truyvan("DELETE FROM PHONGHOC WHERE maPhong='"+maphong+"'"); } 5. Thống kê, báo cáo Trong giao diện chính của chƣơng trình, tại Menu Thống kê, tạo các Menu con cho việc thống kê Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 77 a) Hồ sơ giảng viên Trong Solution QLGD, thêm Form Thống kê, dùng Tabcontrol, Label, Button, ComboBox, CrystalReportViewer, GroupBox tạo giao diện cho 4 Form tìm kiếm: +) Load dữ liệu lên các Form tìm kiếm: private void Report_Load(object sender, EventArgs e) { Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 78 txtMaGV.DataSource=bslg.maGV(); txtMaGV.DisplayMember = "HSGV"; txtMaGV.ValueMember = "maGV"; txtMaGV_KLGD.DataSource = bslg.maGV(); txtMaGV_KLGD.DisplayMember = "HSGV"; txtMaGV_KLGD.ValueMember = "maGV"; txtMaGV_PCGD.DataSource=bslg.maGV(); txtMaGV_PCGD.DisplayMember = "HSGV"; txtMaGV_PCGD.ValueMember = "maGV"; txtKhoa.DataSource = bslg.tenKhoa(); txtKhoa.DisplayMember = "KHOA"; txtKhoa.ValueMember = "tenKhoa"; txtNganh.DataSource = bslg.tenNganh(txtKhoa.Text); txtNganh.DisplayMember = "NGANH"; txtNganh.ValueMember = "tenNganh"; txtKhoahoc.DataSource = bslg.tenKhoaDT(txtNganh.Text); txtKhoahoc.DisplayMember = "KHOADAOTAO"; txtKhoahoc.ValueMember = "tenKhoaDT"; } +) Code cho các sự kiện public partial class Report : Form { public Report() { InitializeComponent(); } BussinessLogic bslg = new BussinessLogic(); string tenkhoa; string tenNganhHoc; string tenKhoaDaoTao; private void btnXem_Click(object sender, EventArgs e) { if (txtMaGV.Text != "") { try { HosoGV rp = new HosoGV(); rp.SetDataSource(bslg.hosoGV(txtMaGV.Text)); crystalReportViewer1.ReportSource = rp; crystalReportViewer1.RefreshReport(); } catch (Exception ec) { MessageBox.Show("Lỗi: "+ec+"\n Xem thống kê thất bại!"); } } } private void btnXemCTDt_Click(object sender, EventArgs e) { if (txtKhoa.Text != ""&&txtNganh.Text!=""&&txtKhoahoc.Text!="") Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 79 { try { tenkhoa = txtKhoa.Text; tenNganhHoc = txtNganh.Text; tenKhoaDaoTao = txtKhoahoc.Text; ChuongtrinhDT rp = new ChuongtrinhDT(); rp.SetDataSource(bslg.chuongTrinhDT(tenkhoa, tenNganhHoc, tenKhoaDaoTao)); crystalReportViewer2.ReportSource = rp; crystalReportViewer2.RefreshReport(); } catch (Exception ec) { MessageBox.Show("Lỗi: " + ec + "\n Xem thống kê thất bại!"); } } } private void btnThoat1_Click(object sender, EventArgs e) { Close(); } private void btnThoat2_Click(object sender, EventArgs e) { Close(); } private void btnThoat3_Click(object sender, EventArgs e) { Close(); } private void btnXemPCGD_Click(object sender, EventArgs e) { if (txtMaGV_PCGD.Text != "") { try { phanconggiangday rp = new phanconggiangday(); rp.SetDataSource(bslg.phanCongGD(txtMaGV_PCGD.Text)); crystalReportViewer3.ReportSource = rp; crystalReportViewer3.RefreshReport(); } catch (Exception ec) { MessageBox.Show("Lỗi: " + ec + "\n Xem thống kê thất bại!"); } } } private void txtKhoa_SelectedIndexChanged(object sender, EventArgs e) { txtNganh.ResetText(); txtKhoahoc.ResetText(); txtNganh.DataSource = bslg.tenNganh(txtKhoa.Text); Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 80 txtNganh.DisplayMember = "NGANH"; txtNganh.ValueMember = "tenNganh"; } private void txtNganh_SelectedIndexChanged(object sender, EventArgs e) { txtKhoahoc.ResetText(); txtKhoahoc.DataSource = bslg.tenKhoaDT(txtNganh.Text); txtKhoahoc.DisplayMember = "KHOADAOTAO"; txtKhoahoc.ValueMember = "tenKhoaDT"; } private void btnXEM_KLGD_Click(object sender, EventArgs e) { if (txtMaGV_KLGD.Text != "") { try { khoiluongGD rp = new khoiluongGD(); rp.SetDataSource(bslg.KhoiLuongGD(txtMaGV_KLGD.Text)); crystalReportViewer4.ReportSource = rp; crystalReportViewer4.RefreshReport(); } catch (Exception ec) { MessageBox.Show("Lỗi: " + ec + "\n Xem thống kê thất bại!"); } } } private void btnThoat4_Click(object sender, EventArgs e) { Close(); } } +) Các câu lệnh truy vấn trong Form: public DataTable maKhoa() { return condata.getTable("SELECT maKhoa FROM KHOA"); } public DataTable tenKhoa() { return condata.getTable("SELECT tenKhoa FROM KHOA"); } public DataTable timKhoa(string timtheo,string tukhoa) { return condata.getTable("SELECT * FROM KHOA WHERE "+timtheo+" = N'"+tukhoa+"'"); } public DataTable timNganh(string timtheo, string tukhoa) { return condata.getTable("SELECT * FROM NGANH WHERE " + timtheo Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 81 + " = N'" + tukhoa + "'"); } public DataTable maNganh() { return condata.getTable("SELECT maNganh From NGANH"); } public DataTable tenNganh(string tenKhoa) { return condata.getTable("SELECT tenNganh from NGANH,KHOA where KHOA.tenKhoa=N'" + tenKhoa + "' and KHOA.maKhoa=NGANH.maKhoa"); } public DataTable maKhoaDT() { return condata.getTable("SELECT maKhoaDT from KHOADAOTAO"); } public DataTable tenKhoaDT(string tenNganh) { return condata.getTable("SELECT tenKhoaDT from KHOADAOTAO,NGANH where tenNganh=N'"+tenNganh+"' and KHOADAOTAO.maNganh=NGANH.maNganh"); } public DataTable timLop(string timtheo,string tukhoa) { return condata.getTable("SELECT * FROM LOP WHERE "+timtheo+"=N'"+tukhoa+"'"); } public DataTable maLop() { return condata.getTable("SELECT maLop From LOP"); } public DataTable maGV() { return condata.getTable("SELECT maGV from HSGV"); } public DataTable timMonhoc(string timtheo,string tukhoa) { return condata.getTable("SELECT * FROM MONHOC WHERE "+timtheo+"=N'"+tukhoa+"' "); } public DataTable maMon() { return condata.getTable("SELECT maMon from MONHOC"); } public DataTable timTT_giangvien(string timtheo, string tukhoa) { return condata.getTable("select * from ThongtinGV where "+timtheo+" like N'%"+tukhoa+"%' "); } public DataTable tim_CTDT(string timtheo, string tukhoa) { return condata.getTable("select * from CTDT where " + timtheo + " like N'%" + tukhoa + "%' "); } public DataTable tim_lop(string timtheo, string tukhoa) { return condata.getTable("select * from LOP where " + timtheo + " like N'%" + tukhoa + "%' "); Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 82 } Trong Solution QLGD, thêm CrystalReport, tạo giao diện nhƣ sau: Tƣơng tự với các Form thống kê khác: b) Chương trình đào tạo Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 83 Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 84 c) Phân công giảng dạy Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 85 d) Khối lƣợng giảng dạy Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 86 6. Tìm kiếm Trong giao diện chính, trong Menu Tìm kiếm, tạo các Menu con: Trong Solution QLGD, thêm 1 Form Timkiem, dùng Label, ComboBox, TabControl, DataGirdView, Button, GroupBox, Textbox tạo đƣợc giao diện: Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 87 +) Hiện thị Form tìm kiếm trên giao diện chính( Double click vào cac Menu, viết Code): private void tìmThôngTinGiảngViênToolStripMenuItem_Click(object sender, EventArgs e) { timKiem f33 = new timKiem(); f33.tabControl1.TabPages.Remove(f33.tabPage2); f33.tabControl1.TabPages.Remove(f33.tabPage3); f33.Show(); } private void tìmThôngTinLớpToolStripMenuItem_Click(object sender, EventArgs e) { timKiem f33 = new timKiem(); f33.tabControl1.TabPages.Remove(f33.tabPage1); f33.tabControl1.TabPages.Remove(f33.tabPage2); f33.Show(); } private void tìmThôngTinChươngTrìnhĐàoTạoToolStripMenuItem_Click(object sender, EventArgs e) { timKiem f33 = new timKiem(); f33.tabControl1.TabPages.Remove(f33.tabPage3); f33.tabControl1.TabPages.Remove(f33.tabPage1); f33.Show(); } Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 88 +) Code cho các sự kiện: public partial class timKiem : Form { public timKiem() { InitializeComponent(); } BussinessLogic bslg = new BussinessLogic(); private void btnTimTTGV_Click(object sender, EventArgs e) { if (txtTimTheoTTGV.Text != null && txtTuKhoaTTGV.Text != null) { dataGridView1.DataSource = bslg.timTT_giangvien(txtTimTheoTTGV.Text, txtTuKhoaTTGV.Text); } else MessageBox.Show("Bạn chưa điền đầy đủ thông tin!"); } private void Thoat1_Click(object sender, EventArgs e) { Close(); } private void btnTimLop_Click(object sender, EventArgs e) { if (txtTimTheoLop.Text != null && txtTuKhoaLop.Text != null) { dataGridView2.DataSource = bslg.tim_lop(txtTimTheoLop.Text, txtTuKhoaLop.Text); } else MessageBox.Show("Bạn chưa điền đầy đủ thông tin!"); } private void Thoat2_Click(object sender, EventArgs e) { Close(); } private void thoat3_Click(object sender, EventArgs e) { Close(); } private void btnTimCTDT_Click(object sender, EventArgs e) { if (txtTimCTDT.Text != null && txtTukhoa_CTDT.Text != null) { dataGridView3.DataSource = bslg.tim_CTDT(txtTimCTDT.Text, txtTukhoa_CTDT.Text); } else MessageBox.Show("Bạn chưa điền đầy đủ thông tin!"); } } +) Các lệnh truy vấn trong Form: Nhom_5_KHMT3_K4 ___Quản lý giảng dạy___ 89 public DataTable timTT_giangvien(string timtheo, string tukhoa) { return condata.getTable("select * from ThongtinGV where "+timtheo+" like N'%"+tukhoa+"%' "); } public DataTable tim_CTDT(string timtheo, string tukhoa) { return condata.getTable("select * from CTDT where " + timtheo + " like N'%" + tukhoa + "%' "); } public DataTable tim_lop(string timtheo, string tukhoa) { return condata.getTable("select * from LOP where " + timtheo + " like N'%" + tukhoa + "%' "); }

Các file đính kèm theo tài liệu này:

  • pdfquan_ly_giang_vien_9839.pdf