public List <Gift_Master> Get_GiftItems() { List <Gift_Master> Items = new List <Gift_Master>(); using (SqlConnection con = new SqlConnection(ConnectionString.GetCon())) { SqlCommand cmd = new SqlCommand("SP_GetGiftItems", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { Gift_Master temp = new Gift_Master(); temp.Gift_ID = Convert.ToInt32(dr["Gift_ID"]); temp.Gift_Name = dr["Gift_Name"].ToString(); temp.Gift_Image = dr["Gift_Image"].ToString(); temp.Gift_Price = Convert.ToInt32(dr["Gift_Price"]); Items.Add(temp); } } } return(Items); }
public int Purchase_GiftItem(int User_ID, Gift_Master Item) { using (SqlConnection con = new SqlConnection(ConnectionString.GetCon())) { SqlCommand cmd = new SqlCommand("SP_PurchaseGiftItem", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("User_ID", User_ID); cmd.Parameters.AddWithValue("Gift_ID", Item.Gift_ID); cmd.Parameters.AddWithValue("Gift_Name", Item.Gift_Name); cmd.Parameters.AddWithValue("Gift_Price", Item.Gift_Price); con.Open(); int i = cmd.ExecuteNonQuery(); return(i); } }