Beispiel #1
0
        private Dictionary <string, object> prepareComputerParameters(clsAllComputers prComputers)
        {
            Dictionary <string, object> par = new Dictionary <string, object>(12);

            //par.Add("ComputerID", prComputers.ComputerID);
            par.Add("Name", prComputers.Name);
            par.Add("Price", prComputers.Price);
            par.Add("LastModified", prComputers.LastModified);
            par.Add("Quantity", prComputers.Quantity);
            par.Add("Type", prComputers.Type);
            par.Add("Ram", prComputers.Ram);
            par.Add("HDD", prComputers.HDD);
            par.Add("Graphics", prComputers.Graphics);
            par.Add("Color", prComputers.Color);
            par.Add("TowerType", prComputers.TowerType);
            par.Add("BrandName", prComputers.BrandName);

            return(par);
        }
Beispiel #2
0
 //Updating the database if any changes are done to a computer
 public string UpdateComputer(clsAllComputers prComputers)
 {
     try
     {
         int lcRecCount = clsDbConnectioncs.Execute("UPDATE tbl_computer SET " +
                                                    "Name = @Name, Price = @Price, LastModified = @LastModified, Quantity = @Quantity, Type = @Type, Ram = @Ram, " +
                                                    "HDD = @HDD, Graphics = @Graphics, Color = @Color, TowerType = @TowerType",
                                                    prepareComputerParameters(prComputers));
         if (lcRecCount == 1)
         {
             return("One Computer Updated");
         }
         else
         {
             return("Unexepected Computer insert count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }
Beispiel #3
0
 //inserting a new computer into the database
 public string InsertComputer(clsAllComputers prComputers)
 {
     try
     {
         int lcRecCount = clsDbConnectioncs.Execute("INSERT INTO tbl_computer " +
                                                    "(Name, Price, LastModified, Quantity, Type, Ram, HDD, Graphics, Color, TowerType, BrandName)" +
                                                    "VALUES (@Name, @Price, @LastModified, @Quantity, @Type, @Ram, @HDD, @Graphics, @Color, @TowerType, @BrandName)",
                                                    prepareComputerParameters(prComputers));
         if (lcRecCount == 1)
         {
             return("One Computer inserted");
         }
         else
         {
             return("Unexepected Computer insert count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }