示例#1
0
        private void dGVClients_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == dGVClients.Columns["edit_column"].Index)
            {
                var       model         = dbClient.getById((int)dGVClients.Rows[dGVClients.CurrentRow.Index].Cells["id"].Value);
                AddClient AddClientForm = new AddClient(this, model);
                AddClientForm.Show();
            }

            if (e.ColumnIndex == dGVClients.Columns["delete_client"].Index)
            {
                //Do something with your button.
                try
                {
                    DialogResult dialogResult = MessageBox.Show("Jesteś pewien, że chcesz usunąć?", "", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        var id = Convert.ToInt32(dGVClients.Rows[dGVClients.CurrentRow.Index].Cells["id"].Value.ToString());
                        dbClient.deleteClientById(id);
                        loadClientsTable();
                        //MessageBox.Show("Usunięto.");
                    }
                }
                catch (Exception ex)
                {
                    Logging.LogWrite(ex.Message);
                    MessageBox.Show("Nie można usunąć.");
                }
            }
        }
示例#2
0
 private void btnAddClient_Click(object sender, EventArgs e)
 {
     AddClientForm = new AddClient(this);
     AddClientForm.Show();
 }