private void btmTambah_Click_1(object sender, EventArgs e) { FormTambahLogistik fr = new FormTambahLogistik(); fr.ShowDialog(); showData(); jumlah = dataGridView1.Rows.Count; lblJml.Text = (jumlah - 1).ToString(); totalData(); }
private void btmSimpan_Click(object sender, EventArgs e) { if (dtTgl.Text == "") { MessageBox.Show("Nama belum diisi!"); dtTgl.Focus(); } 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_logistik VALUES " + "('" + dtTgl.Text + "', '" + txtNama.Text + "', '" + txtAlamat.Text + "', '" + txtTelp.Text + "', '" + txtBeras.Text + "', '" + txtMie.Text + "', '" + txtMasker.Text + "', '" + txtAqua.Text + "', '" + txtNasi.Text + "', '" + txtSusu.Text + "', '" + txtSelimut.Text + "', '" + txtRoti.Text + "', '" + txtLain.Text + "')"; conn.Open(); SqlCommand sqlCmd = new SqlCommand(sqlQuery, conn); sqlCmd.ExecuteNonQuery(); conn.Close(); MessageBox.Show("Data Bantuan Logistik tersimpan!"); FormTambahLogistik fr = new FormTambahLogistik(); this.Close(); } }