public ChangePasswordForm(User user)
 {
     InitializeComponent();
     this.DialogResult = DialogResult.Cancel;
     this.Text = user.login;
     userId = user.id;
 }
Exemple #2
0
        public static void LogOut()
        {
            Properties.Settings.Default.Password = "";
            Properties.Settings.Default.Save();

            loggedUser = null;
            if (activeForm != null)
                activeForm.Close();
            activeForm = new LoginForm();
            ShowActiveForm();
        }
Exemple #3
0
        public static bool TryLogin(string login, string password, bool auto = false)
        {
            try
            {
                if (login == "")
                    throw new Exception("Имя пользователя не может быть пустым");
                
                string queryString = String.Format("SELECT * FROM users WHERE login = '******'", login );
                List<User> userList = DataProvider.GetRecordsFromQuery<User>(queryString);
                if (userList.Count == 0)
                    throw new Exception(String.Format("Пользователь {0} отсутствует в базе", login));

                User user = userList[0];
                if (user.password == null)
                {
                    DialogResult result = new ChangePasswordForm(user).ShowDialog();
                    if (result != DialogResult.OK)
                        return false;
                }
                else
                {
                    if (user.password != Utils.MD5(password))
                        throw new Exception("Пароль не подходит");
                }

                loggedUser = user;

                if (activeForm != null)
                    activeForm.Close();
                activeForm = new MainForm();
                ShowActiveForm();

            }
            catch (Exception error)
            {
                if(!auto)
                    Utils.ErrorMessage(error.Message);
                return false;
            }

            return true;
        }
Exemple #4
0
 private void ListView_SelectedIndexChanged(object sender, EventArgs e)
 {
     Apply(true);
     if (ListView.SelectedIndices.Count == 0)
     {
         selectedUser = null;
         return;
     }
     selectedUser = userList[ListView.SelectedIndices[0]];
     FillFields();
 }