Esempio n. 1
0
        /// <summary>
        /// This method loggs user and sends it's id to the next form
        /// </summary>
        public void LogUser()
        {
            _logInService.SaveDataFromView(_login.UserName, _login.Password);

            try
            {
                if (_logInService.CorrectLogin() == true)
                {
                    if (_login.Stay == true)
                    {
                        Properties.Settings.Default.id               = _logInService.GetIDLoggedUser();
                        Properties.Settings.Default.userPosition     = _logInService.GetPosition();
                        Properties.Settings.Default.Logged           = true;
                        Properties.Settings.Default.LoggedForOneTime = false;
                        Properties.Settings.Default.Save();
                    }
                    else
                    {
                        Properties.Settings.Default.id               = _logInService.GetIDLoggedUser();
                        Properties.Settings.Default.userPosition     = _logInService.GetPosition();
                        Properties.Settings.Default.Logged           = false;
                        Properties.Settings.Default.LoggedForOneTime = true;
                        Properties.Settings.Default.Save();
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Logger.WriteToLogFile(DateTime.Now.ToString()
                                             + "\n" + e.ToString());
                _login.ErrorMessage(e.Message);
            }
        }