コード例 #1
0
        /// <summary>
        /// Updates the edit item form with info from the selected item.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void selectedInvoiceDataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            try
            {
                // casts selection to a clsItem object
                Items.clsItem item = (Items.clsItem)selectedInvoiceDataGrid.SelectedItem;

                if (item == null)
                {
                    return;
                }

                // gets the index of the selected item
                selectedInvoiceSelectedItem = selectedInvoiceDataGrid.SelectedIndex;

                selectedItemCostTxt.Text = item.Cost;
                selectedItemDescTxt.Text = item.Desc;

                ObservableCollection <Items.clsItem> itemsList = logic.GetItems();

                for (int i = 0; i < itemsList.Count; i++)
                {
                    updateItemCbo.Items.Add(itemsList[i]);
                }
            }
            catch (Exception ex)
            {
                //This is the top level method so we want to handle the exception
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets all items.
        /// </summary>
        /// <returns>A list of item objects.</returns>
        public ObservableCollection <Items.clsItem> GetItems()
        {
            try
            {
                int    retVal   = 0;
                string itemsSQL = sql.SelectItems();
                ds = data.ExecuteSQLStatement(itemsSQL, ref retVal);

                itemsList = new ObservableCollection <Items.clsItem>();
                Items.clsItem item;

                // fills itemsList with queried items
                for (int i = 0; i < retVal; i++)
                {
                    item = new Items.clsItem(ds.Tables[0].Rows[i][0].ToString(), ds.Tables[0].Rows[i][2].ToString(), ds.Tables[0].Rows[i][1].ToString());
                    itemsList.Add(item);
                }

                return(itemsList);
            }
            catch (Exception ex)
            {
                //Just throw the exception
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." +
                                    MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
            }
        }
コード例 #3
0
        /// <summary>
        /// Displays the currently selected invoice in the selected invoice datagrid.
        /// </summary>
        /// <returns>An obvservable collection of invoices.</returns>
        public ObservableCollection <Items.clsItem> DisplayInvoie()
        {
            try
            {
                string getInvoiceSQL = sql.SelectLineItem(selectedInvoice);

                int retVal = 0;
                ds = data.ExecuteSQLStatement(getInvoiceSQL, ref retVal);

                dgItems = new ObservableCollection <Items.clsItem>();
                Items.clsItem item;

                // fills dgItems with each queried item
                for (int i = 0; i < retVal; i++)
                {
                    item = new Items.clsItem(ds.Tables[0].Rows[i][0].ToString(), ds.Tables[0].Rows[i][2].ToString(), ds.Tables[0].Rows[i][1].ToString());
                    dgItems.Add(item);
                }

                return(dgItems);
            }
            catch (Exception ex)
            {
                //Just throw the exception
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." +
                                    MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
            }
        }
コード例 #4
0
 /// <summary>
 /// Adds an item to the current working invoice.
 /// </summary>
 /// <param name="item"></param>
 public void AddItem(Items.clsItem item)
 {
     try
     {
         WorkingInvoiceItems.Add(item);
     }
     catch (Exception ex)
     {
         //Just throw the exception
         throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." +
                             MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
     }
 }
コード例 #5
0
 /// <summary>
 /// Updates the dgItems collection.
 /// </summary>
 /// <param name="item"></param>
 /// <param name="index"></param>
 public void UpdateDataGridItem(Items.clsItem item, int index)
 {
     try
     {
         // changes the item at an index to the passed in item.
         dgItems[index] = item;
     }
     catch (Exception ex)
     {
         //Just throw the exception
         throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." +
                             MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
     }
 }
コード例 #6
0
        /// <summary>
        /// Saves the updates made to an invoice item.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void saveUpdatesBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Items.clsItem Item;
                Item = (Items.clsItem)updateItemCbo.Items[updateItemCbo.SelectedIndex];

                logic.UpdateDataGridItem(Item, selectedInvoiceSelectedItem);

                Items.clsItem item = (Items.clsItem)updateItemCbo.SelectedItem;

                logic.UpdateInvoice(logic.selectedInvoice, selectedInvoiceSelectedItem + 1, item.Code);
            }
            catch (Exception ex)
            {
                //This is the top level method so we want to handle the exception
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
コード例 #7
0
        /// <summary>
        /// Sets the working invoice selected item.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void workingInvoiceDataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            try
            {
                // casts selection to a clsItem object
                Items.clsItem item = (Items.clsItem)workingInvoiceDataGrid.SelectedItem;

                if (item == null)
                {
                    return;
                }

                // the index to be removed
                workingInvoiceSelectedItem = workingInvoiceDataGrid.SelectedIndex;
                deleteItemBtn.Visibility   = Visibility.Visible;
            }
            catch (Exception ex)
            {
                //This is the top level method so we want to handle the exception
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }