示例#1
0
        private void addtoCart()
        {
            try
            {
                //error handler for numeric quantity
                bool result = error.checkNum(txtQty.Text);
                //searching through data
                bool found = pos.orderExist(Transactionlbl.Text, _pcode.ToString());
                if (_qty < int.Parse(txtQty.Text))
                {
                    MessageBox.Show("Unable to proceed", "warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                double total = Convert.ToDouble(txtQty.Text) * _price;
                //if quantity is numeric execute if not throw an error message
                if (result == true)
                {
                    //Search through the data if product exist during transaction
                    if (found == true)
                    {
                        //if qty is lessthan from input qty show error
                        if (_qty < (int.Parse(txtQty.Text)) + cart_qty)
                        {
                            MessageBox.Show("Unable to proceed!", "warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }

                        //adding quantity if already exist
                        pos.updateOrder(_pcode.ToString(), txtQty.Text, total);
                        tableShow();
                        textBox6.SelectionStart  = 0;
                        textBox6.SelectionLength = textBox6.Text.Length;
                        textBox6.Clear();
                    }
                    else
                    {
                        //execute if product is not duplicated during transaction
                        pos.insertTransact(_pcode.ToString(),
                                           Transactionlbl.Text,
                                           txtQty.Text, total, label1.Text);

                        tableShow();
                        //pointOfSale.transactionNo();
                        textBox6.SelectionStart  = 0;
                        textBox6.SelectionLength = textBox6.Text.Length;
                        textBox6.Clear();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        private void quantity_KeyPress(object sender, KeyPressEventArgs e)
        {
            //error handler for numeric quantity
            bool result = error.checkNum(quantity.Text);
            //searching through data
            bool found = pos.orderExist(pointOfSale.Transactionlbl.Text, pointOfSale.pcode.ToString());

            if ((e.KeyChar == 13) && (quantity.Text != string.Empty))
            {
                if (pointOfSale.qty < int.Parse(quantity.Text))
                {
                    MessageBox.Show("Unable to proceed", "warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                double total = Convert.ToDouble(quantity.Text) * pointOfSale.price;
                //if quantity is numeric execute if not throw an error message
                if (result == true)
                {
                    //Search through the data if product exist during transaction
                    if (found == true)
                    {
                        //if qty is lessthan from input qty show error
                        if (pointOfSale.qty < (int.Parse(quantity.Text)) + pointOfSale.cart_qty)
                        {
                            MessageBox.Show("Unable to proceed!", "warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }

                        //adding quantity if already exist
                        pos.updateOrder(pointOfSale.pcode.ToString(), quantity.Text, total);
                        this.Hide();
                        pointOfSale.tableShow();
                        pointOfSale.textBox6.Clear();
                    }
                    else
                    {
                        //execute if product is not duplicated during transaction
                        pos.insertTransact(pointOfSale.pcode.ToString(),
                                           pointOfSale.Transactionlbl.Text,
                                           quantity.Text, total, pointOfSale.label1.Text);

                        this.Hide();
                        pointOfSale.tableShow();
                        //pointOfSale.transactionNo();
                        pointOfSale.textBox6.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("Quantity should be numeric!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }