private void btnSave_Click(object sender, EventArgs e)
        {
            BenhNhanObj bnObj = new BenhNhanObj();

            addData(bnObj);
            if (flagLuu == 0)
            {
                if (BNCtr.AddData(bnObj))
                {
                    MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Thêm không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                if (BNCtr.UpdData(bnObj))
                {
                    MessageBox.Show("Sửa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Sửa không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            thongtinbenhnhan_Load(sender, e);
        }
 private void addData(BenhNhanObj bn)
 {
     bn.MaBN = txtMabn.Text.Trim();
     if (cmbGioitinh.SelectedIndex == 0)
     {
         bn.GioiTinh = "Nam";
     }
     else
     {
         bn.GioiTinh = "Nữ";
     }
     bn.DiaChi   = txtDiachi.Text.Trim();
     bn.SDT      = txtSdt.Text.Trim();
     bn.HoTen    = txtHoten.Text.Trim();
     bn.NgaySinh = dateNgaysinh.Text;
 }
Esempio n. 3
0
 public bool UpdData(BenhNhanObj bnObj)
 {
     cmd.CommandText = "Update BenhNhan set HoTen =  N'" + bnObj.HoTen + "', GioiTinh = N'" + bnObj.GioiTinh + "', NgaySinh = CONVERT(DATE,'" + bnObj.NgaySinh + "',103), DiaChi = N'" + bnObj.DiaChi + "',SDT = '" + bnObj.SDT + "' Where MaBN = '" + bnObj.MaBN + "'";
     cmd.CommandType = CommandType.Text;
     cmd.Connection  = con.Connection;
     try
     {
         con.OpenConn();
         cmd.ExecuteNonQuery();
         return(true);
     }
     catch (Exception ex)
     {
         string mex = ex.Message;
         cmd.Dispose();
         con.CloseConn();
     }
     return(false);
 }
Esempio n. 4
0
 public bool AddData(BenhNhanObj bnObj)
 {
     cmd.CommandText = "Insert into BenhNhan values ('" + bnObj.MaBN + "',N'" + bnObj.HoTen + "',N'" + bnObj.GioiTinh + "',CONVERT(DATE,'" + bnObj.NgaySinh + "',103),N'" + bnObj.DiaChi + "','" + bnObj.SDT + "')";
     cmd.CommandType = CommandType.Text;
     cmd.Connection  = con.Connection;
     try
     {
         con.OpenConn();
         cmd.ExecuteNonQuery();
         return(true);
     }
     catch (Exception ex)
     {
         string mex = ex.Message;
         cmd.Dispose();
         con.CloseConn();
     }
     return(false);
 }
Esempio n. 5
0
 public bool UpdData(BenhNhanObj bnObj)
 {
     return(bnMod.UpdData(bnObj));
 }
Esempio n. 6
0
 public bool AddData(BenhNhanObj bnObj)
 {
     return(bnMod.AddData(bnObj));
 }