Esempio n. 1
0
        private void btnNext_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int q;
                if (selectedProduct == null)
                {
                    MessageBox.Show("No selection has been made");
                    cmbProducts.Focus();
                    return ;

                }
                if( String.IsNullOrWhiteSpace(txtQuantity.Text))
                {
                    MessageBox.Show("Please specify the quantity");
                    txtQuantity.Focus();
                    return ;
                }
                if(!Int32.TryParse(txtQuantity.Text,out q ))
                {
                    MessageBox.Show("Invalid Quantity");
                    txtQuantity.Focus();
                    return;
                }
                    newSales.Id = selectedProduct.Id;
                    newSales.InvoiceNo = invoiceNo;
                    newSales.Name = selectedProduct.Name;
                    newSales.UnitPrice = selectedProduct.UnitPrice;
                    newSales.Quantity = Convert.ToInt32(txtQuantity.Text);
                    newSales.Total = newSales.UnitPrice * newSales.Quantity;
                    grandTotal += newSales.Total;
                    salesDetail.Add(newSales);
                    grdSale.ItemsSource = salesDetail;
                    newSales = new SalesDetail();
                    txtQuantity.Text = null;
                    cmbProducts.SelectedItem = null;
                    selectedProduct = null;
                
            }
            catch
            {

            }
        }
Esempio n. 2
0
        private void cmbProducts_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                selectedProduct = (Products)cmbProducts.SelectedItem;
                newSales = new SalesDetail();
                txtQuantity.Focus();
            }
            catch
            {

            }
            
            
        }