Esempio n. 1
0
        private void btnThemSinhVien_Click(object sender, EventArgs e)
        {
            string diachi = txtDiaChi.Text.Trim();
            string tensv  = txtTenSV.Text.Trim();
            string mssv   = txtMSSV.Text.Trim();
            string malop;
            string gioitinh;

            if (radNam.Checked)
            {
                gioitinh = "Nam";
            }
            else
            {
                gioitinh = "Nu";
            }
            if (cboMaLop2.SelectedIndex == -1)
            {
                MessageBox.Show("Vui long chon ma lop them sinh vien");
            }
            else
            {
                int count = st.LayDanhSachSinhVien().Count;
                malop = cboMaLop2.SelectedItem.ToString().Trim();
                if (KiemTraThongTinSinhVienCoThieuKhong(mssv, tensv, diachi) == false)
                {
                    st.ThemSinhVien(new Student(malop, mssv, tensv, gioitinh, diachi));
                    if (st.LayDanhSachSinhVien().Count > count)
                    {
                        MessageBox.Show("Them sinh vien thanh cong");
                        lvSinhVien.Items.Clear();
                        HienThiDanhSachSinhVien();
                        cboMaLop2.Text = "";
                        txtDiaChi.Text = "";
                        txtMSSV.Text   = "";
                        txtTenSV.Text  = "";
                    }
                    else
                    {
                        MessageBox.Show("Them sinh vien that bai");
                        lvSinhVien.Items.Clear();
                        HienThiDanhSachSinhVien();
                        cboMaLop2.Text = "";
                        txtDiaChi.Text = "";
                        txtMSSV.Text   = "";
                        txtTenSV.Text  = "";
                    }
                }
            }
        }