public async Task <IActionResult> Edit(int id, [Bind("IdEstancia,Nombre,Estado")] Estancia estancia)
        {
            if (id != estancia.IdEstancia)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(estancia);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EstanciaExists(estancia.IdEstancia))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(estancia));
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Duracion,Foto,AnfitrionId")] Estancia estancia)
        {
            if (id != estancia.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(estancia);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EstanciaExists(estancia.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AnfitrionId"] = new SelectList(_context.Anfitriones, "Id", "Pueblo", estancia.AnfitrionId);
            return(View(estancia));
        }
Example #3
0
        public static List <Ubicacion> generarListaUbicaciones(DataSet ds)
        {
            if (ds.Tables[0].TableName == "Excepcion")
            {
                throw new ApplicationException((string)ds.Tables[0].Rows[0][0]);
            }
            else
            {
                List <Ubicacion> r = new List <Ubicacion>();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    string apellido2 = string.Empty;
                    if (!(dr["apellido2"] is System.DBNull))
                    {
                        apellido2 = (string)dr["apellido2"];
                    }
                    Persona p = new Persona((string)dr["nif"], (string)dr["apellido1"], apellido2, (string)dr["nombre"],
                                            (bool)dr["espas"], (bool)dr["espdi"], (bool)dr["espdicargo"], (bool)dr["esbecario"], (bool)dr["esexterno"]);

                    Estancia e = new Estancia((string)dr["codigo"]);
                    e.Geometria = (MultiPolygon)SharpMap.Geometries.MultiPolygon.GeomFromText((string)dr["wkt"]);
                    Zona z = new Zona((string)dr["codzona"]);
                    z.Denominacion = (string)dr["denozona"];
                    Edificio ed = new Edificio(z, (string)dr["codedificio"]);
                    ed.Denominacion = (string)dr["denoedificio"];

                    PlantaEdificio pe = new PlantaEdificio(ed, (EnumPlantas)System.Enum.Parse(typeof(EnumPlantas), (string)dr["enumplanta"]));
                    pe.Denominacion  = (string)dr["denoplanta"];
                    e.PlantaEdificio = pe;
                    ActividadSIGUA a = new ActividadSIGUA((short)dr["actividad"]);
                    a.Denominacion = (string)dr["denoActividad"];
                    a.GrupoPropio  = new GrupoPropio((string)dr["denogrupo"]);
                    a.GrupoCRUE    = new GrupoCRUE((string)dr["denocrue"]);
                    a.GrupoUXXI    = new GrupoUXXI((string)dr["denou21"]);
                    DepartamentoSIGUA depsigua = new DepartamentoSIGUA((string)dr["coddpto"]);
                    depsigua.Denominacion   = (string)dr["denodpto"];
                    depsigua.EsCentro       = (bool)dr["es_centro"];
                    depsigua.EsDepartamento = (bool)dr["es_dpto"];
                    depsigua.EsUnidad       = (bool)dr["es_unidad"];
                    e.Actividad             = a;
                    e.Adscripcion           = depsigua;
                    if (dr["denoestancia"].GetType() == typeof(System.DBNull))
                    {
                        e.Denominacion = string.Empty;
                    }
                    else
                    {
                        e.Denominacion = (string)dr["denoestancia"];
                    }

                    r.Add(new Ubicacion(p, e));
                }
                return(r);
            }
        }
        public async Task <IActionResult> Create([Bind("IdEstancia,Nombre,Estado")] Estancia estancia)
        {
            if (ModelState.IsValid)
            {
                _context.Add(estancia);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(estancia));
        }
Example #5
0
        public static List <Estancia> generarListaEstancias(DataSet ds)
        {
            if (ds.Tables[0].TableName == "Excepcion")
            {
                throw new ApplicationException((string)ds.Tables[0].Rows[0][0]);
            }
            else
            {
                List <Estancia> r = new List <Estancia>();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    Estancia e = new Estancia((string)dr["codigo"]);
                    try {
                        e.Geometria = (MultiPolygon)SharpMap.Geometries.MultiPolygon.GeomFromText((string)dr["wkt"]);
                    } catch (Exception ex) {
                        new SIGUANETDesktopException(ExceptionCategory.DATAInvalidGeometry,
                                                     "ObjectFactory.generarListaEstancias", ex, e.Codigo);
                        continue;
                    }

                    Zona z = new Zona((string)dr["codzona"]);
                    z.Denominacion = (string)dr["denozona"];
                    Edificio ed = new Edificio(z, (string)dr["codedificio"]);
                    ed.Denominacion = (string)dr["denoedificio"];

                    PlantaEdificio pe = new PlantaEdificio(ed, (EnumPlantas)System.Enum.Parse(typeof(EnumPlantas), (string)dr["enumplanta"]));
                    pe.Denominacion  = (string)dr["denoplanta"];
                    e.PlantaEdificio = pe;
                    ActividadSIGUA a = new ActividadSIGUA((short)dr["actividad"]);
                    a.Denominacion = (string)dr["denoActividad"];
                    a.GrupoPropio  = new GrupoPropio((string)dr["denogrupo"]);
                    a.GrupoCRUE    = new GrupoCRUE((string)dr["denocrue"]);
                    a.GrupoUXXI    = new GrupoUXXI((string)dr["denou21"]);
                    DepartamentoSIGUA depsigua = new DepartamentoSIGUA((string)dr["coddpto"]);
                    depsigua.Denominacion   = (string)dr["denodpto"];
                    depsigua.EsCentro       = (bool)dr["es_centro"];
                    depsigua.EsDepartamento = (bool)dr["es_dpto"];
                    depsigua.EsUnidad       = (bool)dr["es_unidad"];
                    e.Actividad             = a;
                    e.Adscripcion           = depsigua;
                    if (dr["denoestancia"].GetType() == typeof(System.DBNull))
                    {
                        e.Denominacion = string.Empty;
                    }
                    else
                    {
                        e.Denominacion = (string)dr["denoestancia"];
                    }

                    r.Add(e);
                }
                return(r);
            }
        }
Example #6
0
        private static VectorLayer CrearCapaSelEst(VectorLayer capaBase, Estancia est)
        {
            //Layer de la estancia seleccionada en el arbol de estancias
            VectorLayer capaSelEst = new SharpMap.Layers.VectorLayer(est.Codigo);

            SharpMap.Data.Providers.GeometryProvider provGeo = new SharpMap.Data.Providers.GeometryProvider(est.Geometria);
            provGeo.SRID          = capaBase.SRID;
            capaSelEst.DataSource = provGeo;
            SimbLaySelEst s = new SimbLaySelEst();

            capaSelEst.Enabled = s.visible;
            capaSelEst.Style   = ObtenerEstilo(TipoPaleta.predeterminada, s);
            AsignarEntradaLeyendaSeleccion(capaSelEst.LayerName, capaSelEst, s.titulo);
            return(capaSelEst);
        }
Example #7
0
        public async Task <IActionResult> Create([Bind("Id,Duracion,Foto")] Estancia estancia)
        {
            AppUser user = await _userManager.FindByEmailAsync(User.Identity.Name);

            Anfitrion anfitrion = await _context.Anfitriones.FirstOrDefaultAsync(x => x.UserId == user.Id);

            estancia.Anfitrion   = anfitrion;
            estancia.AnfitrionId = anfitrion.Id;
            if (ModelState.IsValid)
            {
                _context.Add(estancia);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(estancia));
        }
Example #8
0
 void eConsulta(SharpMap.Data.FeatureDataTable resultado)
 {
     try
     {
         if ((resultado as DataTable).Rows.Count > 0)
         {
             SharpMap.Data.FeatureDataRow fdr = TopoUtils.LocatePolygon2(this.ultimaPosicion, resultado);
             Estancia est = AdminMapas.RefrescaCapaInfoEst(this.Mapa, fdr[1].ToString());
             this.actualizarPropiedades(est);
             this.tabControl1.SelectedTab = tpInfo;
             this.miVMapa.Refresh();
         }
     }
     catch (Exception error)
     {
         System.Windows.Forms.MessageBox.Show(error.Message, "Error");
     }
 }
