protected void btnAgregar_Click(object sender, EventArgs e)
        {
            lbElementos.Visible = true;
            grElementos.Visible = true;
            Adapter.AdapterElemento adapter = new Adapter.AdapterElemento();
            EDIFICIO edificio = Controller.ControllerEdificio.buscarIdEdificio(Convert.ToInt64(dplEdificio.SelectedValue));

            adapter._ID_EDIFICIO     = edificio.ID_EDIFICIO;
            adapter._NOMBRE_EDIFICIO = edificio.NOMBRE_EDIFICIO;
            adapter._TIPO            = dplTipo.SelectedValue;
            if (dplTipo.SelectedIndex == 1)
            {
                adapter._CANTIDAD  = Convert.ToInt32(txtCantidadBodega.Text);
                adapter._DIMENSION = Convert.ToDouble(txtDimBodega.Text);
                adapter._PRECIO    = 0;
            }
            else if (dplTipo.SelectedIndex == 2)
            {
                adapter._CANTIDAD  = Convert.ToInt32(txtEstacionamiento.Text);
                adapter._DIMENSION = 0;
                adapter._PRECIO    = Convert.ToInt32(txtPrecio.Text);
            }
            listaElemento.Add(adapter);
            grElementos.DataSource = listaElemento;
            grElementos.DataBind();
            txtCantidadBodega.Text  = "";
            txtDimBodega.Text       = "";
            txtEstacionamiento.Text = "";
        }
Esempio n. 2
0
        public void cargarParametros(string centro)
        {
            panelUpdateHorario.Visible = true;
            CENTRO   aux      = Controller.ControllerCentro.buscarIdCentro(Convert.ToInt64(centro));
            EDIFICIO edificio = Controller.ControllerEdificio.buscarIdEdificio(aux.ID_EDIFICIO);

            cargarCondominio();
            dplCondominio.SelectedValue = edificio.ID_CONDOMINIO.ToString();
            dplCondominio.Enabled       = false;
            List <EDIFICIO> listaEdificio = Controller.ControllerEdificio.buscarEdificioCondominio(edificio.ID_CONDOMINIO);

            dplEdificio.DataSource     = listaEdificio;
            dplEdificio.DataValueField = "ID_EDIFICIO";
            dplEdificio.DataTextField  = "NOMBRE_EDIFICIO";
            dplEdificio.DataBind();
            dplEdificio.Items.Insert(0, "Seleccione un Edificio");
            dplEdificio.SelectedValue   = aux.ID_EDIFICIO.ToString();
            dplEdificio.Enabled         = false;
            lbNombreCentro.Text         = aux.NOMBRE_CENTRO;
            btnRegistroHorario.Visible  = false;
            btnModificarHorario.Visible = true;
            btnAgregarHorario.Visible   = false;
            btnModificar.Visible        = true;

            listaHorarioActual         = new List <HORARIO_CENTRO>();
            listaHorarioActual         = Controller.ControllerHorarioCentro.listadoHorario(Convert.ToInt64(centro));
            grHorarioActual.DataSource = listaHorarioActual;
            grHorarioActual.DataBind();
            centroUpdate = aux;
        }
Esempio n. 3
0
 protected void dplDepartamento_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         long         departamento = Convert.ToInt64(dplDepartamento.SelectedValue);
         DEPARTAMENTO aux          = Controller.ControllerDepartamento.buscarIdDepartamento(departamento);
         if (aux.ID_LUZ_D != null)
         {
             LUZ_DEPARTAMENTO luz = Controller.ControllerLuzDepartamento.buscarIdLuzDepartamento(Convert.ToInt64(aux.ID_LUZ_D));
             lbLuz.Text = luz.CODIGO_LUZ_D;
         }
         else
         {
             lbLuz.Text = "No Posee";
         }
         EDIFICIO   edificio   = Controller.ControllerEdificio.buscarIdEdificio(aux.ID_EDIFICIO);
         CONDOMINIO condominio = Controller.ControllerCondominio.buscarIdCondominio(edificio.ID_CONDOMINIO);
         lbEdificio.Text   = edificio.NOMBRE_EDIFICIO;
         lbCondominio.Text = condominio.NOMBRE_CONDOMINIO;
     }
     catch (Exception ex)
     {
         lbLuz.Text        = "";
         lbCondominio.Text = "";
         lbEdificio.Text   = "";
         System.Diagnostics.Debug.WriteLine("Error:  " + ex);
     }
 }
