Ejemplo n.º 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            SecondaryForm blankForm = new SecondaryForm();
            DialogResult  dr        = blankForm.ShowDialog();

            if (dr == DialogResult.OK)
            {
                OrderList.SingleInstance.AddOrder(orderTmp);
                dgvOrderList.DataSource = OrderList.SingleInstance.Orders.ToList();
            }
        }
Ejemplo n.º 2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvOrderList.SelectedRows.Count == 1)
                {
                    int i = 0;
                    for (; i < OrderList.SingleInstance.Orders.Count; i++)
                    {
                        if (int.Parse(dgvOrderList.SelectedRows[0].Cells[0].Value.ToString()) == OrderList.SingleInstance.Orders[i].OrderId)
                        {
                            break;
                        }
                    }

                    SecondaryForm blankForm = new SecondaryForm(i);
                    DialogResult  dr        = blankForm.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        OrderList.SingleInstance.ReplaceOrder(i, orderTmp);
                        dgvOrderList.DataSource = OrderList.SingleInstance.Orders.ToList();
                    }
                }
                else if (dgvOrderList.SelectedRows.Count == 0)
                {
                    throw new Exception("Nije selektovan nijedan red");
                }
                else
                {
                    throw new Exception("Selektovano previse redova");
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Greska pri izvrsenju", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }