Example #1
0
        /// <summary>
        /// Deletes item from list and from database
        /// </summary>
        /// <param name="pKey"></param>
        public int DeleteItem(string pKey)
        {
            try
            {
                int delReturn = dbLink.DeleteItem(pKey);
                //if error occurred
                if (delReturn != 1)
                {
                    return(delReturn);
                }

                foreach (Item item in itemList)
                {
                    if (item.ItemCode == pKey)
                    {
                        itemList.Remove(item);
                        --listLength;
                        return(1);
                    }
                }
                itemList = GetItems(ref listLength);
                throw new Exception("Item deleted from database but not linked list");
            }
            catch (Exception ex)
            {
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
            }
        }
Example #2
0
        /// <summary>
        /// talks to sql to delete an item from the DB
        /// </summary>
        /// <param name="item"></param>

        public void DeleteItem(ItemDescription item)
        {
            if (_sql.InUse(item.ItemCode) == false)
            {
                _sql.DeleteItem(item.ItemCode);
            }
            else
            {
                MessageBox.Show("Item number " + item.ItemCode + " is still in use on invoice " + _sql.UsedOnInvoice(item.ItemCode));
            }
        }