private DataTable LoadBaoBanGiaoVien() { DataTable dt = new DataTable(); dt.Columns.Add("IDNS_GiaoVien", typeof(int)); dt.Columns.Add("HoTen", typeof(string)); dt.Columns.Add("MaGiaoVien", typeof(string)); dt.Columns.Add("TenVietTat", typeof(string)); foreach (DataRow dr in dtTuan.Rows) { dt.Columns.Add("T" + dr["XL_TuanID"].ToString(), typeof(string)); } dtBaoBan = oBBaoBanGV.GetByHocKy(Program.IDNamHoc, Program.HocKy); if (dtBaoBan.Rows.Count > 0) { int count = 0; DataRow drNew; Lib.clsDataTableHelper cls = new Lib.clsDataTableHelper(); DataTable dtTemp = cls.SelectDistinct(dtBaoBan, new string[] { "NS_GiaoVienID", "HoTen", "MaGiaoVien", "IDTuan" }, new string[] { "TenVietTat" }); string IDGiaoVien = dtTemp.Rows[0]["NS_GiaoVienID"].ToString(); drNew = dt.NewRow(); drNew["IDNS_GiaoVien"] = int.Parse(IDGiaoVien); drNew["HoTen"] = EncodeString(dtTemp.Rows[0]["HoTen"].ToString(), 0); drNew["MaGiaoVien"] = dtTemp.Rows[0]["MaGiaoVien"].ToString(); drNew["TenVietTat"] = dtTemp.Rows[0]["TenVietTat"].ToString(); foreach (DataRow dr in dtTemp.Rows) { if (dr["NS_GiaoVienID"].ToString() != IDGiaoVien) { count++; IDGiaoVien = dr["NS_GiaoVienID"].ToString(); // Add row đã có dữ liệu trước khi khởi tạo row mới. dt.Rows.Add(drNew); // Khởi tạo row mới để gán dữ liệu. drNew = dt.NewRow(); drNew["IDNS_GiaoVien"] = int.Parse(IDGiaoVien); drNew["HoTen"] = EncodeString(dr["HoTen"].ToString(), count); drNew["MaGiaoVien"] = dr["MaGiaoVien"].ToString(); drNew["TenVietTat"] = dr["TenVietTat"].ToString(); if (dr["IDTuan"] + "" != "") { drNew["T" + dr["IDTuan"].ToString()] = " "; } } else { if (dr["IDTuan"] + "" != "") { drNew["T" + dr["IDTuan"].ToString()] = " "; } } } dt.Rows.Add(drNew); } dt.DefaultView.Sort = "TenVietTat, IDNS_GiaoVien"; return(dt); }
// lay tui thi khi chon nhap diem theo so phach private void GetTuiThi() { // get tui thi Lib.clsDataTableHelper cls = new Lib.clsDataTableHelper(); DataTable dtTuiThi = cls.SelectDistinct(dtData, new string[] { "TuiThiSo" }); cmbTuiThi.Properties.DataSource = dtTuiThi; if (dtTuiThi.Rows.Count > 0) { cmbTuiThi.ItemIndex = 0; cmbTuiThi_EditValueChanged(null, null); } }