Exemplo n.º 1
0
        private void txtQuan_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox textboxQuan = sender as TextBox;


            int              index;
            StockOutDetails  r   = new StockOutDetails();
            DependencyObject dep = (DependencyObject)e.OriginalSource;

            while ((dep != null) && !(dep is ListViewItem))
            {
                dep = VisualTreeHelper.GetParent(dep);
            }
            if (dep == null)
            {
                return;
            }
            index = lvDataStockOut.ItemContainerGenerator.IndexFromContainer(dep);


            try
            {
                if (textboxQuan.Text == null || textboxQuan.Text.Length == 0)
                {
                    MessageBox.Show("The quantity of Output Stock can not be blank!");
                    if (!ErrorDetailsItem.Contains(index))
                    {
                        ErrorDetailsItem.Add(index);
                    }
                    return;
                }
                _stockOutDetailsList[index].Quan = int.Parse(textboxQuan.Text);

                LoadStockOutData();
                if (ErrorDetailsItem.Contains(index))
                {
                    ErrorDetailsItem.Remove(index);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something went wrong when try to calculate the input data. Please check your input");
                if (!ErrorDetailsItem.Contains(index))
                {
                    ErrorDetailsItem.Add(index);
                }
            }
        }
Exemplo n.º 2
0
        /*********************************
        * Manipulate Each StockInDetails
        *********************************/

        private void TxtItemPrice_OnTextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox textboxItemPrice = sender as TextBox;


            int index;
            ReceiptNoteDetail r   = new ReceiptNoteDetail();
            DependencyObject  dep = (DependencyObject)e.OriginalSource;

            while ((dep != null) && !(dep is ListViewItem))
            {
                dep = VisualTreeHelper.GetParent(dep);
            }
            if (dep == null)
            {
                return;
            }
            index = lvDataReceipt.ItemContainerGenerator.IndexFromContainer(dep);


            try
            {
                if (textboxItemPrice.Text == null || textboxItemPrice.Text.Length == 0)
                {
                    MessageBox.Show("The Price of Input Ingredients can not be blank!");
                    if (!ErrorDetailsItem.Contains(index))
                    {
                        ErrorDetailsItem.Add(index);
                    }
                    return;
                }
                ReceiptDetailsList[index].ItemPrice = decimal.Parse(textboxItemPrice.Text);

                LoadReceiptData();
                if (ErrorDetailsItem.Contains(index))
                {
                    ErrorDetailsItem.Remove(index);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something went wrong when try to calculate the input data. Please check your input");
                if (!ErrorDetailsItem.Contains(index))
                {
                    ErrorDetailsItem.Add(index);
                }
            }
        }