Пример #1
0
        private string getGoalText(int accountNum)
        {
            string       result = ""; //accrues text to be returned throughout function
            DataAbstract DA     = new DataAbstract();
            DataTable    goals  = DA.returnIncompleteGoals(accountNum).Tables[0];

            result += "Your current Goal Updates \n";
            for (int j = 0; j < goals.Rows.Count; ++j) //iterate through all goals of account
            {
                DataRow g = goals.Rows[j];
                int     notificationCount = Convert.ToInt32(g.Field <object>("NotificationCount"));
                int     goalID            = Convert.ToInt32(g.Field <object>("GoalID"));
                string  goalName          = Convert.ToString(g.Field <object>("Name"));
                double  currentAmt        = Convert.ToDouble(g.Field <object>("CurrentAmt"));
                double  totalAmt          = Convert.ToDouble(g.Field <object>("TotalAmt"));
                double  percent           = currentAmt / totalAmt;

                Notifications N = new Notifications();
                int           notificationCountUpdate = N.Check("goals", percent * 100);

                if (notificationCountUpdate > notificationCount)
                {
                    DA.updateNotificationGoals(goalID, notificationCountUpdate);
                    string percentString = Convert.ToString(percent);
                    percentString = percentString.Remove(percentString.IndexOf('.') + 2);
                    string goalString = goalName + " has reached " + (percent * 100).ToString("N0") + "%\n";
                    result += goalString;
                }
            }//end of specific goal

            return(result);
        }
Пример #2
0
    //Before page loads, the logged in user data is pulled.
    //If none are logged in, user 1 is logged in (for easier development and demonstration)
    protected void Page_PreRender(object sender, EventArgs e)
    {
        DataAbstract DA = new DataAbstract();

        if (Convert.ToInt32(Session["userID"]) != 0)
        {
            userID = Convert.ToInt32(Session["userID"]);
            DataSet accountData = DA.returnAccounts(userID);               //gets all accounts
            System.Data.DataTable accountsTable = accountData.Tables[0];   //table holding all account entries for the user
            object s = accountsTable.Rows[0].Field <object>("AcctNumber"); //sets the default account to the first of the user's accounts. LIKELY CHANGE LATER.
            if (Convert.ToInt64(Session["account"]) == 0)
            {
                Session["account"] = Convert.ToInt64(s);                    //saves the first account as the default account during the session
            }
            userID = Convert.ToInt16(Session["userID"]);                    //saves the Session userID to the variable on this page
        }
        else
        {
            Session["userID"]  = 1; //temporary solution for demo 3/19/2017
            Session["account"] = 211111110;
        }

        DataSet DS = new DataSet();

        //Sets the source for the listview
        //Session's tab key decides if active or inactive tabs are displayed
        if (Convert.ToString(Session["tab"]) == "Inactive")
        {
            Session.Add("tab", "Inactive");
            DS = DA.returnCompleteGoals(Convert.ToInt64(Session["account"]));
            GoalsList.DataSource = DS;
            GoalsList.DataBind();

            //sets addfunds box and button to hidden
            TextBox addbox  = new TextBox();
            Button  addbutn = new Button();
            for (int i = 0; i < GoalsList.Items.Count(); i++)
            {
                addbox  = (TextBox)GoalsList.Items[i].FindControl("AddAmt");
                addbutn = (Button)GoalsList.Items[i].FindControl("AddFundsSubmit");
                if (addbutn != null)
                {
                    if (addbox != null)
                    {
                        addbox.Visible  = false;
                        addbutn.Visible = false;
                    }
                }
            }
        }
        else
        {
            Session.Add("tab", "Active");
            DS = DA.returnIncompleteGoals(Convert.ToInt64(Session["account"]));
            GoalsList.DataSource = DS;
            GoalsList.DataBind();
            //sets addfunds box and button to visible
            TextBox addbox  = new TextBox();
            Button  addbutn = new Button();

            for (int i = 0; i < GoalsList.Items.Count(); i++)
            {
                addbox  = (TextBox)GoalsList.Items[i].FindControl("AddAmt");
                addbutn = (Button)GoalsList.Items[i].FindControl("AddFundsSubmit");
                if (addbutn != null)
                {
                    if (addbox != null)
                    {
                        addbox.Visible  = true;
                        addbutn.Visible = true;
                    }
                }
            }
        }
    }