示例#1
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (SqlConnection conn = new SqlConnection(veri.source))
     {
         conn.Open();
         string     kayit  = "UPDATE tliste SET ad_soyad=@adsoyad,takim_adi=@takimadi,telefon=@telefon,mail=@mail,tc=@tc where idno=@idno";
         SqlCommand komut  = new SqlCommand(kayit, conn);
         string     kayit1 = "UPDATE rezervasyon SET takim_adi=@takimadi1,tarih=@tarih,saat=@saat where idno=@idno";
         SqlCommand komut1 = new SqlCommand(kayit1, conn);
         string     kayit2 = "UPDATE takim_bilgi SET takim_adi=@takimadi2,oyuncu1=@oyuncu1,oyuncu2=@oyuncu2,oyuncu3=@oyuncu3,oyuncu4=@oyuncu4,oyuncu5=@oyuncu5,oyuncu6=@oyuncu6,oyuncu7=@oyuncu7,oyuncu8=@oyuncu8,fiyat=@fiyat where idno=@idno";
         SqlCommand komut2 = new SqlCommand(kayit2, conn);
         komut.Parameters.AddWithValue("@adsoyad", textBox9.Text);
         komut.Parameters.AddWithValue("@takimadi", textBox2.Text);
         komut.Parameters.AddWithValue("@telefon", maskedTextBox1.Text);
         komut.Parameters.AddWithValue("@mail", textBox3.Text);
         komut.Parameters.AddWithValue("@tc", maskedTextBox2.Text);
         komut.Parameters.AddWithValue("@fiyat", textBox1.Text);
         komut.Parameters.AddWithValue("@idno", label12.Text);
         //
         komut1.Parameters.AddWithValue("@takimadi1", textBox2.Text);
         komut1.Parameters.AddWithValue("@tarih", dateTimePicker2.Value);
         komut1.Parameters.AddWithValue("@saat", comboBox1.Text);
         komut1.Parameters.AddWithValue("@idno", label12.Text);
         //
         komut2.Parameters.AddWithValue("@takimadi2", textBox2.Text);
         komut2.Parameters.AddWithValue("@oyuncu1", listBox1.Items[0].ToString());
         komut2.Parameters.AddWithValue("@oyuncu2", listBox1.Items[1].ToString());
         komut2.Parameters.AddWithValue("@oyuncu3", listBox1.Items[2].ToString());
         komut2.Parameters.AddWithValue("@oyuncu4", listBox1.Items[3].ToString());
         komut2.Parameters.AddWithValue("@oyuncu5", listBox1.Items[4].ToString());
         komut2.Parameters.AddWithValue("@oyuncu6", listBox1.Items[5].ToString());
         komut2.Parameters.AddWithValue("@oyuncu7", listBox1.Items[6].ToString());
         komut2.Parameters.AddWithValue("@oyuncu8", listBox1.Items[7].ToString());
         komut2.Parameters.AddWithValue("@idno", label12.Text);
         komut2.ExecuteNonQuery();
         komut1.ExecuteNonQuery();
         komut.ExecuteNonQuery();
         conn.Close();
         MessageBox.Show("Müşteri Bilgileri Güncellendi.");
         menu frm1 = (menu)Application.OpenForms["menu"];
         frm1.tarihgoster();
     }
 }
