public void RegistroDePersona() { Uc = new UsuarioCollection(); string rut = "11111111-1"; string nombre = "Manuel"; string apepa = "Rojas"; string apema = "Rojas"; string contacto = "9638932"; DateTime fecha = new DateTime(1996, 6, 1); string direccion = "Antonio Varas 669"; int id_usuario = 6; var registro = Uc.InsertaDatos(rut, nombre, apepa, apema, contacto, fecha, direccion, id_usuario); Assert.Pass(); }
//Boton para realizar la accion de ingreso datos de Usuario. private void BtnRegistrar_Click(object sender, RoutedEventArgs e) { try { DateTime Hoy = DateTime.Now.Date; if (string.IsNullOrEmpty(txtRut.Text) || txtRut.Text.Length <= 8 && txtRut.Text.Length >= 11) { MessageBox.Show("Rut no debe estar vacío y debe que tener el siguente formato 12345678-9."); } else if (ValidaRut(txtRut.Text) == false) { MessageBox.Show("Formato de Rut inválido (12345678-9)."); } else if (!(Regex.IsMatch(txtNombre.Text, "^[a-zA-Z]")) || string.IsNullOrEmpty(txtNombre.Text)) { MessageBox.Show("Campo nombre no debe estar vacío."); } else if (txtNombre.Text.Length <= 2 && txtNombre.Text.Length >= 101) { MessageBox.Show("Campo nombre debe estar entre 3 a 100 carácteres."); } else if (!(Regex.IsMatch(txtApellidoPa.Text, "^[a-zA-Z]")) || string.IsNullOrEmpty(txtApellidoPa.Text)) { MessageBox.Show("Campo apellido paterno no debe estar vacío."); } else if (txtApellidoPa.Text.Length <= 2 && txtApellidoMa.Text.Length >= 101) { MessageBox.Show("Campo apellido paterno debe estar entre 3 a 100 carácteres."); } else if (!(Regex.IsMatch(txtApellidoMa.Text, "^[a-zA-Z]")) || string.IsNullOrEmpty(txtApellidoMa.Text)) { MessageBox.Show("Campo apellido materno no debe estar vacío."); } else if (txtApellidoMa.Text.Length <= 2 && txtApellidoMa.Text.Length >= 101) { MessageBox.Show("Campo apellido materno debe estar entre 3 a 100 carácteres."); } else if (string.IsNullOrEmpty(txtFono.Text) || txtFono.Text.Length <= 8 && txtFono.Text.Length >= 10) { MessageBox.Show("Campo Fono no debe estar vacío y debe tener 9 dígitos."); } else if (Regex.IsMatch(txtFono.Text, "^[a-zA-Z]")) { MessageBox.Show("Campo Fono no debe letras."); } else if (cldFechaNac.SelectedDate == null) { MessageBox.Show("Debe selecionar una fecha."); } else if (MayoriaEdad(cldFechaNac.SelectedDate.Value) == false) { MessageBox.Show("Debe ser mayor de edad"); } else if (string.IsNullOrEmpty(txtDireccion.Text) || txtDireccion.Text.Length < 5 && txtDireccion.Text.Length > 100) { MessageBox.Show("Dirección no debe estar vacío y tiene que estar entre 5 a 100 carácteres."); } else { string correo = Application.Current.Resources["appCorreo"].ToString(); us = new UsuarioCollection(); var dato_persona = us.ValidaExistencia(correo); int id_usuario = int.Parse(dato_persona.Rows[0]["ID_USUARIO"].ToString()); string rut = txtRut.Text; string nombre = txtNombre.Text; string apePa = txtApellidoPa.Text; string apeMa = txtApellidoMa.Text; string contacto = txtFono.Text; DateTime fecha = cldFechaNac.SelectedDate.Value; string direccion = txtDireccion.Text; var insercion = us.InsertaDatos(rut, nombre, apePa, apeMa, contacto, fecha, direccion, id_usuario); if (insercion == true) { this.Close(); } else { lblmensaje.Content = "Error de inserción."; } } } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error, contacte al administrador: " + ex.Message, "Excepción detectada", MessageBoxButton.OK, MessageBoxImage.Warning); } }