示例#1
0
        private void deleteAccountToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (frmMessageBox messageBox = new frmMessageBox())
            {
                common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
                common.getMainForm().loadedTheme.themeForm(messageBox);

                if (messageBox.show("You are about to DELETE the account [" + loadedAccount.name + "]!\r\n" +
                                    "The account and ALL information associated with it will be LOST, and CANNOT be recovered!\r\n\r\n" +
                                    "Upon deletion of the account, you will be LOGGED OUT of the application!\r\n\r\n" +
                                    "Are you sure you want to DELETE this account?",
                                    "Delete Account: [" + loadedAccount.name + "]",
                                    MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    common.deleteAccount(common.getMainForm().loadedAccount);
                    common.getMainForm().logOut();

                    messageBox.show("Account Deleted Successfully!", "Account Deleted", MessageBoxButtons.OK);

                    using (frmLogin loginForm = new frmLogin())
                    {
                        common.setFormFontSize(loginForm, common.getMainForm().loadedFontSize);
                        common.getMainForm().loadedTheme.themeForm(loginForm);
                        loginForm.ShowDialog();
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Deletes the cashflow currently loaded in the form
        /// after prompting the user. If the user DOES delete the flow
        /// the form closes.
        /// </summary>
        private void deleteCashFlow()
        {
            using (frmMessageBox messageBox = new frmMessageBox())
            {
                common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
                common.getMainForm().loadedTheme.themeForm(messageBox);

                if (loadedFlow == null)
                {
                    messageBox.show("This Cash Flow has not yet been saved (and cannot be deleted).", "Unable To Delete", MessageBoxButtons.OK);
                }
                else
                {
                    if (messageBox.show("You are about to delete the Cash Flow: [" + loadedFlow.name + "]"
                                        + "\r\nfrom the profile: [" + loadedProfile.name + "]"
                                        + "\r\n\r\nThe deleted Flow will be LOST, and cannot be recovered!"
                                        + "\r\n\r\nAre you sure you want to delete this Flow?",
                                        "Delete Cash Flow?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        common.deleteCashFlowFromProfile(loadedProfile, loadedFlow);
                        loadAccountIntoForm(common.getMainForm().loadedAccount);

                        //close the form after deleting the flow
                        messageBox.show("Cash Flow Deleted.", "Flow Deleted", MessageBoxButtons.OK);
                        this.Close();
                    }
                }
            }
        }
示例#3
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            using (frmMessageBox messageBox = new frmMessageBox())
            {
                common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
                common.getMainForm().loadedTheme.themeForm(messageBox);

                if (common.validateNewPassword(txtPassword.Text, txtConfirmPassword.Text))
                {
                    if (common.validateNewUsername(txtUsername.Text))
                    {
                        common.createNewAccount(
                            new userAccount(common.getNextAccountId(), txtUsername.Text, null),
                            txtPassword.Text);

                        messageBox.show("Your account has been created!", "Account Created", MessageBoxButtons.OK);
                        this.Close();
                    }
                    else
                    {
                        messageBox.show("The username you have chosen is ALREADY in use,\r\nplease choose a different username\r\n",
                                        "Invalid Username", MessageBoxButtons.OK);
                    }
                }
                else
                {
                    messageBox.show("Please make sure the password you entered matches the \"confirmed\" password\r\n" +
                                    "and that your password is at least EIGHT characters long.", "Invalid Password", MessageBoxButtons.OK);
                }
            }
        }
示例#4
0
        private void deleteSelectedCashFlowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (frmMessageBox messageBox = new frmMessageBox())
            {
                common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
                common.getMainForm().loadedTheme.themeForm(messageBox);

                if (getSelectedProfile() == null || getSelectedCashFlow() == null)
                {
                    messageBox.show("No Cash Flow Selected.", "No Cash Flow Selected", MessageBoxButtons.OK);
                }
                else
                {
                    if (messageBox.show("You are about to delete the Cash Flow: [" + getSelectedCashFlow().name + "]"
                                        + "\r\nfrom the profile: [" + getSelectedProfile().name + "]"
                                        + "\r\n\r\nThe deleted Flow will be LOST, and cannot be recovered!"
                                        + "\r\n\r\nAre you sure you want to delete this Flow?",
                                        "Delete Cash Flow?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        common.deleteCashFlowFromProfile(getSelectedProfile(), getSelectedCashFlow());
                        common.getMainForm().refreshDataForAllMdiChildren();
                    }
                }
            }
        }
示例#5
0
        private void updateAccount()
        {
            string newUsername = txtAccountName.Text;

            if (loadedAccount.name == newUsername)
            {
                /* if the "New" name is the same as the old name, don't do anything */
                return;
            }

            if (common.validateNewUsername(newUsername))
            {
                userAccount updatedAccount = new userAccount(loadedAccount.id, newUsername, common.getMainForm().loadedAccount.profiles);

                common.updateAccount(common.getMainForm().loadedAccount, updatedAccount);
                common.getMainForm().loadedAccount = updatedAccount;
                common.getMainForm().refreshDataForAllMdiChildren();
            }
            else
            {
                using (frmMessageBox messageBox = new frmMessageBox())
                {
                    common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
                    common.getMainForm().loadedTheme.themeForm(messageBox);
                    messageBox.show("The username you have chosen is ALREADY in use,\r\n" +
                                    "please choose a different username\r\n",
                                    "Invalid Username", MessageBoxButtons.OK);
                }
            }
        }
示例#6
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (isValidLogin(txtUsername.Text, txtPassword.Text))
            {
                common.getMainForm().loadedAccount = common.getAccountFromDatabase(getAccountId(txtUsername.Text, txtPassword.Text));

                if (chkRememberMe.Checked)
                {
                    common.getMainForm().rememberMeToken = common.getRememberMeToken(common.getMainForm().loadedAccount.id);
                }
                else
                {
                    common.getMainForm().rememberMeToken = null;
                }

                this.Close();
            }
            else
            {
                using (frmMessageBox messageBox = new frmMessageBox())
                {
                    common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
                    common.getMainForm().loadedTheme.themeForm(messageBox);
                    messageBox.show("Invalid Username or Password!", "Login Failed", MessageBoxButtons.OK);
                }
                txtPassword.Clear();
            }
        }
示例#7
0
        /// <summary>
        /// runs the procedure for saving a cash flow
        /// returns a boolean to indicate if the flow was saved successfully or not.
        /// </summary>
        /// <returns></returns>
        private bool saveCashFlow()
        {
            if (isFormCashFlowValid())
            {
                cashFlow flowToSave = getCashFlowFromForm();

                if (loadedFlow == null)
                {
                    common.addCashFlowToProfile(loadedProfile, flowToSave);
                    loadCashFlowIntoForm(flowToSave);
                }
                else
                {
                    common.updateCashFlowOnAccount(loadedProfile, loadedFlow, flowToSave);
                    loadCashFlowIntoForm(flowToSave);
                }
                tsslFlowStatus.Text = "Flow Saved: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString();
                return(true);
            }
            else
            {
                using (frmMessageBox messageBox = new frmMessageBox())
                {
                    common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
                    common.getMainForm().loadedTheme.themeForm(messageBox);
                    messageBox.show("Unable to save current flow!\r\n" +
                                    "Please make sure all fields are properly filled out.",
                                    "Error Saving Cash Flow", MessageBoxButtons.OK);
                }
                return(false);
            }
        }
示例#8
0
        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (loadedAccount != null)
            {
                using (frmMessageBox messageBox = new frmMessageBox())
                {
                    common.setFormFontSize(messageBox, this.loadedFontSize);
                    this.loadedTheme.themeForm(messageBox);
                    if (messageBox.show("Are you sure you want to close the application?\r\nAny unsaved work will be lost.", "Close Application?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        e.Cancel = false;

                        if (!rememberMeToolStripMenuItem.Checked)
                        {
                            this.rememberMeToken = null;
                        }
                        else
                        {
                            this.rememberMeToken = common.getRememberMeToken(this.loadedAccount.id);
                        }

                        writeUserSettingsToFile();
                    }
                    else
                    {
                        e.Cancel = true;
                    }
                }
            }
        }
示例#9
0
        private void addNewProfileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (frmInputBox inputBox = new frmInputBox())
            {
                common.getMainForm().loadedTheme.themeForm(inputBox);
                inputBox.Text            = "Add Profile";
                inputBox.lblMessage.Text = "Enter new profile name:";

                inputBox.ShowDialog();

                if (inputBox.DialogResult == DialogResult.OK)
                {
                    if (!string.IsNullOrEmpty(inputBox.result) &&
                        !isNewProfileNameDuplicate(this.loadedAccount.profiles, inputBox.result))
                    {
                        common.addProfileToAccount(common.getMainForm().loadedAccount, new fundingProfile(common.getNextProfileId(), inputBox.result));
                        common.getMainForm().refreshDataForAllMdiChildren();
                    }
                    else
                    {
                        using (frmMessageBox messageBox = new frmMessageBox())
                        {
                            common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
                            common.getMainForm().loadedTheme.themeForm(messageBox);
                            messageBox.show("You cannot have more than one profile with the same name",
                                            "Duplicate Profile Name", MessageBoxButtons.OK);
                        }
                    }
                }
            }
        }
示例#10
0
        private void viewEditSelectedCashFlowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (getSelectedProfile() == null || getSelectedCashFlow() == null)
            {
                using (frmMessageBox messageBox = new frmMessageBox())
                {
                    common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
                    common.getMainForm().loadedTheme.themeForm(messageBox);
                    messageBox.show("No Cash Flow Selected.", "No Cash Flow Selected", MessageBoxButtons.OK);
                }
            }
            else
            {
                using (frmCashFlowDetails cashFlowForm = new frmCashFlowDetails())
                {
                    common.setFormFontSize(cashFlowForm, common.getMainForm().loadedFontSize);
                    common.getMainForm().loadedTheme.themeForm(cashFlowForm);
                    cashFlowForm.Icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetExecutingAssembly().Location);
                    cashFlowForm.loadAccountIntoForm(this.loadedAccount);
                    cashFlowForm.loadProfileIntoForm(getSelectedProfile());
                    cashFlowForm.loadCashFlowIntoForm(getSelectedCashFlow());

                    cashFlowForm.ShowDialog();
                    common.getMainForm().refreshDataForAllMdiChildren();
                }
            }
        }
示例#11
0
        private void renameSelectedProfileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (getSelectedProfile() == null)
            {
                using (frmMessageBox messageBox = new frmMessageBox())
                {
                    common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
                    common.getMainForm().loadedTheme.themeForm(messageBox);
                    messageBox.show("No Profile Selected.", "No Profile Selected", MessageBoxButtons.OK);
                }
            }
            else
            {
                using (frmInputBox inputBox = new frmInputBox())
                {
                    common.setFormFontSize(inputBox, common.getMainForm().loadedFontSize);
                    common.getMainForm().loadedTheme.themeForm(inputBox);
                    inputBox.Text            = "Rename Profile: [" + getSelectedProfile().name + "]";
                    inputBox.lblMessage.Text = "Enter new profile name:";
                    inputBox.txtInput.Text   = getSelectedProfile().name;

                    inputBox.ShowDialog();

                    /* i.e. only process if the user said OK */
                    if (inputBox.DialogResult == DialogResult.OK)
                    {
                        if (!string.IsNullOrEmpty(inputBox.result) &&
                            !isRenameProfileNameDuplicate(this.loadedAccount.profiles, inputBox.result))
                        {
                            //rename profile
                            fundingProfile renamedProfile = new fundingProfile(getSelectedProfile().id, inputBox.result, getSelectedProfile().cashFlows);

                            common.updateProfileOnAccount(common.getMainForm().loadedAccount, getSelectedProfile(), renamedProfile);
                            common.getMainForm().refreshDataForAllMdiChildren();
                        }
                        else
                        {
                            using (frmMessageBox messageBox = new frmMessageBox())
                            {
                                common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
                                common.getMainForm().loadedTheme.themeForm(messageBox);
                                messageBox.show("You cannot have more than one profile with the same name",
                                                "Duplicate Profile Name", MessageBoxButtons.OK);
                            }
                        }
                    }
                }
            }
        }
示例#12
0
 private void logOutToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (frmMessageBox messageBox = new frmMessageBox())
     {
         common.setFormFontSize(messageBox, this.loadedFontSize);
         this.loadedTheme.themeForm(messageBox);
         if (messageBox.show("You will be logged out of the Application?\r\nAny unsaved work will be lost."
                             + "\r\n\r\n Are you sure you want to log out?",
                             "Log Out?", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             logOut();
             showLoginDialog();
         }
     }
 }
示例#13
0
        private void deleteSelectedProfileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (frmMessageBox messageBox = new frmMessageBox())
            {
                common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
                common.getMainForm().loadedTheme.themeForm(messageBox);

                if (getSelectedProfile() == null)
                {
                    messageBox.show("No Profile Selected.", "No Profile Selected", MessageBoxButtons.OK);
                }
                else
                {
                    if (messageBox.show("You are about to delete the profile: [" + getSelectedProfile().name + "]"
                                        + "\r\nThe Profile and ALL of its Cash Flows will be deleted!"
                                        + "\r\n\r\nAre you sure you want to delete this Profile?",
                                        "Delete Profile?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        common.deleteProfileFromAccount(loadedAccount, getSelectedProfile());
                        common.getMainForm().refreshDataForAllMdiChildren();
                    }
                }
            }
        }
示例#14
0
        private void importCashFlowsFromFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (getSelectedProfile() == null)
            {
                using (frmMessageBox messageBox = new frmMessageBox())
                {
                    common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
                    common.getMainForm().loadedTheme.themeForm(messageBox);
                    messageBox.show("No Profile Selected.", "No Profile Selected", MessageBoxButtons.OK);
                }
            }
            else
            {
                string importFile = getFileToImport();

                if (!string.IsNullOrEmpty(importFile))
                {
                    try
                    {
                        importCashFlowsIntoProfile(parseCsvIntoDataTable(importFile), getSelectedProfile());
                        using (frmMessageBox messageBox = new frmMessageBox())
                        {
                            common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
                            common.getMainForm().loadedTheme.themeForm(messageBox);
                            messageBox.show(parseCsvIntoDataTable(importFile).Rows.Count + " Cash Flows Imported.",
                                            "Import Successful", MessageBoxButtons.OK);
                        }
                    }
                    catch (Exception ex)
                    {
                        using (frmMessageBox messageBox = new frmMessageBox())
                        {
                            common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
                            common.getMainForm().loadedTheme.themeForm(messageBox);
                            messageBox.show("Cash Flow Import Failed\r\n" +
                                            "Please Make sure the file is in the proper format.",
                                            "Import Failed", MessageBoxButtons.OK);
                        }
                    }
                    common.getMainForm().refreshDataForAllMdiChildren();
                }
            }
        }
示例#15
0
 private void runReportToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (validateReportBounds(tstbLowerBound.Text, tstbUpperBound.Text))
     {
         chrtReportChart.Series.Clear();
         runReport(getSelectedProfiles(),
                   DateTime.Parse(tstbLowerBound.Text),
                   DateTime.Parse(tstbUpperBound.Text),
                   getReportTypeByName(tscbReportType.Text));
     }
     else
     {
         using (frmMessageBox messageBox = new frmMessageBox())
         {
             common.setFormFontSize(messageBox, common.getMainForm().loadedFontSize);
             common.getMainForm().loadedTheme.themeForm(messageBox);
             messageBox.show("Upper and Lower bounds MUST be dates and the\r\n" +
                             "Lower Bound must be EARLIER than the Upper Bound.",
                             "Invalid Report Bounds!", MessageBoxButtons.OK);
         }
     }
 }