Esempio n. 4
0
        protected void btnAgregarMulta_Click(object sender, EventArgs e)
        {
            lbMultasNuevas.Visible = true;
            lbError.Visible        = false;
            if (txtMulta.Text.Length > 8)
            {
                lbError.Visible = true;
                lbError.Text    = "Monto Incorrecto";
            }
            else
            {
                lbError.Visible = false;
                long         condominio   = Convert.ToInt64(dplCondominio.SelectedValue);
                CONDOMINIO   con          = Controller.ControllerCondominio.buscarIdCondominio(condominio);
                long         edificio     = Convert.ToInt64(dplEdificio.SelectedValue);
                EDIFICIO     edi          = Controller.ControllerEdificio.buscarIdEdificio(edificio);
                long         departamento = Convert.ToInt64(dplDepartamento.SelectedValue);
                DEPARTAMENTO dep          = Controller.ControllerDepartamento.buscarIdDepartamento(departamento);

                Adapter.AdapterDepartamento adapter = new Adapter.AdapterDepartamento();
                adapter._NOMBRE_CONDOMINIO = con.NOMBRE_CONDOMINIO;
                adapter._ID_DEPARTAMENTO   = dep.ID_DEPARTAMENTO;
                adapter._NOMBRE_EDIFICIO   = edi.NOMBRE_EDIFICIO;
                adapter._NUMERO_DEP        = dep.NUMERO_DEP;
                adapter._MULTA             = Convert.ToInt32(txtMulta.Text);
                adapter._MOTIVO            = txtMotivo.Text;

                listaDepartamento.Add(adapter);
                grMulta.DataSource = listaDepartamento;
                grMulta.DataBind();

                txtMotivo.Text = "";
                txtMulta.Text  = "";
            }
        }
        protected void btnModificarLuz_Click(object sender, EventArgs e)
        {
            Adapter.AdapterLuzDepartamento adapter = new Adapter.AdapterLuzDepartamento();
            CONDOMINIO       condominio            = Controller.ControllerCondominio.buscarIdCondominio(Convert.ToInt64(dplCondominio.SelectedValue));
            EDIFICIO         edificio     = Controller.ControllerEdificio.buscarIdEdificio(Convert.ToInt64(dplEdificio.SelectedValue));
            DEPARTAMENTO     departamento = Controller.ControllerDepartamento.buscarIdDepartamento(Convert.ToInt64(dplDepartamento.SelectedValue));
            LUZ_DEPARTAMENTO luz          = Controller.ControllerLuzDepartamento.buscarIdLuzDepartamento(Convert.ToInt64(dplLuz.SelectedValue));

            lbError.Visible = false;
            List <Adapter.AdapterLuzDepartamento> listaAux = listaLuzDepartamentoUpdate;

            if (listaLuzDepartamentoUpdate.Count > 0)
            {
                foreach (Adapter.AdapterLuzDepartamento item in listaAux.ToList())
                {
                    if (item._ID_LUZ_D == Convert.ToInt64(dplLuz.SelectedValue))
                    {
                        lbError.Visible = true;
                        lbError.Text    = "Luz ya Asignada";
                    }
                    else if (item._ID_DEPARTAMENTO == Convert.ToInt64(dplDepartamento.SelectedValue))
                    {
                        lbError.Visible = true;
                        lbError.Text    = "Departamento ya Posee Luz";
                    }
                    else
                    {
                        lbError.Visible            = false;
                        adapter._ID_LUZ_D          = luz.ID_LUZ_D;
                        adapter._CODIGO_LUZ_D      = luz.CODIGO_LUZ_D;
                        adapter._ID_DEPARTAMENTO   = departamento.ID_DEPARTAMENTO;
                        adapter._NUMERO_DEP        = departamento.NUMERO_DEP;
                        adapter._ID_EDIFICIO       = edificio.ID_EDIFICIO;
                        adapter._NOMBRE_EDIFICIO   = edificio.NOMBRE_EDIFICIO;
                        adapter._ID_CONDOMINIO     = condominio.ID_CONDOMINIO;
                        adapter._NOMBRE_CONDOMINIO = condominio.NOMBRE_CONDOMINIO;
                        adapter._ESTADO_LUZ_D      = luz.ESTADO_LUZ_D;
                        listaLuzDepartamentoUpdate.Add(adapter);
                        grLuces.DataSource = listaLuzDepartamentoUpdate;
                        grLuces.DataBind();
                    }
                }
            }
            else
            {
                adapter._ID_LUZ_D          = luz.ID_LUZ_D;
                adapter._CODIGO_LUZ_D      = luz.CODIGO_LUZ_D;
                adapter._ID_DEPARTAMENTO   = departamento.ID_DEPARTAMENTO;
                adapter._NUMERO_DEP        = departamento.NUMERO_DEP;
                adapter._ID_EDIFICIO       = edificio.ID_EDIFICIO;
                adapter._NOMBRE_EDIFICIO   = edificio.NOMBRE_EDIFICIO;
                adapter._ID_CONDOMINIO     = condominio.ID_CONDOMINIO;
                adapter._NOMBRE_CONDOMINIO = condominio.NOMBRE_CONDOMINIO;
                adapter._ESTADO_LUZ_D      = luz.ESTADO_LUZ_D;
                listaLuzDepartamentoUpdate.Add(adapter);
                grLuces.DataSource = listaLuzDepartamentoUpdate;
                grLuces.DataBind();
            }
        }
Esempio n. 6
0
        protected void btnAgregarLuz_Click(object sender, EventArgs e)
        {
            Adapter.AdapterLuzEdificio adapter = new Adapter.AdapterLuzEdificio();
            CONDOMINIO   condominio            = Controller.ControllerCondominio.buscarIdCondominio(Convert.ToInt64(dplCondominio.SelectedValue));
            EDIFICIO     edificio = Controller.ControllerEdificio.buscarIdEdificio(Convert.ToInt64(dplEdificio.SelectedValue));
            LUZ_EDIFICIO luz      = Controller.ControllerLuzEdificio.buscarIdLuzEdificio(Convert.ToInt64(dplLuz.SelectedValue));

            lbError.Visible = false;
            List <Adapter.AdapterLuzEdificio> listaAux = listaLuzEdificio;

            if (listaLuzEdificio.Count > 0)
            {
                foreach (Adapter.AdapterLuzEdificio item in listaAux.ToList())
                {
                    if (item._ID_LUZ_E == Convert.ToInt64(dplLuz.SelectedValue))
                    {
                        lbError.Visible = true;
                        lbError.Text    = "Luz ya Asignada";
                    }
                    else if (item._ID_EDIFICIO == Convert.ToInt64(dplEdificio.SelectedValue))
                    {
                        lbError.Visible = true;
                        lbError.Text    = "Edificio ya Posee Luz";
                    }
                    else
                    {
                        lbError.Visible            = false;
                        adapter._ID_LUZ_E          = luz.ID_LUZ_E;
                        adapter._CODIGO_LUZ_E      = luz.CODIGO_LUZ_E;
                        adapter._ID_EDIFICIO       = edificio.ID_EDIFICIO;
                        adapter._NOMBRE_EDIFICIO   = edificio.NOMBRE_EDIFICIO;
                        adapter._ID_CONDOMINIO     = condominio.ID_CONDOMINIO;
                        adapter._NOMBRE_CONDOMINIO = condominio.NOMBRE_CONDOMINIO;
                        adapter._ESTADO_LUZ_E      = luz.ESTADO_LUZ_E;
                        listaLuzEdificio.Add(adapter);
                        grLuces.DataSource = listaLuzEdificio;
                        grLuces.DataBind();
                    }
                }
            }
            else
            {
                lbError.Visible            = false;
                adapter._ID_LUZ_E          = luz.ID_LUZ_E;
                adapter._CODIGO_LUZ_E      = luz.CODIGO_LUZ_E;
                adapter._ID_EDIFICIO       = edificio.ID_EDIFICIO;
                adapter._NOMBRE_EDIFICIO   = edificio.NOMBRE_EDIFICIO;
                adapter._ID_CONDOMINIO     = condominio.ID_CONDOMINIO;
                adapter._NOMBRE_CONDOMINIO = condominio.NOMBRE_CONDOMINIO;
                adapter._ESTADO_LUZ_E      = luz.ESTADO_LUZ_E;
                listaLuzEdificio.Add(adapter);
                grLuces.DataSource = listaLuzEdificio;
                grLuces.DataBind();
            }
        }
        protected void btnAgregarDep_Click(object sender, EventArgs e)
        {
            Adapter.AdapterDepartamento adapter = new Adapter.AdapterDepartamento();
            lbError.Visible = false;
            Boolean option = true;

            if (listaDepartamento.Count <= 0)
            {
                EDIFICIO     edificio     = Controller.ControllerEdificio.buscarIdEdificio(Convert.ToInt64(dplEdificio.SelectedValue));
                DEPARTAMENTO departamento = Controller.ControllerDepartamento.buscarIdDepartamento(Convert.ToInt64(dplDepartamento.SelectedValue));
                adapter._ID_EDIFICIO     = edificio.ID_EDIFICIO;
                adapter._NOMBRE_EDIFICIO = edificio.NOMBRE_EDIFICIO;
                adapter._ID_DEPARTAMENTO = departamento.ID_DEPARTAMENTO;
                adapter._NUMERO_DEP      = departamento.NUMERO_DEP;
                adapter._DIMENSION_DEP   = Convert.ToDouble(txtDimDepartamento.Text);
                listaDepartamento.Add(adapter);
            }
            else
            {
                foreach (Adapter.AdapterDepartamento item in listaDepartamento)
                {
                    if (Convert.ToInt64(dplDepartamento.SelectedValue) == item._ID_DEPARTAMENTO)
                    {
                        option = false;
                    }
                }

                if (option == true)
                {
                    lbError.Visible = false;
                    EDIFICIO     edificio     = Controller.ControllerEdificio.buscarIdEdificio(Convert.ToInt64(dplEdificio.SelectedValue));
                    DEPARTAMENTO departamento = Controller.ControllerDepartamento.buscarIdDepartamento(Convert.ToInt64(dplDepartamento.SelectedValue));
                    adapter._ID_EDIFICIO     = edificio.ID_EDIFICIO;
                    adapter._NOMBRE_EDIFICIO = edificio.NOMBRE_EDIFICIO;
                    adapter._ID_DEPARTAMENTO = departamento.ID_DEPARTAMENTO;
                    adapter._NUMERO_DEP      = departamento.NUMERO_DEP;
                    adapter._DIMENSION_DEP   = Convert.ToDouble(txtDimDepartamento.Text);
                    listaDepartamento.Add(adapter);
                }
                else
                {
                    lbError.Visible = true;
                }
            }

            grDepartamento.DataSource = listaDepartamento;
            grDepartamento.DataBind();
            lbDep.Visible                 = true;
            grDepartamento.Visible        = true;
            dplDepartamento.SelectedIndex = 0;
            txtDimDepartamento.Text       = "";
        }
Esempio n. 8
0
        protected void btnAgregarPago_Click(object sender, EventArgs e)
        {
            lbErrorRegistro.Visible = false;
            btnPagarGasto.Visible   = true;
            EDIFICIO       edificio     = new EDIFICIO();
            GASTOS_COMUNES gasto        = new GASTOS_COMUNES();
            DEPARTAMENTO   departamento = new DEPARTAMENTO();
            PERSONA        persona      = new PERSONA();
            List <MULTA>   listaMulta   = Controller.ControllerMulta.listaMultaNoPagadaDepartamento(Convert.ToInt64(dplDepartamento.SelectedValue));
            long           multa        = 0;

            foreach (MULTA item in listaMulta)
            {
                multa = multa + item.COSTO_MULTA;
            }
            edificio     = Controller.ControllerEdificio.buscarIdEdificio(Convert.ToInt64(dplEdificio.SelectedValue));
            gasto        = Controller.ControllerGastoComun.buscarGastoComunEdificio(Convert.ToInt64(dplEdificio.SelectedValue));
            departamento = Controller.ControllerDepartamento.buscarIdDepartamento(Convert.ToInt64(dplDepartamento.SelectedValue));
            persona      = Controller.ControllerPersona.buscarPersonaRut(txtPersona.Text);
            if (persona == null)
            {
                lbError.Visible   = true;
                lbPagados.Visible = false;
            }
            else
            {
                lbError.Visible   = false;
                lbPagados.Visible = true;
                Adapter.AdapterBoletaGasto pago = new Adapter.AdapterBoletaGasto();
                long totalBoleta = Convert.ToInt64(gasto.TOTAL_GASTO) + multa;

                pago._ID_GASTOS       = gasto.ID_GASTOS;
                pago._ID_EDIFICIO     = edificio.ID_EDIFICIO;
                pago._ID_DEPARTAMENTO = departamento.ID_DEPARTAMENTO;
                pago._FK_RUT          = persona.FK_RUT;
                pago._NOMBRE_EDIFICIO = edificio.NOMBRE_EDIFICIO;
                pago._NUMERO_DEP      = departamento.NUMERO_DEP;
                pago._TOTAL_GASTO     = gasto.TOTAL_GASTO;
                pago._MULTA           = multa;
                pago._COSTO_BOLETA    = totalBoleta;

                listaGastos.Add(pago);
                grGastos.DataSource = listaGastos;
                grGastos.DataBind();
                total        = total + pago._COSTO_BOLETA;
                lbTotal.Text = total.ToString();
                dplDepartamento.SelectedIndex = 0;
                listGastos.DataSource         = null;
                listGastos.DataBind();
            }
        }
        protected void btnAgregarDepartamento_Click(object sender, EventArgs e)
        {
            Adapter.AdapterDepartamento adapter = new Adapter.AdapterDepartamento();
            lbError.Visible = false;
            Boolean operation = true;

            if (listaDepartamento.Count > 0)
            {
                foreach (Adapter.AdapterDepartamento item in listaDepartamento)
                {
                    if (item._ID_DEPARTAMENTO == Convert.ToInt64(dplDepartamento.SelectedValue))
                    {
                        lbError.Visible = true;
                        lbError.Text    = "Departamento ya Asignado";
                        operation       = false;
                    }
                }
            }

            if (operation == true)
            {
                lbError.Visible = false;
                CONDOMINIO   condominio   = Controller.ControllerCondominio.buscarIdCondominio(Convert.ToInt64(dplCondominio.SelectedValue));
                EDIFICIO     edificio     = Controller.ControllerEdificio.buscarIdEdificio(Convert.ToInt64(dplEdificio.SelectedValue));
                DEPARTAMENTO departamento = Controller.ControllerDepartamento.buscarIdDepartamento(Convert.ToInt64(dplDepartamento.SelectedValue));
                adapter._ID_CONDOMINIO     = condominio.ID_CONDOMINIO;
                adapter._NOMBRE_CONDOMINIO = condominio.NOMBRE_CONDOMINIO;
                adapter._ID_EDIFICIO       = edificio.ID_EDIFICIO;
                adapter._NOMBRE_EDIFICIO   = edificio.NOMBRE_EDIFICIO;
                adapter._ID_DEPARTAMENTO   = departamento.ID_DEPARTAMENTO;
                adapter._NUMERO_DEP        = departamento.NUMERO_DEP;
                listaDepartamento.Add(adapter);
                listaDep.Add(departamento);
                grDepartamento.DataSource = listaDepartamento;
                grDepartamento.DataBind();
                dplCondominio.SelectedIndex   = 0;
                dplEdificio.SelectedIndex     = 0;
                dplDepartamento.SelectedIndex = 0;
            }

            dplDepElemento.DataSource     = listaDep;
            dplDepElemento.DataValueField = "ID_DEPARTAMENTO";
            dplDepElemento.DataTextField  = "NUMERO_DEP";
            dplDepElemento.DataBind();
            dplDepElemento.Items.Insert(0, "Seleccione un Departamento");
            dplDepElemento.SelectedIndex = 0;
        }
Esempio n. 10
0
        protected void txtHoraSalida_TextChanged(object sender, EventArgs e)
        {
            EDIFICIO   edificio   = Controller.ControllerEdificio.buscarIdEdificio(Convert.ToInt64(idEstacionamiento));
            CONDOMINIO condominio = Controller.ControllerCondominio.buscarIdCondominio(edificio.ID_CONDOMINIO);
            int        precio     = condominio.PRECIO_EST;

            DateTime horaE      = Convert.ToDateTime(txtHoraEntrada.Text);
            DateTime horaS      = Convert.ToDateTime(txtHoraSalida.Text);
            TimeSpan diferencia = horaS.Subtract(horaE);

            total = precio * diferencia.Hours;
            if (total < 0)
            {
                total = 0;
            }
            lbTotal.Text = total.ToString();
        }
Esempio n. 11
0
 public static EDIFICIO buscarIdEdificio(long edificio)
 {
     using (EasyLifeEntities dbc = new EasyLifeEntities())
     {
         EDIFICIO query = (from u in dbc.EDIFICIO
                           where u.ID_EDIFICIO == edificio
                           select u).FirstOrDefault();
         if (query != null)
         {
             return(query);
         }
         else
         {
             return(null);
         }
     }
 }
Esempio n. 12
0
        protected void btnAgregarGasto_Click(object sender, EventArgs e)
        {
            Adapter.AdapterGastoComun gasto = new Adapter.AdapterGastoComun();
            grGastos.Visible = true;
            lbGastos.Visible = true;
            lbError.Visible  = false;
            Boolean  option   = true;
            EDIFICIO edificio = Controller.ControllerEdificio.buscarIdEdificio(Convert.ToInt64(dplEdificio.SelectedValue));

            gasto._NOMBRE_EDIFICIO        = edificio.NOMBRE_EDIFICIO;
            gasto._ID_EDIFICIO            = edificio.ID_EDIFICIO;
            gasto._GASTO_CONSERJE         = Convert.ToInt32(txtGConserje.Text);
            gasto._GASTO_GUARDIA          = Convert.ToInt32(txtGGuardia.Text);
            gasto._GASTO_MANTENCION_AREAS = Convert.ToInt32(txtGMantAreas.Text);
            gasto._GASTO_CAMARAS          = Convert.ToInt32(txtGCamaras.Text);
            gasto._GASTO_ARTICULOS_ASEO   = Convert.ToInt32(txtGArtAseo.Text);
            gasto._GASTOS_ASEO            = Convert.ToInt32(txtGAseo.Text);
            gasto._GASTO_ASCENSOR         = Convert.ToInt32(txtGAscensor.Text);
            gasto._GASTO_AGUA_CALIENTE    = Convert.ToInt32(txtGAgua.Text);
            gasto._GASTO_OTRO             = Convert.ToInt32(txtGOtro.Text);
            gasto._TOTAL_GASTO            = Convert.ToInt32(lbTotal.Text);
            if (listaGastos.Count > 0)
            {
                foreach (Adapter.AdapterGastoComun item in listaGastos)
                {
                    if (item._ID_EDIFICIO == edificio.ID_EDIFICIO)
                    {
                        option = false;
                    }
                }
            }

            if (option == true)
            {
                listaGastos.Add(gasto);
                grGastos.DataSource = listaGastos;
                grGastos.DataBind();
            }
            else
            {
                lbError.Visible = true;
            }
        }
