Example #1
0
        private void btn_Trash2_Drop(object sender, DragEventArgs e)
        {
            ProductSale tempPS = (ProductSale)listPS.ElementAt(rowIndex);

            PopUpAmount temp = new PopUpAmount();

            temp.ShowDialog();
            int amount = temp.amount;

            temp.Close();

            if (amount > tempPS.Amount)
            {
                MessageBox.Show("Cannot Return More Then You Have.");
                return;
                // throw new Exception("Cannot Return More Then You Have.");
            }

            // Product tempProduct = new Product(tempPS.PRODUCT);
            //tempProduct.StockCount += amount;
            tempPS.PRODUCT.StockCount += amount;
            if (tempPS.PRODUCT.StockCount == 0)
            {
                tempPS.PRODUCT.INStock = InStock.False;
            }
            else if (tempPS.PRODUCT.StockCount > tempPS.PRODUCT.WhenToOrder)
            {
                tempPS.PRODUCT.INStock = InStock.True;
            }
            else
            {
                tempPS.PRODUCT.INStock = InStock.NeedToOrder;
            }
            tempPS.Amount -= amount;


            if (tempPS.Amount == 0)
            {
                listPS.RemoveAt(rowIndex);
            }

            // itsBL.edit(tempProduct);


            // this.receiptDTG.
            vsDND.reloadData();
            vsDND.tableShow.Children.Clear();
            vsDND.tableShow.Children.Add(new PaymentScreen(itsBL, receipt, vsDND, user));

            //changedProduct.StockCount -= amount;
            //itsBL.edit(changedProduct);
            //listP = itsBL.queryByString(Classes.Product, stringFields.inStock, "True", listP);
            ////Product tempP = new Product(changedProduct);
            //// tempP.StockCount -= amount;
            //// itsBL.edit(tempP)
            //ShowTable(listP);

            //MessageBox.Show(this.receipt.toString());
        }
Example #2
0
        private void btn16x16_Drop(object sender, DragEventArgs e)
        {
            //ProductCollection productCollection = Resources["ProductList"] as ProductCollection;
            Product     changedProduct = (Product)listP.ElementAt(ProductDTG.rowIndex);
            PopUpAmount temp           = new PopUpAmount();

            temp.ShowDialog();
            int amount = temp.amount;

            if (amount <= 0)
            {
                MessageBox.Show("The Amount must be a positive number. Are you trying to test our patience?");
                return;
            }
            ProductSale ps = null;

            try
            {
                ps = new ProductSale(changedProduct, amount);
            }
            catch (Exception u)
            {
                MessageBox.Show(u.Message);
                return;
            }


            this.receipt.addProductSale(ps);

            temp.Close();
            changedProduct.StockCount -= amount;
            itsBL.edit(changedProduct);
            listP = itsBL.queryByString(Classes.Product, stringFields.inStock, "True", listP);

            ShowTable(listP);
        }