Пример #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);
        }