Exemple #1
0
 public List <categoriaModel> searchDescription(categoriaModel categoria)
 {
     using (SqlConnection connection = new SqlConnection(SQLconnection.ConnectionString()))
     {
         Command.Connection  = connection;
         Command.CommandText = "SEARCH_DESCRIPTION__CATEGORIES";
         Command.CommandType = System.Data.CommandType.StoredProcedure;
         Command.Parameters.Clear();
         Command.Parameters.AddWithValue("@DESCRIPTION", categoria.Description);
         Command.Connection.Open();
         SqlDataReader reader = Command.ExecuteReader();
         categorias.Clear();
         if (reader.HasRows)
         {
             while (reader.Read())
             {
                 categorias.Add(new categoriaModel
                 {
                     CategoryID   = (int)reader["CategoryID"],
                     CategoryName = (string)reader["CategoryName"],
                     Description  = (string)reader["Description"],
                     Picture      = (byte[])reader["Picture"]
                 });
             }
         }
         Command.Connection.Close();
         return(categorias);
     }
 }
Exemple #2
0
 public categoriaModel select(categoriaModel categoria)
 {
     using (SqlConnection connection = new SqlConnection(SQLconnection.ConnectionString()))
     {
         Command.Connection  = connection;
         Command.CommandText = "SELECT_CATEGORIES";
         Command.CommandType = System.Data.CommandType.StoredProcedure;
         Command.Parameters.Clear();
         Command.Parameters.AddWithValue("@CATEGORY_ID", categoria.CategoryID);
         Command.Connection.Open();
         SqlDataReader reader = Command.ExecuteReader();
         if (reader.HasRows)
         {
             while (reader.Read())
             {
                 categoria = new categoriaModel
                 {
                     CategoryID   = (int)reader["CategoryID"],
                     CategoryName = (string)reader["CategoryName"],
                     Description  = (string)reader["Description"],
                     Picture      = (byte[])reader["Picture"]
                 };
             }
         }
         Command.Connection.Close();
         return(categoria);
     }
 }
Exemple #3
0
 public int delete(categoriaModel categoria)
 {
     using (SqlConnection connection = new SqlConnection(SQLconnection.ConnectionString()))
     {
         Command.Connection  = connection;
         Command.CommandText = "DELETE_CATEGORIES";
         Command.CommandType = System.Data.CommandType.StoredProcedure;
         Command.Parameters.Clear();
         Command.Parameters.AddWithValue("@CATEGORY_ID", categoria.CategoryID);
         Command.Connection.Open();
         int affected = Command.ExecuteNonQuery();
         Command.Connection.Close();
         return(affected);
     }
 }
Exemple #4
0
 public int insert(categoriaModel categoria)
 {
     using (SqlConnection connection = new SqlConnection(SQLconnection.ConnectionString()))
     {
         Command.Connection  = connection;
         Command.CommandText = "INSERT_CATEGORIES";
         Command.CommandType = System.Data.CommandType.StoredProcedure;
         Command.Parameters.Clear();
         Command.Parameters.AddWithValue("@CATEGORY_NAME", categoria.CategoryName);
         Command.Parameters.AddWithValue("@DESCRIPTION", categoria.Description);
         Command.Parameters.AddWithValue("@PICTURE", categoria.Picture);
         Command.Connection.Open();
         int affected = Command.ExecuteNonQuery();
         Command.Connection.Close();
         return(affected);
     }
 }