Exemple #1
0
        private void buttonAddClient_Click(object sender, EventArgs e)
        {
            try
            {
                clientVM.SetDisplayClient(new Client {
                    ClientCode = ""
                });
                ClientEditDialog dialog = new ClientEditDialog(true);
                dialog.Text     = "Add New Client";
                dialog.ClientVM = clientVM;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    refreshDataGridView();
                    refreshClientLabels();
                }
            }

            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message, "DB Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Processing Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        private void buttonEditClient_Click(object sender, EventArgs e)
        {
            try
            {
                int    index  = dataGridViewClients.CurrentRow.Index;
                Client client = clientVM.Clients[index];
                clientVM.SetDisplayClient(client);
                ClientEditDialog dialog = new ClientEditDialog(false);
                dialog.Text     = "Edit Client Information";
                dialog.ClientVM = clientVM;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    Client dialogUpdatedClient = dialog.ClientVM.GetDisplayClient();
                    clientVM.Clients[index] = dialogUpdatedClient;
                    clientVM.Clients.ResetItem(index);
                    refreshClientLabels();
                }

                dialog.Dispose();
            }

            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message, "DB Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Processing Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }