Beispiel #1
0
        public void UpdateHocSinh(HOCSINHDTO hs)
        {
            string query = string.Format("UPDATE HOCSINH set TenHocSinh = N'{0}', " +
                                         "NgaySinh = '{1}', DiaChi = N'{2}', " +
                                         "Email = '{3}', GioiTinh = N'{4}' " +
                                         "WHERE MaHocSinh = '{5}'", hs.TenHocSinh, hs.NgaySinh, hs.DiaChi, hs.Email, hs.GioiTinh, hs.MaHocSinh);

            SqlProvider.ExecuteNoneQuery(query);
        }
Beispiel #2
0
        public void InsertHocSinh(HOCSINHDTO hs)
        {
            string prefix = "HS100";
            int    n      = int.Parse(hs.MaHocSinh.Substring(5));

            while (CheckIDisUse(hs.MaHocSinh))
            {
                n++;
                hs.MaHocSinh = string.Format("{0}{1}", prefix, n);
            }
            string query = "INSERT INTO HOCSINH(MaHocSinh, TenHocSinh, GioiTinh, NgaySinh, DiaChi, Email) VALUES (N'" + hs.MaHocSinh + "',N'" + hs.TenHocSinh + "',N'" + hs.GioiTinh + "',N'" + hs.NgaySinh + "',N'" + hs.DiaChi + "',N'" + hs.Email + "')";

            SqlProvider.ExecuteNoneQuery(query);
        }
Beispiel #3
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);
        }
Beispiel #4
0
 public void UpdateHocSinh(HOCSINHDTO hs)
 {
     dao = new HOCSINHDAO();
     dao.UpdateHocSinh(hs);
 }
Beispiel #5
0
 public void InsertHocSinh(HOCSINHDTO hs)
 {
     dao = new HOCSINHDAO();
     dao.InsertHocSinh(hs);
 }
Beispiel #6
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;
                }
            }
        }