예제 #1
0
        /// <summary>
        /// Handle button click event to add items to the grid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddItemToGrid(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sSelectedItem != "")
                {
                    clsItem selected = (clsItem)cbItemList.SelectedItem;

                    clsItem Item = new clsItem();
                    Item.sItemDesc = selected.sItemDesc;
                    Item.sItemName = selected.sItemName;
                    Item.iItemCost = selected.iItemCost;

                    cost            += selected.iItemCost;
                    tbTotalCost.Text = cost.ToString();
                    SelectedItems.Add(Item);

                    UpdateDataGrid(SelectedItems);
                    btnSave.IsEnabled = true;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + " " + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
            }
        }
예제 #2
0
        /// <summary>
        /// fill in invoice that's been selected from the search
        /// </summary>
        public void FillInvoice()
        {
            if (sInvoiceID != "none")
            {
                btnEditInvoice.IsEnabled = true;
                btnCancel.IsEnabled      = true;
                btnAddInvoice.IsEnabled  = false;
                cbItemList.IsEnabled     = true;
                dgItemList.IsEnabled     = false;
                btnUpdate.IsEnabled      = true;
                List <clsItem> items = new List <clsItem>();
                ds = sql.SelectInvoice(Convert.ToInt32(sInvoiceID));
                InvoiceNumberLabel.Content = "Invoice # " + sInvoiceID;
                InvoiceDateLabel.Content   = ds.Tables[0].Rows[0][1].ToString();
                tbTotalCost.Text           = ds.Tables[0].Rows[0][2].ToString();

                ds = sql.SelectItem(Convert.ToInt32(sInvoiceID));

                foreach (DataRow item in ds.Tables[0].Rows)
                {
                    NewInvoice           = new clsItem();
                    NewInvoice.sItemName = item[0].ToString();
                    NewInvoice.sItemDesc = item[1].ToString();;
                    NewInvoice.iItemCost = Convert.ToInt32(item[2]);
                    items.Add(NewInvoice);
                }
                SelectedItems = items;
                UpdateDataGrid(items);
            }
        }
예제 #3
0
        /// <summary>
        /// Handles delete item click event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                clsItem item = (clsItem)dgItemList.SelectedItem;
                cost            -= item.iItemCost;
                tbTotalCost.Text = cost.ToString();
                SelectedItems.RemoveAt(dgItemList.SelectedIndex);
                UpdateDataGrid(SelectedItems);
                btnDeleteItem.IsEnabled = false;

                if (SelectedItems.Count == 0)
                {
                    btnSave.IsEnabled = false;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + " " + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
            }
        }