Esempio n. 1
0
        private Dictionary <string, object> preparePhoneParameters(clsPhone prPhone)
        {
            Dictionary <string, object> par = new Dictionary <string, object>(11);

            par.Add("Id", prPhone.ID);
            par.Add("IMEI", prPhone.IMEI);
            par.Add("Name", prPhone.Name);
            par.Add("ItemPrice", prPhone.ItemPrice);
            par.Add("Description", prPhone.Description);
            par.Add("Color", prPhone.Color);
            par.Add("Type", prPhone.Type);
            par.Add("Availability", prPhone.Availability);
            par.Add("Condition", prPhone.Condition);
            par.Add("CategoryId", prPhone.CategoryID);
            par.Add("Warrenty", prPhone.Warrenty);
            return(par);
        }
Esempio n. 2
0
 public string DeletePhone(clsPhone prPhone)
 {
     try
     {
         int lcRecCount = ClsDBConnection.Execute(
             "DELETE FROM tbl_all_products WHERE id = @Id",
             preparePhoneParameters(prPhone));
         if (lcRecCount == 1)
         {
             return("One product deleted");
         }
         else
         {
             return("Error Unexpected product update count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return("Error: " + ex.GetBaseException().Message);
     }
 }
Esempio n. 3
0
 public string PostPhone(clsPhone prPhone)
 {
     try
     {
         int lcRecCount = ClsDBConnection.Execute("INSERT INTO tbl_all_products " +
                                                  "(IMEI, name, item_price, description, color, type, availability, phone_condition, category_id, warrenty) " +
                                                  "VALUES (@IMEI, @Name, @ItemPrice, @Description, @Color, @Type, @Availability, @Condition, @CategoryID, @Warrenty)", preparePhoneParameters(prPhone));
         if (lcRecCount == 1)
         {
             return("One Product inserted");
         }
         else
         {
             return("Error Unexpected Product insert count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return("Error: " + ex.GetBaseException().Message);
     }
 }
Esempio n. 4
0
 public string PutPhone(clsPhone prPhone)
 {
     try
     {
         int lcRecCount = ClsDBConnection.Execute(
             "UPDATE tbl_all_products SET IMEI = @IMEI, name = @Name, item_price = @ItemPrice, description = @Description, color = @Color, type = @Type, availability = @Availability, " +
             "phone_condition = @Condition, category_id = @CategoryID, warrenty = @Warrenty WHERE id = @Id",
             preparePhoneParameters(prPhone));
         if (lcRecCount == 1)
         {
             return("One product updated");
         }
         else
         {
             return("Error Unexpected product update count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return("Error: " + ex.GetBaseException().Message);
     }
 }