private void btnKaydet_Click(object sender, EventArgs e) { if (txtUcakAdi.Text.Trim() != "" && txtModelAdi.Text.Trim() != "" && txtHavayollariAdi.Text.Trim() != "") { Ucak u = new Ucak(); if (u.UcakVarMi(txtModelAdi.Text)) { MessageBox.Show("Uçak zaten kayıtlı!"); } else { u.Aciklama = txtAciklama.Text; u.ModelID = Convert.ToInt32(txtModelID.Text); u.UcakAdi = txtUcakAdi.Text; u.HavayollariID = Convert.ToInt32(txtHavayolllariID.Text); if (u.UcakEkle(u)) { MessageBox.Show("Uçak başarı ile eklendi."); u.UcaklariGetir(lvUcaklar); Temizle(); btnKaydet.Enabled = false; txtAciklama.ReadOnly = true; txtAciklama.ReadOnly = true; } else { MessageBox.Show("Uçak eklenemedi."); } } } else { MessageBox.Show("Uçak adı, havayolları adı ve model adı adı boş bırakılamaz."); } }
private void UcakSorgulama_Load(object sender, EventArgs e) { Ucak u = new Ucak(); ds = u.UcaklariGetir(); dgvUcaklar.DataSource = ds.Tables["Ucaklar"]; }
private void Ucaklar_Load(object sender, EventArgs e) { this.Top = 0; this.Left = 0; Ucak u = new Ucak(); u.UcaklariGetir(lvUcaklar); }
private void btnSil_Click(object sender, EventArgs e) { if (MessageBox.Show("Silmek istediğinizden emin misiniz?", "UYARI", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { Ucak u = new Ucak(); if (u.UcakSil(Convert.ToInt32(txtUcakID.Text))) { MessageBox.Show("Uçak Silindi."); u.UcaklariGetir(lvUcaklar); Temizle(); btnSil.Enabled = false; btnDegistir.Enabled = false; } } }
private void btnBaslat_Click(object sender, EventArgs e) { if (cmbKayitliOyunlar.SelectedIndex > -1) { string jsonkayit = ""; string filename = cmbKayitliOyunlar.SelectedItem.ToString(); string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + $"\\UcaksavarKayit\\"; Directory.CreateDirectory(path); FileStream file = new FileStream(path + filename, FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(file); jsonkayit = reader.ReadToEnd(); reader.Close(); file.Close(); oyun = new UcakOyunu(this); if (!string.IsNullOrWhiteSpace(jsonkayit)) { OyunKayit kayit = JsonConvert.DeserializeObject <OyunKayit>(jsonkayit); oyun.Skor = kayit.Skor; oyun.PictureArkaplan1.Location = new Point(kayit.Arkaplan[0].X, kayit.Arkaplan[0].Y); oyun.PictureArkaplan2.Location = new Point(kayit.Arkaplan[1].X, kayit.Arkaplan[1].Y); foreach (UcaklarKayit item in kayit.Ucak) { Ucak u = new Ucak(new Point(item.X, item.Y)); oyun.Ucaklar.Add(u); this.Controls.Add(u.ResimKutusu); } foreach (YananUcaklarKayit item in kayit.YananUcak) { Ucak u = new Ucak(new Point(item.X, item.Y)); u.YanmaSuresi = item.YanmaSuresi; u.ResimKutusu.Image = Properties.Resources.yanma; oyun.YananUcaklar.Add(u); this.Controls.Add(u.ResimKutusu); } oyun.Ucaksavar.ResimKutusu.Location = new Point(kayit.Ucaksavar.X, kayit.Ucaksavar.Y); foreach (MermilerKayit item in kayit.Mermi) { Roket r = new Roket(new Point(item.X, item.Y)); oyun.Ucaksavar.Roketler.Add(r); this.Controls.Add(r.ResimKutusu); } } } }
public bool EnvanterGuncelle(Ucak u) { try { SqlParameter[] p = { new SqlParameter("@Id_Havayolu", u.Id_Havayolu), new SqlParameter("@Id_Ucak", u.Id_Ucak), new SqlParameter("@Adet", u.Adet) }; return(hlp.ExecuteNonQuery("Update tblHavayoluEnvanter set Adet=@Adet Where Id_Havayolu=@Id_Havayolu and Id_Ucak=@Id_Ucak", p) > 0); } catch (SqlException ex) { throw ex; } catch (Exception ex) { throw ex; } }
private void Form1_Load(object sender, EventArgs e) { //Istavrit ıstavrit = new Istavrit(); //ıstavrit.Yuz(); //ıstavrit.Dal(); //ıstavrit.YuzeyeCik(); Ucak ucak = new Ucak(); ucak.Marka = "aaa"; ucak.Model = "bbb"; MessageBox.Show($"{ucak.Marka} "); ucak.Uc(); Istavrit ıstavrit = new Istavrit(); MessageBox.Show(ıstavrit.Yuz()); }
public bool HavayoluEnvanterKaydet(Ucak u) { try { string cmdtext = "Insert into tblHavayoluEnvanter values(@Id_Havayolu,@Id_Ucak,@Adet)"; SqlParameter[] p = { new SqlParameter("@Id_Havayolu", u.Id_Havayolu), new SqlParameter("@Id_Ucak", u.Id_Ucak), new SqlParameter("@Adet", u.Adet) }; return(hlp.ExecuteNonQuery(cmdtext, p) > 0); } catch (SqlException ex) { throw ex; } catch (Exception ex) { throw ex; } }
private void btnKaydet_Click(object sender, EventArgs e) { HavayoluBL hbl = new HavayoluBL(); foreach (DataRow item in dt.Rows) { Ucak u = new Ucak(); if (item.RowState != DataRowState.Deleted) { //for (int i = 0; i < 5; i++) //{ // MessageBox.Show(item[i].ToString()); //} u.Id_Havayolu = item[4].ToString(); u.Id_Ucak = item[3].ToString(); u.Adet = Convert.ToInt32(item[2].ToString()); } switch (item.RowState) { case DataRowState.Added: hbl.HavayoluEnvanterKaydet(u); MessageBox.Show("Eklendi"); break; case DataRowState.Deleted: hbl.HavayoluEnvanterSil((string)(item[4, DataRowVersion.Original]), (string)(item[3, DataRowVersion.Original])); MessageBox.Show("Silindi"); break; case DataRowState.Modified: u.Id_Havayolu = item[4].ToString(); u.Id_Ucak = item[3].ToString(); u.Adet = Convert.ToInt32(item[2]); hbl.EnvanterGuncelle(u); MessageBox.Show("Guncellendi"); break; default: break; } } }
private void btnHavayoluBul_Click(object sender, EventArgs e) { HavayoluSorgulama frm = new HavayoluSorgulama(); frm.StartPosition = FormStartPosition.CenterScreen; frm.ShowDialog(); txtHavayolllariID.Text = Genel.HavayoluID.ToString(); txtHavayollariAdi.Text = Genel.HavayoluAdi; Ucak u = new Ucak(); string isim = u.IsimBul(Genel.kisaltma); if ("" == isim) { MessageBox.Show(""); } else { txtUcakAdi.Text = isim; Genel.kisaltma = ""; } }
private void btnDegistir_Click(object sender, EventArgs e) { if (txtUcakAdi.Text.Trim() != "" && txtModelAdi.Text.Trim() != "" && txtHavayollariAdi.Text.Trim() != "") { Ucak u = new Ucak(); if (u.UcakVarMi(Convert.ToInt32(txtUcakID.Text), txtUcakAdi.Text)) { MessageBox.Show("Uçak zaten kayıtlı!"); txtAciklama.Focus(); } else { u.Aciklama = txtAciklama.Text; u.ModelID = Convert.ToInt32(txtModelID.Text); u.UcakAdi = txtUcakAdi.Text; u.HavayollariID = Convert.ToInt32(txtHavayolllariID.Text); u.UcakID = Convert.ToInt32(txtUcakID.Text); if (u.UcakGuncelle(u)) { MessageBox.Show("Uçak bilgileri güncellendi."); btnSil.Enabled = false; btnDegistir.Enabled = false; Temizle(); txtAciklama.ReadOnly = true; u.UcaklariGetir(lvUcaklar); } else { MessageBox.Show("Uçak bilgileri güncellenemedi."); txtAciklama.Focus(); } } } else { MessageBox.Show("Uçak adı, havayolları adı ve model adı adı boş bırakılamaz."); } }
private void btnBul_Click(object sender, EventArgs e) { HavayoluBL hbl = new HavayoluBL(); Havayolu ha = hbl.HavayoluBul((string)cmbHavayolu.SelectedValue); Ucak u = null; if (ha == null) { MessageBox.Show("Havayolu Bulunamadı"); } else { UcakBL ubl = new UcakBL(); u = new Ucak(); frm.cmbHavayolu.SelectedValue = ha.Id_Havayolu; frm.cmbHavayolu.DisplayMember = "Havayolu_Adi"; frm.cmbHavayolu.ValueMember = "Id_Havayolu"; frm.cmbUcak.SelectedValue = ha.Havayolu_Adi; frm.cmbAdet.SelectedValue = u.Adet.ToString(); frm.id_havayolu = cmbHavayolu.SelectedValue.ToString(); frm.btnVazgec.Visible = true; frm.btnSil.Visible = true; frm.cmbHavayolu.Enabled = false; frm.btnEkle.Text = "Guncelle"; ubl = new UcakBL(); frm.cmbUcak.DisplayMember = "Ucak_Adi"; frm.cmbUcak.ValueMember = "Id_Ucak"; frm.cmbAdet.DisplayMember = "Adet"; frm.cmbAdet.ValueMember = "Adet"; frm.cmbUcak.DataSource = ubl.UcakEnvanterListesi(ha.Id_Havayolu); frm.cmbAdet.DataSource = ubl.UcakEnvanterListesi(ha.Id_Havayolu); this.Close(); } }
public Havayolu HavayoluEnvanterBul(string Id_Havayolu) { try { SqlParameter[] p = { new SqlParameter("@Id_Havayolu", Id_Havayolu) }; SqlDataReader dr = hlp.ExecuteReader("Select Id_Havayolu,Id_Ucak,Adet from tblHavayoluEnvanter Where Id_Havayolu=@Id_Havayolu", p); Havayolu ha = null; Ucak u = null; if (dr.Read()) { u = new Ucak(); u.Id_Havayolu = dr["Id_Havayolu"].ToString(); u.Id_Ucak = dr["Id_Ucak"].ToString(); u.Adet = Convert.ToInt32(dr["Adet"]); } dr.Close(); return(ha); } catch (Exception) { throw; } }
private void yükleToolStripMenuItem_Click(object sender, EventArgs e) { oyun.durduMu = true; lbl.Text = "Oyun Duraklatıldı. Devam Etmek İçin P'ye basınız.."; this.Text = lbl.Text; timer1.Stop(); dosyaAc.Title = "Bir Kisi XML dosyasını seçiniz"; dosyaAc.Filter = "XML Format | *.xml"; dosyaAc.Multiselect = false; dosyaAc.FileName = string.Empty; dosyaAc.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); if (dosyaAc.ShowDialog() == DialogResult.OK) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(List <Konumlar>)); TextReader reader = new StreamReader(dosyaAc.FileName); oyun = new UcakOyunu(this); oyun.durduMu = false; oyun.roketKonumları.AddRange((List <Konumlar>)xmlSerializer.Deserialize(reader)); this.Controls.Clear(); this.Controls.Add(menuStrip1); foreach (var item in oyun.roketKonumları) { Point pnt = new Point() { X = Convert.ToInt32(item.x), Y = Convert.ToInt32(item.y) }; Roket rkt = new Roket(pnt); rkt.ResimKutusu.Image = Properties.Resources.mermi1; this.Controls.Add(rkt.ResimKutusu); oyun.Ucaksavar.Roketler.Add(rkt); oyun.Skor = Convert.ToInt32(item.skor); } foreach (var item in oyun.roketKonumları) { Point pnt = new Point() { X = Convert.ToInt32(item.z), Y = Convert.ToInt32(item.c) }; Ucak uck = new Ucak(pnt); uck.ResimKutusu.Image = Properties.Resources.ucak; this.Controls.Add(uck.ResimKutusu); oyun.Ucaklar.Add(uck); } this.Controls.Add(oyun.Ucaksavar.ResimKutusu); reader.Close(); reader.Dispose(); //timer1.Start(); lbl.Text = "Oyun Duraklatıldı. Devam Etmek İçin P'ye basınız.."; this.Text = lbl.Text; oyun.durduMu = true; MessageBox.Show($"Oyun {dosyaAc.FileName} adresinden başarıyla yüklendi"); } }
private void btnEkle_Click(object sender, EventArgs e) { try { if (btnSil.Visible != true) { if (SecenekKontrol()) { CmbDropControl(); return; } } HavayoluBL hbl = new HavayoluBL(); Ucak u = new Ucak(); u.Id_Havayolu = cmbHavayolu.SelectedValue.ToString(); u.Id_Ucak = cmbUcak.SelectedValue.ToString(); u.Adet = int.Parse(cmbAdet.Text.ToString()); id_ucak = cmbUcak.SelectedValue.ToString(); if (id_havayolu == null) { MessageBox.Show(hbl.HavayoluEnvanterKaydet(u) ? "Başarılı" : "Başarısız"); Temizle(); } else { if (hbl.EnvanterGuncelle(u)) { id_havayolu = null; Temizle(); MessageBox.Show("Güncelleme Başarılı"); } else { MessageBox.Show("Güncelleme Başarısız!"); } } } catch (SqlException ex) { switch (ex.Number) { case 245: MessageBox.Show("Sayısal Değerleri Doğru Giriniz."); break; default: MessageBox.Show("Veritabanı Hatası" + ex.Number); break; } } catch (FormatException) { MessageBox.Show("Sayısal Değerleri Doğru Giriniz."); } catch (Exception) { MessageBox.Show("Bilinmeyen Hata!!"); } }