Example #9
0
        private void actualizarPropiedades(Estancia est)
        {
            this._lviCodEstancia.SubItems[1].Text  = est.Codigo;
            this._lviDenoEstancia.SubItems[1].Text = est.Denominacion;
            this._lviSuperficie.SubItems[1].Text   = string.Format("{0} m²", est.Geometria.Area.ToString("F"));

            this._lviCodZona.SubItems[1].Text = est.PlantaEdificio.Edificio.Zona.Codigo;
            this._lviNomZona.SubItems[1].Text = est.PlantaEdificio.Edificio.Zona.Denominacion;

            this._lviCodEdificio.SubItems[1].Text = est.PlantaEdificio.Edificio.Codigo;
            this._lviNomEdificio.SubItems[1].Text = est.PlantaEdificio.Edificio.Denominacion;

            this._lviPlanta.SubItems[1].Text = est.PlantaEdificio.Planta.ToString();

            this._lviCodDpto.SubItems[1].Text = est.Adscripcion.Codigo;
            this._lviNomDpto.SubItems[1].Text = est.Adscripcion.Denominacion;

            this._lviCodActividad.SubItems[1].Text    = est.Actividad.Codigo.ToString();
            this._lviDescriActividad.SubItems[1].Text = est.Actividad.Denominacion;

            this._lviNumOcupantes.SubItems[1].Text = est.NumPersonas().ToString();

            if (this._lvgPersonal.Items.Count > 0)
            {
                for (int i = this.listInfo.Items.Count - 1; i >= 0; i--)
                {
                    if (this.listInfo.Items[i].Group == this._lvgPersonal)
                    {
                        this.listInfo.Items.RemoveAt(i);
                    }
                }
            }

            foreach (Persona p in est.ObtenerPersonas())
            {
                ListViewItem item = new ListViewItem(new string[2] {
                    string.Empty, p.ToString()
                });
                this.listInfo.Items.Add(item);
                item.Group = this._lvgPersonal;
            }
        }
