Ejemplo n.º 1
0
 public void Delete(Category entity)
 {
     using (SqlCommand cmd = new SqlCommand("DELETE FROM Categories WHERE CategoryId = @CategoryId"))
     {
         cmd.Parameters.AddWithValue("CategoryId", entity.CategoryId);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Ejemplo n.º 2
0
 public void Add(Category entity)
 {
     using (SqlCommand cmd = new SqlCommand("INSERT INTO Categories(CategoryName) VALUES (@CategoryName)"))
     {
         cmd.Parameters.AddWithValue("CategoryName", entity.CategoryName);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Ejemplo n.º 3
0
 public void Delete(Book book)
 {
     using (SqlCommand cmd =
                new SqlCommand("DELETE FROM Books where Id = @Id"))
     {
         cmd.Parameters.AddWithValue("Id", book.Id);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Ejemplo n.º 4
0
 public void Update(Category entity)
 {
     using (SqlCommand cmd =
                new SqlCommand("UPDATE Categories SET CategoryName = @CategoryName WHERE CategoryId = @CategoryId"))
     {
         cmd.Parameters.AddWithValue("CategoryName", entity.CategoryName);
         cmd.Parameters.AddWithValue("CategoryId", entity.CategoryId);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Ejemplo n.º 5
0
 public void Add(Book book)
 {
     using (SqlCommand cmd =
                new SqlCommand("INSERT INTO Books (Title,Description, Year, CategoryId) VALUES (@Title,@Description, @Year, @CategoryId)"))
     {
         cmd.Parameters.AddWithValue("Title", book.Title);
         cmd.Parameters.AddWithValue("Description", book.Description);
         cmd.Parameters.AddWithValue("Year", book.Year);
         cmd.Parameters.AddWithValue("CategoryId", book.CategoryId);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }
Ejemplo n.º 6
0
 public void Update(Book book)
 {
     using (SqlCommand cmd =
                new SqlCommand("UPDATE Books set Title = @Title, Description = @Description, Year = @Year, CategoryId = @CategoryId where Id = @Id"))
     {
         cmd.Parameters.AddWithValue("Id", book.Id);
         cmd.Parameters.AddWithValue("Title", book.Title);
         cmd.Parameters.AddWithValue("Description", book.Description);
         cmd.Parameters.AddWithValue("Year", book.Year);
         cmd.Parameters.AddWithValue("CategoryId", book.CategoryId);
         VTYS.SqlExecuteNonQuery(cmd);
     }
 }