示例#1
0
 /// <summary>
 /// Adds item to list and to database
 /// </summary>
 /// <param name="pKey"></param>
 /// <param name="ItemDesc"></param>
 /// <param name="cost"></param>
 /// <returns>null if pKey is already used or the new Item if successful</returns>
 public Item AddItem(string pKey, string ItemDesc, double cost)
 {
     try
     {
         if (dbLink.AddItem(pKey, ItemDesc, cost) == -1)
         {
             return(null);
         }
         Item newItem = new Item(pKey, ItemDesc, cost);
         itemList.Add(newItem);
         ++listLength;
         itemList = GetItems(ref listLength);
         return(newItem);
     }
     catch (Exception ex)
     {
         throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
     }
 }
示例#2
0
 /// <summary>
 /// talks to SQL to add item and bumps code number to the next int.
 /// </summary>
 /// <param name="item"></param>
 public void AddItem(ItemDescription item)
 {
     BumpCode();
     _sql.AddItem(item);
 }