private void frmThemGiangVienVaoMon_Load(object sender, EventArgs e) { try { maChiTietMon = frmThemLop.gMaChiTietMon; dtGiangVienCuaMon = GiangVienBUS.LayDanhSachGiangVienCuaMon(maChiTietMon); listGiangVienMon.DataSource = dtGiangVienCuaMon; listGiangVienMon.DisplayMember = "TenGiangVien"; listGiangVienMon.ValueMember = "MaGiangVien"; layDanhSachGiangVien(); } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
public void LayDanhSachChiTietMon() { try { dtChiTietMon = ChiTietMonBUS.GetTable(lopDTO.MaLop); foreach (DataRow dr in dtChiTietMon.Rows) { DataTable dtGiangVienMon = GiangVienBUS.LayDanhSachGiangVienCuaMon(Int32.Parse(dr["MaChiTietMon"].ToString())); if (dtChiTietMon.Rows.Count > 0) { string giangVien = ""; foreach (DataRow drGiangVienMon in dtGiangVienMon.Rows) { if (giangVien == "") { giangVien += drGiangVienMon["TenGiangVien"].ToString(); } else { giangVien = giangVien + Environment.NewLine + drGiangVienMon["TenGiangVien"].ToString(); } } dr["GiangVien"] = giangVien; } DataTable dtCanBoCoiThiLan1 = GiangVienBUS.LayDanhSachCanBoCoiThiLan1CuaMon(Int32.Parse(dr["MaChiTietMon"].ToString())); if (dtCanBoCoiThiLan1.Rows.Count > 0) { string canBoCoiThiLan1 = ""; foreach (DataRow drCanBoCoiThiLan1 in dtCanBoCoiThiLan1.Rows) { if (canBoCoiThiLan1 == "") { canBoCoiThiLan1 += drCanBoCoiThiLan1["TenGiangVien"].ToString(); } else { canBoCoiThiLan1 = canBoCoiThiLan1 + Environment.NewLine + drCanBoCoiThiLan1["TenGiangVien"].ToString(); } } dr["CanBoCoiThiLan1"] = canBoCoiThiLan1; } DataTable dtCanBoCoiThiLan2 = GiangVienBUS.LayDanhSachCanBoCoiThiLan2CuaMon(Int32.Parse(dr["MaChiTietMon"].ToString())); if (dtCanBoCoiThiLan2.Rows.Count > 0) { string canBoCoiThiLan2 = ""; foreach (DataRow drCanBoCoiThiLan2 in dtCanBoCoiThiLan2.Rows) { if (canBoCoiThiLan2 == "") { canBoCoiThiLan2 += drCanBoCoiThiLan2["TenGiangVien"].ToString(); } else { canBoCoiThiLan2 = canBoCoiThiLan2 + Environment.NewLine + drCanBoCoiThiLan2["TenGiangVien"].ToString(); } } dr["CanBoCoiThiLan2"] = canBoCoiThiLan2; } } dtgvChiTietMon.DataSource = dtChiTietMon; //DataGridViewComboBoxColumn namHocCol = new DataGridViewComboBoxColumn(); //namHocCol.Name = "CmbNamHoc"; //namHocCol.HeaderText = "Năm Học"; //namHocCol.ValueType = typeof(int); //dtgvChiTietMon.Columns.Insert(dtgvChiTietMon.Columns["TenMon"].Index + 1, namHocCol); //IList listNamHoc = NamHocBUS.GetList(); //foreach (DataGridViewRow row in this.dtgvChiTietMon.Rows) //{ // ((DataGridViewComboBoxCell)row.Cells["CmbNamHoc"]).DataSource = listNamHoc; // row.Cells["CmbNamHoc"].Value = row.Cells["TenNamHoc"].Value; //} dtgvChiTietMon.Columns["TenMon"].HeaderText = "Môn"; dtgvChiTietMon.Columns["TenNamHoc"].HeaderText = "Năm Học"; dtgvChiTietMon.Columns["ThoiGianHoc"].HeaderText = "Thời Gian Học"; dtgvChiTietMon.Columns["GioHoc"].HeaderText = "Giờ Học"; dtgvChiTietMon.Columns["GiangDuong"].HeaderText = "Giảng Đường"; dtgvChiTietMon.Columns["GiangVien"].HeaderText = "Giảng Viên"; dtgvChiTietMon.Columns["NgayThiLan1"].HeaderText = "Ngày Thi Lần 1"; dtgvChiTietMon.Columns["GioThiLan1"].HeaderText = "Giờ Thi Lần 1"; dtgvChiTietMon.Columns["GiangDuongThiLan1"].HeaderText = "Giảng Đường Thi Lần 1"; dtgvChiTietMon.Columns["CanBoCoiThiLan1"].HeaderText = "Cán Bộ Coi Thi Lần 1"; dtgvChiTietMon.Columns["SoBaiThiLan1"].HeaderText = "Số Bài Thi Lần 1"; dtgvChiTietMon.Columns["NgayThiLan2"].HeaderText = "Ngày Thi Lần 2"; dtgvChiTietMon.Columns["GioThiLan2"].HeaderText = "Giờ Thi Lần 2"; dtgvChiTietMon.Columns["GiangDuongThiLan2"].HeaderText = "Giảng Đường Thi Lần 2"; dtgvChiTietMon.Columns["CanBoCoiThiLan2"].HeaderText = "Cán Bộ Coi Thi Lần 2"; dtgvChiTietMon.Columns["SoBaiThiLan2"].HeaderText = "Số Bài Thi Lần 2"; dtgvChiTietMon.Columns["GhiChu"].HeaderText = "Ghi Chú"; dtgvChiTietMon.Columns["TenMon"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dtgvChiTietMon.Columns["ThoiGianHoc"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dtgvChiTietMon.Columns["GioHoc"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dtgvChiTietMon.Columns["GiangDuong"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dtgvChiTietMon.Columns["GiangVien"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dtgvChiTietMon.Columns["NgayThiLan1"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dtgvChiTietMon.Columns["GioThiLan1"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dtgvChiTietMon.Columns["GiangDuongThiLan1"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dtgvChiTietMon.Columns["CanBoCoiThiLan1"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dtgvChiTietMon.Columns["SoBaiThiLan1"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dtgvChiTietMon.Columns["NgayThiLan2"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dtgvChiTietMon.Columns["GioThiLan2"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dtgvChiTietMon.Columns["GiangDuongThiLan2"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dtgvChiTietMon.Columns["CanBoCoiThiLan2"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dtgvChiTietMon.Columns["SoBaiThiLan2"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dtgvChiTietMon.Columns["GhiChu"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; dtgvChiTietMon.Columns["MaChiTietMon"].Visible = false; dtgvChiTietMon.Columns["MaMon"].Visible = false; dtgvChiTietMon.Columns["MaNamHoc"].Visible = false; dtgvChiTietMon.Columns["TenMon"].ReadOnly = true; dtgvChiTietMon.Columns["TenNamHoc"].ReadOnly = true; dtgvChiTietMon.Columns["GiangVien"].ReadOnly = true; dtgvChiTietMon.Columns["CanBoCoiThiLan1"].ReadOnly = true; dtgvChiTietMon.Columns["CanBoCoiThiLan2"].ReadOnly = true; } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
private void layDanhSachMon(int maGiangVien) { try { if (maGiangVien > 0) { if (cbxTatCaNamHoc.Checked) { dtDanhSachLop = GiangVienBUS.LayDanhSachMonCuaGiangVien(maGiangVien); } else { int maNamHoc = (cmbNamHoc.SelectedItem as NamHocDTO).MaNamHoc; dtDanhSachLop = GiangVienBUS.LayDanhSachMonCuaGiangVien(maGiangVien, maNamHoc); } foreach (DataRow dr in dtDanhSachLop.Rows) { DataTable dtGiangVienMon = GiangVienBUS.LayDanhSachGiangVienCuaMon(Int32.Parse(dr["MaChiTietMon"].ToString())); if (dtGiangVienMon.Rows.Count > 0) { string giangVien = ""; foreach (DataRow drGiangVienMon in dtGiangVienMon.Rows) { if (giangVien == "") { giangVien += drGiangVienMon["TenGiangVien"].ToString(); } else { giangVien = giangVien + Environment.NewLine + drGiangVienMon["TenGiangVien"].ToString(); } } dr["GiangVien"] = giangVien; } DataTable dtCanBoCoiThiLan1 = GiangVienBUS.LayDanhSachCanBoCoiThiLan1CuaMon(Int32.Parse(dr["MaChiTietMon"].ToString())); if (dtCanBoCoiThiLan1.Rows.Count > 0) { string canBoCoiThiLan1 = ""; foreach (DataRow drCanBoCoiThiLan1 in dtCanBoCoiThiLan1.Rows) { if (canBoCoiThiLan1 == "") { canBoCoiThiLan1 += drCanBoCoiThiLan1["TenGiangVien"].ToString(); } else { canBoCoiThiLan1 = canBoCoiThiLan1 + Environment.NewLine + drCanBoCoiThiLan1["TenGiangVien"].ToString(); } } dr["CanBoCoiThiLan1"] = canBoCoiThiLan1; } DataTable dtCanBoCoiThiLan2 = GiangVienBUS.LayDanhSachCanBoCoiThiLan2CuaMon(Int32.Parse(dr["MaChiTietMon"].ToString())); if (dtCanBoCoiThiLan2.Rows.Count > 0) { string canBoCoiThiLan2 = ""; foreach (DataRow drCanBoCoiThiLan2 in dtCanBoCoiThiLan2.Rows) { if (canBoCoiThiLan2 == "") { canBoCoiThiLan2 += drCanBoCoiThiLan2["TenGiangVien"].ToString(); } else { canBoCoiThiLan2 = canBoCoiThiLan2 + Environment.NewLine + drCanBoCoiThiLan2["TenGiangVien"].ToString(); } } dr["CanBoCoiThiLan2"] = canBoCoiThiLan2; } } } else { //groupBox2.Visible = false; } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }