Ejemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.login);
            alrt = new Android.App.AlertDialog.Builder(this);

            Name     = FindViewById <EditText>(Resource.Id.name);
            Password = FindViewById <EditText>(Resource.Id.Password);
            myRegbtn = FindViewById <Button>(Resource.Id.btnReg);
            loginbtn = FindViewById <Button>(Resource.Id.btnLogin);
            adminbtn = FindViewById <Button>(Resource.Id.adminbtn);
            //  edtbtn = FindViewById<Button>(Resource.Id.edtReg);
            // list = FindViewById<Button>(Resource.Id.list);
            myDB            = new DBHelperClass(this);
            loginbtn.Click += delegate
            {
                res = myDB.selectMydata(Name.Text, Password.Text);
                if (res == true)
                {
                    Intent newScreen = new Intent(this, typeof(AfterLogin));
                    StartActivity(newScreen);
                }
                else
                {
                    alert.SetTitle("Error");
                    alert.SetMessage("Invalid login");
                    Dialog myDialog = alert.Create();
                    myDialog.Show();
                }

                //
                //   myDB.login(Name.Text, Password.Text);
            };
            myRegbtn.Click += delegate
            {
                Intent newScreen = new Intent(this, typeof(Register));
                StartActivity(newScreen);
            };
            adminbtn.Click += delegate
            {
                Intent newScreen = new Intent(this, typeof(Admin));
                StartActivity(newScreen);
            };

            /* edtbtn.Click += delegate
             * {
             *   Intent Screen = new Intent(this, typeof(WelcomeScreen));
             *   StartActivity(Screen);
             * };
             * list.Click += delegate
             * {
             *   Intent Screen = new Intent(this, typeof(WelcomeScreen));
             *   StartActivity(Screen);
             * };*/
        }
Ejemplo n.º 2
0
        //private object android;

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.registration);
            // Create your application here

            UserName = FindViewById <EditText>(Resource.Id.name);
            Password = FindViewById <EditText>(Resource.Id.password);
            Email    = FindViewById <EditText>(Resource.Id.email);
            Age      = FindViewById <EditText>(Resource.Id.age);
            regbtn   = FindViewById <Button>(Resource.Id.register);


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


            myDB = new DBHelperClass(this);

            regbtn.Click += delegate
            {
                var value = UserName.Text;
                var email = Email.Text;
                System.Console.WriteLine("Text Value ---- > " + value);
                //check for empty value


                if (value.Trim().Equals("") || value.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
                {  // some value
                    //myDB.OnCreate(database);
                    myDB.insertValue(UserName.Text, Email.Text, Password.Text, Age.Text);

                    // myDB.selectMydata(.Text, Password.Text);
                    //var value = UserName.Text;

                    System.Console.WriteLine("Text Value ---- > " + UserName.Text);
                    System.Console.WriteLine("Text Value ---- > " + Password.Text);
                    System.Console.WriteLine("Text Value ---- > " + Email.Text);
                    System.Console.WriteLine("Text Value ---- > " + Age.Text);
                    Intent i = new Intent(this, typeof(MainActivity));
                    StartActivity(i);
                }
            };
        }