Esempio n. 1
0
 private void addsubjecttohs_Click(object sender, EventArgs e)
 {
     if (subjectoffclassGrid.SelectedRows.Count > 0)
     {
         if (dshsgrid.SelectedRows.Count > 0)
         {
             DataGridViewRow row  = dshsgrid.SelectedRows[0];
             string          mail = row.Cells[5].Value.ToString();
             HSB.GetMaHS(mail);
             DataGridViewRow row2  = subjectoffclassGrid.SelectedRows[0];
             string          two   = row2.Cells[1].Value.ToString() + row2.Cells[2].Value.ToString();
             int             mahk2 = int.Parse(two);
             int             test  = 0;
             HSB.getdsbd();
             var mh = from m in CTMonHoc.mh where m.TenMon1 == row2.Cells[0].Value.ToString() select m.MaMon1;
             foreach (var kt in CTMonHoc.mhHS)
             {
                 string mamh = mh.FirstOrDefault().ToString();
                 if (kt.MaHS1 == HocSinhDTO.id && kt.MaMon1 == mamh)
                 {
                     test = 1;
                     MessageBox.Show("học sinh này đã học môn này");
                     break;
                 }
             }
             if (test == 0)
             {
                 HSB.AddMHtoHS(HocSinhDTO.id, mahk2, row2.Cells[0].Value.ToString());
                 MessageBox.Show("successfull");
             }
         }
         else
         {
             MessageBox.Show("vui lòng chọn học sinh ");
         }
     }
     else
     {
         MessageBox.Show("vui lòng chọn môn cần thiết");
     }
 }