Ejemplo n.º 1
0
        private void dataGridViewOrders_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;
            var indexItem  = Convert.ToInt16(senderGrid.Rows[e.RowIndex].Cells[0].Value.ToString());

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0)
            {
                var but = (DataGridViewButtonColumn)senderGrid.Columns[e.ColumnIndex];
                if (but.Text == "Изменить")
                {
                    orders = GetIdOrder(indexItem);
                    AddOrderForm f = new AddOrderForm(orders);
                    f.ShowDialog();
                    EditOrder(f.item);
                }

                else
                {
                    DeleteOrder(indexItem);
                }

                var items = GetOrders();
                dataGridViewOrders.DataSource = items;
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            AddOrderForm f = new AddOrderForm();

            f.ShowDialog();
            AddOrder(f.item);

            var items = GetOrders();

            dataGridViewOrders.DataSource = items;
        }