Beispiel #1
0
        //This method is for calling from Search method
        public WCSA_Entity_Classes.Product ReturnSingleItemDetail(string searchCode)
        {
            ProductDataSource sds = new ProductDataSource();

            WCSA_Entity_Classes.Product currentProduct = sds.ReturnAnItem(searchCode);
            if (currentProduct == null)
            {
                return(null);
            }
            else
            {
                return(currentProduct);
            }
        }
        /*
         * Item addition to static list starts here
         */
        public double addItemToInvoice(string productCode, double price, uint quantity, double vat)
        {
            ProductDataSource pds = new ProductDataSource();

            WCSA_Entity_Classes.Product tempP = pds.ReturnAnItem(productCode);
            /////////////////***************************pds.ModifyItemInAccordanceWithInvoice(productCode, quantity);
            purchaseList.Add(new Product(productCode, tempP.ProductName, price * quantity, quantity));

            //Console.WriteLine("price = {0}  ||  quantity = {1}", price, quantity);

            //Update total cost
            totalCost += (price * quantity);
            //Console.WriteLine("totalCost = " + totalCost);

            return(totalCost + ((totalCost * vat) / 100));
        }
Beispiel #3
0
        /*
         * Product code Text changed function starts here
         */
        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            reference = new POSPresenter().returnProductDetails(textPCode.Text);
            if (reference != null)
            {
                textPCode.Text      = reference.ProductCode;
                text_P_Name.Text    = reference.ProductName;
                text_P_Name.Enabled = false;

                textQuantity.Text = null;

                //textTotalPrice.Text = tempProduct.Price.ToString();
                textTotalPrice.Enabled = false;

                textUnitPrice.Text = Convert.ToString(reference.Price);
            }
            else
            {
                Console.WriteLine("Product not returned");
            }
        }
Beispiel #4
0
        private void textQuantity_EnterKeyPressed(object sender, EventArgs e)
        {
            if (reference != null)
            {
                uint   originalQuantity = reference.Quantity;
                double VAT;
                uint   quantity;

                /*
                 * Unnecessary code starts here
                 */
                Console.WriteLine("Vat : " + mainFormReference.VAT.ToString());
                textinvoiceVAT.Text = VatForm.vat.ToString();

                /*
                 * Unnecessary code ends here
                 */

                Debug.Assert(reference != null);

                if (double.TryParse(textinvoiceVAT.Text, out VAT))
                {
                    if (uint.TryParse(textQuantity.Text, out quantity))
                    {
                        if (quantity <= originalQuantity)
                        {
                            POSPresenter pp = new POSPresenter();
                            textBoxInvoiceTotalCost.Text = Convert.ToString(pp.addItemToInvoice(reference.ProductCode, Convert.ToDouble(reference.Price),
                                                                                                Convert.ToUInt32(textQuantity.Text), Convert.ToDouble(textinvoiceVAT.Text)));
                            dataGridView1.AutoGenerateColumns = false;
                            dataGridView1.DataSource          = null;
                            var list = new BindingList <WCSA_Entity_Classes.Product>(pp.getInvoiceItemsList());
                            dataGridView1.DataSource      = list;
                            textBoxInvoiceTotalItems.Text = Convert.ToString(pp.getInvoiceItemsList().Count);

                            textPCode.Text        = null;
                            textUnitPrice.Text    = null;
                            text_P_Name.Text      = null;
                            textQuantity.Text     = null;
                            textUnitPrice.Enabled = true;
                            textPCode.Enabled     = true;
                            text_P_Name.Enabled   = true;
                            textTotalPrice.Text   = null;
                            textBarCode.Text      = null;

                            reference = null;
                        }
                        else
                        {
                            MessageBox.Show("Not enough items in stock");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter quantity");
                    }
                }
                else
                {
                    MessageBox.Show("Please input VAT");
                }
            }
            else
            {
                MessageBox.Show("Product Not found !");
            }
        }