示例#1
0
 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;
     }
 }
示例#2
0
        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);
        }
示例#3
0
        protected virtual void OnNuevaTarjeta(NuevaTarjetaEventArgs e)
        {
            var handler = NuevaTarjeta;

            if (handler != null)
            {
                string tipo = "";
                _lt.Clear();
                foreach (Tarjeta t in App.db.SelTarjetas())
                {
                    catEmisorTC em = LsEmisores().Where(x => x.idemisor == t.idemisor).FirstOrDefault();
                    tipo = (em != null ? em.emisor + " " : "") + t.Last4;
                    _lt.Add(new TipoPago()
                    {
                        idtipo = 2, extra = t.idtarjeta, tipo = tipo, saldo = 0, imgtipo = (em != null ? em.img : "")
                    });
                }
                handler(this, new NuevaTarjetaEventArgs {
                    lista = _lt
                });
            }
        }
示例#4
0
        public void RefreshMedios()
        {
            _lm = new ObservableCollection <TipoPago>();
            _lt = new ObservableCollection <TipoPago>();
            if (App.db.SelSaldo() == null)
            {
                App.db.IniciaMonedero();
            }
            _lm.Add(new TipoPago()
            {
                idtipo = 1, tipo = "Saldo", saldo = App.db.SelSaldo().saldo
            });
            string tipo = "";

            foreach (Tarjeta t in App.db.SelTarjetas())
            {
                catEmisorTC em = LsEmisores().Where(x => x.idemisor == t.idemisor).FirstOrDefault();
                tipo = (em != null ? em.emisor + " " : "") + t.Last4;
                _lt.Add(new TipoPago()
                {
                    idtipo = 2, extra = t.idtarjeta, tipo = tipo, saldo = 0, imgtipo = (em != null ? em.img : "")
                });
            }
        }
示例#5
0
        public TarjetasViewModel()
        {
            _opcpais = new opcMenu(1, 0, "País", "Seleccione un país", new FileImageSource()
            {
                File = "globe.png"
            });
            if (App.usr.idpais != 0)
            {
                _opcpais.idOpcion = App.usr.idpais;
                _opcpais.Desc     = lsPais().Where(x => x.idpais == App.usr.idpais).FirstOrDefault().pais;
            }
            _opcemisor = new opcMenu(2, 0, "Tipo tarjeta", "Seleccione emisor", new FileImageSource()
            {
                File = "mastercard.png"
            });
            _opcnumero = new opcMenu(3, 0, "Número de tarjeta", "Seleccione un número", new FileImageSource()
            {
                File = "creditcard.png"
            });
            _opcfecha = new opcMenu(4, 0, "Fecha", "Seleccione un monto", new FileImageSource()
            {
                File = "cal.png"
            });
            _opctitular = new opcMenu(5, 0, "Titular", "Seleccione un cupon", new FileImageSource()
            {
                File = "idcard.png"
            });
            _opcscannear = new opcMenu(6, 0, "Escanear", "Escanear tarjeta", new FileImageSource()
            {
                File = "camera.png"
            });
            _opccalle = new opcMenu(7, 0, "Dirección", "Calle y número", new FileImageSource()
            {
                File = "house.png"
            });
            _opcestado = new opcMenu(8, 0, "Estado", "Seleccione estado", new FileImageSource()
            {
                File = "globe.png"
            });
            _opcciudad = new opcMenu(9, 0, "Ciudad", "Seleccione ciudad", new FileImageSource()
            {
                File = "globe.png"
            });
            _opccp = new opcMenu(10, 0, "Código postal", "Código postal", new FileImageSource()
            {
                File = "mappin.png"
            });

            _lm = new ObservableCollection <TipoPago>();
            _lt = new ObservableCollection <TipoPago>();
            if (App.db.SelSaldo() == null)
            {
                App.db.IniciaMonedero();
            }
            _lm.Add(new TipoPago()
            {
                idtipo = 1, tipo = "Saldo", saldo = App.db.SelSaldo().saldo
            });
            string tipo = "";

            foreach (Tarjeta t in App.db.SelTarjetas())
            {
                catEmisorTC em = LsEmisores().Where(x => x.idemisor == t.idemisor).FirstOrDefault();
                tipo = (em != null ? em.emisor + " " : "") + t.Last4;
                _lt.Add(new TipoPago()
                {
                    idtipo = 2, extra = t.idtarjeta, tipo = tipo, saldo = 0, imgtipo = (em != null ? em.img : "")
                });
            }
        }
示例#6
0
        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>";
                }
            };
        }