private void tblKaydetButton_Click(object sender, EventArgs e) { #region TBLDeğişiki UrunBL urunGoster = new UrunBL(); foreach (DataRow item in dt.Rows) { Urun urun = new Urun(); if (item.RowState != DataRowState.Deleted) { urun.Urun_kodu = item[0].ToString(); urun.Urun_ad = item[1].ToString(); urun.Stok_mik = Convert.ToInt32(item[2]); urun.Fiyat = Convert.ToInt32(item[3]); } switch (item.RowState) { case DataRowState.Added: urunGoster.Urun_Ekle(urun); break; case DataRowState.Modified: urun.Urun_kodu = item[0].ToString(); urunGoster.Urun_Guncelle(urun); break; default: break; } } #endregion #region EntityTabloDegisiklik //using (SirketContext sctx = new SirketContext()) //{ // List<Urun_Tablosu> lst = sctx.Urun_Tablosu.ToList(); // foreach (Urun_Tablosu item in lst) // { // foreach (DataRow tbl in dt.Rows) // { // switch (tbl.RowState) // { // case DataRowState.Added: // Urun_Ekleyici(); // break; // case DataRowState.Deleted: // break; // case DataRowState.Modified: // break; // default: // break; // } // } // } //} #endregion }
private void btnKaydet_Click(object sender, EventArgs e) { UrunBL urun = new UrunBL(); foreach (DataRow item in dt.Rows) { Urun u = new Urun(); if (item.RowState != DataRowState.Deleted) { u.Urun_ad = item[1].ToString(); u.Urun_kodu = item[2].ToString(); u.Stok_mik = (Convert.ToInt32(item[3])); u.Fiyat = (Convert.ToInt32(item[4])); u.urun_renk = item[5].ToString(); u.kategori_id = Convert.ToInt32(item[6]); } switch (item.RowState) { case DataRowState.Added: urun.Urun_Ekle(u); break; case DataRowState.Deleted: urun.Urun_Sil(u); break; case DataRowState.Modified: u.Urun_kodu = item["Urun_Kod"].ToString(); urun.Urun_Guncelle(u); break; default: break; } } }