Пример #1
0
        private void Purchase_button_Click(object sender, EventArgs e)
        {
            double totalFinalPrice = 0, totalStockPrice;
            int    i = 0;

            foreach (Stock st in viewCart)
            {
                st.Qty          = dataGridView1[0, i].Value.ToString();
                totalStockPrice = Double.Parse(st.Qty) * st.LastPrice;

                totalFinalPrice = totalFinalPrice + totalStockPrice;
                i++;
            }

            if (totalFinalPrice > pickedCust.Account.Account_Balance)
            {
                MessageBox.Show("Exceeded Funds");
            }
            else
            {
                Finalizepurchase fin = new Finalizepurchase();

                fin.finstocklist = viewCart;

                fin.finCust = pickedCust;

                this.Hide();
                fin.ShowDialog();
                refreshlist();

                //this.Show();

                pickedCust = fin.finCust;
                viewCart.Clear();

                viewCart.Clear();
                this.Close();
            }
        }
Пример #2
0
        private void purchase_button_Click(object sender, EventArgs e)
        {
            Finalizepurchase purchase = new Finalizepurchase();
            double           d, tryHard;

            if (!Double.TryParse(qty_box.Text, out d))
            {
                Console.WriteLine("Wrong input");
            }
            else
            {
                if (Double.Parse(qty_box.Text) > 0 && currentStock.Name != null)
                {
                    currentStock.Qty = qty_box.Text;

                    purchase.finstocklist.Add(currentStock);
                    purchase.finCust = pickedCustomer;
                    tryHard          = Double.Parse(currentStock.Qty) * currentStock.LastPrice;
                    if (pickedCustomer.Account.Account_Balance - tryHard < 0)
                    {
                        MessageBox.Show("Exceeded Funds");
                    }
                    else
                    {
                        purchase.ShowDialog();

                        pickedCustomer = purchase.finCust;

                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Incorrect Entries!");
                }
            }
        }