protected void btnProgramarLuz_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(5000);
            DateTime     dia       = Convert.ToDateTime(txtDia.Text);
            string       horaI     = txtHoraInicio.Text;
            string       horaT     = txtHoraTermino.Text;
            int          operacion = rbOpcion.SelectedIndex;
            Boolean      opcion    = new Boolean();
            LUZ_EDIFICIO luz       = Controller.ControllerLuzEdificio.buscarIdLuzEdificio(Convert.ToInt64(dplLuz.SelectedValue));

            if (operacion == 0)
            {
                opcion = true;
            }
            else
            {
                opcion = false;
            }
            string horaInicio  = dia.ToString("dd/MM/yyy") + " " + horaI;
            string horaTermino = dia.ToString("dd/MM/yyy") + " " + horaT;
            string result      = Controller.ControllerControlIluminacionEdificio.crearControlEdificio(luz.ID_LUZ_E, horaInicio, horaTermino, opcion);

            if (result.Equals("Control Creado"))
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertIns", "alert('Control Creado');window.location.href='" + Request.RawUrl + "';", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertIns", "alert('Error al Crear Control');window.location.href='" + Request.RawUrl + "';", true);
            }
        }
예제 #2
0
        protected void btnModificarLuz_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 = listaLuzEdificioUpdate;

            if (listaLuzEdificioUpdate.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;
                        listaLuzEdificioUpdate.Add(adapter);
                        grLuces.DataSource = listaLuzEdificioUpdate;
                        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;
                listaLuzEdificioUpdate.Add(adapter);
                grLuces.DataSource = listaLuzEdificioUpdate;
                grLuces.DataBind();
            }
        }
예제 #3
0
 public static LUZ_EDIFICIO buscarIdLuzEdificio(long luz)
 {
     using (EasyLifeEntities dbc = new EasyLifeEntities())
     {
         LUZ_EDIFICIO query = (from u in dbc.LUZ_EDIFICIO
                               where u.ID_LUZ_E == luz
                               select u).SingleOrDefault();
         if (query != null)
         {
             return(query);
         }
         else
         {
             return(null);
         }
     }
 }
 protected void dplLuz_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         long         luz  = Convert.ToInt64(dplLuz.SelectedValue);
         LUZ_EDIFICIO luzE = Controller.ControllerLuzEdificio.buscarIdLuzEdificio(luz);
         if (luzE.ESTADO_LUZ_E == true)
         {
             lbEstado.Text = "Encendida";
         }
         else
         {
             lbEstado.Text = "Apagada";
         }
     }
     catch (Exception ex)
     {
         lbEstado.Text = "";
         System.Diagnostics.Debug.WriteLine("Error:  " + ex);
     }
 }
예제 #5
0
        protected void btnAgregarLuzEdificio_Click(object sender, EventArgs e)
        {
            LUZ_EDIFICIO        luz       = new LUZ_EDIFICIO();
            List <LUZ_EDIFICIO> lista     = Controller.ControllerLuzEdificio.listaLuzEdificio();
            Boolean             operation = true;

            foreach (LUZ_EDIFICIO item in lista)
            {
                if (item.CODIGO_LUZ_E.Equals(txtCod.Text))
                {
                    lbError.Visible = true;
                    lbError.Text    = "Luz ya esta Registrada";
                    operation       = false;
                }
            }

            if (listaLuzEdificio.Count > 0)
            {
                foreach (LUZ_EDIFICIO item in listaLuzEdificio)
                {
                    if (item.CODIGO_LUZ_E.Equals(txtCod.Text))
                    {
                        lbError.Visible = true;
                        lbError.Text    = "Luz ya Ingresada";
                        operation       = false;
                    }
                }
            }

            if (operation == true)
            {
                lbError.Visible  = false;
                luz.CODIGO_LUZ_E = txtCod.Text;
                listaLuzEdificio.Add(luz);
                grCodLuzEdificio.DataSource = listaLuzEdificio;
                grCodLuzEdificio.DataBind();
            }
            txtCod.Text = "";
        }