Example #1
0
        //initialization of screen
        //passes in user info from login screen
        public WelcomeScreen(UserInfo loginInfo)
        {
            user = loginInfo;
            username = loginInfo.getUsername();
            InitializeComponent();

            //Check if any exercises need to be done
             NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=postgres;Password=useitlab;Database=UserData;");
             conn.Open();

            //get all uncompleted exercises for dates before todays date
             string today = DateTime.Today.ToShortDateString();
            string sql = "SELECT exercisenum FROM exerciseinfo WHERE (date < '"+today+"') AND (usernum = (SELECT usernum FROM userinfo WHERE username ='******')) AND (completed = false)";
            NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, conn);
            ds.Reset();
            da.Fill(ds);
            dt = ds.Tables[0];

            if (dt.Rows.Count == 0)
            {

            }
            else
            {
                todayExercise = (int)dt.Rows[0].ItemArray[0];
            }
                this.label1.Text = "Welcome " + username + "!";
                conn.Close();
        }
Example #2
0
        public void fillUsernameAndPass(CreateNewUser newUser, UserInfo newInfo)
        {
            username = newInfo.getUsername();
            password = newInfo.getPassword();
            //NewUser.Close();

            //UserControl1 NewUser2 = new UserControl1();
        }
Example #3
0
 //This constructor is for when a health care professional adds an exercise to the patient's
 //profile, rep number defined
 public ExerciseSession(UserInfo user, exerciseType type, int reps)
 {
     //for (UserHistoryData
     this.user = user;
     this.type = type;
     this.state = exerciseState.incomplete;
     this.addedDate = DateTime.Now;
     this.attempts = 0;
     this.reps = reps;
     this.completedReps = 0;
 }
Example #4
0
 public ExerciseSession(UserInfo user, exerciseType type)
 {
     //for (UserHistoryData
     this.user = user;
     this.type = type;
     this.state = exerciseState.incomplete;
     this.addedDate = DateTime.Now;
     this.attempts = 0;
     //default number of reps if not indicated
     this.reps = 5;
     this.completedReps = 0;
 }
Example #5
0
        //Method for checking if two UserInfo objects are the same
        public bool checkUserInfo(UserInfo compare)
        {
            bool usernamematch = false;
            bool passwordmatch = false;

            if (this.username == compare.username)
                usernamematch = true;
            if (this.password == compare.password)
                passwordmatch = true;

            return (usernamematch & passwordmatch);
        }
Example #6
0
 //This constructor is for copying an existing ExerciseSession, and cancelling the old session
 ExerciseSession(ExerciseSession old)
 {
     this.user = old.user;
     this.type = old.type;
     this.state = old.state;
     old.state = exerciseState.cancelled;
     this.attempts = old.attempts;
     this.addedDate = DateTime.Now;
     old.lastModified = DateTime.Now;
     this.reps = old.reps;
     this.completedReps = 0;
 }
Example #7
0
        //Button for creating a new user
        //We should really rename these buttons into something more descriptive
        private void loginButton_Click(object sender, EventArgs e)
        {
            NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=postgres;Password=useitlab;Database=UserData;");
            conn.Open();

            //create a UserInfo instance with the user input
            UserInfo loginInfo = new UserInfo(textBox1.Text, textBox2.Text);

            string sql = "select * from userinfo where username='******'";
            NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, conn);
            ds.Reset();
            da.Fill(ds);
            dt = ds.Tables[0];

            if (dt.Rows.Count != 0)
            {
                if (dt.Rows[0][2].ToString() == loginInfo.getPassword())
                {
                    WelcomeScreen MainMenu = new WelcomeScreen(loginInfo);
                    MainMenu.ShowDialog();
                    conn.Close();
                }
                else
                {
                    error.show("Error! Password is incorrect!");
                }
            }
            else
            {
                error.show("Error! User does not exist!");
            }
            /***
            //Insert check for username and password
            //Need to check user input to all existing UserInfo instances

            //If the user input matchs existing user information then open the user's welcomescreen and info
            if (storedusers.ContainsKey(loginInfo.getUsername()))
            {
                if(storedusers[loginInfo.getUsername()] == textBox2.Text)
                {
                    //MessageBox.Show("Yay! User exists");
                    //Create and show a main menu screen for the specific user
                    WelcomeScreen MainMenu = new WelcomeScreen(loginInfo);
                    MainMenu.ShowDialog();
                }
                else
                {
                    // If the login fails show a screen that will inform the user
                    // Should provide useful information to user
                     error.show("Error! Password is incorrect!");
                    // LoginFail failed = new LoginFail();
                }
            }
            else
            {
                // If the login fails show a screen that will inform the user
                // Should provide useful information to user
                error.show("Error! Invalid user name.");
               // LoginFail failed = new LoginFail();
            } ***/

            conn.Close();
        }