Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsBiblioteca
  12. { //Partial: indica que la clase (en este caso Form1) esta divida en mas de un archivo
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. btnCerrar.Click += Botones;
  19. btnAceptar.Click += Botones;
  20. }
  21.  
  22. private void Botones(object sender, EventArgs e)
  23. {
  24. //Casteo, similar a ConvertTo
  25. Button boton = (Button)sender;
  26. switch (boton.Name)
  27. {
  28. case "btnCerrar":
  29. Close();
  30. break;
  31. case "btnAceptar":
  32. Entidades.Autor objEntidad = new Entidades.Autor();
  33. Logica.Autor objLogica = new Logica.Autor();
  34. objEntidad.Apellido = txtApellido.Text;
  35. objEntidad.Nombre = txtNombre.Text;
  36. objEntidad.FechaNacimiento = dtpFechaNacimiento.Value;
  37. objEntidad.Nacionalidad = cboNacionalidad.SelectedItem.ToString();
  38. objLogica.Agregar(objEntidad);
  39.  
  40. MessageBox.Show("Autor agregado a la base de datos");
  41. break;
  42.  
  43. }
  44.  
  45. }
  46.  
  47.  
  48.  
  49.  
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement