Ejemplo n.º 1
0
        //gets a single product
        public clsAllProducts getSingleProduct(string ProductCode)
        {
            Dictionary <string, object> par = new Dictionary <string, object>(1);

            par.Add("ProductCode", ProductCode);
            DataTable      lcResult   = clsDbConnection.GetDataTable("SELECT * FROM MobileDevice WHERE ProductCode = @ProductCode", par);
            clsAllProducts lcProducts = new clsAllProducts();

            foreach (DataRow dr in lcResult.Rows)
            {
                lcProducts = dataRow2AllProducts(dr);
            }

            return(lcProducts);
        }
Ejemplo n.º 2
0
        private Dictionary <string, object> prepareProductParameters(clsAllProducts prProduct)
        {
            Dictionary <string, object> par = new Dictionary <string, object>(10);

            par.Add("DeviceTypeName", prProduct.DeviceTypeName);
            par.Add("Brand", prProduct.Brand);
            par.Add("ItemDescription", prProduct.ItemDescription);
            par.Add("ProductCode", prProduct.ProductCode);
            par.Add("PricePerItem", prProduct.PricePerItem);
            par.Add("QuantityInStock", prProduct.QuantityInStock);
            par.Add("NewOrUsed", prProduct.NewOrUsed);
            par.Add("ItemCondition", prProduct.ItemCondition);
            par.Add("Warranty", prProduct.Warranty);
            par.Add("DateTimeLastModified", prProduct.DateTimeLastModified);
            par.Add("ProductName", prProduct.ProductName);
            return(par);
        }
Ejemplo n.º 3
0
 public string PutProduct(clsAllProducts prProduct)
 {
     try
     {
         int lcRecCount = clsDbConnection.Execute(
             "UPDATE MobileDevice SET DeviceTypeName = @DeviceTypeName, Brand = @Brand, ItemDescription = @ItemDescription, PricePerItem = @PricePerItem, QuantityInStock = @QuantityInStock, NewOrUsed = @NewOrUsed, ItemCondition = @ItemCondition, Warranty = @Warranty, DateTimeLastModified = @DateTimeLastModified, ProductName = @ProductName WHERE ProductCode = @ProductCode",
             prepareProductParameters(prProduct));
         if (lcRecCount == 1)
         {
             return("One Product updated");
         }
         else
         {
             return("Unexpected Product update count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }
Ejemplo n.º 4
0
 //-----------------------------------------------Task 3 part 6 XV --------------------------------
 //------------------------------------------PUT & POST PRODUCTS-----------------------------------
 public string PostProduct(clsAllProducts prProduct)
 {   // insert
     try
     {
         int lcRecCount = clsDbConnection.Execute("INSERT INTO MobileDevice" +
                                                  "(DeviceTypeName, Brand, ItemDescription, ProductCode, PricePerItem, QuantityInStock, NewOrUsed, ItemCondition, Warranty, DateTimeLastModified, ProductName) " +
                                                  "VALUES (@DeviceTypeName, @Brand, @ItemDescription, @ProductCode, @PricePerItem, @QuantityInStock, @NewOrUsed, @ItemCondition, @Warranty, @DateTimeLastModified, @ProductName)",
                                                  prepareProductParameters(prProduct));
         if (lcRecCount == 1)
         {
             return("One Product inserted");
         }
         else
         {
             return("Unexpected Product insert count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }