Beispiel #1
0
 private async void AgregarCliente_click(object sender, EventArgs e)
 {
     using (var fromAgregar = new frmAgregarClientes(new Cliente()))
     {
         if (fromAgregar.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 clienteBindingSource.Add(fromAgregar.ClienteCurrent);
                 db.Clientes.Add(fromAgregar.ClienteCurrent);
                 clienteBindingSource.EndEdit();
                 await db.SaveChangesAsync();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Beispiel #2
0
        private void btnModificarCliente_Click(object sender, EventArgs e)
        {
            var obj = clienteBindingSource.Current as Cliente;

            if (obj != null)
            {
                using (var fromAgregar = new frmAgregarClientes(obj))
                {
                    if (fromAgregar.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            clienteBindingSource.EndEdit();
                            db.SaveChanges();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }