private void btmSimpan_Click(object sender, EventArgs e) { if (txtNama.Text == "") { MessageBox.Show("Nama belum diisi!"); txtNama.Focus(); } else if (txtAlamat.Text == "") { MessageBox.Show("Alamat belum diisi!"); txtAlamat.Focus(); } else if (txtTelp.Text == "") { MessageBox.Show("No Telp belum diisi!"); txtTelp.Focus(); } else { sqlQuery = "INSERT INTO tb_tempat VALUES " + "('" + txtNama.Text + "', '" + txtAlamat.Text + "', '" + txtTelp.Text + "')"; conn.Open(); SqlCommand sqlCmd = new SqlCommand(sqlQuery, conn); sqlCmd.ExecuteNonQuery(); conn.Close(); MessageBox.Show("Data tersimpan!"); FormTempat fr = new FormTempat(); this.Close(); } }
private void btmTambah_Click(object sender, EventArgs e) { FormTempat fr = new FormTempat(); fr.ShowDialog(); showData(); jmlData(); }