Ejemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.activity_login);

            userName     = FindViewById <EditText>(Resource.Id.myEmail);
            userPassword = FindViewById <EditText>(Resource.Id.myPassword);
            btn_logIn    = FindViewById <Button>(Resource.Id.logIn_Button);
            btn_signUp   = FindViewById <Button>(Resource.Id.signUp_Button);

            alert = new Android.App.AlertDialog.Builder(this);

            myDB = new DBHelperClass(this);

            btn_logIn.Click += delegate
            {
                var value1 = userName.Text;
                var value2 = userPassword.Text;

                System.Console.WriteLine("UserName: "******"Password: "******" ") || value1.Length < 0 || value2.Trim().Equals(" ") || value2.Length < 0)
                {
                    alert.SetTitle("Error");
                    alert.SetMessage("Please Enter Valid Data");
                    alert.SetPositiveButton("OK", AlertOKButton);
                    alert.SetNegativeButton("Cancel", AlertOKButton);
                    Dialog myDialog = alert.Create();
                    myDialog.Show();
                }
                else
                {
                    if (myDB.checkUser(value1, value2))
                    {
                        string[] userData = myDB.getUserData(value1, value2);

                        Intent newScreen = new Intent(this, typeof(BookingActivity));
                        StartActivity(newScreen);
                    }
                    else
                    {
                        alert.SetTitle("Error");
                        alert.SetMessage("Invalid Email id or Password");
                        alert.SetPositiveButton("OK", AlertOKButton);
                        Dialog myDialog = alert.Create();
                        myDialog.Show();
                    }
                }
            };

            btn_signUp.Click += delegate
            {
                Intent signUpScreen = new Intent(this, typeof(SignUpActivity));
                StartActivity(signUpScreen);
            };
        }