private void CargaLabels() { if (rvm.Tiporecarga == TipoRecarga.RecargaTA) { grdRecarga.IsVisible = true; grdMonedero.IsVisible = false; lblPais.Text = rvm.lsPais().Where(x => x.idpais == rvm.idpais).FirstOrDefault().pais; lblOperadora.Text = rvm.LsOperadoras(rvm.idpais).Where(x => x.idoperadora == rvm.idoperadora).FirstOrDefault().operadora; string formatted = new StringBuilder(12).Append(rvm.NumeroRecarga, 0, 2).Append(" ").Append(rvm.NumeroRecarga, 2, 4).Append(' ').Append(rvm.NumeroRecarga, 6, 4).ToString(); lblNumero.Text = formatted + (!String.IsNullOrEmpty(rvm.ContactoRecarga) ? " (" + rvm.ContactoRecarga + ")" : ""); lblMonto.Text = rvm.LsPaquetes(rvm.idoperadora).Where(x => x.idpaquete == rvm.idpaquete).FirstOrDefault().monto.ToString("c", new System.Globalization.CultureInfo("es-MX")); lblFormapago.Text = (rvm.idFormaPago == 1 ? "Monedero" : "Tarjeta"); } if (rvm.Tiporecarga == TipoRecarga.Monedero) { grdRecarga.IsVisible = false; grdMonedero.IsVisible = true; lblMontoMon.Text = rvm.MontoRecargaMonedero.ToString("c", new System.Globalization.CultureInfo("es-MX")); lblRecargaMon.Text = "Recarga de monedero"; lblFormapagoMon.Text = (rvm.idFormaPago == 1 ? "Monedero" : "Tarjeta"); } if (rvm.idFormaPago == 2) { string tipo = ""; if (rvm.TipoTrans == TipoTransaccion.PrimeraVez) { catEmisorTC em = rvm.LsEmisores().Where(x => x.idemisor == tvm.idemisor).FirstOrDefault(); tipo = (em != null ? em.emisor + " " : "") + tvm.NumeroTarjeta.Substring(tvm.NumeroTarjeta.Length - 4, 4); } else { Tarjeta t = App.db.SelTarjetas().Where(x => x.idtarjeta == rvm.IdTarjeta).FirstOrDefault(); catEmisorTC em = rvm.LsEmisores().Where(x => x.idemisor == t.idemisor).FirstOrDefault(); tipo = (em != null ? em.emisor + " " : "") + t.Last4; } if (rvm.Tiporecarga == TipoRecarga.RecargaTA) { lblEmisor.Text = tipo; lblEmisor.IsVisible = true; } if (rvm.Tiporecarga == TipoRecarga.Monedero) { lblEmisorMon.Text = tipo; lblEmisorMon.IsVisible = true; } } else { lblEmisor.IsVisible = false; } }
private void Refresh() { string json = "", formapag = ""; tvm = Session["tvm"] as TarjetasViewModel; json = ws.GetCatalogo(13, "where idusuario = " + Session["idusrlogged"].ToString()); List <RecargaProg> lsRec = JsonConvert.DeserializeObject <List <RecargaProg> >(json); json = ws.GetCatalogo(9, "where idusuario = " + Session["idusrlogged"].ToString()); List <Tarjeta> lsTar = JsonConvert.DeserializeObject <List <Tarjeta> >(json); foreach (RecargaProg r in lsRec) { if (r.idformapago == 1) { formapag = "Monedero"; } if (r.idformapago == 2) { Tarjeta t = lsTar.Where(x => x.idtarjeta == r.idtarjeta).FirstOrDefault(); formapag = tvm.LsEmisores().Where(x => x.idemisor == t.idemisor).FirstOrDefault().emisor + " " + (t != null ? t.last4 : ""); } HtmlTableRow row = new HtmlTableRow(); row.Cells.Add(new HtmlTableCell() { Width = "30%;", InnerHtml = r.numerorecarga }); row.Cells.Add(new HtmlTableCell() { Width = "30%;", InnerHtml = formapag }); row.Cells.Add(new HtmlTableCell() { Width = "30%;", InnerHtml = r.diasmes.Substring(0, r.diasmes.Length - 1) + " de cada mes" }); Label lbldel = new Label(); lbldel.Text = "<a id=\"del" + r.idrecarga.ToString() + "\" class=\"btn default btn-xs bg-black white\" href=\"javascript:borrarecarga(" + r.idrecarga.ToString() + ");\"><i class=\"fa fa-trash\"></i> Borrar recarga</a>"; row.Cells.Add(new HtmlTableCell() { Width = "60%;" }); row.Cells[3].Controls.Add(lbldel); row.Cells.Add(new HtmlTableCell() { Width = "15%;", InnerHtml = "" }); tbTarjetas.Rows.Add(row); } }
/*public event EventHandler<AltaTarjetaCompletedEventArgs> TarjetaAlta; * protected virtual void OnTarjetaAlta(AltaTarjetaCompletedEventArgs ea) * { * var handler = TarjetaAlta; * if (handler != null) * { * handler(this, ea); * } * }*/ /*public void Alta() * { * byte[] cvccrypto = Crypto.EncryptAes(_cvc.ToString(), Settings.PwdCrypto, Crypto.String2ByteArray(Settings.SaltCrypto)); * * Tarjeta t = new Tarjeta() * { * idusuario = _idusuario, * idpais = _idpais, * idemisor = _idemisor, * permtoken = _numerotarjeta, * Last4 = _last4, * titularFN = _titularFN, * titularLN = _titularLN, * calleynumero = _calleynum, * idestado = _idestado, * idciudad = _idciudad, * codigopostal = _cp * }; * EventHandler<AltaTarjetaCompletedEventArgs> atc = null; * atc = (s, ea) => * { * App.WS.AltaTarjetaCompleted -= atc; * if (ea.Error == null && !ea.Cancelled) * { * t.idtarjeta = ea.Result; * App.db.AltaTarjeta(t); * } * Device.BeginInvokeOnMainThread(() => OnTarjetaAlta(ea)); * Device.BeginInvokeOnMainThread(() => OnNuevaTarjeta(null)); * App.WS.Close(); * }; * App.Current.IniciaWS(); * App.WS.AltaTarjetaCompleted += atc; * App.WS.AltaTarjetaAsync(ConvertTarjetaToTemp(t)); * }*/ tempuri.org.Tarjeta ConvertTarjetaToTemp(Tarjeta t) { //string cvccrypto = Crypto.DecryptAes(t.cvv, Settings.PwdCrypto, Crypto.String2ByteArray(Settings.SaltCrypto)); tempuri.org.Tarjeta tot = new tempuri.org.Tarjeta { idusuario = t.idusuario, idpais = t.idpais, idemisor = t.idemisor, permtoken = t.permtoken, Last4 = t.Last4, expirationMMYY = t.expirationMMYY, titularFN = t.titularFN, titularLN = t.titularLN, calleynumero = t.calleynumero, idestado = t.idestado, idciudad = t.idciudad, codigopostal = t.codigopostal }; return(tot); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { int idtarjeta = (int)value; string ret = ""; TarjetasViewModel tvm = new TarjetasViewModel(); if (idtarjeta == -1) { ret = "Monedero"; } else { Tarjeta t = App.db.SelTarjetas().Where(x => x.idtarjeta == idtarjeta).FirstOrDefault(); if (t != null) { catEmisorTC em = tvm.LsEmisores().Where(x => x.idemisor == t.idemisor).FirstOrDefault(); ret = (em != null ? em.emisor + " " : "") + t.Last4; } } return(ret); }
public void AltaTarjeta(Tarjeta item) { lock (locker) { item.titularFN = ""; item.titularLN = ""; item.calleynumero = ""; item.idciudad = 0; item.codigopostal = ""; item.idestado = 0; item.permtoken = ""; item.expirationMMYY = ""; if ((from i in database.Table <Tarjeta>() where i.idtarjeta == item.idtarjeta select i).Count() > 0) { database.Update(item); } else { database.Insert(item); } } }
protected void Page_Load(object sender, EventArgs e) { //-------------------------------------------------------------------------------------------------- int idusr = 0; if (!IsPostBack) { divMenu.InnerHtml = check.GeneraMenu(); if (Session["idusrlogged"] != null) { if (int.TryParse(Session["idusrlogged"].ToString(), out idusr)) { if (idusr > 0) { ws = Session["wsac"] as wsac.IsacClient; string json = ws.GetUser(idusr, "", ""); List <Usuario> lu = JsonConvert.DeserializeObject <List <Usuario> >(json); if (lu.Count > 0) { Session["usrlogged"] = lu.FirstOrDefault(); lblCtaNom.Text = lu.FirstOrDefault().name; if (!String.IsNullOrEmpty(lu.FirstOrDefault().picture)) { imgFoto.ImageUrl = lu.FirstOrDefault().picture; } else { imgFoto.ImageUrl = "assets/images/icono_app.png"; } } else { Response.Redirect("index.aspx"); } } else { Response.Redirect("index.aspx"); } } else { Response.Redirect("index.aspx"); } } } else { if (Request["__EVENTTARGET"] == "lnkSalir") { Session["idusrlogged"] = 0; Session["usrlogged"] = null; Response.Redirect("index.aspx"); Session.Abandon(); Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", "")); } } //-------------------------------------------------------------------------------------------------- btnProgramar.Click += async(s, ea) => { wsac.AltaRecargaProgResponse rr = new wsac.AltaRecargaProgResponse(); string dias = hidDias.Value.Trim(); if (dias.Length > 1) { try { ws = Session["wsac"] as wsac.IsacClient; rvm = Session["rvm"] as RecargasViewModel; tvm = Session["tvm"] as TarjetasViewModel; wsac.RecargaProg rp = new wsac.RecargaProg() { idusuario = rvm.IdUsuario, idpais = rvm.idpais, idoperadora = rvm.idoperadora, idpaquete = rvm.idpaquete, idformapago = rvm.idFormaPago, idtarjeta = (rvm.idFormaPago == 2) ? rvm.IdTarjeta : -1, numerorecarga = rvm.NumeroRecarga, contactorecarga = rvm.ContactoRecarga, diasmes = dias, }; rr = await ws.AltaRecargaProgAsync(rp); if (rr.Body.AltaRecargaProgResult > 0) { spnJS.Text = "<script>programada('Su recarga quedo programada');</script>"; } } catch (Exception ex) { spnJS.Text = "<script>msgError('Ocurrio un error');</script>"; } } else { spnJS.Text = "<script>msgError('Seleccione al menos un dia');</script>"; } }; if (!IsPostBack) { catPais pa = new catPais(); catOperadora op = new catOperadora(); catPaquete cp = new catPaquete(); Tarjeta tar = new Tarjeta(); catEmisorTC em = new catEmisorTC(); string tipo = ""; rvm = Session["rvm"] as RecargasViewModel; tvm = Session["tvm"] as TarjetasViewModel; if (rvm == null) { Response.Redirect("datosrecarga.aspx"); } else { jsonOp = ws.GetCatalogo(1, ""); List <catOperadora> lsoper = JsonConvert.DeserializeObject <List <catOperadora> >(jsonOp); op = lsoper.Where(x => x.idpais == rvm.idpais && x.idoperadora == rvm.idoperadora).FirstOrDefault(); Session["catOperadora"] = op; jsonPa = ws.GetCatalogo(2, ""); List <catPais> lspais = JsonConvert.DeserializeObject <List <catPais> >(jsonPa); pa = lspais.Where(x => x.idpais == rvm.idpais).FirstOrDefault(); jsonPq = ws.GetCatalogo(3, ""); List <catPaquete> lspq = JsonConvert.DeserializeObject <List <catPaquete> >(jsonPq); cp = lspq.Where(x => x.idpaquete == rvm.idpaquete).FirstOrDefault(); Session["catPaquete"] = cp; if (rvm.idFormaPago == 2) { //tarjeta if (rvm.TipoTrans == TipoTransaccion.PrimeraVez) { jsonEmi = ws.GetCatalogo(4, ""); List <catEmisorTC> lsemi = JsonConvert.DeserializeObject <List <catEmisorTC> >(jsonEmi); em = lsemi.Where(x => x.idemisor == tvm.idemisor).FirstOrDefault(); tipo = (em != null ? em.emisor + " " : "") + tvm.NumeroTarjeta.Substring(tvm.NumeroTarjeta.Length - 4, 4); } if (rvm.TipoTrans == TipoTransaccion.SegundaVez) { jsonTar = ws.GetCatalogo(9, "where idusuario = " + Session["idusrlogged"].ToString()); List <Tarjeta> lstar = JsonConvert.DeserializeObject <List <Tarjeta> >(jsonTar); tar = lstar.Where(x => x.idtarjeta == rvm.IdTarjeta).FirstOrDefault(); jsonEmi = ws.GetCatalogo(4, ""); List <catEmisorTC> lsemi = JsonConvert.DeserializeObject <List <catEmisorTC> >(jsonEmi); em = lsemi.Where(x => x.idemisor == tar.idemisor).FirstOrDefault(); tipo = (em != null ? em.emisor + " " : "") + tar.last4; } } string formatted = new StringBuilder(12).Append(rvm.NumeroRecarga, 0, 2).Append(" ").Append(rvm.NumeroRecarga, 2, 4).Append(' ').Append(rvm.NumeroRecarga, 6, 4).ToString(); lblPais.Text = pa.pais; lblNumero.Text = formatted; lblOperadora.Text = op.operadora; lblMonto.Text = cp.monto.ToString("c"); lblFormaPago.Text = (rvm.idFormaPago == 1 ? "Monedero" : "Tarjeta"); if (rvm.idFormaPago == 2) { lblEmisor.Text = tipo; } if (rvm.idFormaPago == 1) { lblTarjTxt.Text = ""; } } } else { if (Request.Form["__EVENTTARGET"] == "programaexito") { Session["rvm"] = null; Session["tvm"] = null; Response.Redirect("datosrecarga.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { //-------------------------------------------------------------------------------------------------- int idusr = 0; if (!IsPostBack) { divMenu.InnerHtml = check.GeneraMenu(); if (Session["idusrlogged"] != null) { if (int.TryParse(Session["idusrlogged"].ToString(), out idusr)) { if (idusr > 0) { ws = Session["wsac"] as wsac.IsacClient; string json = ws.GetUser(idusr, "", ""); List <Usuario> lu = JsonConvert.DeserializeObject <List <Usuario> >(json); if (lu.Count > 0) { Session["usrlogged"] = lu.FirstOrDefault(); lblCtaNom.Text = lu.FirstOrDefault().name; if (!String.IsNullOrEmpty(lu.FirstOrDefault().picture)) { imgFoto.ImageUrl = lu.FirstOrDefault().picture; } else { imgFoto.ImageUrl = "assets/images/icono_app.png"; } } else { Response.Redirect("index.aspx"); } } else { Response.Redirect("index.aspx"); } } else { Response.Redirect("index.aspx"); } } } else { if (Request["__EVENTTARGET"] == "lnkSalir") { Session["idusrlogged"] = 0; Session["usrlogged"] = null; Response.Redirect("index.aspx"); Session.Abandon(); Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", "")); } } //-------------------------------------------------------------------------------------------------- if (!IsPostBack) { catPais pa = new catPais(); catOperadora op = new catOperadora(); catPaquete cp = new catPaquete(); Tarjeta tar = new Tarjeta(); catEmisorTC em = new catEmisorTC(); string tipo = ""; rvm = Session["rvm"] as RecargasViewModel; tvm = Session["tvm"] as TarjetasViewModel; if (rvm == null) { Response.Redirect("datosrecarga.aspx"); } else { jsonOp = ws.GetCatalogo(1, ""); List <catOperadora> lsoper = JsonConvert.DeserializeObject <List <catOperadora> >(jsonOp); op = lsoper.Where(x => x.idpais == rvm.idpais && x.idoperadora == rvm.idoperadora).FirstOrDefault(); Session["catOperadora"] = op; jsonPa = ws.GetCatalogo(2, ""); List <catPais> lspais = JsonConvert.DeserializeObject <List <catPais> >(jsonPa); pa = lspais.Where(x => x.idpais == rvm.idpais).FirstOrDefault(); jsonPq = ws.GetCatalogo(3, ""); List <catPaquete> lspq = JsonConvert.DeserializeObject <List <catPaquete> >(jsonPq); cp = lspq.Where(x => x.idpaquete == rvm.idpaquete).FirstOrDefault(); Session["catPaquete"] = cp; if (rvm.idFormaPago == 2) { //tarjeta if (rvm.TipoTrans == TipoTransaccion.PrimeraVez) { jsonEmi = ws.GetCatalogo(4, ""); List <catEmisorTC> lsemi = JsonConvert.DeserializeObject <List <catEmisorTC> >(jsonEmi); em = lsemi.Where(x => x.idemisor == tvm.idemisor).FirstOrDefault(); tipo = (em != null ? em.emisor + " " : "") + tvm.NumeroTarjeta.Substring(tvm.NumeroTarjeta.Length - 4, 4); } if (rvm.TipoTrans == TipoTransaccion.SegundaVez) { jsonTar = ws.GetCatalogo(9, "where idusuario = " + Session["idusrlogged"].ToString()); List <Tarjeta> lstar = JsonConvert.DeserializeObject <List <Tarjeta> >(jsonTar); tar = lstar.Where(x => x.idtarjeta == rvm.IdTarjeta).FirstOrDefault(); jsonEmi = ws.GetCatalogo(4, ""); List <catEmisorTC> lsemi = JsonConvert.DeserializeObject <List <catEmisorTC> >(jsonEmi); em = lsemi.Where(x => x.idemisor == tar.idemisor).FirstOrDefault(); tipo = (em != null ? em.emisor + " " : "") + tar.last4; } } lblMonto.Text = rvm.MontoRecargaMonedero.ToString("c"); lblFormaPago.Text = (rvm.idFormaPago == 1 ? "Monedero" : "Tarjeta"); if (rvm.idFormaPago == 2) { lblEmisor.Text = tipo; } } } else { if (Request.Form["__EVENTTARGET"] == "recargaexito") { Session["rvm"] = null; Session["tvm"] = null; Response.Redirect("monedero.aspx"); } } btnCancel.Click += (s, ea) => { Response.Redirect("monedero.aspx"); }; txtNip4.TextChanged += async(s, ea) => { string nip = Request.Form["__EVENTARGUMENT"].ToString(); Usuario u = Session["usrlogged"] as Usuario; if (u.nip == nip) { await Recargar(); } else { spnJS.Text = "<script>msgError('NIP invalido. Vuelva a intentar');</script>"; } }; }