private void button_kaydet_Click(object sender, EventArgs e) { DateTime kalkisZamani = new DateTime(dateTimePicker_kalkisZamanGun.Value.Year, dateTimePicker_kalkisZamanGun.Value.Month, dateTimePicker_kalkisZamanGun.Value.Day, dateTimePicker_kalkisZamansaat.Value.Hour, dateTimePicker_kalkisZamansaat.Value.Minute, 0); DateTime varisZamani = new DateTime(dateTimePicker_varisZamanGun.Value.Year, dateTimePicker_varisZamanGun.Value.Month, dateTimePicker_varisZamanGun.Value.Day, dateTimePicker_varisZamansaat.Value.Hour, dateTimePicker_varisZamansaat.Value.Minute, 0); TimeSpan fark = varisZamani.Subtract(kalkisZamani); if (fark.TotalMinutes <= 0) { toolStripStatusLabel_kayitdurum.Text = "Varış zamanı kalkış zamanından büyük olmak zorunda"; return; } textBox_tahminiSure.Text = fark.ToString(); double ucret = 0; try { ucret = double.Parse(textBox_bilettutar.Text); } catch (Exception) { toolStripStatusLabel_kayitdurum.Text = "Ücret bloğunu kontrol ediniz."; } toolStripStatusLabel_kayitdurum.Text = ""; Seferler sefer = new Seferler(); sefer.KalkisSehirID = (comboBox_guzergah.SelectedItem as Guzergah).kalkis_sehir; sefer.VarisSehirID = (comboBox_guzergah.SelectedItem as Guzergah).varis_sehir; sefer.OtobusID = (comboBox_otobus.SelectedItem as Otobusler).ID; sefer.MuavinID = (comboBox_muavin.SelectedItem as Calisanlar).ID; sefer.SoforID = (comboBox_sofor.SelectedItem as Calisanlar).ID; sefer.KalkisZamani = kalkisZamani; sefer.VarisZamani = varisZamani; sefer.TahminiSure = textBox_tahminiSure.Text; sefer.BiletTutar = Convert.ToDecimal(ucret); sefer.guzergahID = (comboBox_guzergah.SelectedItem as Guzergah).ID; ctx.Seferlers.InsertOnSubmit(sefer); try { ctx.SubmitChanges(); toolStripStatusLabel_kayitdurum.Text = "Kayıt başarılı"; } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_kayitdurum.Text = "Kayıt başarısız."; } }
private void button_guncelle_Click(object sender, EventArgs e) { textBox_plaka.Text = textBox_plaka.Text.Trim().ToUpper(); if (textBox_plaka.Text.Length == 0) { textBox_plaka.BackColor = Color.Red; toolStripStatusLabel_guncelleme_durum.Text = "Eksik bilgileri kontrol ediniz."; return; } otobus.Plaka = textBox_plaka.Text; otobus.AktifMi = checkBox_aktifMi.Checked; try { ctx.SubmitChanges(); toolStripStatusLabel_guncelleme_durum.Text = "Güncelleme başarılı."; label_otobusID.Text = ""; textBox_plaka.Text = ""; label_koltukSayisi.Text = ""; label_marka.Text = ""; button_guncelle.Enabled = false; button_butun_otobusler_Click(null, null); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_guncelleme_durum.Text = "Güncelleme başarısız oldu"; } }
private void button_bilet_bul_Click(object sender, EventArgs e) { try { int biletID = Convert.ToInt32(textBox_biletNumarasi.Text); bilet = ctx.Biletlers.Where(b => b.ID == biletID).Select(b => b).Single(); Seferler sefer = ctx.Seferlers.Where(s => s.ID == bilet.SeferID).Select(s => s).Single(); label_sefer.Text = sefer.ToString(); label_zaman.Text = bilet.IslemZaman.ToLongDateString(); label_koltuk.Text = bilet.KultukNo.ToString(); label_ad.Text = bilet.YolcuAd; label_soyad.Text = bilet.YolcuSoyad; if (bilet.SatisTip) { label_satis_tip.Text = "Nakit"; } else { label_satis_tip.Text = "Kredi Kartı"; } label_ucret.Text = bilet.Ucret.ToString(".##"); label_inis.Text = ctx.Sehirlers.Where(s => s.ID == bilet.InisSehirID).Select(s => s.SehirAd).Single(); label_binis.Text = ctx.Sehirlers.Where(s => s.ID == bilet.BinisSehirID).Select(s => s.SehirAd).Single(); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_biletBilgi.Text = "Bilet bulunamadı"; } }
private void button_ekle_Click(object sender, EventArgs e) { textBox_markaAdi.Text = textBox_markaAdi.Text.Trim().ToUpper(); if (textBox_markaAdi.Text.Length == 0) { toolStripStatusLabel_marka_ekleme.Text = "Marka adı girmediniz."; return; } try { Markalar marka = new Markalar(); marka.MarkaAd = textBox_markaAdi.Text; ctx.Markalars.InsertOnSubmit(marka); ctx.SubmitChanges(); toolStripStatusLabel_marka_ekleme.Text = "Kayıt başarı ile eklendi."; textBox_markaAdi.Text = ""; MarkalariCek(); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_marka_ekleme.Text = "Kayıt eklenirken bir hata ile karşılaşıldı."; } }
private void button__ara_Click(object sender, EventArgs e) { Musteriler musteri = null; try { int musteriID = Convert.ToInt32(textBox_ID.Text); musteri = ctx.Musterilers.Where(m => m.ID == musteriID).Select(m => m).Single(); Form_musteriKayitAl musteriKaydi = new Form_musteriKayitAl(musteri); foreach (Form item in this.MdiParent.MdiChildren) { if (item.Text == musteriKaydi.Text) { item.Close(); musteriKaydi.MdiParent = this.MdiParent; musteriKaydi.Show(); this.Close(); return; } } musteriKaydi.MdiParent = this.MdiParent; musteriKaydi.Show(); this.Close(); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_bilgi.Text = "Aranan müşteri bulunamadı"; } }
private void button_sil_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Sefer silinecek. Onaylamak için " + DialogResult.Yes.ToString() + " butonuna basın.", "Dikkat", MessageBoxButtons.YesNo, MessageBoxIcon.Stop); if (result == DialogResult.Yes) { Seferler sefer = ctx.Seferlers.Where(s => s.ID == seferID).Select(s => s).Single(); IEnumerable <Biletler> biletler = ctx.Biletlers.Where(b => b.SeferID == seferID).Select(b => b); IEnumerable <DoluKoltuklar> doluKoltuklar = ctx.DoluKoltuklars.Where(d => d.SeferID == seferID).Select(d => d); IEnumerable <OtobusMasraflari> masraflar = ctx.OtobusMasraflaris.Where(ms => ms.SeferID == seferID).Select(ms => ms); ctx.OtobusMasraflaris.DeleteAllOnSubmit(masraflar); ctx.DoluKoltuklars.DeleteAllOnSubmit(doluKoltuklar); ctx.Biletlers.DeleteAllOnSubmit(biletler); ctx.Seferlers.DeleteOnSubmit(sefer); try { ctx.SubmitChanges(); toolStripStatusLabel_bilgi.Text = "Sefer başarı ile silindi."; IEnumerable <Guzergah> guzergahlar = ctx.Guzergahs.Select(g => g); comboBox_guzergahlar.DataSource = guzergahlar; } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_bilgi.Text = "Sefer silinirken hata oluştu."; } } }
private void button1_Click(object sender, EventArgs e) { try { if (VeriGirisKontrol()) { int secilen_sehir = (comboBox_sube_sehir.SelectedItem as Sehirler).ID; string sube_ad = textBox_sube_ad.Text.Trim(); VeriTabaniIslemleriDataContext ctx = new VeriTabaniIslemleriDataContext(); Subeler sube = new Subeler(); sube.SubeAd = sube_ad; sube.SehirID = secilen_sehir; ctx.Subelers.InsertOnSubmit(sube); ctx.SubmitChanges(); MessageBox.Show(comboBox_sube_sehir.SelectedItem + " şubesi eklendi", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); MessageBox.Show(comboBox_sube_sehir.SelectedItem + " şubesi eklenirken bir oluştu.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button_kaydet_Click(object sender, EventArgs e) { textBox_pozisyon_adi.Text = textBox_pozisyon_adi.Text.Trim().ToUpper(); if (IsimDoğrula(textBox_pozisyon_adi.Text)) { CalisanTipleri calisanTip = new CalisanTipleri(); calisanTip.TipAd = textBox_pozisyon_adi.Text; try { ctx.CalisanTipleris.InsertOnSubmit(calisanTip); ctx.SubmitChanges(); toolStripStatusLabel_bilgi.Text = "Pozisyon başarı ile eklendi."; textBox_pozisyon_adi.Text = ""; PozisyonlariCek(); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_bilgi.Text = "Pozisyon eklenirken hata oluştu."; } } else { toolStripStatusLabel_bilgi.Text = "Lütfen ismi kontrol ediniz."; } }
private void button_kaydet_Click(object sender, EventArgs e) { if (textBox_plaka.BackColor == Color.Red) { toolStripStatusLabel_kayit_durum.Text = "Eksik alanları kontrol ediniz."; return; } if (textBox_koltuk_sayisi.Text.Length == 0) { textBox_koltuk_sayisi.BackColor = Color.Red; toolStripStatusLabel_kayit_durum.Text = "Eksik alanları kontrol ediniz."; return; } Otobusler otobus = new Otobusler(); otobus.Plaka = textBox_plaka.Text; otobus.KoltukSayisi = Convert.ToByte(textBox_koltuk_sayisi.Text); otobus.MarkaID = (comboBox_marka.SelectedItem as Markalar).ID; otobus.AktifMi = checkBox_aktifMi.Checked; try { ctx.Otobuslers.InsertOnSubmit(otobus); ctx.SubmitChanges(); toolStripStatusLabel_kayit_durum.Text = "Yeni otobüs başarı ile eklendi."; textBox_plaka.Text = ""; textBox_koltuk_sayisi.Text = ""; textBox_koltuk_sayisi.BackColor = Color.White; } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_kayit_durum.Text = "Ekleme başarısız."; } }
private void button_kaydet_Click(object sender, EventArgs e) { try { decimal tutar = Convert.ToDecimal(textBox_tutar.Text); OtobusMasraflari masraf = new OtobusMasraflari(); masraf.OtobusId = sefer.OtobusID; masraf.MasrafTipID = (comboBox_masraf.SelectedItem as MasrafTipleri).ID; masraf.Tutar = tutar; masraf.PersonelID = (comboBox_calisan.SelectedItem as Calisanlar).ID; masraf.SeferID = sefer.ID; ctx.OtobusMasraflaris.InsertOnSubmit(masraf); ctx.SubmitChanges(); toolStripStatusLabel_bilgi.Text = "Masraf kaydı başarı ile gerçekleşti"; textBox_tutar.Text = ""; SeciliSefereAitButunMasraflar(sefer.ID); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_bilgi.Text = "Masraf eklenirken bir hata ile karşılaşıldı."; } }
private void button_kaydet_Click(object sender, EventArgs e) { textBox_MasrafAdi_adi.Text = textBox_MasrafAdi_adi.Text.Trim().ToUpper(); if (IsimDoğrula(textBox_MasrafAdi_adi.Text)) { MasrafTipleri masrafTip = new MasrafTipleri(); masrafTip.MasrafAd = textBox_MasrafAdi_adi.Text; try { ctx.MasrafTipleris.InsertOnSubmit(masrafTip); ctx.SubmitChanges(); toolStripStatusLabel_bilgi.Text = "Masraf Çeşiti başarı ile eklendi."; MasrafTipleriniCek(); textBox_MasrafAdi_adi.Text = ""; } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_bilgi.Text = "Masraf Çeşiti eklenirken hata oluştu."; } } else { toolStripStatusLabel_bilgi.Text = "Lütfen ismi kontrol ediniz."; } }
private void button_guncelle_Click(object sender, EventArgs e) { textBox_MasrafYeniAd.Text = textBox_MasrafYeniAd.Text.Trim().ToUpper(); if (IsimDoğrula(textBox_MasrafYeniAd.Text)) { int masrafTipID = (listBox_masrafCesitleri.SelectedItem as MasrafTipleri).ID; MasrafTipleri masrafTip = ctx.MasrafTipleris.Where(ct => ct.ID == masrafTipID).Select(ct => ct).Single(); masrafTip.MasrafAd = textBox_MasrafYeniAd.Text; DialogResult result = MessageBox.Show("Masraf Tipi güncellenecek. Onaylamak için " + DialogResult.Yes.ToString() + " butonuna basın.", "Dikkat", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (result == DialogResult.Yes) { try { ctx.SubmitChanges(); toolStripStatusLabel_bilgi.Text = "Güncelleme işlemi başarı ile gerçekleşti."; MasrafTipleriniCek(); textBox_MasrafYeniAd.Text = ""; } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_bilgi.Text = "Güncelleme işlemi başarısız oldu."; } } } else { toolStripStatusLabel_bilgi.Text = "Lütfen ismi kontrol ediniz."; } }
private void button_sil_Click(object sender, EventArgs e) { try { ctx.Musterilers.DeleteOnSubmit(Musteri); ctx.SubmitChanges(); MessageBox.Show("Silme işlemi başarı ile tamamlanmıştır.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); return; } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_bilgi.Text = "Silme işlemi hata ile karşılaştı."; } }
private void button_yolcuyuSorgula_Click(object sender, EventArgs e) { try { yolcuID = Convert.ToInt32(textBox_yolcuID.Text); Musteriler musteri = ctx.Musterilers.Where(m => m.ID == yolcuID).Select(m => m).First(); textBox_yolcuAd.Text = musteri.Ad; textBox_yolcuSoyad.Text = musteri.Soyad; comboBox_cinsiyet.SelectedIndex = Convert.ToInt32(musteri.Cinsiyet); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_islemstatu.Text = "Arama sırasında bir hata ile karşılaşıldı."; } }
private void button_guncelle_kayit_Click(object sender, EventArgs e) { string sube_ad = textBox_subeAd.Text; if (IsimHataliMi(sube_ad)) { MessageBox.Show("Şube adı sadece harf veya rakam içerebilir.", "Yanlış bilgi!", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } if (sube_ad.Length < 1) { MessageBox.Show("Şube adını girmediniz.", "Eksik bilgi!", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } DialogResult secim = MessageBox.Show(dataGridView_subeler.SelectedRows[0].Cells[1].Value.ToString() + " şubesi " + sube_ad + " olarak güncellenecek. Onaylıyor musunuz?", "Onay İstemi", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (secim != DialogResult.Yes) { return; } try { VeriTabaniIslemleriDataContext db = new VeriTabaniIslemleriDataContext(); int sube_id = Convert.ToInt32(label_sube_kodu.Text); Subeler guncellenecek_sube = db.Subelers.First(s => s.ID == sube_id); guncellenecek_sube.SubeAd = sube_ad; db.SubmitChanges(); MessageBox.Show(dataGridView_subeler.SelectedRows[0].Cells[1].Value.ToString() + " şubesi " + sube_ad + " olarak güncellendi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information); button_grid_yenile.Enabled = true; dataGridView_subeler.Enabled = true; comboBox_sehirler.Enabled = true; panel_guncelleme.Visible = false; textBox_subeAd.ReadOnly = true; button_grid_yenile_Click(null, null); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); MessageBox.Show("Kayıt güncellenirken bir hata ile karşılaşıldı.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button_ara_Click(object sender, EventArgs e) { try { int seferID = Convert.ToInt32(textBox_seferID.Text); sefer = ctx.Seferlers.Where(s => s.ID == seferID).Select(s => s).Single(); label_otobus.Text = sefer.Otobusler.ToString(); comboBox_calisan.DataSource = ctx.Calisanlars.Where(c => (c.ID == sefer.MuavinID || c.ID == sefer.SoforID)).Select(c => c); comboBox_kayitli_calisan.DataSource = ctx.Calisanlars.Where(c => (c.ID == sefer.MuavinID || c.ID == sefer.SoforID)).Select(c => c); SeciliSefereAitButunMasraflar(seferID); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_bilgi.Text = "Aradığınız sefer bilgisine ulaşılamadı. Lütfen kontrol ederek tekrar deneyiniz."; } }
private void button_kaydet_Click(object sender, EventArgs e) { foreach (Char item in textBox_calisan_ID.Text) { if (!Char.IsDigit(item)) { toolStripStatusLabel_durum.Text = "Numara sadece rakamlardan oluşabilir."; return; } } int guncellenecekID = Convert.ToInt32(textBox_calisan_ID.Text); Calisanlar calisan = null; try { calisan = db.Calisanlars.Where(s => s.ID == guncellenecekID).Select(s => s).First(); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_durum.Text = "Çalışan bulunamadı."; return; } Form_personel_guncelle_ekle frm_guncelle = new Form_personel_guncelle_ekle(calisan); frm_guncelle.Text = "Personel Güncelle"; if (Form_personel_guncelle_ekle.form_acik_mi) { foreach (Form item in this.MdiParent.MdiChildren) { if (item.Text == frm_guncelle.Text) { MessageBox.Show("Lütfen açık olan güncelleme penceresini kapatıp tekrar deneyiniz.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Stop); item.BringToFront(); return; } } } frm_guncelle.MdiParent = this.MdiParent; frm_guncelle.Show(); this.Close(); }
private void button_guncelle_Click(object sender, EventArgs e) { try { decimal tutar = Convert.ToDecimal(textBox_kayitliTutar.Text); masraf_.MasrafTipID = (comboBox_kayitliMasraf.SelectedItem as MasrafTipleri).ID; masraf_.Tutar = tutar; masraf_.PersonelID = (comboBox_kayitli_calisan.SelectedItem as Calisanlar).ID; ctx.SubmitChanges(); toolStripStatusLabel_bilgi.Text = "Masraf güncellemesi başarı ile gerçekleşti"; textBox_tutar.Text = ""; SeciliSefereAitButunMasraflar(sefer.ID); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_bilgi.Text = "Masraf güncellenirken bir hata ile karşılaşıldı."; } }
private void button_ekle_Click(object sender, EventArgs e) { Guzergah guzergah = new Guzergah(); guzergah.Tanim = textBox_guzergahIsmi.Text; guzergah.kalkis_sehir = (comboBox_baslamaSehir.SelectedItem as Sehirler).ID; guzergah.varis_sehir = (comboBox_varisSehir.SelectedItem as Sehirler).ID; try { ctx.Guzergahs.InsertOnSubmit(guzergah); ctx.SubmitChanges(); toolStripStatusLabel_kayit.Text = "Kayıt başarılı.\nGüzergah üzeri şehir seçiniz."; groupBox_GuzergahSehirleri.Enabled = true; panel_guzergahEkle.Enabled = false; guzergahID = ctx.Guzergahs.Where(g => g.Tanim.CompareTo(guzergah.Tanim) == 0).Select(g => g.ID).First(); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_kayit.Text = "Kayıt başarısız."; } }
private void button_sil_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Masraf Çeşiti silinecek. Onaylamak için " + DialogResult.Yes.ToString() + " butonuna basın.", "Dikkat", MessageBoxButtons.YesNo, MessageBoxIcon.Stop); if (result == DialogResult.Yes) { int masrafTipID = (listBox_masrafCesitleri.SelectedItem as MasrafTipleri).ID; MasrafTipleri masrafTip = ctx.MasrafTipleris.Where(ct => ct.ID == masrafTipID).Select(ct => ct).Single(); ctx.MasrafTipleris.DeleteOnSubmit(masrafTip); try { ctx.SubmitChanges(); toolStripStatusLabel_bilgi.Text = "Pozisyon başarı ile silindi."; MasrafTipleriniCek(); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_bilgi.Text = "Pozisyon silinirken hata oluştu."; } } }
private void subeyiSilToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult secim = MessageBox.Show(textBox_subeAd.Text + " şubesi silinecek. Onaylıyor musunuz?", "Onay İstemi", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (secim != DialogResult.Yes) { return; } try { VeriTabaniIslemleriDataContext db = new VeriTabaniIslemleriDataContext(); int sube_id = Convert.ToInt32(label_sube_kodu.Text); Subeler silinecekSube = db.Subelers.First(s => s.ID == sube_id); db.Subelers.DeleteOnSubmit(silinecekSube); db.SubmitChanges(); MessageBox.Show(silinecekSube.SubeAd + " şubesi başarı ile silindi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information); comboBox_sehirler_SelectedIndexChanged(null, null); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); MessageBox.Show("Kayıt silinirken bir hata ile karşılaşıldı.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button_sil_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Güzergah silinecek. Onaylamak için " + DialogResult.Yes.ToString() + " butonuna basın.", "Dikkat", MessageBoxButtons.YesNo, MessageBoxIcon.Stop); if (result == DialogResult.Yes) { Guzergah guzergah = ctx.Guzergahs.Where(g => g.ID == GuzergahID).Select(g => g).Single(); ctx.Guzergahs.DeleteOnSubmit(guzergah); IEnumerable <GuzergahItem> GuzergahItems = ctx.GuzergahItems.Where(gi => gi.SeferID == GuzergahID).Select(gi => gi); ctx.GuzergahItems.DeleteAllOnSubmit(GuzergahItems); IEnumerable <Seferler> seferler = ctx.Seferlers.Where(s => s.guzergahID == GuzergahID).Select(s => s); ctx.Seferlers.DeleteAllOnSubmit(seferler); foreach (Seferler item in seferler) { IEnumerable <Biletler> biletler = ctx.Biletlers.Where(b => b.SeferID == item.ID).Select(b => b); ctx.Biletlers.DeleteAllOnSubmit(biletler); IEnumerable <DoluKoltuklar> doluKoltuklar = ctx.DoluKoltuklars.Where(d => d.SeferID == item.ID).Select(d => d); ctx.DoluKoltuklars.DeleteAllOnSubmit(doluKoltuklar); } try { ctx.SubmitChanges(); toolStripStatusLabel_bilgi.Text = "Güzergah başarı ile silindi."; GuzergahlariCek(); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_bilgi.Text = "Güzergah silinirken hata oluştu."; } } }
private void button_guncelle_Click(object sender, EventArgs e) { int markaID = Convert.ToInt32(label_markaKodu.Text); Markalar marka = ctx.Markalars.Where(m => m.ID == markaID).Select(m => m).First(); textBox_markanin_adi.Text = textBox_markanin_adi.Text.Trim().ToUpper(); if (textBox_markanin_adi.Text.Length == 0) { toolStripStatusLabel_marka_guncelle_sil.Text = "Marka adını yazmadınız."; return; } marka.MarkaAd = textBox_markanin_adi.Text; try { ctx.SubmitChanges(); toolStripStatusLabel_marka_guncelle_sil.Text = "Marka adı başarı ile güncellendi."; MarkalariCek(); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_marka_guncelle_sil.Text = "Marka adı güncelleme başarısız."; } }
private void button_sehirleriKaydet_Click(object sender, EventArgs e) { bool basari = false; foreach (var item in groupBox_GuzergahSehirleri.Controls) { if (item is ComboBox) { ComboBox combo = item as ComboBox; GuzergahItem guzergahItem = new GuzergahItem(); guzergahItem.SeferID = guzergahID; guzergahItem.GececegiIlID = (combo.SelectedItem as Sehirler).ID; ctx.GuzergahItems.InsertOnSubmit(guzergahItem); try { ctx.SubmitChanges(); basari = true; } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); basari = false; } } } if (basari) { toolStripStatusLabel_itemKayit.Text = "Kayıtlar başarılı"; } else { toolStripStatusLabel_itemKayit.Text = "Kayıtlar başarısız"; } panel_guzergahEkle.Enabled = true; groupBox_GuzergahSehirleri.Enabled = false; }
/// <summary> /// Kayıt işleminden önce bütün bilgilerin doğruluğu kontrol ediliyor. Bunun için fon rengi kırmızı olan textbox olmaması gerekiyor. /// </summary> private void button_kaydet_Click(object sender, EventArgs e) { if (textBox_sifre.Text.CompareTo(textBox_sifre_tekrar.Text) != 0) { toolStripStatusLabel_kayit_durum.Text = "Şifreler aynı değil."; return; } if (!ZorlayiciKayitlariSina()) { toolStripStatusLabel_kayit_durum.Text = "Kırmızı ile boyanmış bilgiler eksik veya yanlış girilmiştir"; return; } int subeid = (comboBox_sube.SelectedItem as Subeler).ID; int calismaPozisyonu = (comboBox_calisan_tipi.SelectedItem as CalisanTipleri).ID; if (ID > 0 && guncellenecek_Calisan == null) { Calisanlar calisan_update = db.Calisanlars.Where(c => c.ID == ID).Select(s => s).First(); calisan_update.Ad = textBox_ad.Text; calisan_update.Soyad = textBox_soyad.Text; calisan_update.Telefon = textBox_telefon.Text; calisan_update.Email = textBox_mail.Text; calisan_update.EvAdres = textBox_ev_adres.Text; calisan_update.KullaniciAd = textBox_kullanici_ad.Text; calisan_update.Sifre = textBox_sifre.Text; calisan_update.YoneticiMi = checkBox_yonetici_mi.Checked; calisan_update.CalisanTipID = calismaPozisyonu; calisan_update.SubeID = subeid; try { db.SubmitChanges(); MessageBox.Show(calisan_update.Ad + " " + calisan_update.Soyad + ", " + comboBox_sube.SelectedValue + " şubesinde güncellendi", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_kayit_durum.Text = "Güncelleme başarısız. Bir hata ile karşılaşıldı."; } return; } Calisanlar calisan = new Calisanlar(); calisan.Ad = textBox_ad.Text; calisan.Soyad = textBox_soyad.Text; calisan.Telefon = textBox_telefon.Text; calisan.Email = textBox_mail.Text; calisan.EvAdres = textBox_ev_adres.Text; calisan.KullaniciAd = textBox_kullanici_ad.Text; calisan.Sifre = textBox_sifre.Text; calisan.YoneticiMi = checkBox_yonetici_mi.Checked; calisan.CalisanTipID = calismaPozisyonu; calisan.SubeID = subeid; try { db.Calisanlars.InsertOnSubmit(calisan); db.SubmitChanges(); MessageBox.Show(calisan.Ad + " " + calisan.Soyad + ", " + comboBox_sube.SelectedValue + " şubesine eklendi", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception) { toolStripStatusLabel_kayit_durum.Text = "Kayıt başarısız. Bir hata ile karşılaşıldı."; } }
private void button_kaydet_Click(object sender, EventArgs e) { if (!(ad && soyad && email && telefon && adres)) { toolStripStatusLabel_bilgi.Text = "İşaretli eksik bilgileri tamamlayınız."; return; } if (Musteri == null) { Musteriler musteri = new Musteriler(); musteri.Ad = textBox_ad.Text; musteri.Soyad = textBox_soyad.Text; musteri.Email = textBox_email.Text; musteri.Telefon = textBox_telefon.Text; musteri.Cinsiyet = Convert.ToBoolean(comboBox_cinsiyet.SelectedIndex); musteri.DogumTarih = dateTimePicker_dogumTarih.Value; musteri.SehirID = (comboBox_sehir.SelectedItem as Sehirler).ID; musteri.Adres = textBox_adres.Text; musteri.KartNumarasi = textBox_kartNumarasi.Text; musteri.KartTeslim = checkBox_kartTeslim.Checked; musteri.MevcutPara = 0; ctx.Musterilers.InsertOnSubmit(musteri); try { ctx.SubmitChanges(); toolStripStatusLabel_bilgi.Text = "Kayıt işlemi başarı ile tamamlanmıştır."; FormuYapilandir(); return; } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_bilgi.Text = "Kayıt işlemi hata ile karşılaştı."; return; } } else { Musteri.Ad = textBox_ad.Text; Musteri.Soyad = textBox_soyad.Text; Musteri.Email = textBox_email.Text; Musteri.Telefon = textBox_telefon.Text; Musteri.Cinsiyet = Convert.ToBoolean(comboBox_cinsiyet.SelectedIndex); Musteri.DogumTarih = dateTimePicker_dogumTarih.Value; Musteri.SehirID = (comboBox_sehir.SelectedItem as Sehirler).ID; Musteri.Adres = textBox_adres.Text; Musteri.KartNumarasi = textBox_kartNumarasi.Text; Musteri.KartTeslim = checkBox_kartTeslim.Checked; try { ctx.SubmitChanges(); toolStripStatusLabel_bilgi.Text = "Güncelleme işlemi başarı ile tamamlanmıştır."; FormuYapilandir(); return; } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_bilgi.Text = "Güncelleme işlemi hata ile karşılaştı."; return; } } }
private void button_satisYap_Click(object sender, EventArgs e) { Biletler bilet = new Biletler(); int binisSehirID = Convert.ToInt32(dt_binis_sehirleri.Rows[comboBox_binisSehir.SelectedIndex].ItemArray[0]); bilet.BinisSehirID = binisSehirID; int inisSehirID = Convert.ToInt32(dt_inis_sehirleri.Rows[comboBox_inisSehir.SelectedIndex].ItemArray[0]); bilet.InisSehirID = inisSehirID; try { bilet.YolcuID = Convert.ToInt32(textBox_yolcuID.Text.Trim()); } catch (Exception) { } bilet.SeferID = (comboBox_sefer.SelectedItem as Seferler).ID; bilet.SatisMiRezarvasyonMu = radioButton_satis.Checked; int koltukNo = Convert.ToInt32(comboBox_koltukNo.SelectedItem); bilet.KultukNo = Convert.ToByte(koltukNo); bilet.YolcuCinsiyet = Convert.ToBoolean(comboBox_cinsiyet.SelectedIndex); bilet.YolcuAd = textBox_yolcuAd.Text.Trim().ToUpper(); bilet.YolcuSoyad = textBox_yolcuSoyad.Text.Trim().ToUpper(); bilet.SatisTip = radioButton_nakit.Checked; decimal ucret = Convert.ToDecimal(textBox_ucret.Text); bilet.Ucret = ucret; bilet.IslemZaman = DateTime.Now; bilet.IslemYapanPersonelID = Form_ana_ekran.calisan_id; try { ctx.Biletlers.InsertOnSubmit(bilet); ctx.SubmitChanges(); int sonBiletID = ctx.Biletlers.Where(b => (b.SeferID == bilet.SeferID && b.KultukNo == bilet.KultukNo)).Select(b => b.ID).First(); int inis = Convert.ToInt32(dt_inis_sehirleri.Rows[comboBox_inisSehir.SelectedIndex].ItemArray[2]); int binis = Convert.ToInt32(dt_binis_sehirleri.Rows[comboBox_binisSehir.SelectedIndex].ItemArray[2]); for (int i = binis; i < inis; i++) { DoluKoltuklar doldur = new DoluKoltuklar(); int sehirID = ctx.GuzergahItems.Where(g => g.ID == i).Select(g => g.GececegiIlID).First(); doldur.BinisSehirID = ctx.Subelers.Where(s => s.SehirID == sehirID).Select(s => s.SehirID).First(); doldur.SeferID = seferID; doldur.KoltukID = koltukNo; doldur.BiletNo = sonBiletID; ctx.DoluKoltuklars.InsertOnSubmit(doldur); ctx.SubmitChanges(); } toolStripStatusLabel_islemstatu.Text = "Bilet satışı yapıldı"; } catch (Exception ex) { Form_ana_ekran.HataKaydi(ex); toolStripStatusLabel_islemstatu.Text = "Bilet satışı başarısız"; } //Boş dolu koltuklar yeniden düzenleniyor comboBox_sefer_SelectedIndexChanged(null, null); }