protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            //initializing objects of form controls
            myUsername = FindViewById <EditText>(Resource.Id.user_name);
            myPassword = FindViewById <EditText>(Resource.Id.user_password);
            myLoginBtn = FindViewById <Button>(Resource.Id.btn_login);
            mySignup   = FindViewById <Button>(Resource.Id.btn_signup);

            myDB = new DBHelperClass(this);

            //myUsername.Text = "Username Please";
            // myPassword.Text = "Password Please";
            myLoginBtn.Click += delegate { // login button
                var user_name     = myUsername.Text;
                var user_password = myPassword.Text;
                alert = new Android.App.AlertDialog.Builder(this);
                // validation
                if (user_name.Trim().Equals("") || user_name.Length < 0 || user_password.Trim().Equals("") || user_password.Length < 0)
                {
                    alert.SetTitle("Error");
                    alert.SetMessage("Please fill all fields");
                    alert.SetPositiveButton("OK", alertOKButton);
                    Dialog myDialog = alert.Create();
                    myDialog.Show();
                }
                else
                {
                    bool f = myDB.checkUser(user_name.Trim(), user_password.Trim());
                    if (f)
                    {
                        myUsername.Text = ""; myPassword.Text = "";
                        Intent homeScreen = new Intent(this, typeof(Home)); // on success loading signup page
                        homeScreen.PutExtra("userName", user_name.Trim());
                        homeScreen.PutExtra("userPassword", user_password.Trim());
                        StartActivity(homeScreen);
                    }
                    else
                    {
                        alert.SetTitle("Error");
                        alert.SetMessage("Incorrect email id or password!");
                        alert.SetPositiveButton("OK", alertOKButton);
                        Dialog myDialog = alert.Create();
                        myDialog.Show();
                    }
                }
            };

            mySignup.Click += delegate                                  // signup button
            {
                Intent signupScreen = new Intent(this, typeof(SignUp)); // on success loading signup page
                StartActivity(signupScreen);
            };
        }
Beispiel #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Home);

            myText_username = FindViewById <TextView>(Resource.Id.lb_main_head);
            myDB            = new DBHelperClass(this);

            userName             = Intent.GetStringExtra("userName");
            userPass             = Intent.GetStringExtra("userPassword");
            myText_username.Text = "Welcome, " + myDB.getUsername(userName);
            // Create your application here

            //Object initialization
            myFirstName = FindViewById <EditText>(Resource.Id.txt_first_name);
            myLastName  = FindViewById <EditText>(Resource.Id.txt_last_name);

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

            myAge        = FindViewById <EditText>(Resource.Id.txt_age);
            mySpassword  = FindViewById <EditText>(Resource.Id.txt_password);
            myScpassword = FindViewById <EditText>(Resource.Id.txt_con_password);

            editBtn      = FindViewById <Button>(Resource.Id.editBtn1);
            deleteBtn    = FindViewById <Button>(Resource.Id.btnDelete);
            usersListBtn = FindViewById <Button>(Resource.Id.list_of_users_Btn);

            userData = myDB.getUserDetails(userName);// feteching user details

            myFirstName.Text  = userData[0];
            myLastName.Text   = userData[1];
            myAge.Text        = userData[2];
            mySpassword.Text  = userData[3];
            myScpassword.Text = userData[3];

            /*myFirstName.Text = myDB.getUserDetails(userName)[0];
             * myLastName.Text = myDB.getUserDetails(userName)[1];
             * myAge.Text = myDB.getUserDetails(userName)[2];
             * mySpassword.Text = myDB.getUserDetails(userName)[3];
             * myScpassword.Text = myDB.getUserDetails(userName)[3];
             * myFirstName.Enabled = false;
             * System.Console.WriteLine("Name from Login ---> " + userName);
             * System.Console.WriteLine("Pasword from Login ---> " + userPass);*/


            editBtn.Click      += editBtnClicEvent;
            deleteBtn.Click    += deleteBtnClicEvent;
            usersListBtn.Click += usersListBtnClicEvent;
        }
Beispiel #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.SignUp);

            //Object initialization
            myFirstName  = FindViewById <EditText>(Resource.Id.txt_first_name);
            myLastName   = FindViewById <EditText>(Resource.Id.txt_last_name);
            myEmail      = FindViewById <EditText>(Resource.Id.txt_email);
            myAge        = FindViewById <EditText>(Resource.Id.txt_age);
            mySpassword  = FindViewById <EditText>(Resource.Id.txt_password);
            myScpassword = FindViewById <EditText>(Resource.Id.txt_con_password);



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

            myAlreadyLogin = FindViewById <Button>(Resource.Id.btn_already_login);
            mySignUp       = FindViewById <Button>(Resource.Id.btn_signup);

            // Function definition
            myAlreadyLogin.Click += delegate
            {                                                                // Already login button
                Intent loginScreen = new Intent(this, typeof(MainActivity)); // on success loading signup page
                StartActivity(loginScreen);
            };
            mySignUp.Click += delegate
            { // Signup button
                alert.SetTitle("Error");
                if (myFirstName.Text.Trim().Equals("") || myFirstName.Text.Length < 0 || myLastName.Text.Trim().Equals("") || myLastName.Text.Length < 0 || myEmail.Text.Trim().Equals("") || myEmail.Text.Length < 0 || myAge.Text.Trim().Equals("") || myAge.Text.Length < 0 || mySpassword.Text.Trim().Equals("") || mySpassword.Text.Length < 0 || myScpassword.Text.Trim().Equals("") || myScpassword.Text.Length < 0)
                {
                    alert.SetMessage("Please fill all fields");
                    alert.SetPositiveButton("OK", alertOKButton);
                    Dialog myDialog = alert.Create();
                    myDialog.Show();
                }
                else if (!re.IsMatch(myEmail.Text.Trim()))
                {
                    alert.SetMessage("Please enter valid Email address");
                    alert.SetPositiveButton("OK", alertOKButton);
                    Dialog myDialog = alert.Create();
                    myDialog.Show();
                }
                else if (mySpassword.Text.Trim() != myScpassword.Text.Trim())
                {
                    alert.SetMessage("Passwords are not matching");
                    alert.SetPositiveButton("OK", alertOKButton);
                    Dialog myDialog = alert.Create();
                    myDialog.Show();
                }
                else
                {
                    Boolean f = myDB.insertValue(myFirstName.Text.Trim(), myLastName.Text.Trim(), myEmail.Text.Trim(), Int32.Parse(myAge.Text.Trim()), mySpassword.Text.Trim());
                    if (f)
                    {
                        myFirstName.Text = ""; myLastName.Text = ""; myEmail.Text = ""; myAge.Text = ""; mySpassword.Text = ""; myScpassword.Text = "";
                        alert.SetMessage("Registration successfull!");
                    }
                    else
                    {
                        alert.SetMessage("User already exist!");
                    }
                    alert.SetTitle("Information");
                    alert.SetPositiveButton("OK", redirectToLogin);
                    Dialog myDialog = alert.Create();
                    myDialog.Show();
                }
            };
        }