Esempio n. 13
0
        public void cargarPropietario(long propietario)
        {
            List <DEPARTAMENTO> listaDepartamento = Controller.ControllerDepartamento.listaDepartamentoPersona(propietario);

            listaEdificio   = new List <EDIFICIO>();
            listaCondominio = new List <CONDOMINIO>();
            if (listaDepartamento.Count > 0)
            {
                foreach (DEPARTAMENTO item in listaDepartamento)
                {
                    EDIFICIO   edificio   = Controller.ControllerEdificio.buscarIdEdificio(item.ID_EDIFICIO);
                    CONDOMINIO condominio = Controller.ControllerCondominio.buscarIdCondominio(edificio.ID_CONDOMINIO);
                    listaEdificio.Add(edificio);
                    listaCondominio.Add(condominio);
                }
            }

            var listEdificio   = listaEdificio.GroupBy(x => x.ID_EDIFICIO).Select(y => y.FirstOrDefault());
            var listCondominio = listaCondominio.GroupBy(x => x.ID_CONDOMINIO).Select(y => y.FirstOrDefault());

            listaEdificio   = listEdificio.ToList();
            listaCondominio = listCondominio.ToList();

            dplCondominio.DataSource     = listCondominio;
            dplCondominio.DataValueField = "ID_CONDOMINIO";
            dplCondominio.DataTextField  = "NOMBRE_CONDOMINIO";
            dplCondominio.DataBind();
            dplCondominio.Items.Insert(0, "Seleccione un Condominio");
            dplCondominio.SelectedIndex = 0;

            dplEdificio.DataSource     = listEdificio;
            dplEdificio.DataValueField = "ID_EDIFICIO";
            dplEdificio.DataTextField  = "NOMBRE_EDIFICIO";
            dplEdificio.DataBind();
            dplEdificio.Items.Insert(0, "Seleccione un Edificio");
            dplEdificio.SelectedIndex = 0;
        }
