Exemplo n.º 1
0
 protected virtual void LoadGrid()
 {
     try
     {
         var tb1 = Statistic.GopKetQua(_list);
         var tb2 = Statistic.GopKetQua1(_list);
         if (tb2.Rows.Count > 0 && _list.Count > 1)
         {
             IList <Sinhvien> listthongke = new List <Sinhvien>();
             foreach (DataRow row in tb2.Rows)
             {
                 var a = int.Parse(row["MaSV"].ToString());
                 foreach (var sv in listthongke.Where(sv => sv.MaSV == a))
                 {
                     for (var i = 0; i < _list.Count; i++)
                     {
                         var ten  = "Diem" + (i + 1);
                         var diem = row[ten].ToString();
                         if (!string.IsNullOrEmpty(diem))
                         {
                             sv.Diemthi[i] = int.Parse(row[ten].ToString());
                         }
                     }
                     goto b;
                 }
                 var sv1 = new Sinhvien(_list.Count)
                 {
                     MaSV     = a,
                     HoSV     = row["HoSV"].ToString(),
                     TenSV    = row["TenSV"].ToString(),
                     MaLop    = row["MaLop"].ToString(),
                     NgaySinh = row["NgaySinh"].ToString(),
                 };
                 for (var i = 0; i < _list.Count; i++)
                 {
                     var ten  = "Diem" + (i + 1);
                     var diem = row[ten].ToString();
                     if (!string.IsNullOrEmpty(diem))
                     {
                         sv1.Diemthi[i] = double.Parse(row[ten].ToString());
                     }
                     else
                     {
                         sv1.Diemthi[i] = 0;
                     }
                 }
                 listthongke.Add(sv1);
                 b :;
             }
             var t = tb1.Rows.Count;
             foreach (var item in listthongke)
             {
                 tb1.Rows.Add(++t, item.MaSV, item.HoSV, item.TenSV, item.NgaySinh, item.MaLop);
                 for (var i = 0; i < _list.Count; i++)
                 {
                     var ten = "Diem" + (i + 1);
                     tb1.Rows[tb1.Rows.Count - 1][ten] = item.Diemthi[i];
                 }
                 tb1.Rows[tb1.Rows.Count - 1]["TongDiem"] = item.Tinhtong();
             }
             Invoke((Action)(() => _listtk = listthongke));
         }
         Invoke((Action)(() => dgv_DanhSach.DataSource = tb1));
         Invoke((Action)(() => pnl_from.Visible = true));
         lock (LockTotal)
         {
             OnCloseDialog();
         }
     }
     catch (Exception ex)
     {
         Log2File.LogExceptionToFile(ex);
     }
 }
 protected virtual void LoadGrid()
 {
     try
     {
         var tb1 = Statistic.GopKetQua(_list);
         var tb2 = Statistic.GopKetQua1(_list);
         if (tb2.Rows.Count > 0 && _list.Count > 1)
         {
             IList<Sinhvien> listthongke = new List<Sinhvien>();
             foreach (DataRow row in tb2.Rows)
             {
                 var a = int.Parse(row["MaSV"].ToString());
                 foreach (var sv in listthongke.Where(sv => sv.MaSV == a))
                 {
                     for (var i = 0; i < _list.Count; i++)
                     {
                         var ten = "Diem" + (i + 1);
                         var diem = row[ten].ToString();
                         if (!string.IsNullOrEmpty(diem))
                             sv.Diemthi[i] = int.Parse(row[ten].ToString());
                     }
                     goto b;
                 }
                 var sv1 = new Sinhvien(_list.Count)
                 {
                     MaSV = a,
                     HoSV = row["HoSV"].ToString(),
                     TenSV = row["TenSV"].ToString(),
                     MaLop = row["MaLop"].ToString(),
                     NgaySinh = row["NgaySinh"].ToString(),
                 };
                 for (var i = 0; i < _list.Count; i++)
                 {
                     var ten = "Diem" + (i + 1);
                     var diem = row[ten].ToString();
                     if (!string.IsNullOrEmpty(diem))
                         sv1.Diemthi[i] = double.Parse(row[ten].ToString());
                     else
                         sv1.Diemthi[i] = 0;
                 }
                 listthongke.Add(sv1);
                 b:;
             }
             var t = tb1.Rows.Count;
             foreach (var item in listthongke)
             {
                 tb1.Rows.Add(++t, item.MaSV, item.HoSV, item.TenSV, item.NgaySinh, item.MaLop);
                 for (var i = 0; i < _list.Count; i++)
                 {
                     var ten = "Diem" + (i + 1);
                     tb1.Rows[tb1.Rows.Count - 1][ten] = item.Diemthi[i];
                 }
                 tb1.Rows[tb1.Rows.Count - 1]["TongDiem"] = item.Tinhtong();
             }
             Invoke((Action)(() => _listtk = listthongke));
         }
         Invoke((Action)(()=>dgv_DanhSach.DataSource = tb1));
         Invoke((Action)(() => pnl_from.Visible = true));
         lock (LockTotal)
         {
             OnCloseDialog();
         }
     }
     catch (Exception ex)
     {
         Log2File.LogExceptionToFile(ex);
     }
 }