Example #1
0
        private void MprofileTracker_mOnProfileChanged(object sender, OnProfileChangedEventArgs e)
        {
            if (e.mProfile != null)
            {
                try
                {
                    Profile p    = e.mProfile;
                    int     idUS = bd.loginfacebook(p.Id);
                    if (idUS != 0)//consulta para iniciar sesion
                    {
                        Intent i   = new Intent(this, typeof(Inicio));
                        string aux = Convert.ToString(idUS);
                        i.PutExtra("idUs", aux);
                        StartActivity(i);
                    }
                    else
                    {
                        AlertDialog alerta = new AlertDialog.Builder(this).Create();
                        alerta.SetTitle("Error ");
                        alerta.SetMessage("FB no esta enlazado a ninguna cuenta de usuario");
                        alerta.SetButton("Aceptar", (a, b) => { });
                        alerta.Show();
                    }

                    // tengo que crear el layout del  config y pasar los datos a una sesion para almacenarlos entre pestañas
                }
                catch (Java.Lang.Exception ex) { }
            }
            else
            {
            }
        }
Example #2
0
        private void BtnLogin_Click(object sender, EventArgs e)//login normal
        {
            try
            {
                string correo = correoLogin.Text;
                string pass   = passLogin.Text;
                int    aux    = 0;
                aux = bd.LoginNormal(correo, pass).Idusuario;

                if (aux != 0)
                {
                    Intent i = new Intent(this, typeof(MainActivity));
                    i.PutExtra("idUs", Convert.ToString(aux));
                    StartActivity(i);
                }
                else
                {
                    AlertDialog alerta = new AlertDialog.Builder(this).Create();
                    alerta.SetTitle("Error ");
                    alerta.SetMessage("El usuario o la contraseña son incorrectos. Compruebe su conexion a internet");
                    alerta.SetButton("Aceptar", (a, b) => { });
                    alerta.Show();
                }
            }
            catch (Exception ex)
            {
                AlertDialog alerta = new AlertDialog.Builder(this).Create();
                alerta.SetTitle("Error ");
                alerta.SetMessage(ex.Message);
                alerta.SetButton("Aceptar", (a, b) => { });
                alerta.Show();
            }
        }
Example #3
0
        // Display that there's not enough questions to play the game and redirect to the `ListQuestionsActivity`.
        private void ShowNotEnoughQuestionsAlert()
        {
            AlertDialog notEnoughQuestionsAlert = new AlertDialog.Builder(this).Create();

            notEnoughQuestionsAlert.SetCanceledOnTouchOutside(false);
            notEnoughQuestionsAlert.SetMessage(string.Format("Sorry, you don't have enough questions to play this game! Please add at least {0} using the 'MANAGE QUESTIONS' section", minNumberOfQuestions));
            notEnoughQuestionsAlert.SetButton("Okay", (sender, args) => { StartActivity(typeof(ListQuestionsActivity)); Finish(); });
            notEnoughQuestionsAlert.Show();
        }
Example #4
0
        private void ItemLongClicked(object sender, AdapterView.ItemLongClickEventArgs args)
        {
            var contact = contacts[args.Position];

            var alert = new AlertDialog.Builder(this).Create();

            alert.SetTitle("Delete");
            alert.SetMessage(string.Format("Are you sure to delete {0}?", contact.Name));

            alert.SetButton("Yes", delegate
            {
                contacts.Remove(contact);
                adapter.NotifyDataSetChanged();
            });
            alert.SetButton2("No", delegate
            {
            });

            alert.Show();
        }
Example #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            try
            {
                SidUs = (Intent.GetStringExtra("idUs"));
                idUS  = Convert.ToInt32(SidUs);
            }
            catch (Exception ex)
            {
                AlertDialog alerta = new AlertDialog.Builder(this).Create();
                alerta.SetTitle("Error ");
                alerta.SetMessage(ex.Message + "'asdasd'");
                alerta.SetButton("Aceptar", (a, b) => { });
                alerta.Show();
            }



            BottomNavigationView navigation = FindViewById <BottomNavigationView>(Resource.Id.navigation);

            navigation.SetOnNavigationItemSelectedListener(this);
            frame = FindViewById <FrameLayout>(Resource.Id.frameLayout);
            this.SetTitle(Resource.String.app_name);//nombre por defecto

            /// tengo que pasar el id

            Bundle bundle = new Bundle();

            bundle.PutString("idUs", SidUs);
            Inicio fragInfo = new Inicio();

            fragInfo.Arguments = bundle;
            var trans = SupportFragmentManager.BeginTransaction();

            trans.Replace(Resource.Id.frameLayout, fragInfo);
            trans.Commit();
        }
Example #6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.configCuenta);
            BtnFBLogin = FindViewById <LoginButton>(Resource.Id.fb_btn2);

            try
            {
                SiduS = (Intent.GetStringExtra("idUs"));
                idUS  = Convert.ToInt32(SiduS);
            }
            catch (Exception ex)
            {
                AlertDialog alerta = new AlertDialog.Builder(this).Create();
                alerta.SetTitle("Error ");
                alerta.SetMessage(ex.Message + "'asdasd'");
                alerta.SetButton("Aceptar", (a, b) => { });
                alerta.Show();
            }

            us = new Usuario();
            us = crus.mostrarDatosUsuario(idUS);


            var btnModificar = FindViewById <Button>(Resource.Id.btnModificar);

            txtNombre   = FindViewById <EditText>(Resource.Id.txtNombre);
            txtApellido = FindViewById <EditText>(Resource.Id.txtApellido);
            txtRut      = FindViewById <EditText>(Resource.Id.txtRut);


            txtContraseña    = FindViewById <EditText>(Resource.Id.txtPass);
            txtConfirmContra = FindViewById <EditText>(Resource.Id.txtConfirmPass);
            txtCorreo        = FindViewById <EditText>(Resource.Id.txtCorreo);
            txtConfirmCorreo = FindViewById <EditText>(Resource.Id.txtconfirmCorreo);
            txtFecNac        = FindViewById <Button>(Resource.Id.btnFecNac);

            spinnerTipoPrevision = FindViewById <Spinner>(Resource.Id.SpinnerTipoPre);
            spinnerPrevision     = FindViewById <Spinner>(Resource.Id.SpinnerPre);
            spinnerTipoSangre    = FindViewById <Spinner>(Resource.Id.SpinnerTipoSangre);
            spinnerFactorRh      = FindViewById <Spinner>(Resource.Id.SpinnerFactorRh);
            spinnerRegion        = FindViewById <Spinner>(Resource.Id.SpinnerRegion);
            spinnerCiudad        = FindViewById <Spinner>(Resource.Id.SpinnerCiudad);
            spinnerComuna        = FindViewById <Spinner>(Resource.Id.SpinnerComuna);
            spinnerTipoDiabetes  = FindViewById <Spinner>(Resource.Id.SpinnerTipoDiabetes);


            //carga de datos
            txtNombre.Text        = us.Nombre;
            txtApellido.Text      = us.Apellido;
            txtRut.Text           = us.Rut;
            txtCorreo.Text        = us.Uss;
            txtConfirmCorreo.Text = us.Uss;
            txtFecNac.Text        = us.FNac.ToShortDateString();



            //Spinners relacionados con isapres y fonasa

            spinnerTipoPrevision.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelectedPrev);
            var adapter = ArrayAdapter.CreateFromResource(
                this, Resource.Array.Dropdown_arraysTipoPrev, Android.Resource.Layout.SimpleSpinnerItem);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinnerTipoPrevision.Adapter = adapter;
            spinnerTipoPrevision.SetSelection(us.Fk_tipoPrevision - 1);


            //Spinner relacionados con tipo sangre
            spinnerTipoSangre.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelectedTipoSangre);
            var adapter2 = ArrayAdapter.CreateFromResource(
                this, Resource.Array.Dropdown_arraysTiposangre, Android.Resource.Layout.SimpleSpinnerItem);

            adapter2.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinnerTipoSangre.Adapter = adapter2;
            spinnerTipoSangre.SetSelection(us.Fk_TipoSangre - 1);

            //
            //Spinner Relacionado con factor Rh
            spinnerFactorRh.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelectedFactorRh);
            var adapter3 = ArrayAdapter.CreateFromResource(
                this, Resource.Array.Dropdown_arraysfactorRh, Android.Resource.Layout.SimpleSpinnerItem);

            adapter3.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinnerFactorRh.Adapter = adapter3;
            spinnerFactorRh.SetSelection(us.Fk_FactorRh - 1);

            //Spinner Region
            try
            {
                spinnerRegion.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelectedRegion);
                var adapterRegion = ArrayAdapter.CreateFromResource(
                    this, Resource.Array.Dropdown_arraysRegion, Android.Resource.Layout.SimpleSpinnerItem);
                adapterRegion.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
                spinnerRegion.Adapter = adapterRegion;
                spinnerRegion.SetSelection(us.Comuna.IdRegion - 1);
            }
            catch (Exception)
            {
                throw;
            }



            //Spinner Tipo Diabetes
            spinnerTipoDiabetes.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelectedTipoDiabetes);
            var adapterDiabetes = ArrayAdapter.CreateFromResource(
                this, Resource.Array.Dropdown_arraystipoDiabetes, Android.Resource.Layout.SimpleSpinnerItem);

            adapterDiabetes.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinnerTipoDiabetes.Adapter = adapterDiabetes;
            spinnerTipoDiabetes.SetSelection(us.Fk_Eferglucosa - 1);



            //Spinner Comuna
            // spinnerComuna.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_ItemSelectedComuna);
            // var adapterComuna = ArrayAdapter.CreateFromResource(
            // this, Resource.Array.Dropdown_arraysComunasSantiago, Android.Resource.Layout.SimpleSpinnerItem);
            // adapterComuna.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            //spinnerComuna.Adapter = adapterComuna;


            btnModificar.Click += BtnModificar_Click;

            //llamada a botones
            txtFecNac.Click += Fecha_Click;

            try
            {
                //carga de datos
                txtNombre.Text   = us.Nombre;
                txtApellido.Text = us.Apellido;
                txtRut.Text      = us.Rut;
                //spinnerRegion.SetSelection(us.Comuna.IdRegion);
                // spinnerCiudad.SetSelection(us.Comuna.IdCiudad);
                // spinnerComuna.SetSelection(us.Comuna.IdComuna);
            }
            catch (Exception ex)
            {
                string toast = string.Format("Error: {0}", ex.Message);
                Toast.MakeText(this, toast, ToastLength.Long).Show();;
            }
        }
Example #7
0
        private void BtnModificar_Click(object sender, EventArgs e)
        {
            try
            {
                Usuario us = new Usuario();

                //inicio validacion correo
                if (txtCorreo.Text == txtConfirmCorreo.Text)
                {
                    us.Uss = txtCorreo.Text;
                    //if validacion contraseña
                    if (txtContraseña.Text == txtConfirmContra.Text && txtContraseña.Text.Length > 1 && txtConfirmContra.Text.Length > 1)
                    {
                        us.Pass = txtContraseña.Text;

                        //if validacion fecha nac
                        if (txtFecNac.Text != null)
                        {
                            us.FNac = Convert.ToDateTime(txtFecNac.Text);

                            //ingreso restos de datos
                            //validacion rut
                            us.Rut = txtRut.Text;
                            //validacionfb
                            us.IdFacebook = idFacebook;
                            //validacion Comuna
                            Comuna c = new Comuna();
                            c.IdComuna = idComunaActivity;
                            us.Comuna  = c;
                            //validacion tipo usuario normal
                            us.Fk_TipoU = 1;
                            //validacion tipo prevision.
                            us.Fk_idPrevision = idPrevision;
                            //validacion tipo de diabetes
                            us.Fk_Eferglucosa = idtipoDiabetes;
                            //fk tipo de sangre
                            us.Fk_TipoSangre = idTipoSangre;
                            //fk factor Rh
                            us.Fk_FactorRh = idFactorRh;
                            //nombre y apellido
                            us.Nombre   = txtNombre.Text;
                            us.Apellido = txtApellido.Text;

                            CrudUsuario cu = new CrudUsuario();

                            if (cu.modificarUsuario(us, idUS))
                            {
                                AlertDialog alerta = new AlertDialog.Builder(this).Create();
                                alerta.SetTitle("Registro ");
                                alerta.SetMessage("Cuenta Modificada correctamente!");
                                alerta.SetButton("Aceptar", (a, b) =>
                                {
                                    Intent i = new Intent(this, typeof(Login));
                                    StartActivity(i);
                                });
                                alerta.Show();
                            }
                            else
                            {
                                AlertDialog alerta = new AlertDialog.Builder(this).Create();
                                alerta.SetTitle("Registro ");
                                alerta.SetMessage("A ocurrido un error al modificar");
                                alerta.SetButton("Aceptar", (a, b) =>
                                {
                                });
                                alerta.Show();
                            }
                        }
                        else
                        {
                            AlertDialog alerta = new AlertDialog.Builder(this).Create();
                            alerta.SetTitle("Registro ");
                            alerta.SetMessage("Debe ingresar alguna fecha de nacimiento");
                            alerta.SetButton("Aceptar", (a, b) =>
                            {
                            });
                            alerta.Show();
                        }
                    }
                    else if (txtContraseña.Text.Length == 0 && txtConfirmContra.Text.Length == 0)
                    {
                        us.Pass = "";
                        //if validacion fecha nac
                        if (txtFecNac.Text != null)
                        {
                            us.FNac = Convert.ToDateTime(txtFecNac.Text);

                            //ingreso restos de datos
                            //validacion rut
                            us.Rut = txtRut.Text;
                            //validacionfb
                            us.IdFacebook = idFacebook;
                            //validacion Comuna
                            Comuna c = new Comuna();
                            c.IdComuna = idComunaActivity;
                            us.Comuna  = c;
                            //validacion tipo usuario normal
                            us.Fk_TipoU = 1;
                            //validacion tipo prevision.
                            us.Fk_idPrevision = idPrevision;
                            //validacion tipo de diabetes
                            us.Fk_Eferglucosa = idtipoDiabetes; //problemas aca
                            //fk tipo de sangre
                            us.Fk_TipoSangre = idTipoSangre;
                            //fk factor Rh
                            us.Fk_FactorRh = idFactorRh;
                            //nombre y apellido
                            us.Nombre   = txtNombre.Text;
                            us.Apellido = txtApellido.Text;

                            CrudUsuario cu = new CrudUsuario();

                            if (cu.modificarUsuario(us, idUS))
                            {
                                AlertDialog alerta = new AlertDialog.Builder(this).Create();
                                alerta.SetTitle("Registro ");
                                alerta.SetMessage("Cuenta Modificada correctamente!");
                                alerta.SetButton("Aceptar", (a, b) =>
                                {
                                    Intent i = new Intent(this, typeof(MainActivity));
                                    i.PutExtra("idUs", SiduS);
                                    StartActivity(i);
                                    Finish();
                                });
                                alerta.Show();
                            }
                            else
                            {
                                AlertDialog alerta = new AlertDialog.Builder(this).Create();
                                alerta.SetTitle("Registro ");
                                alerta.SetMessage("A ocurrido un error al modificar");
                                alerta.SetButton("Aceptar", (a, b) =>
                                {
                                });
                                alerta.Show();
                            }
                        }
                    }
                    else
                    {
                        AlertDialog alerta = new AlertDialog.Builder(this).Create();
                        alerta.SetTitle("Registro ");
                        alerta.SetMessage("Los campos “Correo” y “Confirmar correo” deben ser iguales.");
                        alerta.SetButton("Aceptar", (a, b) =>
                        {
                        });
                        alerta.Show();
                    }
                }
                else
                {
                    AlertDialog alerta = new AlertDialog.Builder(this).Create();
                    alerta.SetTitle("Registro ");
                    alerta.SetMessage("Los campos “Correo” y “Confirmar correo” deben ser iguales.");
                    alerta.SetButton("Aceptar", (a, b) =>
                    {
                    });
                    alerta.Show();
                }
            }
            catch (Exception ex)
            {
                AlertDialog alerta = new AlertDialog.Builder(this).Create();
                alerta.SetTitle("A ocurrido un error al momento de crear la cuenta. ");
                alerta.SetMessage(ex.Message);
                alerta.SetButton("Aceptar", (a, b) => { });
                alerta.Show();;
            }
        }
Example #8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.agregar);
            btn_agregar        = FindViewById <Button>(Resource.Id.button1);
            btn_agregar.Click += Btn_agregar_ClickAsync;
            this.SetTitle(Resource.String.app_name_add);
            try
            {
                SidUs = (Intent.GetStringExtra("idUs"));
                idUS  = Convert.ToInt32(SidUs);
            }
            catch (Exception ex)
            {
                AlertDialog alerta = new AlertDialog.Builder(this).Create();
                alerta.SetTitle("Error ");
                alerta.SetMessage(ex.Message + "'asdasd'");
                alerta.SetButton("Aceptar", (a, b) => { });
                alerta.Show();
            }

            btnfecha        = FindViewById <Button>(Resource.Id.fecha);
            btnfecha.Click += BtnFecha_Click;

            btnDesayunoAntes        = FindViewById <Button>(Resource.Id.btnDesayunoAntes);
            btnDesayunoAntes.Click += BtnDesayunoAntes_Click;
            txt_des_antes           = FindViewById <EditText>(Resource.Id.txt_des_antes);

            btnDesayunoDespues        = FindViewById <Button>(Resource.Id.btnDesayunoDespues);
            btnDesayunoDespues.Click += BtnDesayunoDespues_Click;
            txt_des_Des = FindViewById <EditText>(Resource.Id.txt_des_Des);

            btnAlmuerzoAntes        = FindViewById <Button>(Resource.Id.btnAlmuerzoAntes);
            btnAlmuerzoAntes.Click += BtnAlmuerzoAntes_Click;
            txt_alm_antes           = FindViewById <EditText>(Resource.Id.txt_alm_antes);

            btnAlmuerzoDespues        = FindViewById <Button>(Resource.Id.btnAlmuerzoDespues);
            btnAlmuerzoDespues.Click += BtnAlmuerzoDespues_Click;
            txt_alm_des = FindViewById <EditText>(Resource.Id.txt_alm_des);

            btnAntesCena        = FindViewById <Button>(Resource.Id.btnAntesCena);
            btnAntesCena.Click += BtnAntesCena_Click;
            Txt_cen_Antes       = FindViewById <EditText>(Resource.Id.Txt_cen_Antes);

            btnDespuesCena        = FindViewById <Button>(Resource.Id.btnDespuesCena);
            btnDespuesCena.Click += BtnDespuesCena_Click;
            Txt_cen_Despues       = FindViewById <EditText>(Resource.Id.Txt_cen_Despues);

            btnDormirAntes        = FindViewById <Button>(Resource.Id.btnDormirAntes);
            btnDormirAntes.Click += BtnDormirAntes_Click;
            Txt_Dor_Antes         = FindViewById <EditText>(Resource.Id.Txt_Dor_Antes);

            btnDormirDespues        = FindViewById <Button>(Resource.Id.btnDormirDespues);
            btnDormirDespues.Click += BtnDormirDespues_Click;
            Txt_Dor_Despues         = FindViewById <EditText>(Resource.Id.Txt_Dor_Despues);
            txt_obs = FindViewById <EditText>(Resource.Id.txt_obs);

            // insulina
            mnna_rap    = FindViewById <EditText>(Resource.Id.mnna_rap);
            mnna_regul  = FindViewById <EditText>(Resource.Id.mnna_regul);
            mnna_mezcla = FindViewById <EditText>(Resource.Id.mnna_mezcla);

            tarde_rap    = FindViewById <EditText>(Resource.Id.tarde_rap);
            tarde_regul  = FindViewById <EditText>(Resource.Id.tarde_regul);
            tarde_mezcla = FindViewById <EditText>(Resource.Id.tarde_mezcla);

            noche_rap    = FindViewById <EditText>(Resource.Id.noche_rap);
            noche_regul  = FindViewById <EditText>(Resource.Id.noche_regul);
            noche_mezcla = FindViewById <EditText>(Resource.Id.noche_mezcla);

            dormir_rap    = FindViewById <EditText>(Resource.Id.dormir_rap);
            dormir_regul  = FindViewById <EditText>(Resource.Id.dormir_regul);
            dormir_mezcla = FindViewById <EditText>(Resource.Id.dormir_mezcla);
        }
Example #9
0
        private void dialogImpressaoGPOS(String texto, int size)
        {
            Console.WriteLine("Texto: " + texto.IndexOf("\n"));
            AlertDialog   alertDialog = new AlertDialog.Builder(this).Create();
            StringBuilder cupom       = new StringBuilder();

            cupom.Append("Deseja realizar a impressão pela aplicação?");
            alertDialog.SetTitle("Realizar Impressão");
            alertDialog.SetMessage(cupom.ToString());
            alertDialog.SetButton("Sim", OkAction);
            alertDialog.SetButton2("Não", CancelAction);
            alertDialog.Show();

            void OkAction(object sender, DialogClickEventArgs e)
            {
                String textoEstabelecimento = "";
                String textoCliente         = "";

                configPrint.Alinhamento = ("LEFT");
                configPrint.Fonte       = ("MONOSPACE");
                configPrint.Tamanho     = (size);
                configPrint.Negrito     = (true);
                configPrint.Italico     = (false);
                configPrint.SubLinhado  = (false);
                try
                {
                    printer.getStatusImpressora();
                    if (printer.IsImpressoraOK())
                    {
                        printer.setConfigImpressao(configPrint);
                        Console.WriteLine("GertecPrinter" + printer);
                        if (rbGer7.Checked)
                        {
                            textoEstabelecimento = texto.Substring(0, texto.IndexOf("\f"));
                            Console.WriteLine("Aqui " + texto.Substring(0, texto.IndexOf("\f")));
                            textoCliente = texto.Substring(texto.IndexOf("\f"));

                            //printer.ImprimeTexto(textoEstabelecimento);
                            ImprimaGer7(textoEstabelecimento);
                            printer.AvancaLinha(100);
                            ImprimaGer7(textoCliente);
                            //printer.ImprimeTexto(textoCliente);
                        }
                        else
                        {
                            printer.ImprimeTexto(texto);
                        }
                        printer.AvancaLinha(150);
                    }
                    printer.ImpressoraOutput();
                }
                catch (System.Exception)
                {
                    Console.WriteLine(System.Environment.StackTrace);
                }
            }

            void CancelAction(object sender, DialogClickEventArgs e)
            {
                //não faz nada
                Console.WriteLine("Não faz nada aqui");
            }
        }