public void escribir_buscar() { List<Persona> lista = new NPersona().N_listar_persona(); var filtro = from Persona in lista where Persona.Nombre.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) || Persona.Apellidos.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) || Persona.Sexo.ToUpper().Contains(text_buscar.Text.ToUpper()) || Persona.Dni.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) || Persona.Direccion.ToUpper().Contains(text_buscar.Text.ToUpper()) || Persona.Edad.ToUpper().Contains(text_buscar.Text.ToUpper()) || Persona.Tel_mov.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) || Persona.Tel_claro.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) || Persona.Tel_nex.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) || Persona.Rpm.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) || Persona.Email.ToUpper().Contains(text_buscar.Text.ToUpper()) || Persona.Facebook.ToUpper().Contains(text_buscar.Text.ToUpper()) || Persona.Hor_disp.ToUpper().Contains(text_buscar.Text.ToUpper()) || Persona.Tel_casa.ToString().ToUpper().Contains(text_buscar.Text.ToUpper()) select Persona; lista = filtro.ToList<Persona>(); this.grilla_adoptantes.Rows.Clear(); for (int i = 0; i < lista.Count; i++) { int reglon = this.grilla_adoptantes.Rows.Add(); this.grilla_adoptantes.Rows[reglon].Cells["ID_Persona"].Value = lista[i].Id.ToString(); this.grilla_adoptantes.Rows[reglon].Cells["Nombre"].Value = lista[i].Nombre.ToString(); this.grilla_adoptantes.Rows[reglon].Cells["Apellidos"].Value = lista[i].Apellidos.ToString(); this.grilla_adoptantes.Rows[reglon].Cells["Dni"].Value = lista[i].Dni.ToString(); this.grilla_adoptantes.Rows[reglon].Cells["Direccion"].Value = lista[i].Direccion.ToString(); this.grilla_adoptantes.Rows[reglon].Cells["Sexo"].Value = lista[i].Sexo.ToString(); this.grilla_adoptantes.Rows[reglon].Cells["Edad"].Value = lista[i].Edad.ToString(); this.grilla_adoptantes.Rows[reglon].Cells["Email"].Value = lista[i].Email.ToString(); this.grilla_adoptantes.Rows[reglon].Cells["Facebook"].Value = lista[i].Facebook.ToString(); this.grilla_adoptantes.Rows[reglon].Cells["Rpm"].Value = lista[i].Rpm.ToString(); if ((lista[i].Tel_mov == null) || (lista[i].Tel_mov == 0)) { this.grilla_adoptantes.Rows[reglon].Cells["Movistar"].Value = ""; } else { this.grilla_adoptantes.Rows[reglon].Cells["Movistar"].Value = lista[i].Tel_mov.ToString(); } if ((lista[i].Tel_claro == null) || (lista[i].Tel_claro == 0)) { this.grilla_adoptantes.Rows[reglon].Cells["Claro"].Value = ""; } else { this.grilla_adoptantes.Rows[reglon].Cells["Claro"].Value = lista[i].Tel_claro.ToString(); } this.grilla_adoptantes.Rows[reglon].Cells["Nextel"].Value = lista[i].Tel_nex.ToString(); if ((lista[i].Tel_casa == 0) || (lista[i].Tel_casa == null)) { this.grilla_adoptantes.Rows[reglon].Cells["Telefono"].Value = ""; } else { this.grilla_adoptantes.Rows[reglon].Cells["Telefono"].Value = lista[i].Tel_casa.ToString(); } this.grilla_adoptantes.Rows[reglon].Cells["Horario_disponible"].Value = lista[i].Hor_disp.ToString(); } }
private void btn_registrar_Click(object sender, EventArgs e) { Boolean band1 = false, band2 = false, band3 = false; String mensaje = "Por Favor Complete los campos obligatorios : \n"; String nombre = ""; String apellidos = ""; String dni = ""; String direccion = ""; String sexo = ""; String edad = ""; int movistar = 0; int claro = 0; int telefono = 0; String nextel = ""; String rpm = ""; String email = ""; String facebook = ""; String horario = ""; if (!String.IsNullOrEmpty(text_nombre.Text)) { nombre = text_nombre.Text; } else { mensaje = mensaje + "\n - Casilla de Nombre "; band1 = true; } if (!String.IsNullOrEmpty(text_apellido.Text)) { apellidos = text_apellido.Text; } else { mensaje = mensaje + "\n - Casilla de Apellidos "; band2 = true; } if (!String.IsNullOrEmpty(text_dni.Text)) { dni = text_dni.Text; } else { mensaje = mensaje + "\n - Casilla de Dni "; band3 = true; } if (!String.IsNullOrEmpty(text_direccion.Text)) { direccion = text_direccion.Text; } if (radio_masculino.Checked == true) { sexo = "Masculino"; } else { sexo = "Femenino"; } if (!String.IsNullOrEmpty(text_edad.Text)) { edad = text_edad.Text; } if (!String.IsNullOrEmpty(text_email.Text)) { email = text_email.Text; } if (!String.IsNullOrEmpty(text_facebook.Text)) { facebook = text_facebook.Text; } if (!String.IsNullOrEmpty(text_rpm.Text)) { rpm = text_rpm.Text; } if (!String.IsNullOrEmpty(text_movistar.Text)) { movistar = int.Parse(text_movistar.Text); } if (!String.IsNullOrEmpty(text_claro.Text)) { claro = int.Parse(text_claro.Text); } if (!String.IsNullOrEmpty(text_nextel.Text)) { nextel = text_nextel.Text; } if (!String.IsNullOrEmpty(text_telefono.Text)) { telefono = int.Parse(text_telefono.Text); } if (!String.IsNullOrEmpty(text_horario.Text)) { horario = text_horario.Text; } if (band1 == true || band2 == true || band3 == true) { MessageBox.Show(mensaje); } else { int confir1 = new NPersona().N_registrar_persona(nombre, apellidos, dni, direccion, sexo, edad, email, facebook, rpm, movistar, claro, nextel, telefono, horario); if (confir1 == 0) { MessageBox.Show("Error Al Registrar Por favor intente nuevamente"); } else { MessageBox.Show("Registrado Correctamente"); adopcion.actualizar_lista_adoptante(); this.Close(); } } }