Esempio n. 14
0
 /// <summary>
 /// metodo que conecta con la base de datos para extraer todos los registros
 /// </summary>
 /// <returns>listado de tipo "ETNIA"</returns>
 public IQueryable <CELDA> ObtenerTodos(string buscar = "", MUNICIPIO municipio = null, CENTRO centro = null, EDIFICIO edificio = null, SECTOR sector = null)
 {
     try
     {
         getDbSet();
         if (string.IsNullOrEmpty(buscar))
         {
             #region municipio
             if (municipio.ID_MUNICIPIO == 0)
             {
                 #region centro
                 if (centro.ID_CENTRO == 0)
                 {
                     #region edificio
                     if (edificio.ID_EDIFICIO == 0)
                     {
                         #region sector
                         if (sector.ID_SECTOR == 0)
                         {
                             return(GetData());
                         }
                         else
                         {
                             return(GetData().Where(w => w.ID_SECTOR == sector.ID_SECTOR && w.ID_EDIFICIO == sector.ID_EDIFICIO && w.ID_CENTRO == sector.ID_CENTRO));
                         }
                         #endregion
                     }
                     else
                     {
                         #region sector
                         if (sector.ID_SECTOR == 0)
                         {
                             return(GetData().Where(w => w.ID_EDIFICIO == edificio.ID_EDIFICIO && w.ID_CENTRO == edificio.ID_CENTRO));
                         }
                         else
                         {
                             return(GetData().Where(w => w.ID_EDIFICIO == edificio.ID_EDIFICIO && w.ID_CENTRO == edificio.ID_CENTRO && w.ID_SECTOR == sector.ID_SECTOR));
                         }
                         #endregion
                     }
                     #endregion
                 }
                 else
                 {
                     #region edificio
                     if (edificio.ID_EDIFICIO == 0)
                     {
                         #region sector
                         if (sector.ID_SECTOR == 0)
                         {
                             return(GetData().Where(w => w.ID_CENTRO == centro.ID_CENTRO));
                         }
                         else
                         {
                             return(GetData().Where(w => w.ID_CENTRO == centro.ID_CENTRO && w.ID_SECTOR == sector.ID_SECTOR && w.ID_EDIFICIO == sector.ID_EDIFICIO));
                         }
                         #endregion
                     }
                     else
                     {
                         #region sector
                         if (sector.ID_SECTOR == 0)
                         {
                             return(GetData().Where(w => w.ID_CENTRO == centro.ID_CENTRO && w.ID_EDIFICIO == edificio.ID_EDIFICIO));
                         }
                         else
                         {
                             return(GetData().Where(w => w.ID_CENTRO == centro.ID_CENTRO && w.ID_EDIFICIO == edificio.ID_EDIFICIO && w.ID_SECTOR == sector.ID_SECTOR));
                         }
                         #endregion
                     }
                     #endregion
                 }
                 #endregion
             }
             else
             {
                 #region centro
                 if (centro.ID_CENTRO == 0)
                 {
                     #region edificio
                     if (edificio.ID_EDIFICIO == 0)
                     {
                         #region sector
                         if (sector.ID_SECTOR == 0)
                         {
                             return(GetData().Where(w => w.SECTOR.EDIFICIO.CENTRO.ID_MUNICIPIO == municipio.ID_MUNICIPIO));
                         }
                         else
                         {
                             return(GetData().Where(w => w.SECTOR.EDIFICIO.CENTRO.ID_MUNICIPIO == municipio.ID_MUNICIPIO && w.ID_SECTOR == sector.ID_SECTOR &&
                                                    w.ID_EDIFICIO == sector.ID_EDIFICIO && w.ID_CENTRO == sector.ID_CENTRO));
                         }
                         #endregion
                     }
                     else
                     {
                         #region sector
                         if (sector.ID_SECTOR == 0)
                         {
                             return(GetData().Where(w => w.SECTOR.EDIFICIO.CENTRO.ID_MUNICIPIO == municipio.ID_MUNICIPIO && w.ID_EDIFICIO == edificio.ID_EDIFICIO &&
                                                    w.ID_CENTRO == edificio.ID_CENTRO));
                         }
                         else
                         {
                             return(GetData().Where(w => w.SECTOR.EDIFICIO.CENTRO.ID_MUNICIPIO == municipio.ID_MUNICIPIO && w.ID_EDIFICIO == edificio.ID_EDIFICIO &&
                                                    w.ID_SECTOR == sector.ID_SECTOR && w.ID_CENTRO == edificio.ID_CENTRO));
                         }
                         #endregion
                     }
                     #endregion
                 }
                 else
                 {
                     #region edificio
                     if (edificio.ID_EDIFICIO == 0)
                     {
                         #region sector
                         if (sector.ID_SECTOR == 0)
                         {
                             return(GetData().Where(w => w.SECTOR.EDIFICIO.CENTRO.ID_MUNICIPIO == municipio.ID_MUNICIPIO && w.ID_CENTRO == centro.ID_CENTRO));
                         }
                         else
                         {
                             return(GetData().Where(w => w.SECTOR.EDIFICIO.CENTRO.ID_MUNICIPIO == municipio.ID_MUNICIPIO && w.ID_CENTRO == centro.ID_CENTRO &&
                                                    w.ID_SECTOR == sector.ID_SECTOR && w.ID_EDIFICIO == sector.ID_EDIFICIO));
                         }
                         #endregion
                     }
                     else
                     {
                         #region sector
                         if (sector.ID_SECTOR == 0)
                         {
                             return(GetData().Where(w => w.SECTOR.EDIFICIO.CENTRO.ID_MUNICIPIO == municipio.ID_MUNICIPIO && w.ID_CENTRO == centro.ID_CENTRO &&
                                                    w.ID_EDIFICIO == edificio.ID_EDIFICIO));
                         }
                         else
                         {
                             return(GetData().Where(w => w.SECTOR.EDIFICIO.CENTRO.ID_MUNICIPIO == municipio.ID_MUNICIPIO && w.ID_CENTRO == centro.ID_CENTRO &&
                                                    w.ID_EDIFICIO == edificio.ID_EDIFICIO && w.ID_SECTOR == sector.ID_SECTOR));
                         }
                         #endregion
                     }
                     #endregion
                 }
                 #endregion
             }
             #endregion
         }
         else
         {
             #region municipio
             if (municipio.ID_MUNICIPIO == 0)
             {
                 #region centro
                 if (centro.ID_CENTRO == 0)
                 {
                     #region edificio
                     if (edificio.ID_EDIFICIO == 0)
                     {
                         #region sector
                         if (sector.ID_SECTOR == 0)
                         {
                             return(GetData().Where(w => (w.ID_CELDA.Contains(buscar) || w.SECTOR.DESCR.Contains(buscar) || w.SECTOR.EDIFICIO.DESCR.Contains(buscar) ||
                                                          w.SECTOR.EDIFICIO.CENTRO.DESCR.Contains(buscar))));
                         }
                         else
                         {
                             return(GetData().Where(w => (w.ID_CELDA.Contains(buscar) || w.SECTOR.DESCR.Contains(buscar) || w.SECTOR.EDIFICIO.DESCR.Contains(buscar) ||
                                                          w.SECTOR.EDIFICIO.CENTRO.DESCR.Contains(buscar)) && w.ID_SECTOR == sector.ID_SECTOR && w.ID_EDIFICIO == sector.ID_EDIFICIO &&
                                                    w.ID_CENTRO == sector.ID_CENTRO));
                         }
                         #endregion
                     }
                     else
                     {
                         #region sector
                         if (sector.ID_SECTOR == 0)
                         {
                             return(GetData().Where(w => (w.ID_CELDA.Contains(buscar) || w.SECTOR.DESCR.Contains(buscar) || w.SECTOR.EDIFICIO.DESCR.Contains(buscar) ||
                                                          w.SECTOR.EDIFICIO.CENTRO.DESCR.Contains(buscar)) && w.ID_EDIFICIO == edificio.ID_EDIFICIO &&
                                                    w.ID_CENTRO == edificio.ID_CENTRO));
                         }
                         else
                         {
                             return(GetData().Where(w => (w.ID_CELDA.Contains(buscar) || w.SECTOR.DESCR.Contains(buscar) || w.SECTOR.EDIFICIO.DESCR.Contains(buscar) ||
                                                          w.SECTOR.EDIFICIO.CENTRO.DESCR.Contains(buscar)) && w.ID_EDIFICIO == edificio.ID_EDIFICIO && w.ID_SECTOR == sector.ID_SECTOR &&
                                                    w.ID_CENTRO == edificio.ID_CENTRO));
                         }
                         #endregion
                     }
                     #endregion
                 }
                 else
                 {
                     #region edificio
                     if (edificio.ID_EDIFICIO == 0)
                     {
                         #region sector
                         if (sector.ID_SECTOR == 0)
                         {
                             return(GetData().Where(w => (w.ID_CELDA.Contains(buscar) || w.SECTOR.DESCR.Contains(buscar) || w.SECTOR.EDIFICIO.DESCR.Contains(buscar) ||
                                                          w.SECTOR.EDIFICIO.CENTRO.DESCR.Contains(buscar)) && w.ID_CENTRO == centro.ID_CENTRO));
                         }
                         else
                         {
                             return(GetData().Where(w => (w.ID_CELDA.Contains(buscar) || w.SECTOR.DESCR.Contains(buscar) || w.SECTOR.EDIFICIO.DESCR.Contains(buscar) ||
                                                          w.SECTOR.EDIFICIO.CENTRO.DESCR.Contains(buscar)) && w.ID_CENTRO == centro.ID_CENTRO && w.ID_SECTOR == sector.ID_SECTOR &&
                                                    w.ID_EDIFICIO == sector.ID_EDIFICIO));
                         }
                         #endregion
                     }
                     else
                     {
                         #region sector
                         if (sector.ID_SECTOR == 0)
                         {
                             return(GetData().Where(w => (w.ID_CELDA.Contains(buscar) || w.SECTOR.DESCR.Contains(buscar) || w.SECTOR.EDIFICIO.DESCR.Contains(buscar) ||
                                                          w.SECTOR.EDIFICIO.CENTRO.DESCR.Contains(buscar)) && w.ID_CENTRO == centro.ID_CENTRO && w.ID_EDIFICIO == edificio.ID_EDIFICIO));
                         }
                         else
                         {
                             return(GetData().Where(w => (w.ID_CELDA.Contains(buscar) || w.SECTOR.DESCR.Contains(buscar) || w.SECTOR.EDIFICIO.DESCR.Contains(buscar) ||
                                                          w.SECTOR.EDIFICIO.CENTRO.DESCR.Contains(buscar)) && w.ID_CENTRO == centro.ID_CENTRO && w.ID_EDIFICIO == edificio.ID_EDIFICIO &&
                                                    w.ID_SECTOR == sector.ID_SECTOR));
                         }
                         #endregion
                     }
                     #endregion
                 }
                 #endregion
             }
             else
             {
                 #region centro
                 if (centro.ID_CENTRO == 0)
                 {
                     #region edificio
                     if (edificio.ID_EDIFICIO == 0)
                     {
                         #region sector
                         if (sector.ID_SECTOR == 0)
                         {
                             return(GetData().Where(w => (w.ID_CELDA.Contains(buscar) || w.SECTOR.DESCR.Contains(buscar) || w.SECTOR.EDIFICIO.DESCR.Contains(buscar) ||
                                                          w.SECTOR.EDIFICIO.CENTRO.DESCR.Contains(buscar)) && w.SECTOR.EDIFICIO.CENTRO.ID_MUNICIPIO == municipio.ID_MUNICIPIO));
                         }
                         else
                         {
                             return(GetData().Where(w => (w.ID_CELDA.Contains(buscar) || w.SECTOR.DESCR.Contains(buscar) || w.SECTOR.EDIFICIO.DESCR.Contains(buscar) ||
                                                          w.SECTOR.EDIFICIO.CENTRO.DESCR.Contains(buscar)) && w.SECTOR.EDIFICIO.CENTRO.ID_MUNICIPIO == municipio.ID_MUNICIPIO &&
                                                    w.ID_SECTOR == sector.ID_SECTOR && w.ID_EDIFICIO == sector.ID_EDIFICIO));
                         }
                         #endregion
                     }
                     else
                     {
                         #region sector
                         if (sector.ID_SECTOR == 0)
                         {
                             return(GetData().Where(w => (w.ID_CELDA.Contains(buscar) || w.SECTOR.DESCR.Contains(buscar) || w.SECTOR.EDIFICIO.DESCR.Contains(buscar) ||
                                                          w.SECTOR.EDIFICIO.CENTRO.DESCR.Contains(buscar)) && w.SECTOR.EDIFICIO.CENTRO.ID_MUNICIPIO == municipio.ID_MUNICIPIO &&
                                                    w.ID_EDIFICIO == edificio.ID_EDIFICIO));
                         }
                         else
                         {
                             return(GetData().Where(w => (w.ID_CELDA.Contains(buscar) || w.SECTOR.DESCR.Contains(buscar) || w.SECTOR.EDIFICIO.DESCR.Contains(buscar) ||
                                                          w.SECTOR.EDIFICIO.CENTRO.DESCR.Contains(buscar)) && w.SECTOR.EDIFICIO.CENTRO.ID_MUNICIPIO == municipio.ID_MUNICIPIO &&
                                                    w.ID_EDIFICIO == edificio.ID_EDIFICIO && w.ID_SECTOR == sector.ID_SECTOR));
                         }
                         #endregion
                     }
                     #endregion
                 }
                 else
                 {
                     #region edificio
                     if (edificio.ID_EDIFICIO == 0)
                     {
                         #region sector
                         if (sector.ID_SECTOR == 0)
                         {
                             return(GetData().Where(w => w.ID_CELDA.Contains(buscar) && w.SECTOR.EDIFICIO.CENTRO.ID_MUNICIPIO == municipio.ID_MUNICIPIO &&
                                                    w.ID_CENTRO == centro.ID_CENTRO));
                         }
                         else
                         {
                             return(GetData().Where(w => w.ID_CELDA.Contains(buscar) && w.SECTOR.EDIFICIO.CENTRO.ID_MUNICIPIO == municipio.ID_MUNICIPIO &&
                                                    w.ID_CENTRO == centro.ID_CENTRO && w.ID_SECTOR == sector.ID_SECTOR && w.ID_EDIFICIO == sector.ID_EDIFICIO));
                         }
                         #endregion
                     }
                     else
                     {
                         #region sector
                         if (sector.ID_SECTOR == 0)
                         {
                             return(GetData().Where(w => w.ID_CELDA.Contains(buscar) && w.SECTOR.EDIFICIO.CENTRO.ID_MUNICIPIO == municipio.ID_MUNICIPIO &&
                                                    w.ID_CENTRO == centro.ID_CENTRO && w.ID_EDIFICIO == edificio.ID_EDIFICIO));
                         }
                         else
                         {
                             return(GetData().Where(w => w.ID_CELDA.Contains(buscar) && w.SECTOR.EDIFICIO.CENTRO.ID_MUNICIPIO == municipio.ID_MUNICIPIO &&
                                                    w.ID_CENTRO == centro.ID_CENTRO && w.ID_EDIFICIO == edificio.ID_EDIFICIO && w.ID_SECTOR == sector.ID_EDIFICIO));
                         }
                         #endregion
                     }
                     #endregion
                 }
                 #endregion
             }
             #endregion
         }
     }
     catch (Exception ex)
     {
         throw new ApplicationException(ex.Message);
     }
 }
        protected void btnRegistroPropietario_Click1(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(5000);
            persona = new PERSONA();
            string  resultPropietario  = "";
            string  resultDepartamento = "";
            string  resultElemento     = "";
            string  rut    = txtRut.Text;
            long    rol    = 4;
            Boolean luz    = false;
            string  opcion = dplLuz.SelectedValue;

            if (opcion.Equals("Si"))
            {
                luz = true;
            }

            if (listaDepartamento.Count > 0)
            {
                resultPropietario = Controller.ControllerPersona.crearPersona(rol, txtNombre.Text, txtApellido.Text, txtRut.Text, txtTelefono.Text, txtEmail.Text, luz,
                                                                              radioSexo.SelectedValue);

                if (resultPropietario.Equals("Persona Creada"))
                {
                    persona = Controller.ControllerPersona.buscarPersonaRut(txtRut.Text);
                    foreach (Adapter.AdapterDepartamento item in listaDepartamento)
                    {
                        resultDepartamento = Controller.ControllerDepartamento.asignarDepartamentoPropietario(persona.ID_PERSONA, item._ID_DEPARTAMENTO);
                    }

                    if (resultDepartamento.Equals("Departamento Asignado"))
                    {
                        if (listaElemento.Count > 0)
                        {
                            foreach (Adapter.AdapterElemento item in listaElemento)
                            {
                                if (item._TIPO.Equals("Estacionamiento"))
                                {
                                    resultElemento = Controller.ControllerEstacionamiento.asignarEstacionamiento(item._ID_EST, item._ID_DEP);
                                }
                                else
                                {
                                    resultElemento = Controller.ControllerBodega.asignarBodega(item._ID_BODEGA, item._ID_DEP);
                                }
                            }
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertIns", "alert('Propietario Registrado');window.location.href='" + Request.RawUrl + "';", true);
                            List <DEPARTAMENTO> lista = Controller.ControllerDepartamento.listaDepartamentoPersona(persona.ID_PERSONA);
                            foreach (DEPARTAMENTO item in lista)
                            {
                                EDIFICIO edificio  = Controller.ControllerEdificio.buscarIdEdificio(item.ID_EDIFICIO);
                                double   prorroteo = (item.DIMENSION_DEP / edificio.DIMENSION_EDIFICIO) * 100;
                                string   result    = Controller.ControllerDepartamento.asignarProrroteoDep(item.ID_DEPARTAMENTO, prorroteo);
                            }
                            persona = new PERSONA();
                        }

                        if (resultElemento.Equals("Elemento Asignado"))
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertIns", "alert('Propietario Registrado');window.location.href='" + Request.RawUrl + "';", true);
                            List <DEPARTAMENTO> lista = Controller.ControllerDepartamento.listaDepartamentoPersona(persona.ID_PERSONA);
                            foreach (DEPARTAMENTO item in lista)
                            {
                                EDIFICIO      edificio   = Controller.ControllerEdificio.buscarIdEdificio(item.ID_EDIFICIO);
                                List <BODEGA> list       = Controller.ControllerBodega.buscarBodegaDepartamento(item.ID_DEPARTAMENTO);
                                double        dimensionB = 0;
                                foreach (BODEGA adapter in list)
                                {
                                    dimensionB = adapter.DIMENSION_BODEGA + dimensionB;
                                }
                                double prorroteo = ((item.DIMENSION_DEP + dimensionB) / edificio.DIMENSION_EDIFICIO) * 100;
                                string result    = Controller.ControllerDepartamento.asignarProrroteoDep(item.ID_DEPARTAMENTO, prorroteo);
                            }
                            persona = new PERSONA();
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertIns", "alert('Error al Asignar Elementos');window.location.href='" + Request.RawUrl + "';", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "alertIns", "alert('Error al Asignar Departamento');window.location.href='" + Request.RawUrl + "';", true);
                    }
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertIns", "alert('No ha Registrado Ningun Departamento');window.location.href='" + Request.RawUrl + "';", true);
            }
        }
        protected void btnAgregarBodega_Click(object sender, EventArgs e)
        {
            lbElementos.Visible     = true;
            grElementos.Visible     = true;
            lbErrorElemento.Visible = false;
            Adapter.AdapterElemento adapter = new Adapter.AdapterElemento();
            long    bodegaDpl = Convert.ToInt64(dplBodega.SelectedValue);
            Boolean operation = true;

            if (listaElemento.Count <= 0)
            {
                long         dep          = Convert.ToInt64(dplDepElemento.SelectedValue);
                DEPARTAMENTO departamento = Controller.ControllerDepartamento.buscarIdDepartamento(dep);
                BODEGA       bodega       = Controller.ControllerBodega.buscarBodega(bodegaDpl);
                EDIFICIO     edificio     = Controller.ControllerEdificio.buscarIdEdificio(departamento.ID_EDIFICIO);
                adapter._NOMBRE_EDIFICIO = edificio.NOMBRE_EDIFICIO;
                adapter._DEP             = departamento.NUMERO_DEP;
                adapter._ID_DEP          = departamento.ID_DEPARTAMENTO;
                adapter._TIPO            = "Bodega";
                adapter._ID_EST          = 0;
                adapter._ID_BODEGA       = bodega.ID_BODEGA;
                adapter._NUMERO_ELEMENTO = bodega.NUMERO_BODEGA;
                adapter._DIMENSION       = bodega.DIMENSION_BODEGA;
                adapter._PRECIO          = 0;
                listaElemento.Add(adapter);
            }
            else
            {
                foreach (Adapter.AdapterElemento item in listaElemento)
                {
                    if (item._ID_BODEGA == bodegaDpl)
                    {
                        operation = false;
                    }
                }

                if (operation == true)
                {
                    long         dep          = Convert.ToInt64(dplDepElemento.SelectedValue);
                    DEPARTAMENTO departamento = Controller.ControllerDepartamento.buscarIdDepartamento(dep);
                    BODEGA       bodega       = Controller.ControllerBodega.buscarBodega(bodegaDpl);
                    EDIFICIO     edificio     = Controller.ControllerEdificio.buscarIdEdificio(departamento.ID_EDIFICIO);
                    adapter._NOMBRE_EDIFICIO = edificio.NOMBRE_EDIFICIO;
                    adapter._DEP             = departamento.NUMERO_DEP;
                    adapter._ID_DEP          = departamento.ID_DEPARTAMENTO;
                    adapter._TIPO            = "Bodega";
                    adapter._ID_EST          = 0;
                    adapter._ID_BODEGA       = bodega.ID_BODEGA;
                    adapter._NUMERO_ELEMENTO = bodega.NUMERO_BODEGA;
                    adapter._DIMENSION       = bodega.DIMENSION_BODEGA;
                    adapter._PRECIO          = 0;
                    listaElemento.Add(adapter);
                }
                else
                {
                    lbErrorElemento.Visible = true;
                }
            }

            grElementos.DataSource = listaElemento;
            grElementos.DataBind();
            dplEstacionamiento.SelectedIndex = 0;
        }
 public void AddToEDIFICIOS(EDIFICIO eDIFICIO)
 {
     base.AddObject("EDIFICIOS", eDIFICIO);
 }
 public static EDIFICIO CreateEDIFICIO(long cODIGO_EDIFICIO, string nOMBRE)
 {
     EDIFICIO eDIFICIO = new EDIFICIO();
     eDIFICIO.CODIGO_EDIFICIO = cODIGO_EDIFICIO;
     eDIFICIO.NOMBRE = nOMBRE;
     return eDIFICIO;
 }