private void btnDelete_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 0) { MessageBox.Show("Silmek istediğiniz satırı seçin", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DialogResult result = MessageBox.Show("Seçili satırı silmek istediğinize emin misiniz ?", "Uyarı", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { try { int sehirId = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value); SehirManager.Delete(sehirId); MessageBox.Show("İşleminiz başarıyla gerçekleşti", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information); dataGridView1.DataSource = SehirManager.GetObjects(); dataGridView1.Refresh(); } catch (Exception ex) { MessageBox.Show("İşleminiz gerçekleştirilirken hata oluştu :" + ex.Message, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnSave_Click(object sender, EventArgs e) { try { //Düzenlenecek if (willUpdateItem != null) { willUpdateItem.SehirAdi = txtSehirAdi.Text; SehirManager.Update(willUpdateItem); } //Yeni eklenecek else { Sehir sehir = new Sehir(); sehir.SehirAdi = txtSehirAdi.Text; SehirManager.Insert(sehir); } MessageBox.Show("İşleminiz başarıyla gerçekleşti", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception ex) { MessageBox.Show("İşleminiz gerçekleştirilirken hata oluştu :" + ex.Message); } }
private void FillSehir() { sehirList = SehirManager.GetObjects(); foreach (var item in sehirList) { cmbSehir.Properties.Items.Add(item.SehirAdi); } }
private void btnEdit_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 0) { MessageBox.Show("Düzenlemek istediğiniz satırı seçin", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int sehirId = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value); Sehir sehir = SehirManager.GetObjectById(sehirId); frmSehirDetay frm = new frmSehirDetay(sehir); frm.ShowDialog(); }
private void btnRefresh_Click(object sender, EventArgs e) { dataGridView1.DataSource = SehirManager.GetObjects(); dataGridView1.Refresh(); }
private void frmSehir_Load(object sender, EventArgs e) { dataGridView1.DataSource = SehirManager.GetObjects(); }
private void Loading() { SehirManager sm = new SehirManager(); GrupManager gm = new GrupManager(); try { cmbIl.DataSource = sm.SehirListe(new SehirFiltreDTO() { AktifMi = true, DilID = Properties.Settings.Default.DilID, KullaniciID = Properties.Settings.Default.KullaniciID, SilindiMi = false, SirketID = Properties.Settings.Default.SirketID, UlkeID = "1" }); cmbIl.DisplayMember = "SehirAd"; cmbIl.ValueMember = "SehirID"; cmbGrup.DataSource = gm.GrupListe(new GrupFiltreDTO() { AktifMi = true, DilID = Properties.Settings.Default.DilID, KullaniciID = Properties.Settings.Default.KullaniciID, SilindiMi = false, SirketID = Properties.Settings.Default.SirketID, UstGrupID = "0", AlanTipi = "Cari" }); cmbGrup.DisplayMember = "GrupAd"; cmbGrup.ValueMember = "GrupID"; } catch (MyNotImplementedException error) { MessageBox.Show(error.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (MyDbEntityValidationException error) { MessageBox.Show(error.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (MyArgumentNullException error) { MessageBox.Show(error.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (MyArgumentException error) { MessageBox.Show(error.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (MyInvalidOperationException error) { MessageBox.Show(error.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (MyNullReferenceException error) { MessageBox.Show(error.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (MyAggregateException error) { MessageBox.Show(error.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (MyFormatException error) { MessageBox.Show(error.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (NullDataOnDatabaseCustomException) { throw new NullDataOnDatabaseCustomException(); } catch (NotModifiedDataOnDatabaseCustomException) { throw new NotModifiedDataOnDatabaseCustomException(); } catch (Exception error) { MessageBox.Show(error.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { sm = null; gm = null; } }