Exemplo n.º 1
0
        private void pictureBox_Click(object sender, EventArgs e)
        {
            PictureBox pictureBox = sender as PictureBox;

            string[] word  = pictureBox.Tag.ToString().Split(',');
            string   name  = word[0];
            string   price = word[1];

            EditOrder    editOrder = new EditOrder();
            DialogResult dialog    = editOrder.ShowDialog();

            if (editOrder.getIsOrder() == true)
            {
                string size = "";

                if (editOrder.getRegularOrLarge() == true)
                {
                    size = "Regular";
                }
                else
                {
                    size = "Large";
                }

                string cream = "";

                if (editOrder.getCream() == true)
                {
                    cream = "Yes";
                }
                else
                {
                    cream = "No";
                }

                string sugar_level = editOrder.getSugar_Level();
                string zone        = editOrder.getZone();
                int    quantity    = editOrder.getQuantity();

                int no = dgvOrder.Rows.Count;
                no++;

                dgvOrder.Rows.Add(no, name, size, sugar_level, cream, quantity.ToString(), price, zone);

                lblTotalAmount.Text = getTotalAmount().ToString();
            }
        }
Exemplo n.º 2
0
        private void dgvOrder_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            int edit_IndexColumn   = 8;
            int remove_IndexColumn = 9;

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)
            {
                if (e.ColumnIndex == edit_IndexColumn)
                {
                    string size        = dgvOrder.Rows[dgvRowIndex].Cells[2].Value.ToString();
                    int    quantity    = int.Parse(dgvOrder.Rows[dgvRowIndex].Cells[5].Value.ToString());
                    string cream       = dgvOrder.Rows[dgvRowIndex].Cells[4].Value.ToString();
                    string sugar_level = dgvOrder.Rows[dgvRowIndex].Cells[3].Value.ToString();
                    string zone        = dgvOrder.Rows[dgvRowIndex].Cells[7].Value.ToString();

                    EditOrder editOrder = new EditOrder(size, quantity, cream, sugar_level, zone);
                    editOrder.ShowDialog();

                    if (editOrder.getRegularOrLarge() == true)
                    {
                        size = "Regular";
                    }
                    else
                    {
                        size = "Large";
                    }

                    if (editOrder.getCream() == true)
                    {
                        cream = "Yes";
                    }
                    else
                    {
                        cream = "No";
                    }

                    sugar_level = editOrder.getSugar_Level();
                    zone        = editOrder.getZone();
                    quantity    = editOrder.getQuantity();

                    dgvOrder.Rows[dgvRowIndex].Cells[2].Value = size;
                    dgvOrder.Rows[dgvRowIndex].Cells[5].Value = quantity.ToString();
                    dgvOrder.Rows[dgvRowIndex].Cells[4].Value = cream;
                    dgvOrder.Rows[dgvRowIndex].Cells[3].Value = sugar_level;
                    dgvOrder.Rows[dgvRowIndex].Cells[7].Value = zone;
                }
                else if (e.ColumnIndex == remove_IndexColumn)
                {
                    DialogResult dialogResult = MessageBox.Show("Are You Sure that You Want To Delete?", "Confimation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (dialogResult == DialogResult.Yes)
                    {
                        dgvOrder.Rows.RemoveAt(dgvRowIndex);
                    }
                }
            }

            lblTotalAmount.Text = getTotalAmount().ToString();
        }