Exemplo n.º 1
0
        public bool getColegio(DtoColegio trab)
        {
            SqlCommand cmd = new SqlCommand("sp_getColegio", conexion);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@codColegio", trab.codColegio);

            conexion.Open();
            bool hayRegistros;

            SqlDataReader reader = cmd.ExecuteReader();

            hayRegistros = reader.Read();

            if (hayRegistros)
            {
                trab.nombre      = reader[1].ToString();
                trab.direccion   = reader[2].ToString();
                trab.caracter    = reader[3].ToString();
                trab.latitud     = Convert.ToDouble(reader[4].ToString());
                trab.longitud    = Convert.ToDouble(reader[5].ToString());
                trab.estado      = reader[6].ToString();
                trab.codDistrito = int.Parse(reader[7].ToString());
            }

            conexion.Close();
            return(hayRegistros);
        }
Exemplo n.º 2
0
        public void cargarDatosColeyTallerA()
        {
            DtoTallerAperturado tallape   = new DtoTallerAperturado();
            CtrTallerAperturado ctrTallap = new CtrTallerAperturado();

            tallape.codTallerAperturado = int.Parse(Session["t"].ToString());

            ctrTallap.consultarTallerAperturado3(tallape);

            txtNombTallerAperturado.Text = ctrTallap.consultarTallerAperturado2(tallape);
            //-------------------
            DtoColegio cole   = new DtoColegio();
            CtrColegio ctrcol = new CtrColegio();

            cole.codColegio = int.Parse(Session["r"].ToString());

            ctrcol.consultarColegio(cole);

            txtCole.Text      = cole.nombre;
            lblLat2.Text      = cole.latitud.ToString();
            lblLng2.Text      = cole.longitud.ToString();
            idTallerAper.Text = tallape.codTallerAperturado.ToString();
            lbldia.Text       = tallape.dia;
            lblalerta.Text    = tallape.codProfesor.ToString();

            caracteristicasGmap(cole.latitud.ToString(), cole.longitud.ToString());
        }
Exemplo n.º 3
0
        public DataTable evaluarCercanos(DataSet dsProfesores, double km)
        {
            /*KM es el rango de distancias para el que debe buscar*/

            DataTable  dtAux  = dsProfesores.Tables[0].Clone();
            DtoColegio cole   = new DtoColegio();
            CtrColegio ctrcol = new CtrColegio();

            cole.codColegio = int.Parse(Session["r"].ToString());

            ctrcol.consultarColegio(cole);
            txtCole.Text = cole.nombre;
            lblLat2.Text = cole.latitud.ToString();
            lblLng2.Text = cole.longitud.ToString();
            double lat, lng, aux = 50;

            foreach (DataTable thisTable in dsProfesores.Tables)
            {
                foreach (DataRow row in thisTable.Rows) //Para cada fila evalua la distancia
                {
                    lat = Double.Parse(row["latitud"].ToString());
                    lng = Double.Parse(row["longitud"].ToString());
                    double dist = distancia(lat, lng, Double.Parse(cole.latitud.ToString()), Double.Parse(cole.longitud.ToString()));

                    if (row["diasDisponible"].ToString().Contains(lbldia.Text))
                    {
                        if (dist < km)
                        {
                            dtAux.ImportRow(row); //Si la distancia es menor al rango "km" entonces importa la fila a mi tabla auxiliar

                            //Pinta marcador del profesor
                            GLatLng latlng  = new GLatLng(lat, lng);
                            GLatLng latlng2 = new GLatLng(Convert.ToDouble(cole.latitud.ToString()), Convert.ToDouble(cole.longitud.ToString()));

                            GIcon icon = new GIcon();
                            icon.labeledMarkerIconOptions = new LabeledMarkerIconOptions(Color.Gold, Color.White, "P", Color.Green);
                            GMarker     ii     = new GMarker(latlng, icon);
                            GInfoWindow window = new GInfoWindow(ii, "" + row["nombres"]);

                            //Pinta la linea entre profesor y colegio
                            List <GLatLng> puntos = new List <GLatLng>();
                            puntos.Add(latlng);
                            puntos.Add(latlng2);
                            GPolyline linea = new GPolyline(puntos, "FF0000", 2);
                            gmap1.Add(linea);
                            gmap1.Add(ii);
                            if (dist < aux)
                            {
                                //busca la mejor distancia
                                dista.Text   = "La mejor distancia es del profesor " + row["nombres"] + " " + row["apPaterno"] + " con " + dist.ToString() + " km de distancia.";
                                aux          = dist;
                                idProfe.Text = "" + row["codPersona"];
                            }
                            else
                            {
                            }
                        }
                        if (dtAux.Rows.Count == 0)
                        {
                            btnAmpliarRango.Enabled = true;
                        }
                    }
                }
            }

            return(dtAux);
        }
Exemplo n.º 4
0
 public bool consultarColegio(DtoColegio prof)
 {
     return(daoColegio.getColegio(prof));
 }