private void BtnAgregar_Click(object sender, EventArgs e)
        {
            Editorial editor = new Editorial();

            editor.Nombre    = txtNombre.Text;
            editor.Direccion = txtDireccion.Text;
            editor.Telefono  = Convert.ToInt32(txtTelefono.Text);
            editor.Email     = txtEmail.Text;


            Editorial.AgregarEditorial(editor);
            ActualizarLista();
            Limpiar();
        }
Esempio n. 2
0
        private void but_agregar_editorial_Click(object sender, EventArgs e)
        {
            if (this.verificar_datos_editorial())
            {
                if (tex_direccion.Text.Length == 0)
                {
                    tex_direccion.Text = "";
                }

                StringBuilder errorMessages = new StringBuilder();
                Editorial     edi           = new Editorial();

                edi.v_nombre_editorial    = tex_nombre_editorial.Text;
                edi.v_Dpais               = com_pais.SelectedItem.ToString();
                edi.v_direccion_editorial = tex_direccion.Text;
                edi.v_usuario_i           = this.usuario;

                try
                {
                    if (edi.AgregarEditorial(edi) != 0)
                    {
                        MessageBox.Show("Editorial creada correctamente" + "\n" + "Nombre: " + edi.v_nombre_editorial,
                                        "Agregar Editorial",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                        this.inicializarDatos();
                    }
                }
                catch (SqlException ex)
                {
                    for (int i = 0; i < ex.Errors.Count; i++)
                    {
                        errorMessages.Append("Index #" + i + "\n" +
                                             "Message: " + ex.Errors[i].Message + "\n" +
                                             "LineNumber: " + ex.Errors[i].LineNumber + "\n" +
                                             "Source: " + ex.Errors[i].Source + "\n" +
                                             "Procedure: " + ex.Errors[i].Procedure + "\n");
                    }
                    Console.WriteLine(errorMessages.ToString());
                    this.inicializarDatos();
                    MessageBox.Show(ex.Errors[0].Message.ToString(),
                                    "Agregar Editorial",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                }
            }
        }
 private void btnAgregar2_Click(object sender, EventArgs e)
 {
     try
     {
         if (ValidarCampos())
         {
             Editorial edi = new Editorial();
             edi.nombre    = txtNombre.Text;
             edi.direccion = txtDireccion.Text;
             edi.telefono  = txtTelefono.Text;
             Editorial.AgregarEditorial(edi);
             LimpiarFormulario();
             ActualizarListaEditoriales();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }