Example #1
0
        public void btnAcceso_Click(Object sender, EventArgs e)
        {
            string str_email = email.Value;
            string str_Nip   = NIP.Value;

            Session["fallo"] = null;

            if (!string.IsNullOrEmpty(str_email) && !string.IsNullOrEmpty(str_Nip))
            {
                ws = Session["wsac"] as wsac.IsacClient;
                string json             = ws.GetAdmin(0, check.SafeSqlLiteral(str_email), check.SafeSqlLiteral(str_Nip));
                List <administrador> lu = JsonConvert.DeserializeObject <List <administrador> >(json);

                if (lu.Count > 0)
                {
                    Session["idadminlogged"] = lu.FirstOrDefault().idadministrador;
                    Session["adminlogged"]   = lu.FirstOrDefault();
                    Response.Redirect("recargas_historial_admin.aspx");
                }
                else
                {
                    Session["fallo"] = "1";
                    Response.Redirect("login_admin.aspx");
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int idusr = 0;

            if (!IsPostBack)
            {
                if (Session["idadminlogged"] != null)
                {
                    if (int.TryParse(Session["idadminlogged"].ToString(), out idusr))
                    {
                        if (idusr > 0)
                        {
                            ws = Session["wsac"] as wsac.IsacClient;
                            //string json = ws.GetCatalogo(15, "where idadministrador = " + idusr + "");
                            string json             = ws.GetAdmin(idusr, "", "");
                            List <administrador> lu = JsonConvert.DeserializeObject <List <administrador> >(json);
                            if (lu.Count > 0)
                            {
                                Session["adminlogged"] = lu.FirstOrDefault();
                                loadoperadora();
                                loadpaquete(null);
                                getoperadora(" ");
                                GridView2.Visible = false;
                            }
                            else
                            {
                                Response.Redirect("login_admin.aspx");
                            }
                        }
                        else
                        {
                            Response.Redirect("login_admin.aspx");
                        }
                    }
                    else
                    {
                        Response.Redirect("login_admin.aspx");
                    }
                }
            }
            else
            {
                if (Request["__EVENTTARGET"] == "lnkSalir")
                {
                    Session["idadminlogged"] = 0;
                    Session["usrlogged"]     = null;
                    Response.Redirect("index.aspx");
                    Session.Abandon();
                    Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));
                }
            }
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //--------------------------------------------------------------------------------------------------
            int idusr = 0;

            if (!IsPostBack)
            {
                if (Session["idadminlogged"] != null)
                {
                    if (int.TryParse(Session["idadminlogged"].ToString(), out idusr))
                    {
                        if (idusr > 0)
                        {
                            ws = Session["wsac"] as wsac.IsacClient;
                            string         json = ws.GetAdmin(idusr, "", "");
                            List <Usuario> lu   = JsonConvert.DeserializeObject <List <Usuario> >(json);
                            if (lu.Count > 0)
                            {
                                Session["adminlogged"] = 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["idadminlogged"] = 0;
                    Session["adminlogged"]   = null;
                    Response.Redirect("index.aspx");
                    Session.Abandon();
                    Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));
                }
            }

            //-------------------------------------------------------------------------------------------------
            if (!IsPostBack)
            {
                ws = Session["wsac"] as wsac.IsacClient;
                if (tvm == null)
                {
                    tvm            = new TarjetasViewModel();
                    Session["tvm"] = tvm;
                }
                tvm.WS = ws;
                tvm.Inicia();
                //if (Session["rvm"] == null)
                //    Response.Redirect("datosrecarga.aspx");
                //else
                //    Refresh();
            }
            else
            {
                if (Request.Form["__EVENTTARGET"] == "delrec")
                {
                    int idr = int.Parse(Request.Form["__EVENTARGUMENT"].ToString());
                    ws = Session["wsac"] as wsac.IsacClient;
                    if (ws.EliminaRecProg(idr))
                    {
                        Response.Redirect("histrecprog.aspx");
                    }
                }
            }
            btnExcel.Click += (s, ea) =>
            {
                DateTime dtini = DateTime.MinValue; DateTime dtfin = DateTime.MinValue;
                if (DateTime.TryParseExact(fini.Value, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dtini) && DateTime.TryParseExact(ffin.Value, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dtfin))
                {
                    DumpExcel(dtini.ToString("yyyyMMdd"), dtfin.ToString("yyyyMMdd"));
                    spnJS.Text = "";
                }
                else
                {
                    spnJS.Text = "<script>msgError('Faltan fecha de inicio y fin');</script>";
                }
            };
            btnConsultar.Click += (s, ea) =>
            {
                DateTime dtini = DateTime.MinValue; DateTime dtfin = DateTime.MinValue;
                if (DateTime.TryParseExact(fini.Value, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dtini) && DateTime.TryParseExact(ffin.Value, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dtfin))
                {
                    Refresh(dtini.ToString("yyyyMMdd"), dtfin.ToString("yyyyMMdd"));
                    spnJS.Text = "";
                }
                else
                {
                    spnJS.Text = "<script>msgError('Faltan fecha de inicio y fin');</script>";
                }
            };
        }