public static int Insert(EntityLayer.EKategori item) { int etkilenen = 0; try { SqlCommand com = new SqlCommand("Kategori_İnsert ", Baglanti.Con); com.CommandType = CommandType.StoredProcedure; if (com.Connection.State != ConnectionState.Open) { com.Connection.Open(); } com.Parameters.AddWithValue("Adi", item.Adi); etkilenen = com.ExecuteNonQuery(); } catch { etkilenen = -1; } return(etkilenen); }
public static bool Update(EntityLayer.EKategori item) { bool sonuc = false; try { SqlCommand com = new SqlCommand("Kategori_Update ", Baglanti.Con); com.CommandType = CommandType.StoredProcedure; if (com.Connection.State != ConnectionState.Open) { com.Connection.Open(); } com.Parameters.AddWithValue("ID", item.ID); com.Parameters.AddWithValue("Adi", item.Adi); sonuc = com.ExecuteNonQuery() > 0; } catch { sonuc = false; } return(sonuc); }
public static List <EntityLayer.EKategori> SelectList() { List <EntityLayer.EKategori> itemlist = null; try { SqlCommand com = new SqlCommand("Kategori_SelectList ", Baglanti.Con); com.CommandType = CommandType.StoredProcedure; if (com.Connection.State != ConnectionState.Open) { com.Connection.Open(); } SqlDataReader rdr = com.ExecuteReader(); if (rdr.HasRows) { itemlist = new List <EntityLayer.EKategori>(); while (rdr.Read()) { EntityLayer.EKategori item = new EntityLayer.EKategori(); item = new EntityLayer.EKategori(); item.ID = Convert.ToInt32(rdr["Id"]); item.Adi = rdr["Adı"].ToString(); itemlist.Add(item); } } rdr.Close(); } catch { itemlist = null; } return(itemlist); }