private void btn_sil_Click(object sender, EventArgs e)
 {
     if (dgv_Tarifeler.SelectedRows.Count == 0)
     {
         MessageBox.Show("Tarife seçmediğiniz için işleminizi gerçekleştiremiyorum.");
     }
     else
     {
         DialogResult dr = MessageBox.Show("Silmek istediğinize emin misiniz?", "Dikkat!", MessageBoxButtons.YesNo);
         if (dr == DialogResult.Yes)
         {
             try
             {
                 string id = dgv_Tarifeler.CurrentRow.Cells["id"].Value.ToString();
                 d.myConnection.Open();
                 string        sql = "delete from TBL_Tarifeler where id = @id";
                 SQLiteCommand delete_tarifeler = new SQLiteCommand(sql, d.myConnection);
                 delete_tarifeler.Parameters.AddWithValue("@id", id);
                 int result = delete_tarifeler.ExecuteNonQuery();
                 if (result > 0)
                 {
                     MessageBox.Show("Kayıt başarı ile silindi.");
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.ToString());
             }
             finally
             {
                 d.myConnection.Close();
                 Frm_TarifeGoruntule frm = (Frm_TarifeGoruntule)Application.OpenForms["Frm_TarifeGoruntule"];
                 string aranacak         = "";
                 frm.doldur(aranacak);
             }
         }
     }
 }
Beispiel #2
0
        private void btn_Tarifeler_Click(object sender, EventArgs e)
        {
            Frm_TarifeGoruntule frm = new Frm_TarifeGoruntule();

            frm.ShowDialog();
        }
Beispiel #3
0
 private void btn_Kaydet_Click(object sender, EventArgs e)
 {
     if (id == "0")
     {
         if (txt_TarifeAdi.Text.Length == 0 && txt_TarifeAdi.Text == "")
         {
             MessageBox.Show("Dikkat!", "Tarife adı boş bırakılamaz.", MessageBoxButtons.OK);
         }
         else if (txt_Fiyat.Text.Length == 0 && txt_Fiyat.Text == "")
         {
             MessageBox.Show("Dikkat!", "Tarife fiyatı  boş bırakılamaz.", MessageBoxButtons.OK);
         }
         else
         {
             string tarife_adi = txt_TarifeAdi.Text;
             int    fiyat      = int.Parse(txt_Fiyat.Text);
             try
             {
                 d.myConnection.Open();
                 string        sql = "INSERT INTO TBL_Tarifeler(tarife_adi,fiyat) VALUES(@ad,@fiyat)";
                 SQLiteCommand insert_tarifeler = new SQLiteCommand(sql, d.myConnection);
                 insert_tarifeler.Parameters.AddWithValue("@ad", tarife_adi);
                 insert_tarifeler.Parameters.AddWithValue("@fiyat", fiyat);
                 int result = insert_tarifeler.ExecuteNonQuery();
                 if (result > 0)
                 {
                     MessageBox.Show("Tarife Kaydı Başarılı.");
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.ToString());
             }
             finally
             {
                 d.myConnection.Close();
                 Frm_TarifeGoruntule frm = (Frm_TarifeGoruntule)Application.OpenForms["Frm_TarifeGoruntule"];
                 string aranacak         = "";
                 frm.doldur(aranacak);
                 this.Close();
             }
         }
     }
     else
     {
         if (txt_TarifeAdi.Text.Length == 0 && txt_TarifeAdi.Text == "")
         {
             MessageBox.Show("Tarife adı  boş bırakılamaz.", "Dikkat!", MessageBoxButtons.OK);
         }
         else if (txt_Fiyat.Text.Length == 0 && txt_Fiyat.Text == "")
         {
             MessageBox.Show("Tarife fiyatı  boş bırakılamaz.", "Dikkat!", MessageBoxButtons.OK);
         }
         else
         {
             string tarife_adi = txt_TarifeAdi.Text;
             int    fiyat      = int.Parse(txt_Fiyat.Text);
             try
             {
                 d.myConnection.Open();
                 string        sql = "update TBL_Tarifeler set tarife_adi = @ad ,fiyat = @fiyat where id = @id";
                 SQLiteCommand update_tarifeler = new SQLiteCommand(sql, d.myConnection);
                 update_tarifeler.Parameters.AddWithValue("@ad", tarife_adi);
                 update_tarifeler.Parameters.AddWithValue("@fiyat", fiyat);
                 update_tarifeler.Parameters.AddWithValue("@id", id);
                 int result = update_tarifeler.ExecuteNonQuery();
                 if (result > 0)
                 {
                     MessageBox.Show("Tarife başarı ile güncellendi.");
                     Frm_TarifeGoruntule frm = (Frm_TarifeGoruntule)Application.OpenForms["Frm_TarifeGoruntule"];
                     string aranacak         = "";
                     frm.doldur(aranacak);
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.ToString());
             }
             finally
             {
                 d.myConnection.Close();
                 this.Close();
             }
         }
     }
 }