private void btnThem_Click(object sender, EventArgs e)
        {
            string   maBN     = txtMaBN.Text;
            string   tenBN    = txtHoTen.Text;
            DateTime ngaySinh = dtpNgaySinh.Value;
            string   gioiTinh = "";

            if (radNam.Checked == true)
            {
                gioiTinh = "Nam";
            }
            else
            {
                gioiTinh = "Nữ";
            }
            string maBHXH = txtBHXH.Text;
            string maKhoa = cboKhoa.SelectedValue.ToString();

            BenhNhan bn = new BenhNhan(maBN, tenBN, ngaySinh, gioiTinh, maBHXH, maKhoa);

            BenhNhanBUL bnBUL = new BenhNhanBUL();

            if (bnBUL.Them(bn))
            {
                MessageBox.Show("Thêm bản ghi thành công!");
            }
            else
            {
                MessageBox.Show("Thêm bản ghi thất bại!");
            }
            ReLoad();
        }
Exemple #2
0
        private void btTimBN_TextChanged(object sender, EventArgs e)
        {
            String          key       = btTimBN.Text.Trim();
            List <BenhNhan> benhNhans = new BenhNhanBUL().Tim(key);

            dataGridView1.DataSource = benhNhans;
        }
Exemple #3
0
 private void btUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         int    id       = int.Parse(tbID.Text.Trim());
         String name     = tbName.Text.Trim();
         int    namsinh  = int.Parse(tbNamSinh.Text.Trim());
         String gioitinh = tbGioiTinh.Text.Trim();
         String sdt      = tbSDT.Text.Trim();
         if (Regex.IsMatch(sdt, @"^\d+$"))
         {
             String   ngayXN = tbNgayXN.Text.Trim();
             BenhNhan bn     = new BenhNhan()
             {
                 MaBN = id, TenBN = name, NamSinh = namsinh, GioiTinh = gioitinh, SDT = sdt, NgayXN = ngayXN
             };
             bool result = new BenhNhanBUL().Sua(id, bn);
             if (result)
             {
                 Reload();
             }
         }
         else
         {
             MessageBox.Show("Số điện thoại không hợp lệ !", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     catch
     {
         MessageBox.Show("Cập nhật thông tin thất bại", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
        private void btnTim_Click(object sender, EventArgs e)
        {
            string          maBN  = txtMaBN.Text;
            BenhNhanBUL     bnBUL = new BenhNhanBUL();
            List <BenhNhan> dsBN  = bnBUL.Tim(maBN);

            if (dsBN.Count > 0)
            {
                MessageBox.Show("Tìm thấy bản ghi!");
                dgvBenhNhan.DataSource = dsBN;
            }
            else
            {
                MessageBox.Show("Không tìm thấy bản ghi!");
                ReLoad();
            }
        }
Exemple #5
0
 private void btADD_Click(object sender, EventArgs e)
 {
     try
     {
         int    namsinh = 0;
         String sdt     = "";
         if (tbNamSinh.Text != "")
         {
             namsinh = int.Parse(tbNamSinh.Text.Trim());
         }
         String name     = tbName.Text.Trim();
         String gioitinh = cbbGioiTinh.SelectedItem.ToString();
         String ngayXN   = DateTime.Now.ToString("dd/MM/yyyy");
         if (Regex.IsMatch(tbSDT.Text.Trim(), @"^\d+$") && tbNamSinh.Text != "")
         {
             sdt = tbSDT.Text.Trim();
             BenhNhan bn = new BenhNhan()
             {
                 TenBN = name, NamSinh = namsinh, GioiTinh = gioitinh, SDT = sdt, NgayXN = ngayXN
             };
             bool result = new BenhNhanBUL().Them(bn);
             if (result)
             {
                 MessageBox.Show("Thêm thành công");
                 Form1 frm = new Form1();
                 frm1.Reload();
             }
             else
             {
                 MessageBox.Show("Thêm thất bại");
             }
         }
         else
         {
             MessageBox.Show("Số điện thoại không hợp lệ !", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Lỗi thông tin", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
        private void btnXoa_Click(object sender, EventArgs e)
        {
            string       maBN  = txtMaBN.Text;
            BenhNhanBUL  bnBUL = new BenhNhanBUL();
            DialogResult rs    = MessageBox.Show("Bạn muốn xóa bản ghi này?", "Xóa bản ghi",
                                                 MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (rs == DialogResult.Yes)
            {
                if (bnBUL.Xoa(maBN))
                {
                    MessageBox.Show("Xóa bản ghi thành công!");
                }
                else
                {
                    MessageBox.Show("Xóa bản ghi thất bại!");
                }
            }
            ReLoad();
        }
Exemple #7
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            DialogResult Dresult = MessageBox.Show("Bạn chắc chắn chứ ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (Dresult == DialogResult.Yes)
            {
                try
                {
                    int    id       = int.Parse(tbID.Text.Trim());
                    String name     = tbName.Text.Trim();
                    int    namsinh  = int.Parse(tbNamSinh.Text.Trim());
                    String gioitinh = tbGioiTinh.Text.Trim();
                    String sdt      = tbSDT.Text.Trim();
                    if (Regex.IsMatch(sdt, @"^\d+$"))
                    {
                        String   ngayXN = tbNgayXN.Text.Trim();
                        BenhNhan bn     = new BenhNhan()
                        {
                            MaBN = id, TenBN = name, NamSinh = namsinh, GioiTinh = gioitinh, SDT = sdt, NgayXN = ngayXN
                        };
                        bool result = new BenhNhanBUL().Delete(id);
                        if (result)
                        {
                            Reload();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Xóa thành công");
                    }
                }
                catch
                {
                    MessageBox.Show("Xóa thất bại", "Kiểm tra lại", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
        private void ShowDataGridView()
        {
            BenhNhanBUL bnBUL = new BenhNhanBUL();

            dgvBenhNhan.DataSource = bnBUL.DanhSach();
        }
Exemple #9
0
        public void Reload()
        {
            List <BenhNhan> benhNhans = new BenhNhanBUL().GetAll();

            dataGridView1.DataSource = benhNhans;
        }