public HttpResponseMessage UpdateConfirmar([FromBody] Llave llave) { HttpResponseMessage msg = null; try { if (llave == null) { msg = Request.CreateErrorResponse(HttpStatusCode.NotFound, "NOTFOUND"); } else { if (LlaveBRL.ConfirmaRecibido(llave) == true) { msg = Request.CreateResponse(HttpStatusCode.OK, "OK"); } else { msg = Request.CreateResponse(HttpStatusCode.OK, "RPT"); } } } catch (Exception e) { msg = Request.CreateErrorResponse(HttpStatusCode.NotFound, "ERROR" + e); return(msg); } return(msg); }
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 GetLlavesPrestadas([FromBody] Llave llave) { HttpResponseMessage msg = null; try { List <Llave> llaves = LlaveBRL.GetLlavesPrestadas(llave.AlarmaId, llave.UsuarioId); if (llaves == null) { msg = Request.CreateErrorResponse(HttpStatusCode.NotFound, "NOTFOUND"); } else { msg = Request.CreateResponse(HttpStatusCode.OK, llaves); } } catch (Exception e) { msg = Request.CreateErrorResponse(HttpStatusCode.NotFound, "ERROR" + e); return(msg); } return(msg); }
public HttpResponseMessage GetLlavesPropias(string UsuarioID) { HttpResponseMessage msg = null; try { List <Llave> llaves = LlaveBRL.GetLlavesPropias(Int32.Parse(UsuarioID)); if (llaves == null) { msg = Request.CreateErrorResponse(HttpStatusCode.NotFound, "NOTFOUND"); } else { msg = Request.CreateResponse(HttpStatusCode.OK, llaves); } } catch (Exception e) { msg = Request.CreateErrorResponse(HttpStatusCode.NotFound, "ERROR" + e); return(msg); } return(msg); }
public HttpResponseMessage GetLlaveByLlaveId(string LlaveId) { HttpResponseMessage msg = null; try { Llave llave = LlaveBRL.GetLlaveByLlaveId(Int32.Parse(LlaveId)); if (llave == null) { msg = Request.CreateErrorResponse(HttpStatusCode.NotFound, "NOTFOUND"); } else { msg = Request.CreateResponse(HttpStatusCode.OK, llave); } } catch (Exception e) { msg = Request.CreateErrorResponse(HttpStatusCode.NotFound, "ERROR" + e); return(msg); } return(msg); }
public HttpResponseMessage Update([FromBody] Llave llave) { HttpResponseMessage msg = null; try { if (llave == null) { msg = Request.CreateErrorResponse(HttpStatusCode.NotFound, "NOTFOUND"); } else { LlaveBRL.UpdateLlave(llave); msg = Request.CreateResponse(HttpStatusCode.OK, "OK"); } } catch (Exception e) { msg = Request.CreateErrorResponse(HttpStatusCode.NotFound, "ERROR" + e); return(msg); } return(msg); }
public HttpResponseMessage InserLlave(Llave llave) { HttpResponseMessage msg = null; try { if (llave == null /*String.IsNullOrEmpty(Codigo) | String.IsNullOrEmpty(Estado) | String.IsNullOrEmpty(Tipo) | String.IsNullOrEmpty(Nick) | String.IsNullOrEmpty(AlarmaId)*/) { msg = Request.CreateErrorResponse(HttpStatusCode.NotFound, "NOTFOUND"); } else { LlaveBRL.InsertarLlave(llave); msg = Request.CreateResponse(HttpStatusCode.OK, "OK"); } } catch (Exception e) { msg = Request.CreateErrorResponse(HttpStatusCode.NotFound, "ERROR" + e); return(msg); } return(msg); }
protected void GridLlavesObtenidas_RowCommand(object sender, GridViewCommandEventArgs e) { int llaveid = 0; try { llaveid = Convert.ToInt32(e.CommandArgument); } catch (Exception ex) { } if (llaveid <= 0) { return; } if (e.CommandName == "EditarLlave") { Response.Redirect("Formularios/FormularioLlave.aspx?Id=" + llaveid.ToString()); } else if (e.CommandName == "EliminarLlave") { LlaveBRL.DeleteLlave(llaveid); } }
protected void registrarAlarma(object sender, EventArgs e) { String codigoAlarma = fcodigoAlarma.Text.Trim(); String nombreAlarma = fnombreAlarma.Text.Trim(); String contrasenaAlarma = fcontrasenaAlarma.Text.Trim(); Usuario user = (Usuario)Session["USUARIO"]; int usuario = user.UsuarioID; if (string.IsNullOrEmpty(codigoAlarma)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('El campo del código de Alarma no debe quedar vacío')", true); return; } if (string.IsNullOrEmpty(nombreAlarma)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('El campo del nombre de la Alarma no puede quedar vacío')", true); return; } if (string.IsNullOrEmpty(contrasenaAlarma)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('El campo de la contraseña de la Alarma no puede quedar vacío')", true); return; } string AL_latitud = latitudHidden.Value; string AL_longitud = longitudHidden.Value; if (string.IsNullOrEmpty(AL_latitud) || string.IsNullOrEmpty(AL_longitud)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Error de Red, Asegurese de que el equipo tenga Conexión a INTERNET')", true); return; } if (id == 0) { Alarma alarma = AlarmaBRL.GetAlarmaByCodigo(codigoAlarma); if (alarma != null && alarma.UsuarioID == -1) { alarma.Alerta = 0; alarma.UsuarioID = usuario; alarma.Nombre = nombreAlarma; alarma.Contrasena = contrasenaAlarma; alarma.Latitud = AL_latitud; alarma.Longitud = AL_longitud; AlarmaBRL.UpdateAlarma(alarma); Llave llave = new Llave(); llave.Codigo = contrasenaAlarma; llave.Estado = 1; llave.Tipo = "P"; llave.Nick = "Propietario"; llave.AlarmaId = alarma.AlarmaId; LlaveBRL.InsertarLlave(llave); Response.Redirect("~/AlarmaConfiguracion.aspx"); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('El código de la alarma no es válido')", true); Response.Redirect("~/AlarmaConfiguracion.aspx"); } } else { Alarma alarma2 = AlarmaBRL.GetAlarmaByID(id); if (alarma2 != null && alarma2.UsuarioID == usuario) { alarma2.Alerta = 0; alarma2.UsuarioID = usuario; alarma2.Nombre = nombreAlarma; alarma2.Contrasena = contrasenaAlarma; alarma2.Latitud = AL_latitud; alarma2.Longitud = AL_longitud; AlarmaBRL.UpdateAlarma(alarma2); Response.Redirect("~/AlarmaConfiguracion.aspx"); } } }
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"); } }