Exemplo n.º 1
0
        /// <summary>
        /// ask the user if are he shure and then check the answer.
        /// if the answer is yes, insert the value of mood and the Date in database.
        /// if the insert is correctly , the program will show the next window.
        /// in case of error , the program show a message of error.
        /// </summary>
        /// <param name="mood"></param>
        public void validate(int mood)
        {
            fechaHoy = DateTime.Today.ToShortDateString();
            var result = MessageBox.Show("Estas seguro?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                Boolean b = moodController.validateInsert(user.Id, mood, fechaHoy.ToString());
                if (b == true)
                {
                    MainUser mainUser = new MainUser(user);
                    this.Hide();
                    mainUser.ShowDialog();
                    if (mainUser.Exit == true)
                    {
                        Login login = new Login();
                        login.ShowDialog();
                    }
                }
                else
                {
                    MessageBox.Show("No se ha podido insertar tu estado de animo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 2
0
        private void validate(object sender, EventArgs e)
        {
            String username = tbUsername.Text;
            String password = tbPassword.Text;

            if (username.Equals("") || password.Equals(""))
            {
                MessageBox.Show("Username or password are empty!!");
            }
            else
            {
                String rol = userController.validateUser(username, password);
                if (rol.Equals(String.Empty))
                {
                    MessageBox.Show("Users or password are incorrect");
                }
                else if (rol.Equals("admin"))
                {
                    MessageBox.Show("ADMIN!! ");
                }
                else if (rol.Equals("user"))
                {
                    MainUser user = new MainUser(userController.User);
                    user.ShowDialog();
                }

                cleanFields();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///we collect the data from the textbox, if the fields are empty the program returns an error message
        ///If the information is complete, we search for a user with those credentials in the database.
        ///If the user is not found, the program notifies the client, otherwise the program accesses the following window with the user's complete information.
        ///To decide which window goes to the user, the program looks at 2 factors: 1- Registration of a state of mind 2- If that registration is from today or not
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void validate(object sender, EventArgs e)
        {
            String username = tbUsername.Text;
            String password = tbPassword.Text;

            DateTime today = DateTime.Today;


            if (username.Equals("") || password.Equals(""))
            {
                MessageBox.Show("Ningun campo puede estar vacio!!");
            }
            else
            {
                user = userController.validateUser(username, password);
                if (user != null)
                {
                    if (user.Rol.Equals("user"))
                    {
                        DateTime lastDate = moodController.takeDate(user.Id);
                        if (lastDate == today)
                        {
                            MainUser mainUser = new MainUser(user);
                            this.Hide();
                            mainUser.ShowDialog();
                            if (mainUser.Exit == true)
                            {
                                this.Show();
                            }
                        }
                        else
                        {
                            AnswerMood answerMood = new AnswerMood(user);
                            this.Hide();
                            answerMood.ShowDialog();
                        }
                    }
                    else if (user.Rol.Equals("admin"))
                    {
                        MainUser mainUser = new MainUser(user);
                        this.Hide();
                        mainUser.ShowDialog();
                        if (mainUser.Exit == true)
                        {
                            this.Show();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("No existe un usuario con estas credenciales!");
                }
                cleanFields();
            }
        }