Exemplo n.º 1
0
        private Dictionary <string, object> prepareInstrumentParameters(clsAllInstrument prInstrument)
        {
            Dictionary <string, object> par = new Dictionary <string, object>(3);

            par.Add("CategoryName", prInstrument.CategoryName);
            par.Add("InstrumentID", prInstrument.InstrumentID);
            par.Add("InstrumentName", prInstrument.InstrumentName);
            par.Add("Description", prInstrument.Description);
            par.Add("Brand", prInstrument.Brand);
            par.Add("Type", prInstrument.Type);
            par.Add("InstrumentPrice", prInstrument.InstrumentPrice);
            par.Add("Quantity", prInstrument.Quantity);
            //par.Add("ModifyTime", prInstrument.ModifyTime);
            par.Add("Condition", prInstrument.Condition);
            par.Add("DateOfReturn", prInstrument.DateOfReturn);
            par.Add("WarrantyPeriod", prInstrument.WarrantyPeriod);
            par.Add("ImportDate", prInstrument.ImportDate);
            return(par);
        }
Exemplo n.º 2
0
        //private List<clsOrders> GetOrders(int OrderID)
        //{
        //    Dictionary<string, object> par = new Dictionary<string, object>(1);
        //    par.Add("OrderID", OrderID);
        //    DataTable lcResult = clsDbConnection.GetDataTable("SELECT * FROM Orders WHERE OrderID = @OrderID", par);
        //    List<clsOrders> lcOrders = new List<clsOrders>();
        //    foreach (DataRow dr in lcResult.Rows)
        //        lcOrders.Add(dataRow2Orders(dr));
        //    return lcOrders;

        //}
        //public string PutQuantity(clsAllInstrument prInstrument)
        //{ // update
        //    try
        //    {
        //        int lcRecCount = clsDbConnection.Execute(
        //       "UPDATE Order SET Quantity = @Quantity WHERE InstrumentID = @InstrumentID",
        //       prepareInstrumentParameters(prInstrument));
        //        if (lcRecCount == 1)
        //            return "One instrument updated";
        //        else
        //            return "Unexpected instrument update count: " + lcRecCount;
        //    }
        //    catch (Exception ex)
        //    {
        //        return ex.GetBaseException().Message;
        //    }
        //}
        public string PutInstrument(clsAllInstrument prInstrument)
        { // update
            try
            {
                int lcRecCount = clsDbConnection.Execute(
                    "UPDATE Instrument SET Brand = @Brand, Description = @Description, InstrumentPrice = @InstrumentPrice, Quantity = @Quantity, ModifyTime = GETDATE(), [Condition] = @Condition, DateOfReturn = @DateOfReturn, WarrantyPeriod = @WarrantyPeriod, ImportDate = @ImportDate WHERE InstrumentID = @InstrumentID",
                    prepareInstrumentParameters(prInstrument));
                if (lcRecCount == 1)
                {
                    return("One instrument updated");
                }
                else
                {
                    return("Unexpected instrument update count: " + lcRecCount);
                }
            }
            catch (Exception ex)
            {
                return(ex.GetBaseException().Message);
            }
        }
Exemplo n.º 3
0
 public string PostInstrument(clsAllInstrument prInstrument)
 { // insert
     try
     {
         int lcRecCount = clsDbConnection.Execute(
             "INSERT INTO Instrument (CategoryName, InstrumentName, Brand, Description, Type, InstrumentPrice, Quantity, ModifyTime, Condition, DateOfReturn, WarrantyPeriod, ImportDate) VALUES (@CategoryName, @InstrumentName, @Brand, @Description, @Type, @InstrumentPrice, @Quantity, GETDATE(), @Condition, @DateOfReturn, @WarrantyPeriod, @ImportDate)",
             prepareInstrumentParameters(prInstrument));
         if (lcRecCount == 1)
         {
             return("One instrument added");
         }
         else
         {
             return("Unexpected instrument count: " + lcRecCount);
         }
     }
     catch (Exception ex)
     {
         return(ex.GetBaseException().Message);
     }
 }