Example #1
0
        private void btnEkle_Click(object sender, EventArgs e)
        {
            try
            {
                HavaalaniBL hbl = new HavaalaniBL();
                Havaalani   ha  = new Havaalani();

                ha.Id_Yer  = txtHavaalaniID.Text.Trim();
                ha.Yer_Adi = txtHavaalaniAdi.Text.Trim();


                if (id_havaalani == null)
                {
                    MessageBox.Show(hbl.HavaalaniKaydet(ha) ? "Başarılı" : "Başarısız");
                    Temizle();
                }
                else
                {
                    if (hbl.HavaalaniGuncelle(ha))
                    {
                        id_havaalani = null;
                        Temizle();
                        MessageBox.Show("Güncelleme Başarılı");
                    }
                    else
                    {
                        MessageBox.Show("Güncelleme Başarısız!");
                    }
                }
            }
            catch (SqlException ex)
            {
                switch (ex.Number)
                {
                default:
                    MessageBox.Show("Veritabanı Hatası" + ex.Number);
                    break;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Bilinmeyen Hata!!");
            }
        }
Example #2
0
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            HavaalaniBL hbl = new HavaalaniBL();

            foreach (DataRow item in dt.Rows)
            {
                Havaalani h = new Havaalani();
                if (item.RowState != DataRowState.Deleted)
                {
                    h.Id_Yer  = item[0].ToString();
                    h.Yer_Adi = item[2].ToString();
                }

                switch (item.RowState)
                {
                case DataRowState.Added:
                    hbl.HavaalaniKaydet(h);
                    MessageBox.Show("Eklendi");
                    break;

                case DataRowState.Deleted:
                    hbl.HavaalaniSil((string)(item[0, DataRowVersion.Original]));
                    MessageBox.Show("Silindi");
                    break;

                case DataRowState.Modified:
                    h.Id_Yer = item[0].ToString();
                    hbl.HavaalaniGuncelle(h);
                    MessageBox.Show("Guncellendi");
                    break;

                default:
                    break;
                }
            }
        }