private void SilEvet_Click(object sender, EventArgs e) { try { byte sonuc; Urunler Uruns = (Urunler)Application.OpenForms["Urunler"]; FbConnection baglan = new FbConnection(fk.Baglanti_Kodu()); baglan.Open(); FbCommand SatisTab = new FbCommand("SELECT Satis_id FROM Satis WHERE Satis_urun='" + id + "'", baglan); FbDataReader SatisIdOku = SatisTab.ExecuteReader(); while (SatisIdOku.Read()) { fk.Sil("Satis", "Satis_id='" + SatisIdOku["Satis_id"].ToString() + "'"); } baglan.Close(); baglan.Open(); FbCommand RaporTab = new FbCommand("SELECT rapor_id FROM Rapor WHERE rapor_satisId='" + id + "'", baglan); FbDataReader RaporIdOku = RaporTab.ExecuteReader(); while (RaporIdOku.Read()) { fk.Sil("Rapor", "rapor_id='" + RaporIdOku["rapor_id"].ToString() + "'"); } baglan.Close(); sonuc = fk.Sil("Urunler", "Urun_id='" + id + "'"); if (sonuc == 1) { MessageBox.Show("Ürün başarıyla silinmiştir", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information); Uruns.GridGuncelle(); Uruns.FormLoad(); this.Close(); } else { MessageBox.Show("Ürün silinemedi ( Hata kodu: U-04 )", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception e1) { MessageBox.Show(e1.Message, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Guncelle_Click(object sender, EventArgs e) { try { Urunler Uruns = (Urunler)Application.OpenForms["Urunler"]; UrunAdi.Text = UrunAdi.Text.Replace("'", "’"); UrunFiyat.Text = UrunFiyat.Text.Replace(',', '.'); AlisFiyat.Text = AlisFiyat.Text.Replace(',', '.'); string ad, barkod, fiyat, kategori; string katId = ""; ad = UrunAdi.Text; barkod = UrunBarkod.Text; fiyat = UrunFiyat.Text; kategori = UrunKategori.Text; if ((ad != "" && ad.Length > 3) && fiyat != "" && kategori != "" && AlisFiyat.Text != "") { // urun id yi çıkar // FbConnection baglanti = new FbConnection(fk.Baglanti_Kodu()); FbDataReader KategoriIdCek; baglanti.Open(); FbCommand KategoriAdiSorgu = new FbCommand("SELECT Kategori_id FROM Urun_kategori WHERE Kategori_adi='" + kategori + "'", baglanti); KategoriIdCek = KategoriAdiSorgu.ExecuteReader(); KategoriIdCek.Read(); katId = KategoriIdCek["Kategori_id"].ToString(); baglanti.Close(); // urun id yi çıkar // if (barkodlu.Checked == true) { // Ürünü güncelle // byte sonuc; sonuc = fk.Guncelle("Urunler", "Urun_barkodNo='0',Urun_adi='" + fk.IlkHarfleriBuyut(ad) + "',Urun_fiyat='" + fiyat + "',Urun_kategori='" + katId + "',Urun_alisFiyat='" + AlisFiyat.Text + "'", "Urun_id='" + id + "'"); if (sonuc == 1) { MessageBox.Show("Ürün başarıyla güncellenmiştir", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information); if (Uruns.UrunAdi.Text != "") { Uruns.GridGuncelle(); Uruns.UrunAra(); } else if (Uruns.BarkodNo.Text != "") { Uruns.GridGuncelle(); Uruns.UrunAraBarkod(); } else { Uruns.GridGuncelle(); Uruns.FormLoad(); } } else { MessageBox.Show("Ürün güncellenemedi ( Hata kodu: M-03 )", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Error); } // Ürünü güncelle // } else { barkod = UrunBarkod.Text; if (barkod.Length > 14) { // Ürünü güncelle // byte sonuc; sonuc = fk.Guncelle("Urunler", "Urun_barkodNo='" + barkod + "',Urun_adi='" + ad + "',Urun_fiyat='" + fiyat + "',Urun_alisFiyat='" + AlisFiyat.Text + "', Urun_kategori='" + katId + "'", "Urun_id='" + id + "'"); if (sonuc == 1) { MessageBox.Show("Ürün başarıyla güncellenmiştir", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information); if (Uruns.UrunAdi.Text != "") { Uruns.GridGuncelle(); Uruns.UrunAra(); } else if (Uruns.BarkodNo.Text != "") { Uruns.GridGuncelle(); Uruns.UrunAraBarkod(); } else { Uruns.GridGuncelle(); Uruns.FormLoad(); } } else { MessageBox.Show("Ürün güncellenemedi ( Hata kodu: M-03 )", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Error); } // Ürünü güncelle // } else { MessageBox.Show("Barkod numarasını 15 hane olarak giriş yapınız", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } else { // BOŞ ALANLAR } } catch (Exception e1) { MessageBox.Show(e1.Message, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } }