Exemple #1
0
        void ButtonChangePasswordClick(object sender, EventArgs e)
        {
            ComboUserItem item = (ComboUserItem)comboBoxUsers.SelectedItem;

            if (item == null)
            {
                return;
            }

            // Password Strength: http://xkcd.com/936/
            InputBoxValidation validation = delegate(string val) {
                if (val.Length < 8)
                {
                    return("Password must contain at least 8 characters.");
                }

                return("");
            };

            string password = "";

            if (DialogResult.OK == InputBox.Show("Change Password", "Enter a new password (min. 8 characters):", ref password, validation))
            {
                // change password
                UserDatabase.SetPassword(item.UserId, password);
            }
        }
Exemple #2
0
        void ComboBoxUsersSelectedIndexChanged(object sender, EventArgs e)
        {
            // Apply values to previously selected user.

            // Show values for current user.
            ComboUserItem item = (ComboUserItem)comboBoxUsers.SelectedItem;

            if (item == null)
            {
                return;
            }

            using (SQLiteDataReader reader = Database.Instance.ExecuteReader("SELECT id, username, fullname, home_list_id, use_comicrack_progress FROM user JOIN user_settings ON user.id=user_settings.user_id WHERE user.id = " + item.UserId + " LIMIT 1;"))
            {
                if (reader.Read())
                {
                    textBoxUsername.Text = reader.GetString(1);
                    if (!reader.IsDBNull(2))
                    {
                        textBoxFullName.Text = reader.GetString(2);
                    }
                    else
                    {
                        textBoxFullName.Text = "";
                    }

                    Guid listId;


                    if (!reader.IsDBNull(3))
                    {
                        try
                        {
                            listId = new Guid(reader.GetString(3));
                            // Check if list still exists, if not, select Library and update database
                            var list = Program.Database.ComicLists.FindItem(listId);
                            if (list == null)
                            {
                                listId = libraryGuid;
                            }
                        }
                        catch (Exception ex)
                        {
                            // invalid Guid format or reader.GetString(3) failed, just ignore and use main library list...
                            Console.WriteLine(ex.ToString());
                            listId = libraryGuid;
                        }
                    }
                    else
                    {
                        listId = libraryGuid;
                    }

                    checkBoxUseProgressFromComicRack.Checked = (reader.GetInt32(4) != 0);

                    comboTreeHomeList.SelectedNode = comboTreeHomeList.Nodes.FirstOrDefault((ComboTreeNode ctn) => ctn.Tag.Equals(listId));
                }
            }
        }
Exemple #3
0
        void CheckBoxUseProgressFromComicRackCheckedChanged(object sender, EventArgs e)
        {
            ComboUserItem item = (ComboUserItem)comboBoxUsers.SelectedItem;

            if (item == null)
            {
                return;
            }

            Database.Instance.ExecuteNonQuery("UPDATE user_settings SET use_comicrack_progress = " + (checkBoxUseProgressFromComicRack.Checked ? "1" : "0") + " WHERE user_id=" + item.UserId + ";");
        }
Exemple #4
0
        void TextBoxFullNameValidated(object sender, EventArgs e)
        {
            ComboUserItem item = (ComboUserItem)comboBoxUsers.SelectedItem;

            if (item == null)
            {
                return;
            }

            UserDatabase.SetFullName(item.UserId, ((System.Windows.Forms.TextBox)sender).Text);
        }
Exemple #5
0
        void ComboTreeHomeListSelectedNodeChanged(object sender, EventArgs e)
        {
            ComboUserItem item = (ComboUserItem)comboBoxUsers.SelectedItem;

            if (item == null)
            {
                return;
            }

            if (comboTreeHomeList.SelectedNode != null)
            {
                string listId = comboTreeHomeList.SelectedNode.Tag.ToString();
                Database.Instance.ExecuteNonQuery("UPDATE user_settings SET home_list_id='" + listId + "' WHERE user_id=" + item.UserId + ";");
            }
        }
Exemple #6
0
        void ButtonRemoveUserClick(object sender, System.EventArgs e)
        {
            ComboUserItem item = (ComboUserItem)comboBoxUsers.SelectedItem;

            if (item == null)
            {
                return;
            }

            if (DialogResult.Yes == System.Windows.Forms.MessageBox.Show("Are you sure you want to remove user '" + item.Text + "'?", "Remove user", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2))
            {
                // remove user
                UserDatabase.RemoveUser(item.UserId);
                System.Windows.Forms.MessageBox.Show("User removed.", "Remove User", MessageBoxButtons.OK, MessageBoxIcon.Information);
                FillComboUsers();
            }
        }