예제 #1
0
 public string PutInstrumentTest(clsAllInstruments prInstrument)
 {
     //update test
     if (prInstrument.ModifiedDate == (GetInstrument(prInstrument.SerialNo)).ModifiedDate)
     {
         return("Instrument NOT changed in DB");
     }
     else
     {
         return("Instrument changed in DB");
     }
 }
예제 #2
0
        private Dictionary <string, object> prepareInstrumentParameters(clsAllInstruments prInstrument)
        {
            Dictionary <string, object> par = new Dictionary <string, object>(10);

            par.Add("SerialNo", prInstrument.SerialNo);
            par.Add("Quantity", prInstrument.Quantity);
            par.Add("Tuning", prInstrument.Tuning);
            par.Add("InstrumentName", prInstrument.InstrumentName);
            par.Add("Price", prInstrument.Price);
            par.Add("InstrumentType", prInstrument.InstrumentType);
            par.Add("ModifiedDate", prInstrument.ModifiedDate);
            par.Add("Manufacturer", prInstrument.Manufacturer);
            par.Add("MyCondition", prInstrument.MyCondition);
            par.Add("CategoryName", prInstrument.CategoryName);
            return(par);
        }
예제 #3
0
 public string PutInstrument(clsAllInstruments prInstrument)
 {   //update
     try
     {
         int lcRecCount = clsDbConnection.Execute(
             "UPDATE instrument SET InstrumentName = @InstrumentName, InstrumentType = @InstrumentType, Quantity = @Quantity, Tuning = @Tuning, Price = @Price, ModifiedDate = @ModifiedDate, Manufacturer = @Manufacturer, MyCondition = @MyCondition WHERE CategoryName = @CategoryName AND SerialNo = @SerialNo",
             prepareInstrumentParameters(prInstrument));
         if (lcRecCount == 1)
         {
             return("One Instrument updated");
         }
         else
         {
             return("Unexpected Instrument update count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }
예제 #4
0
 public string PostInstrument(clsAllInstruments prInstrument)
 {   //insert
     try
     {
         int lcRecCount = clsDbConnection.Execute("INSERT INTO instrument" +
                                                  "(SerialNo, Quantity, Tuning, InstrumentName, Price, InstrumentType, ModifiedDate, Manufacturer, MyCondition, CategoryName)" +
                                                  "values (@SerialNo, @Quantity, @Tuning, @InstrumentName, @Price, @InstrumentType, @ModifiedDate, @Manufacturer, @MyCondition, @CategoryName)",
                                                  prepareInstrumentParameters(prInstrument));
         if (lcRecCount == 1)
         {
             return("One instrument inserted");
         }
         else
         {
             return("Unexpected instrument insert count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }