Esempio n. 1
0
        public static void GetPerfil()
        {
            //Tratamos de conseguir el perfil offline
            string JsonResult = UtilsAppsNica.GetOnePreference("PerfilJson");

            if (!(JsonResult == null))
            {
                UserPerfil = Newtonsoft.Json.JsonConvert.DeserializeObject <Perfil>(UtilsAppsNica.GetOnePreference("PerfilJson"));
            }
            else
            {
                //sino hay datos offile nos conectamos al  API
                if (LoginResult == null)
                {
                    LoginResult.tokenDelUsuario = UtilsAppsNica.GetOnePreference("Token");
                }

                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", LoginResult.tokenDelUsuario);
                var response = client.GetAsync("https://sigi.unan.edu.ni/RAServices/Api/PortalEstudiante/GetPortal");

                JsonResult = response.Result.Content.ReadAsStringAsync().Result;
                UtilsAppsNica.SaveOnePreference("PerfilJson", JsonResult);

                UserPerfil = Newtonsoft.Json.JsonConvert.DeserializeObject <Perfil>(JsonResult);
            }
        }
Esempio n. 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.cuenta);
            btnatras        = FindViewById <ImageButton>(Resource.Id.imageButton2);
            btnatras.Click += Btnatras_Click;


            FindViewById <TextView>(Resource.Id.txtnombre).Text = ClienteApi.UserPerfil.Nombres + " " + ClienteApi.UserPerfil.Apellidos;
            if (ClienteApi.GetEstadoCuenta())
            {
                creditos = ClienteApi.Cuentas.Where(x => x.CodigoDelTipoDeMovimiento == "C").Sum(x => x.Monto);
                abonos   = ClienteApi.Cuentas.Where(x => x.CodigoDelTipoDeMovimiento == "A").Sum(x => x.Monto);
                saldo    = creditos - abonos;
                FindViewById <TextView>(Resource.Id.txtcreditos).Text = "Total créditos: C$ " + creditos;
                FindViewById <TextView>(Resource.Id.txtabonos).Text   = "Total abonos: C$ " + abonos;
                FindViewById <TextView>(Resource.Id.txttotal).Text    = "C$ " + saldo;

                FindViewById <ListView>(Resource.Id.lvmovimientos).Adapter = new Adaptermovimientos(this, ClienteApi.Cuentas);
            }
            else
            {
                UtilsAppsNica.Msg(this, ClienteApi.error);
            }
        }
Esempio n. 3
0
 private void Btnsalir_Click(object sender, EventArgs e)
 {
     // UtilsAppsNica.Alerta(this, "Logout", "Quiere cerrar la sesion?");
     //remover credenciales
     UtilsAppsNica.ClearLoginPreferences();
     band = false;
     UtilsAppsNica.RestartApp(this);
 }
Esempio n. 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.panelestudiante);
            //UtilsAppsNica.SetHeader(this,  Color.ParseColor( GetString(Resource.Color.colorFondoPanel)));
            CargarDatos();
            btnatras = FindViewById <ImageButton>(Resource.Id.btnback);
            btnsalir = FindViewById <ImageButton>(Resource.Id.btnlogout);

            btnatras.Click += Btnatras_Click;
            btnsalir.Click += Btnsalir_Click;

            btnperfil        = FindViewById <ImageButton>(Resource.Id.btnperfil);
            btnperfil.Click += Btnperfil_Click;
            btnplan          = FindViewById <ImageButton>(Resource.Id.btnplan);

            btncuenta        = FindViewById <ImageButton>(Resource.Id.btncuenta);
            btncuenta.Click += Btncuenta_Click;
            btnbeca          = FindViewById <ImageButton>(Resource.Id.btnbeca);

            btnmatricula = FindViewById <ImageButton>(Resource.Id.btnmatricula);
            btncal       = FindViewById <ImageButton>(Resource.Id.btncal);

            btncal.Click += Btncal_Click;


            btncamera        = FindViewById <ImageButton>(Resource.Id.btncamera);
            btncamera.Click += Btncamera_Click;

            btnmarca        = FindViewById <ImageButton>(Resource.Id.btnmarca);
            btnmarca.Click += Btnmarca_Click;

            photo        = FindViewById <ImageView>(Resource.Id.profile_image);
            photo.Click += Photo_Click;

            string sphoto = UtilsAppsNica.GetOnePreference("photo");

            //vericando si hay foto en las preferencias y mostrandola
            if (sphoto != null)
            {
                byte[] imageAsBytes = Base64.Decode(sphoto, Base64Flags.Default);
                Bitmap bitmap2      = BitmapFactory.DecodeByteArray(imageAsBytes, 0, imageAsBytes.Length);

                BitmapDrawable ob = new BitmapDrawable(bitmap2);
                photo.SetBackgroundDrawable(ob);
            }
        }
Esempio n. 5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.home);
            btnentrar = FindViewById <Button>(Resource.Id.button1);
            btnlogin  = FindViewById <Button>(Resource.Id.btnlogin);
            btnsalir  = FindViewById <Button>(Resource.Id.btnlogout);

            btnagenda = FindViewById <ImageButton>(Resource.Id.imageButton2);
            btninfo   = FindViewById <ImageButton>(Resource.Id.imageButton3);

            //Panel logeo y panel usuario logeado
            cplogin = FindViewById <LinearLayout>(Resource.Id.cplogin);
            cpuser  = FindViewById <LinearLayout>(Resource.Id.cpuser);

            btnagenda.Click += Btnagenda_Click;
            btninfo.Click   += Btninfo_Click;

            btnentrar.Click += Btnentrar_Click;
            //Toast.MakeText(this, "Datos ", ToastLength.Long).Show();

            btnlogin.Click += Btnlogin_Click;
            btnsalir.Click += Btnsalir_Click;

            if (UtilsAppsNica.GetOnePreference("User") != null)
            {
                band = true;
            }

            if (!band)
            {
                cplogin.Visibility = ViewStates.Visible;
                cpuser.Visibility  = ViewStates.Invisible;
            }
            else
            {
                cplogin.Visibility = ViewStates.Invisible;
                cpuser.Visibility  = ViewStates.Visible;
                ClienteApi.GetPerfil();
                btnlogin.Text = "Entrar como " + ClienteApi.UserPerfil.Nombres;
            }
        }
Esempio n. 6
0
        private void Btnentrar_Click(object sender, EventArgs e)
        {
            string carnet = FindViewById <EditText>(Resource.Id.editText1).Text;
            string clave  = FindViewById <EditText>(Resource.Id.editText2).Text;

            Toast.MakeText(this, "Datos hola " + clave, ToastLength.Long).Show();
            if (ClienteApi.GetPostToken(carnet, clave))
            {
                //Guardar credenciales
                UtilsAppsNica.SaveLoginPreferences(carnet, clave);
                UtilsAppsNica.SaveOnePreference("Token", ClienteApi.LoginResult.tokenDelUsuario);
                band = true;
                UtilsAppsNica.RestartApp(this);
            }
            else
            {
                UtilsAppsNica.Msg(this, ClienteApi.error);
            }
        }
Esempio n. 7
0
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            Bitmap bitmap = (Bitmap)data.Extras.Get("data");

            //Bitmap to Byte
            using (var stream = new MemoryStream())
            {
                bitmap.Compress(Bitmap.CompressFormat.Png, 0, stream);
                bitmapData = stream.ToArray();
            }

            //Byte to bitmap
            Bitmap         bitmap2 = BitmapFactory.DecodeByteArray(bitmapData, 0, bitmapData.Length);
            BitmapDrawable ob      = new BitmapDrawable(bitmap2);

            photo.SetBackgroundDrawable(ob);

            //Guardar foto como cadena de caracteres
            UtilsAppsNica.SaveOnePreference("photo", Base64.EncodeToString(bitmapData, Base64Flags.Default));
        }
Esempio n. 8
0
 private void Btnsalir_Click(object sender, EventArgs e)
 {
     //remover credenciales
     UtilsAppsNica.ClearLoginPreferences();
     UtilsAppsNica.RestartApp(this);
 }