Exemple #1
0
        /*********************************
        * Manipulate Each Stock
        *********************************/

        private void lvDataStock_PreviewMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Stock stock = (Stock)lvDataStock.SelectedItem;

            if (stock == null)
            {
                return;
            }

            if (checkWareHouse(stock))
            {
                StockOutDetails r = new StockOutDetails();

                var foundIteminReceipt = _stockOutDetailsList.FirstOrDefault(c => c.StockId.Equals(stock.StoId));
                if (foundIteminReceipt == null)
                {
                    r.StockId   = stock.StoId;
                    r.Quan      = 1;
                    r.ItemPrice = stock.StandardPrice;
                    _stockOutDetailsList.Add(r);
                }
                else
                {
                    foundIteminReceipt.Quan++;
                }
                lvDataStockOut.Items.Refresh();
                LoadStockOutData();
            }
        }
Exemple #2
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);
                }
            }
        }
Exemple #3
0
        private void bntDelete_Click(object sender, RoutedEventArgs e)
        {
            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);



            if (_stockOutDetailsList[index].Quan > 1 && !ErrorDetailsItem.Contains(index))
            {
                r.Quan      = _stockOutDetailsList[index].Quan - 1;
                r.StockId   = _stockOutDetailsList[index].StockId;
                r.ItemPrice = _stockOutDetailsList[index].ItemPrice;
                _stockOutDetailsList[index] = r;
            }
            else
            {
                _stockOutDetailsList.RemoveAt(index);
                if (ErrorDetailsItem.Contains(index))
                {
                    ErrorDetailsItem.Remove(index);
                }
            }
            lvDataStockOut.Items.Refresh();
            LoadStockOutData();
        }