Пример #1
0
        private Dictionary <string, object> prepareProductParameters(clsProduct prProduct)
        {
            Dictionary <string, object> par = new Dictionary <string, object>(11);

            par.Add("ProductID", prProduct.ProductID);
            par.Add("Category", prProduct.Category);
            par.Add("ProductName", prProduct.ProductName);
            par.Add("ProductType", prProduct.ProductType);
            par.Add("Brand", prProduct.Brand);
            par.Add("NewOrUsed", prProduct.NewOrUsed);
            par.Add("Warranty", prProduct.Warranty);
            par.Add("Condition", prProduct.Condition);
            par.Add("Quantity", prProduct.Quantity);
            par.Add("DateModified", prProduct.DateModified);
            par.Add("Price", prProduct.Price);
            return(par);
        }
Пример #2
0
 public string PostProduct(clsProduct prProduct)
 {
     try
     {
         int lcRecCount = clsDBConnection.Execute("INSERT INTO tblProduct " +
                                                  "(Category, ProductName, ProductType, Brand, NewOrUsed, Warranty, Condition, Quantity, DateModified, Price) " +
                                                  "VALUES (@Category, @ProductName, @ProductType, @Brand, @NewOrUsed, @Warranty, @Condition, @Quantity, @DateModified, @Price)",
                                                  prepareProductParameters(prProduct));
         if (lcRecCount == 1)
         {
             return("One product inserted");
         }
         else
         {
             return("Unexpected product insert count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }
Пример #3
0
 public string PutProduct(clsProduct prProduct)
 {
     try
     {
         int lcRecCount = clsDBConnection.Execute("UPDATE tblProduct SET " +
                                                  "ProductName = @ProductName, ProductType = @ProductType, Brand = @Brand," +
                                                  "NewOrUsed = @NewOrUsed, Warranty = @Warranty, Condition = @Condition, Quantity = @Quantity," +
                                                  "DateModified = @DateModified, Price = @Price " +
                                                  "WHERE ProductID = @ProductID",
                                                  prepareProductParameters(prProduct));
         if (lcRecCount == 1)
         {
             return("One product updated");
         }
         else
         {
             return("Unexpected product update count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }