protected void Page_Load(object sender, EventArgs e) { Usuario usuario = (Usuario)Session["USUARIO"]; user = usuario.UsuarioID; if (AlarmaBRL.GetAlarmaByIdUsuario(user) != null) { List <DailyDB.App_Code.Model.Alarma> alarmas = AlarmaBRL.GetAlarmaByIdUsuario(user); GridAlarma.DataSource = alarmas; GridAlarma.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { Usuario usuario = (Usuario)Session["USUARIO"]; user = usuario.UsuarioID; List <DailyDB.App_Code.Model.Alarma> alarmas = AlarmaBRL.GetAlarmaByIdUsuario(user); List <DailyDB.App_Code.Model.Llave> llave = LlaveBRL.GetLlavesPorAlarma(alarmas[0].AlarmaId); GridLlavesObtenidas.DataSource = llave; GridLlavesObtenidas.DataBind(); }
public HttpResponseMessage GetAlarmaByUsuario(string UsuarioID) { HttpResponseMessage msg = null; try { List <Alarma> alarmas = AlarmaBRL.GetAlarmaByIdUsuario(int.Parse(UsuarioID)); if (alarmas == null || alarmas.Count <= 0) { msg = Request.CreateErrorResponse(HttpStatusCode.NotFound, "NOTFOUND"); } else { msg = Request.CreateResponse(HttpStatusCode.OK, alarmas); } } catch (Exception e) { msg = Request.CreateErrorResponse(HttpStatusCode.NotFound, "ERROR" + e); } return(msg); }
protected void RegistrarLlave_Click(object sender, EventArgs e) { Usuario usuario = (Usuario)Session["USUARIO"]; int user = 0; if (usuario == null) { Response.Redirect("../LlaveConfiguracion.aspx"); } else { user = usuario.UsuarioID; } bool permanente = RadioButtonList1.Items[0].Selected; bool temporal = RadioButtonList1.Items[1].Selected; string nick1 = txtNick.Text; string fechaInicio = FechaInicioc.Value; string fechaFin = FechaFinc.Value; if (permanente == false && temporal == false) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Debe seleccionar alguna opción de tipo de llave')", true); return; } if (string.IsNullOrEmpty(nick1)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Debe ingresar el Nick')", true); return; } if (string.IsNullOrEmpty(fechaInicio)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Debe ingresar el Nick')", true); return; } String cod = Guid.NewGuid().ToString().Substring(0, 10); List <Alarma> alarma = AlarmaBRL.GetAlarmaByIdUsuario(user); //Horario Inicio TimeSpan ts = TimeSpan.Parse(horaInicio.Value); //Horario Fin TimeSpan ts2 = TimeSpan.Parse(horaFin.Value); Llave llave = new Llave(); if (permanente) { llave.Tipo = "P"; llave.AlarmaId = alarma[0].AlarmaId; llave.Codigo = cod; llave.Nick = nick1; llave.FechaInicio = DateTime.Parse(fechaInicio); llave.FechaFin = DateTime.Parse(fechaFin); llave.HoraInicio = ts; llave.HoraFin = ts2; llave.ActHora = 1; llave.Estado = 1; } if (temporal) { llave.Tipo = "T"; llave.Nombre = "Temporal"; llave.AlarmaId = alarma[0].AlarmaId; llave.Codigo = cod; llave.Nick = nick1; llave.FechaInicio = DateTime.Parse(fechaInicio); llave.FechaFin = DateTime.Parse(fechaFin); llave.HoraInicio = ts; llave.HoraFin = ts2; llave.ActHora = 1; llave.ActDias = 1; llave.Estado = 1; } if (id == 0) { LlaveBRL.InsertarLlave(llave); Response.Redirect("~/LlaveConfiguracion.aspx"); } else { llave.LlaveId = id; LlaveBRL.UpdateLlave(llave); Response.Redirect("~/LlaveConfiguracion.aspx"); } }