private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            int pos_x;
            int pos_y;

            pos_x = e.X;
            pos_y = e.Y;

            int indexx;

            indexx = (((pos_x / 100) + 1) + ((pos_y / 100)) * 5) - 1;
            if (MessageBox.Show("Are you sure to print the invoice?", "Message", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (indexx < DB.cake.Count())
                {
                    printDocument1.Print();
                    DB.Delivered(DB.cake[indexx].cakeid, LogIn.uname);
                    DB.DeliveryInfo();
                    DB.DeliveryBag(LogIn.uname);
                    Refresh();
                    label7.Text = "Capacity = " + DB.bag.Count().ToString();

                    pictureBox2.Height = 100;
                    pictureBox2.Width  = 100 * DB.bag.Count;;
                    flowLayoutPanel2.Controls.Add(pictureBox2);
                    setPicturebox();
                }
            }
        }
 private void Delivery_Load(object sender, EventArgs e)
 {
     label1.Text = LogIn.uname;
     DB.DeliveryInfo();
     DB.DeliveryBag(LogIn.uname);
     setPicturebox();
     flowLayoutPanel1.Controls.Add(pictureBox1);
     label7.Text        = "Capacity = " + DB.bag.Count().ToString();
     pictureBox2.Height = 100;
     pictureBox2.Width  = 100 * DB.bag.Count;;
     flowLayoutPanel2.Controls.Add(pictureBox2);
     Refresh();
 }
        private void button1_Click(object sender, EventArgs e)
        {
            int check = 0;

            foreach (var x in DB.bag)
            {
                if (x.cakeid == label9.Text)
                {
                    check = 1;
                    if (MessageBox.Show("Comfirm to payment?", "Message", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        try
                        {
                            if (Convert.ToDouble(ReceiveTB.Text) >= Convert.ToDouble(PriceTB.Text))
                            {
                                DB.payment(label9.Text);
                                DB.createTransaction(DateTime.Now.ToString() + "_" + LogIn.uname, label9.Text, Convert.ToDouble(ReceiveTB.Text), Convert.ToDouble(ChangeTB.Text));


                                MessageBox.Show("Success");
                                DB.DeliveryInfo();
                                DB.DeliveryBag(LogIn.uname);

                                Refresh();

                                clear();
                            }
                            else
                            {
                                MessageBox.Show("Not enough money");
                            }
                        }
                        catch
                        {
                            MessageBox.Show("wrong iput");
                        }
                    }
                    break;
                }
            }
            if (check == 0)
            {
                MessageBox.Show("You have to print an Invoice");
            }
        }