示例#1
0
文件: Repos.cs 项目: Buchan28/PLM
 public bool AddCategory(Category category)
 {
     var idParam = new SqlParameter
     {
         ParameterName = "categoryName",
         Value = category.CategoryName
     };
     try
     {
         _dc.Database.ExecuteSqlCommand(
             "INSERT INTO Categories (CategoryName) VALUES (@CategoryName)", idParam
             );
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }
示例#2
0
文件: Repos.cs 项目: Buchan28/PLM
 public bool UpdateCategory(Category category)
 {
     var idParam = new SqlParameter
     {
         ParameterName = "CategoryName",
         Value = category.CategoryName
     };
     var idParam1 = new SqlParameter
     {
         ParameterName = "CategoryID",
         Value = category.CategoryID
     };
     try
     {
         _dc.Database.ExecuteSqlCommand(
             "UPDATE Categories SET CategoryName = @CategoryName WHERE CategoryID = @CategoryID", idParam, idParam1
             );
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }