Beispiel #1
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            MongoManager mongo = new MongoManager();

            string user = txtNewUser.Text;
            string pass = txtNewPass.Text;

            if (user == "" || pass == "")
            {
                System.Windows.Forms.MessageBox.Show("Enter username and password.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (mongo.ProfileExistsInDB(user))
            {
                System.Windows.Forms.MessageBox.Show("That username is already taken.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                Profile profile = new Profile(user, pass);
                mongo.SaveProfile(profile);

                Main nextForm = new Main(profile);
                this.Hide();
                nextForm.ShowDialog();
                this.Show();
            }
        }
Beispiel #2
0
        private void btnSignIn_Click(object sender, EventArgs e)
        {
            MongoManager mongo = new MongoManager();

            string user = txtUser.Text;
            string pass = txtPass.Text;

            if (user == "" || pass == "")
            {
                System.Windows.Forms.MessageBox.Show("Enter username and password.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (mongo.ProfileExistsInDB(user))
            {
                if (mongo.ProfileAuthentication(user, pass))
                {
                    Profile profile = mongo.GetProfileData(user);

                    Main nextForm = new Main(profile);
                    this.Hide();
                    nextForm.ShowDialog();
                    this.Show();
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Password is incorrect.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Username is incorrect or doesn't exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            UpdateTotal();
            if (character.Name != "" && character.Race != "" && character.Class != "")
            {
                character.Points      = Int32.Parse(txtPointsAvail.Text);
                character.Description = txtDescription.Text;

                MongoManager mongo = new MongoManager();

                if (status == "New")
                {
                    mongo.SaveCharacter(profile, character);
                    mongo.UpdateProfileRefs(profile);
                }
                else    // "Updated"
                {
                    mongo.UpdateCharacter(character);
                }

                this.Close();
            }
            else
            {
                MessageBox.Show("You must choose a name, race and class before saving.", "Error");
            }
        }
Beispiel #4
0
        public Main(Profile profile)
        {
            InitializeComponent();

            lblSignedIn.Text = profile.Username;

            mongo        = new MongoManager();
            this.profile = profile;

            RefreshList();
            listCharacters.DisplayMember = "Title";
            listResult.DisplayMember     = "Title";
        }