public DataTable Lay_diem_theo_hocki_lop(string lop, string hocki, int lan)
{
DataTable bangdiem = new DataTable();//Tao 1 bang chuyen trong de chua du lieu sau khi chuyen
DataTable monhoc = Laymonhoc_hockilop(lop, hocki,1);//Lấy về tổng số môn học trong bảng điểm
// bangdiem.DataSet = null;
//Tao cau truc bang
bangdiem.Columns.Add("STT");
bangdiem.Columns.Add("Họ lót"); //Tao them 1 cot masv tren bang chuyen
bangdiem.Columns.Add("Tên");
bangdiem.Columns.Add("Ngày sinh");
int tam = 0;
for (int i = 0; i < monhoc.Rows.Count; i++) //Tao them cac cot chua mamon k0 trung nhau
{
bangdiem.Columns.Add(monhoc.Rows[i]["mahocphan"].ToString()).MaxLength.Equals(50); //Tao them 1 cot chua mamon
tam = i + 1;
}
if(lan==1)
bangdiem.Columns.Add("TB_lan1").MaxLength.Equals(50);
else
if(lan==2)
bangdiem.Columns.Add("TB_l2").MaxLength.Equals(50);
if (lan == 0)
bangdiem.Columns.Add("TBchung").MaxLength.Equals(50);
DataTable sv = LaySv_theolop(lop,hocki); //Lay cac masv k0 trung nhau
for (int i = 0; i < sv.Rows.Count; i++)
{
DataRow dr = bangdiem.NewRow();//Tao them 1 dong trong trong bang chuyen
string masv = sv.Rows[i]["masinhvien"].ToString();//Dua ma sv vao cot dau tien cua mang chuyen
dr[0] = masv;
float tb = 0;
int tongdv = 0;
for (int j = 0; j < monhoc.Rows.Count; j++)//Lan luot chuyen diem cua tung mon vao cho sv co ma la: masv
{
int t = Lay_diem_masv_hp(masv, monhoc.Rows[j]["mahocphan"].ToString(),lan);
int sodvht = Lay_sodvht_theo_mon(monhoc.Rows[j]["mahocphan"].ToString());
dr[j + 4] = t.ToString();
tb += t * sodvht;
tongdv += sodvht;
}
bangdiem.Rows.Add(dr); //Add dr vao bang chuyen
dr[0] = (i + 1).ToString();
dr[1] = sv.Rows[i]["ho"].ToString();
dr[2] = sv.Rows[i]["ten"].ToString();
dr[3] = sv.Rows[i]["ngaysinh"].ToString();
dr[tam + 4] = Math.Round(tb / tongdv, 2);
}
return bangdiem;
}