示例#1
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         if (f)
         {
             string   tenbn     = txtTenBenhNhan.Text;
             string   qq        = txtQueQuan.Text;
             string   cmnd      = txtCMND.Text;
             DateTime ns        = DateTime.Parse(dateTimePicker1.Text);
             string   sdt       = txtSDT.Text;
             string   gt        = comboBox1.Text;
             bool     trangthai = bn.ThemBenhNhan(tenbn, qq, cmnd, ns, sdt, gt);
             if (trangthai)
             {
                 MessageBox.Show("Thêm dữ liệu thành công!!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 LoadData();
             }
             else
             {
                 MessageBox.Show("Không thêm được dữ liệu !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             bool trangthai = bn.SuaBenhNhan(curMaBN, txtTenBenhNhan.Text, txtQueQuan.Text, txtCMND.Text, dateTimePicker1.Value, txtSDT.Text, comboBox1.Text);
             if (trangthai)
             {
                 MessageBox.Show("Cập nhật dữ liệu thành công!!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 LoadData();
             }
             else
             {
                 MessageBox.Show("Không cập nhật được dữ liệu !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     catch (SqlException) { }
 }
 //Them Hoc Sinh
 public static bool ThemBenhNhan(BENHNHAN bnDTO)
 {
     return(BenhNhanDAO.ThemBenhNhan(bnDTO));
 }