コード例 #1
0
 /// <summary>
 /// updates the cost in teh database
 /// </summary>
 /// <param name="invoicenumber"></param>
 public void UpdateCost(int invoicenumber)
 {
     try
     {
         dCost = Double.Parse(tboxCost.Text);
         DAItem.UpdateItemCost(this, invoicenumber);
     }
     catch (Exception ex)
     {
         Exceptions.Spool(ex);
     }
 }
コード例 #2
0
 /// <summary>
 /// Called if number of items combobox is changed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CboItem_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         iNumber = ((ComboBox)sender).SelectedIndex;
         DAItem.UpdateAmount(iInvoiceNumber, iItemNumber, iNumber);
         tblkTotal.Text = itemTotal().ToString();
     }
     catch (Exception ex)
     {
         Exceptions.Spool(ex);
     }
 }
コード例 #3
0
 /// <summary>
 /// Constructor for creating an item in an inventory list, this will include the cost paid rather than
 /// the cost of the item, as well as the number of items purchased
 /// </summary>
 public Item(int itemnumber, double cost, int numberof)
 {
     try
     {
         iItemNumber = itemnumber;
         dCost       = cost;
         iNumber     = numberof;
         //get info of item
         Item tempI = DAItem.GetItem(iItemNumber);
         sItemName    = tempI.sItemName;
         sDescription = tempI.sDescription;
     }
     catch (Exception ex)
     {
         Exceptions.Spool(ex);
     }
 }
コード例 #4
0
        /// <summary>
        /// Creates the grid for each item
        /// </summary>
        /// <param name="iInvoiceNumber"> invoice number</param>
        /// <param name="inv">invoice</param>
        /// <returns></returns>
        public Grid InvoiceItem(int iInvoiceNumber, Invoice inv)
        {
            try
            {
                //get the iNumber from the database
                iNumber = DAItem.getiNumber(iInvoiceNumber, iItemNumber);

                this.iInvoiceNumber = iInvoiceNumber;


                Grid grd = new Grid();
                grd.Height = 24;


                //Stack Pannel -set height
                StackPanel stkPanel = new StackPanel();
                stkPanel.Height      = 24;
                stkPanel.Width       = 670;
                stkPanel.Orientation = Orientation.Horizontal;

                //Combobox
                cboItem = new ComboBox();
                //set width
                cboItem.Width = 40;
                for (int i = 0; i <= 200; i++)
                {
                    cboItem.Items.Add(i);
                }
                //Select number of items
                cboItem.SelectedIndex     = iNumber;
                cboItem.SelectionChanged += new SelectionChangedEventHandler(CboItem_SelectionChanged);
                cboItem.SelectionChanged += new SelectionChangedEventHandler(inv.updatetotal);
                cboItem.IsEnabled         = false;
                stkPanel.Children.Add(cboItem);


                //Item number - set width
                tblkItem               = new TextBlock();
                tblkItem.Width         = 100;
                tblkItem.Text          = iItemNumber.ToString();
                tblkItem.TextAlignment = TextAlignment.Center;
                stkPanel.Children.Add(tblkItem);

                //Item name  - set width
                tblkName       = new TextBlock();
                tblkName.Width = 324;
                tblkName.Text  = sItemName;
                stkPanel.Children.Add(tblkName);



                // Item Cost - set width
                tboxCost               = new TextBox();
                tboxCost.Width         = 100;
                tboxCost.TextAlignment = TextAlignment.Center;
                tboxCost.IsEnabled     = false;
                tboxCost.TextChanged  += new TextChangedEventHandler(Cost_TextChanged);
                tboxCost.Text          = string.Format("{0:0.00}", dCost);
                stkPanel.Children.Add(tboxCost);

                //Item Total -set width
                tblkTotal               = new TextBlock();
                tblkTotal.Width         = 80;
                tblkTotal.TextAlignment = TextAlignment.Right;
                tblkTotal.Text          = itemTotal().ToString("c");
                stkPanel.Children.Add(tblkTotal);

                btnDelete = new Button();
                Thickness m = new Thickness();
                m.Left               = 4;
                btnDelete.Margin     = m;
                btnDelete.Width      = 20;
                btnDelete.Content    = "X";
                btnDelete.Foreground = Brushes.Red;
                btnDelete.Visibility = Visibility.Hidden;
                btnDelete.Tag        = iItemNumber;
                btnDelete.Click     += new RoutedEventHandler(inv.DeleteSelectedItem);
                stkPanel.Children.Add(btnDelete);

                grd.Children.Add(stkPanel);
                return(grd);
            }
            catch (Exception ex)
            {
                Exceptions.Spool(ex);
                return(null);
            }
        }