예제 #1
0
 /// <summary>
 /// Event Handler of the button Save.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrWhiteSpace(txtNombre.Text) && !String.IsNullOrWhiteSpace(txtApellido.Text))
     {
         txtNombre.Text   = txtNombre.Text.Trim();
         txtApellido.Text = txtApellido.Text.Trim();
         person.Apellido  = txtApellido.Text;
         person.Nombre    = txtNombre.Text;
         PersonaDAO.Guardar(person);
         UpdateListBox();
     }
 }
예제 #2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            string nombre;
            string apellido;

            PersonaDAO personaDAO;
            Persona    auxPersona;

            personaDAO = new PersonaDAO();

            nombre   = txtNombre.Text;
            apellido = txtApellido.Text;

            auxPersona = new Persona(nombre, apellido);

            personaDAO.Guardar(auxPersona);
        }
예제 #3
0
 private void btn_Guardar_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(txt_Name.Text) || string.IsNullOrEmpty(txt_LastName.Text))
         {
             throw new Exception("El o los campos de Nombre y Apellido no pueden quedar vacios.");
         }
         else
         {
             Persona persona = new Persona(txt_Name.Text, txt_LastName.Text, checkBox.Checked);
             if (PersonaDAO.Guardar(persona))
             {
                 MessageBox.Show("Se creo la persona con éxito", "Exito", MessageBoxButtons.OK);
                 ActualizarDataGrid();
             }
         }
         LimpiarTxtBox();
     }  catch (Exception ex) {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK);
     }
 }
예제 #4
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (txtNombre.Text.Length > 0 && txtApellido.Text.Length > 0)
     {
         Persona persona = new Persona(txtNombre.Text, txtApellido.Text);
         try
         {
             if (PersonaDAO.Guardar(persona))
             {
                 MessageBox.Show("Guardado correctamente!!");
                 btnLeer_Click(sender, e);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("ERROR: " + ex.ToString());
         }
     }
     else
     {
         MessageBox.Show("Para agregar las casillas de nombre y apellido no pueden estar vacías.");
     }
 }
예제 #5
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     p1 = new Persona(txtNombre.Text, txtApellido.Text);
     dao.Guardar(p1);
 }