Exemple #1
0
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            string sorgu = "INSERT INTO Araclar (Plaka ,KoltukSayisi) VALUES ('" + txtPlaka.Text + "'," + txtKoltukSay.Text + ")";

            Asistan.iduSql(sorgu);
            MessageBox.Show("İşlem tamamlandı...");
            Asistan.dgvYenile("SELECT Plaka,KoltukSayisi FROM Araclar", dgvOtobus);
        }
Exemple #2
0
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            string sorgu       = "INSERT INTO Soforler ([Adi],[Soyadi],[TcNo],[Telefon],[Adres]) VALUES ('" + txtAd.Text + "','" + txtSoyad.Text + "','" + txtTC.Text + "','" + txtTel.Text + "','" + txtAdres.Text + "')";
            string sorgu_liste = "SELECT [SoforID],[Adi],[Soyadi],[TcNo],[Telefon],[Adres] FROM Soforler";

            Asistan.iduSql(sorgu);
            MessageBox.Show("İşlem tamamlandı...");
            Asistan.dgvYenile(sorgu_liste, dgvSofor);
        }
        private void btnDuzenle_Click(object sender, EventArgs e)
        {
            string srgKullaniciDuzenle = "UPDATE Kullanici SET KullaniciAdi ='" + txtKullaniciAdi.Text + "' ,[Sifre] ='" + txtSifre.Text + "'    ,[Adi] ='" + txtAd.Text + "',[Soyadi] ='" + txtSoyad.Text + "' WHERE KullaniciID=" + dataGridViewListe.CurrentRow.Cells[0].Value.ToString();

            Asistan.iduSql(srgKullaniciDuzenle);
            Asistan.iduSql("ENABLE TRIGGER guncelle ON Kullanici");

            Asistan.dgvYenile(dgvYenile, dataGridViewListe);
        }
        private void btnEkle_Click(object sender, EventArgs e)
        {
            string srgEkle = "INSERT INTO Kullanici(KullaniciAdi ,Sifre,Adi,Soyadi) VALUES ('" + txtKullaniciAdi.Text + "','" + txtSifre.Text + "','" + txtAd.Text + "','" + txtSoyad.Text + "')";

            try
            {
                Asistan.iduSql(srgEkle);

                MessageBox.Show("İşlem tamamlandı...");
                Asistan.dgvYenile(dgvYenile, dataGridViewListe);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Hata");
            }
        }
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "")
            {
                MessageBox.Show("Boş alan bırakmayınız");
            }
            else
            {
                string tarih       = dateTimePicker1.Value.ToString("yyyy-MM-dd ");
                string saat        = textBox1.Text + ":" + textBox2.Text + ":00.000";
                string sorgu_Kayit = "INSERT INTO Seferler (Kalkis ,Varis,Tarih,Arac ,Sofor) VALUES(" + comboBoxKalkis.SelectedValue + "," + comboBoxVaris.SelectedValue + ",'" + tarih + saat + "','" + comboBoxArac.SelectedValue + "'," + comboBoxSofor.SelectedValue + ")";


                Asistan.iduSql(sorgu_Kayit);
                MessageBox.Show("İşlem Tamamlandı...");
            }
        }
        private void btnBiletSil_Click(object sender, EventArgs e)
        {
            DialogResult secim = MessageBox.Show("Silmek istiyor musunuz ?", "Onay", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (secim == DialogResult.Yes)
            {
                string srg1 = "delete from Yolcu  where YolcuID= " + lbIDYolcu.Text;
                string srg  = "DELETE FROM Bilet WHERE KoltukNo= " + lblBiletNo.Text;


                Asistan.iduSql(srg1);
                Asistan.iduSql(srg);

                lbIDYolcu.Text = "*";
                lblAd.Text     = "*";
                lblSoyad.Text  = "*"; lbCinsiyet.Text = "*"; lbTelefon.Text = "*"; lblSeferTarih.Text = "*"; lblSeferNo.Text = "*";  lblSatisTipi.Text = "*"; lblKoltukNo.Text = "*"; lblBiletNo.Text = "*"; lblBİletFiyati.Text = "*";
            }
        }
        private void comboBoxKalkis_SelectionChangeCommitted(object sender, EventArgs e)
        {
            comboBoxVaris.Enabled = true;
            string sorgu_ilVaris = "select distinct i.ilKodu,i.ilAdi from Seferler s, iller i where i.ilKodu=s.Varis and s.Kalkis=" + comboBoxKalkis.SelectedValue.ToString();

            Asistan.comboBoxDoldur(comboBoxVaris, sorgu_ilVaris, "ilAdi", "ilKodu"); comboBoxVaris.SelectedIndex = -1; comboBoxVaris.Text = "Lütfen Seçiniz";
            if (comboBoxVaris.SelectedIndex != -1)
            {
                if (comboBoxVaris.SelectedValue.ToString() == comboBoxKalkis.SelectedValue.ToString())
                {
                    MessageBox.Show("Aynı iller seçilemez");
                }
                else
                {
                    string sorgu_sefer = "SELECT SeferID,Tarih FROM Seferler where Kalkis=" + comboBoxKalkis.SelectedValue + " and Varis=" + comboBoxVaris.SelectedValue;
                    Asistan.iduSql(sorgu_sefer); Asistan.comboBoxDoldur(comboBoxSefer, sorgu_sefer, "SeferID", "SeferID");
                    comboBoxSefer.Enabled = true; comboBoxSefer.Text = "Lütfen Seçiniz";
                }
            }
        }
        private void koltuklarClick(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            BasılanButon = (Button)sender;
            int          koltukNo = int.Parse(BasılanButon.Text);
            string       cinsiyet = "";
            DialogResult secim    = MessageBox.Show("Bu koltuğa kayıt yapılsın mı ?", "Koltuk Onay", MessageBoxButtons.YesNo);

            if (secim == DialogResult.Yes)
            {
                if (txtUcret.Text == "" || comboBoxOSekli.SelectedIndex == -1)
                {
                    MessageBox.Show("Ödeme bilgilerini giriniz."); goto hata;
                }
                if (rdoBayan.Checked == true)
                {
                    cinsiyet               = "K";
                    koltukcins[koltukNo]   = "K";
                    BasılanButon.BackColor = Color.LightPink;
                }
                else if (rdoErkek.Checked == true)
                {
                    cinsiyet               = "E";
                    koltukcins[koltukNo]   = "E";
                    BasılanButon.BackColor = Color.LightBlue;
                }
                else
                {
                    MessageBox.Show("Hata ! Lütfen seçimlerinizi kontrol ediniz..."); goto hata;
                }
                BasılanButon.Enabled   = false;
                yolcular[koltukNo - 1] = txtAd.Text.PadRight(12, ' ') + txtSoyad.Text.PadRight(12, ' ') + cinsiyet.PadRight(8, ' ');
                yolcuSayisi++;
                string odeme = "";
                if (comboBoxOSekli.Text == "Nakit")
                {
                    odeme = "1";
                }
                else
                {
                    odeme = "2";
                }
                string tarih = Asistan.tarihFormat(DateTime.Now.Day.ToString(), DateTime.Now.Month.ToString(), DateTime.Now.Year.ToString());

                string    Yolcu_kayit  = " Insert into Yolcu(SeferID,Adi,Soyadi,Cinsiyet,Telefon,Aciklama) VALUES (" + comboBoxSefer.Text + ",'" + txtAd.Text + "','" + txtSoyad.Text + "','" + cinsiyet + "','" + txtTel.Text + "',' ')"; Asistan.iduSql(Yolcu_kayit);
                DataTable dtSefer      = Asistan.dataTable("Select * from Seferler where SeferID=" + comboBoxSefer.GetItemText(comboBoxSefer.SelectedItem));
                DataTable dtYolcu      = Asistan.dataTable("Select * from Yolcu where SeferID=" + comboBoxSefer.Text + " and Adi='" + txtAd.Text + "' and  Soyadi='" + txtSoyad.Text + "'");
                string    koltuk_kayit = "Insert into Koltuk(Plaka,KoltukNo,SeferID,YolcuID,Fiyat,OdemeSekli,AlınmaTarihi) VALUES ('" + dtSefer.Rows[0]["Arac"].ToString() + "','" + BasılanButon.Text + "'," + comboBoxSefer.Text + "," + dtYolcu.Rows[0]["YolcuID"] + "," + txtUcret.Text + "," + odeme + ",'" + tarih + "')";

                Asistan.iduSql(koltuk_kayit);
                SqlConnection cnn = Asistan.baglan();
                cnn.Open();

                SqlCommand cmd = new SqlCommand("Insert into Bilet(Plaka,SeferID,KoltukNo,Fiyat,OdemeSekli,YolcuID) values(@Plaka,@SeferID,@KoltukNo,@Fiyat,@OdemeSekli,@YolcuID)", cnn);


                cmd.Parameters.AddWithValue("@Plaka", dtSefer.Rows[0]["Arac"].ToString());
                cmd.Parameters.AddWithValue("@KoltukID", "Koltuk.KoltukID");
                cmd.Parameters.AddWithValue("@SeferID", comboBoxSefer.Text);
                cmd.Parameters.AddWithValue("@KoltukNo", BasılanButon.Text);
                cmd.Parameters.AddWithValue("@Fiyat", txtUcret.Text);
                cmd.Parameters.AddWithValue("@OdemeSekli", odeme);
                cmd.Parameters.AddWithValue("@YolcuID", dtYolcu.Rows[0]["YolcuID"]);


                cmd.ExecuteNonQuery(); cnn.Close();


                formTemizle();
                hata :;
            }
        }