Exemple #1
0
 public CategoryCell AddCategory(ref CategoryCell category)
 {
     lock (locker)
     {
         using (MySqlCommand commandSQL = new MySqlCommand(insertCategory, connection))
         {
             commandSQL.Parameters.AddWithValue("@category_name", category.category_name);
             commandSQL.Parameters.AddWithValue("@category_position", category.category_position);
             commandSQL.Parameters.AddWithValue("@created_at", category.created_at);
             commandSQL.ExecuteNonQuery();
             category.category_id = (int)commandSQL.LastInsertedId;
             commandSQL.Dispose();
         }
     }
     return(category);
 }
Exemple #2
0
 private CategoryCell SelectCategory(MySqlCommand commandSQL)
 {
     lock (locker)
     {
         using (MySqlDataReader readerMassive = commandSQL.ExecuteReader())
         {
             while (readerMassive.Read())
             {
                 CategoryCell category = new CategoryCell();
                 category.category_id       = readerMassive.GetInt32("category_id");
                 category.category_name     = readerMassive.GetString("category_name");
                 category.category_position = readerMassive.GetInt16("category_position");
                 category.created_at        = readerMassive.GetString("created_at");
                 commandSQL.Dispose();
                 return(category);
             }
             return(null);
         }
     }
 }
Exemple #3
0
        private List <CategoryCell> SelectCategories(MySqlCommand commandSQL)
        {
            List <CategoryCell> categories = new List <CategoryCell>();

            lock (locker)
            {
                using (MySqlDataReader readerMassive = commandSQL.ExecuteReader())
                {
                    while (readerMassive.Read())
                    {
                        CategoryCell category = new CategoryCell();
                        category.category_id       = readerMassive.GetInt32("category_id");
                        category.category_name     = readerMassive.GetString("category_name");
                        category.category_position = readerMassive.GetInt16("category_position");
                        category.created_at        = readerMassive.GetString("created_at");
                        categories.Add(category);
                    }
                    commandSQL.Dispose();
                }
            }
            return(categories);
        }