Пример #1
0
        public Boolean insertUser(User user, Type type, String errorMethod)
        {
            int evaluetionMethod;
            EvaluetionMethodInfo emInfo = user.getEvaluetionMethodInfo();
            if(user.getEvaluetionMethodInfo().getEvaluetionMethod().Equals(EvaluetionMethod.Grade))
                evaluetionMethod = 0;
            else
                evaluetionMethod = 1;

            String insertUserString = "INSERT INTO USER (login, password, name, evaluetionMethod, " +
                                                         "higherLimit, lowerLimit, step) " +
                                                         "VALUES ('" +
                                                         user.getLogin() + "', '" +
                                                         user.getPassword() + "', '" +
                                                         user.getName() + "', " +
                                                         evaluetionMethod + ", " +
                                                         emInfo.getHigherLimit() + ", " +
                                                         emInfo.getLowerLimit() + ", '" +
                                                         emInfo.getStep().ToString() + "')";

            return executeNonQuery(insertUserString, type, errorMethod, "Insert user into databese failed.");
        }
Пример #2
0
        private void tryToLogIn()
        {
            if (tbLogIn.Text.Length != 0 && tbPassword.Text.Length != 0)
            {
                DaoUser daoUser = new DaoUser();
                daoUser.openConnection(this.GetType(), "sqlErrorHandler");
                user = daoUser.getUserByLogin(tbLogIn.Text, this.GetType(), "sqlErrorHandler");
                daoUser.closeConnection();

                if (user != null && user.getPassword().Equals(tbPassword.Text))
                {
                    valid = true;
                }

                if (valid)
                    this.Close();
                else
                {
                    MessageBox.Show("Usuário ou senha não encontrados. " +
                                    "Tente novamente ou cadastre-se");
                    tbLogIn.Focus();
                }
            }
            else
                emptyFieldsWarning();
        }