Example #10
0
 public static void guardar(Estancia estancia)
 {
     try
     {
         using (SqlCommand comando = new SqlCommand())
         {
             comando.Connection  = PrincipalUI.Cnxion;
             comando.CommandType = CommandType.StoredProcedure;
             comando.CommandText = Sentencias.CREAR_ESTANCIA;
             comando.Parameters.Add(new SqlParameter("@pAuditoria", SqlDbType.Int)).Value          = estancia.auditoria;
             comando.Parameters.Add(new SqlParameter("@pIdAtencion", SqlDbType.Int)).Value         = estancia.idAtencion;
             comando.Parameters.Add(new SqlParameter("@pIdUsuarioOrigen", SqlDbType.Int)).Value    = Sesion.IdUsuario;
             comando.Parameters.Add(new SqlParameter("@pTblEstancia", SqlDbType.Structured)).Value = estancia.dtCambiosEstancia;
             comando.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #11
0
        private static TreeNode obtenerNodoCampus(Estancia e, TreeNode nodoUA)
        {
            TreeNode nodoCampus = new TreeNode();
            bool     existe     = false;

            foreach (TreeNode n in nodoUA.Nodes)
            {
                Zona candidato = (Zona)n.Tag;
                if (candidato.Codigo == e.PlantaEdificio.Edificio.Zona.Codigo)
                {
                    nodoCampus = n;
                    existe     = true;
                }
            }
            if (!existe)
            {
                nodoCampus.Text = e.PlantaEdificio.Edificio.Zona.Denominacion;
                nodoCampus.Tag  = e.PlantaEdificio.Edificio.Zona;
                nodoUA.Nodes.Add(nodoCampus);
            }
            return(nodoCampus);
        }
Example #12
0
        public static TreeNode obtenerNodoPlanta(Estancia e, TreeNode nodoUA)
        {
            TreeNode nodoEdificio = obtenerNodoEdificio(e, nodoUA);
            TreeNode nodoPlanta   = new TreeNode();
            bool     existe       = false;

            foreach (TreeNode n in nodoEdificio.Nodes)
            {
                PlantaEdificio candidato = (PlantaEdificio)n.Tag;
                if (candidato.Codigo == e.PlantaEdificio.Codigo)
                {
                    nodoPlanta = n;
                    existe     = true;
                }
            }
            if (!existe)
            {
                nodoPlanta.Text = e.PlantaEdificio.Planta.ToString();
                nodoPlanta.Tag  = e.PlantaEdificio;
                nodoEdificio.Nodes.Add(nodoPlanta);
            }
            return(nodoPlanta);
        }
Example #13
0
        private static TreeNode obtenerNodoEdificio(Estancia e, TreeNode nodoUA)
        {
            TreeNode nodoCampus   = obtenerNodoCampus(e, nodoUA);
            TreeNode nodoEdificio = new TreeNode();
            bool     existe       = false;

            foreach (TreeNode n in nodoCampus.Nodes)
            {
                Edificio candidato = (Edificio)n.Tag;
                if (candidato.Codigo == e.PlantaEdificio.Edificio.Codigo)
                {
                    nodoEdificio = n;
                    existe       = true;
                }
            }
            if (!existe)
            {
                nodoEdificio.Text = string.Format("{0}-{1}", e.PlantaEdificio.Edificio.Codigo, e.PlantaEdificio.Edificio.Denominacion);
                nodoEdificio.Tag  = e.PlantaEdificio.Edificio;
                nodoCampus.Nodes.Add(nodoEdificio);
            }
            return(nodoEdificio);
        }
Example #14
0
 public Ubicacion(Persona persona, Estancia estancia)
 {
     _persona  = persona;
     _estancia = estancia;
 }
Example #15
0
        public static void CrearMapa(Graphics canvas, Map mapa, IUnidadGeoEstadistica uge, List <Geometry> lp, Estancia est, TipoMapa tipo, TipoPaleta paleta)
        {
            _paleta = paleta;
            switch (tipo)
            {
            case TipoMapa.Predeterminado:
                CrearMapaPorDefecto(canvas, mapa, uge, lp, est);
                break;

            case TipoMapa.TemaUso:
                CrearMapaTematicoUsos(canvas, mapa, uge, lp, est);
                break;

            case TipoMapa.TemaAdscripcion:
                CrearMapaTematicoAdscripcion(canvas, mapa, uge, lp, est);
                break;

            default:
                break;
            }
        }
Example #16
0
 public static void CrearMapa(Graphics canvas, Map mapa, IUnidadGeoEstadistica uge, List <Geometry> lp, Estancia est)
 {
     CrearMapaPorDefecto(canvas, mapa, uge, lp, est);
 }
Example #17
0
        private static void CrearMapaTematicoAdscripcion(Graphics canvas, Map mapa, IUnidadGeoEstadistica uge, List <Geometry> lp, Estancia est)
        {
            _leyenda.Canvas = canvas;
            _leyenda.Tipo   = TipoMapa.TemaAdscripcion;
            _leyenda.Reiniciar();
            mapa.Layers.Clear();
            VectorLayer capaBase = CrearCapaTemaAdscripcion(uge);

            if (capaBase != null)
            {
                mapa.Layers.Add(capaBase);
                mapa.Layers.Add(CrearCapaEdificioMuro(uge));
                mapa.Layers.Add(CrearCapaSelPlanta(capaBase, lp));
                if (est != null)
                {
                    mapa.Layers.Add(CrearCapaSelEst(capaBase, est));
                }
                else
                {
                    _leyenda.EntradaSeleccion = null;
                }
                mapa.Layers.Add(CrearCapaInfoEst(capaBase));
                LabelLayer capaEtiq = CrearCapaEtiq(CrearCapaCentroidesEdificio(uge));
                if (capaEtiq != null)
                {
                    mapa.Layers.Add(capaEtiq);
                }
                mapa.ZoomToExtents();
            }
        }
Example #18
0
        private void RefrescarMapa(TreeNode nodo)
        {
            //Comprueba el nodo que está seleccionado
            if (nodo.Tag.GetType() == typeof(BaseOrg))
            {
                this.limpiarPropiedades();
                this.tpLeyenda.Enabled = false;
                this.panelLeyenda.Refresh();
                this.tpPDF.Enabled = false;
                this.Preview.SetRenderEvent(null);
                this.tsbPDFGuardar.Enabled  = false;
                this.tsbPDFImprimir.Enabled = false;
                this.miVMapa.Visible        = false;
                this.toolStrip1.Enabled     = false;
            }

            if (nodo.Tag.GetType() == typeof(Zona))
            {
                this.limpiarPropiedades();
                this.tpLeyenda.Enabled = false;
                this.panelLeyenda.Refresh();
                this.tpPDF.Enabled = false;
                this.Preview.SetRenderEvent(null);
                this.tsbPDFGuardar.Enabled  = false;
                this.tsbPDFImprimir.Enabled = false;
                this.miVMapa.Visible        = false;
                this.toolStrip1.Enabled     = false;
            }

            if (nodo.Tag.GetType() == typeof(Edificio))
            {
                this.limpiarPropiedades();
                this.tpLeyenda.Enabled = false;
                this.panelLeyenda.Refresh();
                this.tpPDF.Enabled = false;
                this.Preview.SetRenderEvent(null);
                this.tsbPDFGuardar.Enabled  = false;
                this.tsbPDFImprimir.Enabled = false;
                this.miVMapa.Visible        = false;
                this.toolStrip1.Enabled     = false;
            }

            // Para la planta del edificio
            if (nodo.Tag.GetType() == typeof(PlantaEdificio))
            {
                PlantaEdificio pe = (PlantaEdificio)nodo.Tag;
                this.limpiarPropiedades();
                this.tpLeyenda.Enabled = true;
                this.tpPDF.Enabled     = true;
                this.Preview.SetRenderEvent(null);
                this.tsbPDFGuardar.Enabled  = false;
                this.tsbPDFImprimir.Enabled = false;

                this.miVMapa.Visible = true;
                // Crear una lista de geometria a partir de los nodos hijos de PlantaEdificio
                List <Geometry> lp = new List <Geometry>();

                foreach (TreeNode n in nodo.Nodes)
                {
                    Estancia estHija;
                    if (n.Tag is Estancia)
                    {
                        estHija = (Estancia)n.Tag;
                        lp.Add(estHija.Geometria);
                    }
                    else if (n.Tag is Ubicacion)
                    {
                        estHija = (n.Tag as Ubicacion).Estancia;
                        lp.Add(estHija.Geometria);
                    }
                }

                AdminMapas.CrearMapa(this.panelLeyenda.CreateGraphics(), this.Mapa,
                                     (IUnidadGeoEstadistica)pe, lp, null,
                                     this._tipoMapa, this._tipoPaleta);

                this.miVMapa.Map = this.Mapa;
            }

            // Si es un nodo de estancia
            if (nodo.Tag.GetType() == typeof(Estancia))
            {
                Estancia est = (Estancia)nodo.Tag;
                this.actualizarPropiedades(est);
                this.tpLeyenda.Enabled = true;
                this.tpPDF.Enabled     = true;
                this.Preview.SetRenderEvent(null);
                this.tsbPDFGuardar.Enabled  = false;
                this.tsbPDFImprimir.Enabled = false;
                this.miVMapa.Visible        = true;
                // Selección de elementos de la consulta
                List <Geometry> lp = new List <Geometry>();
                foreach (TreeNode n in nodo.Parent.Nodes)
                {
                    Estancia estHija = (Estancia)n.Tag;
                    lp.Add(estHija.Geometria);
                }

                AdminMapas.CrearMapa(this.panelLeyenda.CreateGraphics(), this.Mapa,
                                     (IUnidadGeoEstadistica)est.PlantaEdificio, lp, est,
                                     this._tipoMapa, this._tipoPaleta);

                this.miVMapa.Map = this.Mapa;
            }

            // Si es un nodo de ubicacion
            if (nodo.Tag.GetType() == typeof(Ubicacion))
            {
                Estancia est = (nodo.Tag as Ubicacion).Estancia;
                this.actualizarPropiedades(est);
                this.tpLeyenda.Enabled = true;
                this.miVMapa.Visible   = true;
                // Selección de elementos de la consulta
                List <Geometry> lp = new List <Geometry>();
                foreach (TreeNode n in nodo.Parent.Nodes)
                {
                    Estancia estHija = (n.Tag as Ubicacion).Estancia;
                    lp.Add(estHija.Geometria);
                }

                AdminMapas.CrearMapa(this.panelLeyenda.CreateGraphics(), this.Mapa,
                                     (IUnidadGeoEstadistica)est.PlantaEdificio, lp, est,
                                     this._tipoMapa, this._tipoPaleta);

                this.miVMapa.Map = this.Mapa;
            }
        }
Example #19
0
 public GanadoBuilder AsignarEstanciaOrigen(Estancia estancia)
 {
     _ganado.IdEstanciaOrigen = estancia.IdEstancia;
     return(this);
 }