public void buscar(AlumnoBO oAlumno) { //AlumnoBO oAlumnoBO = new AlumnoBO(); AlumnoCtrl oAlumnoCtrl = new AlumnoCtrl(); DataTable dt = oAlumnoCtrl.devuelveAlumno(oAlumno).Tables[0]; if (dt.Rows.Count != 0) { txtAM.Text = dt.Rows[0]["ApellidoMaterno"].ToString(); txtAP.Text = dt.Rows[0]["ApellidoPaterno"].ToString(); txtDireccion.Text = dt.Rows[0]["Direccion"].ToString(); txtGrado.Text = dt.Rows[0]["Grado"].ToString(); txtGrupo.Text = dt.Rows[0]["Grupo"].ToString(); txtMatricula.Text = dt.Rows[0]["Matricula"].ToString(); txtNombre.Text = dt.Rows[0]["Nombre"].ToString(); txtTelefono.Text = dt.Rows[0]["Telefono"].ToString(); } else { this.Close(); } }
public DataSet devuelveAlumno(object obj) { string cadenaWhere = ""; bool edo = false; AlumnoBO data = (AlumnoBO)obj; cmd = new SQLiteCommand(); dsAlumno = new DataSet(); da = new SQLiteDataAdapter(); con = new Conexion(); cmd.Connection = con.establecerConexion(); con.abrirConexion(); if (data.Matricula > 0) { cadenaWhere = cadenaWhere + " matricula=" + data.Matricula + " and"; edo = true; } if (data.Nombre != null) { cadenaWhere = cadenaWhere + " Nombre='" + data.Nombre.Trim() + "' and"; edo = true; } if (data.Apellidopaterno != null) { cadenaWhere = cadenaWhere + " Apellidopaterno='" + data.Apellidopaterno.Trim() + "' and"; edo = true; } if (data.Apellidomaterno != null) { cadenaWhere = cadenaWhere + " Apellidomaterno='" + data.Apellidomaterno.Trim() + "' and"; edo = true; } if (data.Direccion != null) { cadenaWhere = " Direccion='" + data.Direccion.Trim() + "' and"; edo = true; } if (data.Telefono != null) { cadenaWhere = " Telefono='" + data.Telefono.Trim() + "' and"; edo = true; } if (data.Grado > 0) { cadenaWhere = cadenaWhere + " Grado=" + data.Grado + " and"; edo = true; } if (data.Grupo != null) { cadenaWhere = cadenaWhere + " Grupo='" + data.Grupo.Trim() + "' and"; edo = true; } if (edo == true) { cadenaWhere = " WHERE " + cadenaWhere.Remove(cadenaWhere.Length - 3, 3); } sql = " SELECT * FROM Alumno " + cadenaWhere; cmd.CommandText = sql; DataSet ds = new DataSet(); da.SelectCommand = cmd; da.Fill(dsAlumno); con.cerrarConexion(); return(dsAlumno); }