private void button1_Click(object sender, EventArgs e) { lblName.Text = "-"; lblID.Text = "-"; lblJEK.Text = "-"; lblJET.Text = "-"; btnIsi.Enabled = false; using (var db = new PasienModel()) { var query = from pasien in db.Pasiens where pasien.Nama == tbNP.Text select pasien; foreach (var item in query) { lblName.Text = item.Nama; lblID.Text = item.NIK; lblJEK.Text = item.JenisKelamin; lblJET.Text = item.JenisTes; btnIsi.Enabled = true; } } }
private void InputData() { if (tbNama.Text != "" && tbNIK.Text != "" && tbJK.Text != "") { using (var db = new PasienModel()) { pasien = new Pasien { Nama = tbNama.Text, NIK = tbNIK.Text, JenisKelamin = tbJK.Text, JenisTes = tbJT.Text, }; db.Pasiens.Add(pasien); db.SaveChanges(); MessageBox.Show("Pasien telah terdaftar"); Close(); } } else { MessageBox.Show("Data pasien harus diisi"); } }