private void IlacEkran_Load(object sender, EventArgs e) { ilacCrud ic = new ilacCrud(); dataGridView1.DataSource = ic.tablolar(); CbilacTur.Items.Clear(); Database db = new Database(); if (db.baglanti.State == ConnectionState.Open) { db.baglanti.Close(); } try { db.baglanti.Open(); SqlCommand cbKomut = new SqlCommand("select tur_ismi from ilac_turleri", db.baglanti); SqlDataReader read = cbKomut.ExecuteReader(); while (read.Read()) { CbilacTur.Items.Add(read["tur_ismi"]); } db.baglanti.Close(); } catch (Exception) { MessageBox.Show("İlaç Türleri Yüklenemedi !"); } finally { db.baglanti.Close(); } }
private void BtnSil_Click(object sender, EventArgs e) { int satir = dataGridView1.CurrentRow.Index; string id = dataGridView1.Rows[satir].Cells["ilac_id"].Value.ToString(); ilacCrud ic = new ilacCrud(); ic.ilacSil(id); dataGridView1.DataSource = ic.tablolar(); }
private void BtnGüncelle_Click(object sender, EventArgs e) { ilacCrud ic = new ilacCrud(); int satir = dataGridView1.CurrentRow.Index; string id = dataGridView1.Rows[satir].Cells["ilac_id"].Value.ToString(); float deger = float.Parse(TbFiyat.Text); string tur = CbilacTur.SelectedItem.ToString(); ic.ilacGuncelle(id, TbAd.Text, tur, deger, TbAdet.Text, DtUretim.Value, DtSonKullanim.Value); dataGridView1.DataSource = ic.tablolar(); }
private void BtnKaydet_Click(object sender, EventArgs e) { ilacCrud ic = new ilacCrud(); if (CbilacTur.SelectedItem == null || TbAd.Text == null || TbAd.Text == "" || TbAd.Text == " " || TbAdet.Text == "" || TbFiyat.Text == "") { MessageBox.Show("Boş Kutucuk Bırakmayınız"); } else { float deger = float.Parse(TbFiyat.Text); string tur = CbilacTur.SelectedItem.ToString(); ic.ekle(TbAd.Text, deger, TbAdet.Text, tur, DtUretim.Value, DtSonKullanim.Value); dataGridView1.DataSource = ic.tablolar(); } }