private void btnTamam_Click_1(object sender, EventArgs e) { foreach (Control item in this.Controls) { if (item is TextBox) { if (item.Text == "") { MessageBox.Show("Lütfen gerekli alanları doldurunuz!"); return; } } } Biletler blt = new Biletler(); blt.setad(textAd.Text); blt.setsoyad(textSoyad.Text); blt.settel(maskTexTel.Text); if (rdbKadin.Checked) { blt.setcinsiyet(rdbKadin.Text); } else { blt.setcinsiyet(rdbErkek.Text); } /*blt.set(textBox1.Text); * blt.setTip(txtTip.Text); * blt.setBiletFiyat(Convert.ToInt32(txtBiletFiyat.Text));*/ DAO.BiletEkle(blt); MessageBox.Show("Başarıyla Eklendi"); this.DialogResult = DialogResult.OK; this.Close(); }
public static void BiletEkle(Biletler blt) { SqlConnection con = openConnection(); SqlCommand cmd = new SqlCommand("INSERT INTO Biletler(ad,soyad,tel,cinsiyet,koltukNo,SeferID)VALUES(@ad,@soyad,@tel,@cinsiyet,@koltukNo,@SeferID)", con); cmd.Parameters.AddWithValue("@ad", blt.getad()); cmd.Parameters.AddWithValue("@soyad", blt.getsoyad()); cmd.Parameters.AddWithValue("@tel", blt.gettel()); cmd.Parameters.AddWithValue("@cinsiyet", blt.getcinsiyet()); cmd.Parameters.AddWithValue("@koltukNo", Convert.ToInt32(blt.getkoltukNo())); cmd.Parameters.AddWithValue("@SeferID", Convert.ToInt32(blt.getSeferID())); try { cmd.ExecuteNonQuery(); } catch (Exception) { throw; } finally { connectionClose(con); } }