Example #1
0
        void DeleteHocSinh()
        {
            HOCSINHBUS bus = new HOCSINHBUS();

            bus.DeleteHocSinh(txtMaHocSinh.Text);
            MessageBox.Show("Xóa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #2
0
        void UpDateHocSinh()
        {
            HOCSINHDTO hs = new HOCSINHDTO();

            hs.MaHocSinh  = txtMaHocSinh.Text;
            hs.TenHocSinh = txtHoTen.Text;
            hs.NgaySinh   = dtNgaySinh.Value;
            hs.DiaChi     = txtDiaChi.Text;
            hs.Email      = txtEmail.Text;

            if (rdbNam.Checked)
            {
                hs.GioiTinh = "Nam";
            }
            else if (rdbNu.Checked)
            {
                hs.GioiTinh = "Nữ";
            }

            HOCSINHBUS bus = new HOCSINHBUS();

            bus.UpdateHocSinh(hs);
            MessageBox.Show("Cập nhật thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #3
0
        void AddHocSinh()
        {
            HOCSINHDTO hs     = new HOCSINHDTO();
            HOCSINHBUS bus    = new HOCSINHBUS();
            string     prefix = "HS100";
            int        n      = dgvHocSinh.Rows.Count + 1;

            hs.MaHocSinh = string.Format("{0}{1}", prefix, n);

            while (true)
            {
                if (string.IsNullOrWhiteSpace(txtHoTen.Text))
                {
                    MessageBox.Show("Tên không được để trống!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtHoTen.Focus();
                    break;
                }

                else if (string.IsNullOrWhiteSpace(txtDiaChi.Text))
                {
                    MessageBox.Show("Địa chỉ không được để trống!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtDiaChi.Focus();
                    break;
                }

                else if (string.IsNullOrWhiteSpace(txtEmail.Text) || IsEmail(txtEmail.Text) == false)
                {
                    MessageBox.Show("Địa chỉ Email không hợp lệ!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtDiaChi.Focus();
                    break;
                }
                else if (rdbNam.Checked == false && rdbNu.Checked == false)
                {
                    MessageBox.Show("Hãy xác định giới tính của bạn!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                }
                else if (bus.CheckAge(DateTime.Now.Year - dtNgaySinh.Value.Year) == false)
                {
                    MessageBox.Show("Tuổi của bạn không phù hợp!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                }
                else
                {
                    if (rdbNam.Checked)
                    {
                        hs.GioiTinh = "Nam";
                    }
                    else if (rdbNu.Checked)
                    {
                        hs.GioiTinh = "N'Nữ'";
                    }

                    hs.TenHocSinh = txtHoTen.Text;
                    hs.NgaySinh   = dtNgaySinh.Value;
                    hs.DiaChi     = txtDiaChi.Text;
                    hs.Email      = txtEmail.Text;

                    bus.InsertHocSinh(hs);
                    MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                }
            }
        }
Example #4
0
        void LoadHocSinh()
        {
            HOCSINHBUS bus = new HOCSINHBUS();

            dgvHocSinh.DataSource = bus.GetAllHocSinh();
        }