示例#2
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         bool retVal = false;
         retVal = Regex.IsMatch(textBox3.Text, MatchEmailPattern);
         if (retVal && maskedTextBox2.TextLength == 11 && maskedTextBox1.TextLength == 14)
         {
             using (SqlConnection conn = new SqlConnection(veri.source))
             {
                 if (conn.State == ConnectionState.Closed)
                 {
                     conn.Open();
                 }
                 string     kayit = "insert into tliste(ad_soyad,takim_adi,telefon,mail,tc) values (@adsoyad,@takimadi,@telefon,@mail,@tc)";
                 SqlCommand komut = new SqlCommand(kayit, conn);
                 komut.Parameters.AddWithValue("@adsoyad", comboBox2.Text);
                 komut.Parameters.AddWithValue("@takimadi", textBox2.Text);
                 komut.Parameters.AddWithValue("@telefon", maskedTextBox1.Text);
                 komut.Parameters.AddWithValue("@mail", textBox3.Text);
                 komut.Parameters.AddWithValue("@tc", maskedTextBox2.Text);
                 //Parametrelerimize Form üzerinde ki kontrollerden girilen verileri aktarıyoruz.
                 komut.ExecuteNonQuery();
                 //Veritabanında değişiklik yapacak komut işlemi bu satırda gerçekleşiyor.
                 conn.Close();
                 if (conn.State == ConnectionState.Closed)
                 {
                     conn.Open();
                 }
                 // Bağlantımızı kontrol ediyoruz, eğer kapalıysa açıyoruz.
                 kayit = "insert into rezervasyon(takim_adi,tarih,saat,fiyat) values (@takimadi,@tarih,@saat,@fiyat)";
                 // müşteriler tablomuzun ilgili alanlarına kayıt ekleme işlemini gerçekleştirecek sorgumuz.
                 SqlCommand komut1 = new SqlCommand(kayit, conn);
                 //Sorgumuzu ve baglantimizi parametre olarak alan bir SqlCommand nesnesi oluşturuyoruz.
                 komut1.Parameters.AddWithValue("@takimadi", textBox2.Text);
                 komut1.Parameters.AddWithValue("@tarih", dateTimePicker2.Value);
                 komut1.Parameters.AddWithValue("@saat", comboBox1.Text);
                 komut1.Parameters.AddWithValue("@fiyat", textBox1.Text);
                 //Parametrelerimize Form üzerinde ki kontrollerden girilen verileri aktarıyoruz.
                 komut1.ExecuteNonQuery();
                 //Veritabanında değişiklik yapacak komut işlemi bu satırda gerçekleşiyor.
                 conn.Close();
                 if (conn.State == ConnectionState.Closed)
                 {
                     conn.Open();
                 }
                 // Bağlantımızı kontrol ediyoruz, eğer kapalıysa açıyoruz.
                 kayit = "insert into takim_bilgi(takim_adi,oyuncu1,oyuncu2,oyuncu3,oyuncu4,oyuncu5,oyuncu6,oyuncu7,oyuncu8) values (@takimadi,@oyuncu1,@oyuncu2,@oyuncu3,@oyuncu4,@oyuncu5,@oyuncu6,@oyuncu7,@oyuncu8)";
                 // müşteriler tablomuzun ilgili alanlarına kayıt ekleme işlemini gerçekleştirecek sorgumuz.
                 SqlCommand komut2 = new SqlCommand(kayit, conn);
                 //Sorgumuzu ve baglantimizi parametre olarak alan bir SqlCommand nesnesi oluşturuyoruz.
                 komut2.Parameters.AddWithValue("@takimadi", textBox2.Text);
                 komut2.Parameters.AddWithValue("@oyuncu1", listBox1.Items[0].ToString());
                 komut2.Parameters.AddWithValue("@oyuncu2", listBox1.Items[1].ToString());
                 komut2.Parameters.AddWithValue("@oyuncu3", listBox1.Items[2].ToString());
                 komut2.Parameters.AddWithValue("@oyuncu4", listBox1.Items[3].ToString());
                 komut2.Parameters.AddWithValue("@oyuncu5", listBox1.Items[4].ToString());
                 komut2.Parameters.AddWithValue("@oyuncu6", listBox1.Items[5].ToString());
                 komut2.Parameters.AddWithValue("@oyuncu7", listBox1.Items[6].ToString());
                 komut2.Parameters.AddWithValue("@oyuncu8", listBox1.Items[7].ToString());
                 //Parametrelerimize Form üzerinde ki kontrollerden girilen verileri aktarıyoruz.
                 komut2.ExecuteNonQuery();
                 //Veritabanında değişiklik yapacak komut işlemi bu satırda gerçekleşiyor.
                 conn.Close();
                 MessageBox.Show("Kayıt işlemi tamamlandı.");
                 menu frm1 = (menu)Application.OpenForms["menu"];
                 frm1.tarihgoster();
             }
         }
         else
         {
             MessageBox.Show("Mail Adresini ve diğer bilgileri düzgün girdiginizden emin olun");
         }
     }
     catch (Exception hata)
     {
         MessageBox.Show("Lütfen tüm bilgileri girdiğinizden emin olun.Eğer bir hata olduğunu düşünüyorsanız programcınız ile iletişime geçiniz.");
         MessageBox.Show(hata.ToString());
     }
 }