Beispiel #1
0
        private void dataGridViewServices_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;
            var indexItem  = 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 == "Изменить")
                {
                    services = GetIdService(indexItem);
                    AddServiceForm f = new AddServiceForm(services);
                    f.ShowDialog();
                    EditService(f.item);
                }

                else
                {
                    DeleteService(indexItem);
                }

                var items = GetServices();
                dataGridViewServices.DataSource = items;
            }
        }
Beispiel #2
0
        private void buttonAddService_Click(object sender, EventArgs e)
        {
            AddServiceForm f = new AddServiceForm();

            f.ShowDialog();
            AddService(f.item);

            var items = GetServices();

            dataGridViewServices.DataSource = items;
        }