static public void notifyOne(int userID) { Boolean notifyGoals; Boolean notifyBudgets; DataAbstract DA = new DataAbstract(); notifyBudgets = Convert.ToBoolean(DA.returnUser(userID).Tables[0].Rows[0].Field <object>("GoalsNotifications")); notifyGoals = Convert.ToBoolean(DA.returnUser(userID).Tables[0].Rows[0].Field <object>("BudgetsNotifications")); DataTable accounts = DA.returnAccounts(userID).Tables[0]; string emailMsg = "Report on your financial status \n"; for (int i = 0; i < accounts.Rows.Count; ++i) //iterate through all accounts of the user { long accountNum = Convert.ToInt64(accounts.Rows[i].Field <object>("AcctNumber")); //Section for proceessing Goal portion of email if (notifyGoals) { //emailMsg += getGoalText(accountNum); }//end of goals section //Section for processing Budget section of email if (notifyBudgets) { DataTable budgets = DA.returnBudgets(accountNum).Tables[0]; emailMsg += "\n\nYour current Budget Updates \n"; for (int j = 0; j < budgets.Rows.Count; ++j) { DataRow b = budgets.Rows[j]; int notificationCount = Convert.ToInt32(b.Field <object>("NotificationCount")); int budgetID = Convert.ToInt32(b.Field <object>("BudgetID")); string categoryName = DA.returnCategoryName(Convert.ToInt32(b.Field <object>("CategoryID"))); double currentAmt = Convert.ToDouble(b.Field <object>("CurrentAmt")); double maxAmt = Convert.ToDouble(b.Field <object>("MaxAmt")); double percent = currentAmt / maxAmt; Notifications N = new Notifications(); int notificationCountUpdate = N.Check("budget", percent * 100); if (notificationCountUpdate > notificationCount) { DA.updateNotificationBudgets(budgetID, notificationCountUpdate); string budgetString = categoryName + " has reached " + (percent * 100).ToString("N0") + "%\n"; emailMsg += budgetString; } }//end of budgets } string[] m = emailMsg.Trim().Split(); Notifications Note = new Notifications(); Note.sendEmail(emailMsg, accountNum.ToString()); }//end of specific account }
public static string[,] getbudgetData() { DataAbstract DA = new DataAbstract(); DataSet accountData = DA.returnAccounts(userID); System.Data.DataTable accountsTable = accountData.Tables[0]; //table holding all account entries for the user int accountCount = accountsTable.Rows.Count; //the total number of accounts for the user int totalBudgetCount = 0; //grab each account under the userID, grab the goals for each account, sum number of all goals for (int num = 0; num < accountCount; ++num) { System.Data.DataRow accountRow = accountsTable.Rows[num]; object s = accountRow.Field <object>("AcctNumber"); long accountNum = Convert.ToInt64(s); totalBudgetCount += DA.returnBudgets(accountNum).Tables[0].Rows.Count; } string[,] result = new string[totalBudgetCount, 9]; //will hold data for all goals in all accounts int total = 0; //populate the 2D array for (int i = 0; i < accountCount; ++i) //variable i iterates through accounts { System.Data.DataRow accountRow = accountsTable.Rows[i]; long accountNum = Convert.ToInt64(accountRow.Field <object>("AcctNumber")); DataSet D = DA.returnBudgets(accountNum); System.Data.DataTable T = D.Tables[0]; //Gets the actual Goals Table, filtered appropriately int rowCount = T.Rows.Count; //Number of entries for (int j = 0; j < rowCount; ++j) //variable j iterates through budgets of an account { //RAW DATABASE OBJECTS object BudgetIDData, CategoryIDData, StartDateData, EndDateData, MaxAmtData, CompletedData, FailedData, CurrentAmt; //BUDGET INFOS TO BECOME STRINGS string BudgetID, CategoryID, AcctNumber, StartDate, EndDate, MaxAmt, Completed, Failed, Current; System.Data.DataRow DR = T.Rows[j]; //gets the current row we're copying //BudgetID BudgetIDData = DR.Field <object>("BudgetID"); BudgetID = Convert.ToString(BudgetIDData); //CategoryID CategoryIDData = DR.Field <object>("CategoryID"); CategoryID = DA.returnCategoryName(Convert.ToInt32(CategoryIDData)); //AcctNumber AcctNumber = Convert.ToString(accountNum); //StartDate StartDateData = DR.Field <object>("StartDate"); StartDate = Convert.ToDateTime(StartDateData).ToString("M dd, yyyy"); //EndDate EndDateData = DR.Field <object>("EndDate"); EndDate = Convert.ToDateTime(EndDateData).ToString("M dd, yyyy"); //MaxAmy MaxAmtData = DR.Field <object>("MaxAmt"); MaxAmt = Convert.ToInt32(MaxAmtData).ToString("C2"); //Completed? CompletedData = DR.Field <object>("Completed"); Completed = Convert.ToString(CompletedData); //Failed? FailedData = DR.Field <object>("Failed"); Failed = Convert.ToString(FailedData); CurrentAmt = DR.Field <object>("CurrentAmt"); Current = Convert.ToString(CurrentAmt); result[total, 0] = BudgetID; result[total, 1] = CategoryID; result[total, 2] = AcctNumber; result[total, 3] = StartDate; result[total, 4] = EndDate; result[total, 5] = MaxAmt; result[total, 6] = Completed; // "false" or "true" result[total, 7] = Failed; // "false" or "true" result[total, 8] = Current; ++total; } //end goal } return(result); }