示例#1
0
        private void kLcombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (kLcombo.SelectedItem != null)
            {
                List <string> l = new List <string>();
                foreach (var s in clasDTO.lop)
                {
                    string tk   = kLcombo.SelectedItem.ToString();
                    char[] ar   = s.TenL1.ToCharArray();
                    string test = ar[0].ToString() + ar[1].ToString();
                    if (tk == test)
                    {
                        l.Add(s.TenL1);
                    }
                }

                classcombo.DataSource = l.ToList();

                if (l.Count() == 0)
                {
                    classcombo.Text = null;
                }
                if (KL.Checked == true)
                {
                    dshsgrid.Rows.Clear();
                    HSB.Loadhsk(kLcombo.SelectedItem.ToString());
                    foreach (var s in HocSinhDTO.lisths)
                    {
                        string gt = "";
                        if (s.Gioitinh == true)
                        {
                            gt = "Nam";
                        }
                        else
                        {
                            gt = "Nữ";
                        }
                        DataGridViewRow row = new DataGridViewRow();

                        DataGridViewCell cell = new DataGridViewTextBoxCell();
                        cell.Value = s.Name;
                        row.Cells.Add(cell);
                        cell       = new DataGridViewTextBoxCell();
                        cell.Value = s.Clas;
                        row.Cells.Add(cell);
                        cell       = new DataGridViewTextBoxCell();
                        cell.Value = gt;
                        row.Cells.Add(cell);
                        cell       = new DataGridViewTextBoxCell();
                        cell.Value = s.Ngsinh;
                        row.Cells.Add(cell);
                        cell       = new DataGridViewTextBoxCell();
                        cell.Value = s.Diachi;
                        row.Cells.Add(cell);
                        cell       = new DataGridViewTextBoxCell();
                        cell.Value = s.Email;
                        row.Cells.Add(cell);
                        cell       = new DataGridViewTextBoxCell();
                        cell.Value = s.HK11;
                        row.Cells.Add(cell);
                        cell       = new DataGridViewTextBoxCell();
                        cell.Value = s.HK21;
                        row.Cells.Add(cell);

                        dshsgrid.Rows.Add(row);
                    }
                }
                else
                {
                    dshsgrid.Rows.Clear();
                }
            }
        }