DanhSachMonThi DsMonThi() { DanhSachMonThi Dsmt = new DanhSachMonThi(new List <MonThi>()); foreach (DataGridViewRow r in grwDanhSach.Rows) { if (Convert.ToString(r.Cells[3].Value) != "") { MonThi mt = new MonThi(Convert.ToString(r.Cells[1].Value)); foreach (DataGridViewRow r2 in grwDanhSach.Rows) { if (r2.Index != r.Index) { string bac1 = Convert.ToString(r.Cells[3].Value); string bac2 = Convert.ToString(r2.Cells[3].Value); bool thimay1 = Convert.ToBoolean(((DataGridViewCheckBoxCell)r.Cells[4]).Value); bool thimay2 = Convert.ToBoolean(((DataGridViewCheckBoxCell)r2.Cells[4]).Value); string phong1 = Convert.ToString(((DataGridViewComboBoxCell)r.Cells[11]).Value); string phong2 = Convert.ToString(((DataGridViewComboBoxCell)r2.Cells[11]).Value); if (bac2 != "") { if (bac1 == bac2 || (thimay1 && thimay2 && Phong.TrungPhong(phong1, phong2))) { mt.ThemMonCungNhom(Convert.ToString(r2.Cells[1].Value)); } } } } Dsmt.ds.Add(mt); } } return(Dsmt); }