private void button1_Click(object sender, EventArgs e) { BenhNhan bn = BenhNhanDAO.FindBenhNhanById(tf_msbn.Text); if (bn != null) { tf_msbn.Text = bn.msbn; tf_hoten.Text = bn.hoten; tf_diachi.Text = bn.diachi; tf_socmnd.Text = bn.socmnd; } }
private void bt_luu_Click(object sender, EventArgs e) { BenhNhan bn = new BenhNhan(); bn.diachi = tf_diachi.Text; bn.hoten = tf_hoten.Text; bn.msbn = tf_msbn.Text; bn.socmnd = tf_socmnd.Text; ConnectDB.instance(); if (BenhNhanDAO.InsertBenhNhan(bn)) { SendText(bn); MessageBox.Show("Success"); tf_diachi.Text = ""; tf_hoten.Text = ""; tf_msbn.Text = ""; tf_socmnd.Text = ""; tf_diachi.Focus(); } else { if (tf_msbn != null) { SendText(BenhNhanDAO.FindBenhNhanById(tf_msbn.Text)); MessageBox.Show("Success"); } else if (tf_socmnd != null) { SendText(BenhNhanDAO.FindBenhNhanByCMND(tf_socmnd.Text)); MessageBox.Show("Success"); } else { MessageBox.Show("Error"); } } ConnectDB.disconnect(); Console.WriteLine("send oke"); Console.ReadLine(); }