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; } BudgetDS = DA.returnBoundedBudgets(Convert.ToInt64(Session["account"]), d1, d2); //Sets the source for the listview BudgetList.DataSource = BudgetDS; BudgetList.DataBind(); //LoadSubjects(); DataTable accounts = DA.returnAccounts(userID).Tables[0]; DropDownList DDL = AccountList; DDL.Items.Insert(0, new ListItem("Select Account", "0")); DDL.DataSource = accounts; DDL.DataTextField = "AcctNumber"; DDL.DataValueField = "AcctNumber"; DDL.DataBind(); DataTable categories = DA.returnCategories(userID).Tables[0]; DropDownList DDL2 = CategorySelect; DDL2.Items.Insert(0, new ListItem("Select Category", "0")); DDL2.DataSource = categories; DDL2.DataTextField = "Name"; DDL2.DataValueField = "CategoryID"; DDL2.DataBind(); }
public static string[,] getPieValues(long account) { DataAbstract DA = new DataAbstract(); DateTime DT = System.DateTime.Now; DateTime before = DT.AddMonths(-1); DataSet accountData = DA.returnAccounts(userID); System.Data.DataTable accountsTable = accountData.Tables[0]; //table holding all account entries for the user //object accountObject = accountsTable.Rows[0].Field<object>("AcctNumber"); //long accountNumber = Convert.ToInt64(accountObject); DataSet catData = DA.returnCategories(userID); System.Data.DataTable catTable = catData.Tables[0]; int resLength = catTable.Rows.Count; string[,] result = new string[resLength, 3]; double totalTransactions = 0; for (int i = 0; i < catTable.Rows.Count; ++i) //get name and total spent for each category { object catIDData = catTable.Rows[i].Field <object>("CategoryID"); object nameData = catTable.Rows[i].Field <object>("Name"); int catID = Convert.ToInt32(catIDData); string category = Convert.ToString(nameData); DateTime start = DateTime.Now.AddMonths(-1); DateTime end = DateTime.Now; //double catSum = DA.returnTransactionCategoryBoundTotals(catID, account, start, end); //one month span //TEMPORARY RANGE WITH USEABLE DATA double catSum = DA.returnTransactionCategoryBoundTotals(catID, account, Convert.ToDateTime("12/1/2016"), Convert.ToDateTime("1/1/2017")); //other span totalTransactions += catSum; result[i, 0] = category; result[i, 1] = Convert.ToString(catSum); } //end of for loop //result has names and totals of each category double degreeCheck = 0; for (int i = 0; i < catTable.Rows.Count; ++i) //get degrees of pie chart for each category { double catSum = Convert.ToDouble(result[i, 1]); double percent = catSum / totalTransactions; if (catSum == 0) { percent = 0; } double degrees = percent * 360; result[i, 2] = Convert.ToString(Math.Round(degrees)); degreeCheck += degrees; } return(result); }
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 void getAccounts(object sender, EventArgs e) { DataAbstract DA = new DataAbstract(); DataTable accounts = DA.returnAccounts(userID).Tables[0]; DropDownList DDL = AccountList; DDL = (DropDownList)sender; DDL.Items.Insert(0, new ListItem("Select Account", "0")); DDL.DataSource = accounts; DDL.DataTextField = "AcctNumber"; DDL.DataValueField = "AcctNumber"; //DDL.DataBind(); DDL.ID = "EditAccountList"; //sender = DDL; }
protected void Page_PreRender() { if (!IsPostBack) { 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 (Session["account"] == null) { 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; } // long, datetime, datetime int, int transactions = DA.returnTransactions(Convert.ToInt64(Session["account"])); TransactionsList.DataSource = transactions; TransactionsList.DataBind(); int uid = Convert.ToInt32(Session["userID"]); ChangeCategoryDD.Items.Insert(0, new ListItem("Select Account", "0")); ChangeCategoryDD.DataSource = DA.returnCategories(uid); ChangeCategoryDD.DataTextField = "Name"; ChangeCategoryDD.DataValueField = "CategoryID"; ChangeCategoryDD.DataBind(); ListItem LVI = ChangeCategoryDD.Items.FindByValue("6"); //set listview selected to 'other' on load if (LVI != null) { int index = ChangeCategoryDD.Items.IndexOf(LVI); ChangeCategoryDD.SelectedIndex = index; } } }
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 (Session["account"] == null) { 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; } GoalDS = DA.returnFavorites("Goal", Convert.ToInt64(Session["account"])); //Sets the source for the listview FaveGoalsList.DataSource = GoalDS; FaveGoalsList.DataBind(); BudgetDS = DA.returnFavorites("Budget", Convert.ToInt64(Session["account"])); //Sets the source for the listview FaveBudgetsList.DataSource = BudgetDS; FaveBudgetsList.DataBind(); hfAcctNum.Value = Convert.ToString(Session["account"]); getPieValues(Convert.ToInt64(Session["account"])); }
//DateTime now = DateTime.Now; //DateTime later = DateTime.Now.AddMonths(1); protected void Page_Load(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; } }
private void LoadSubjects() { DataAbstract DA = new DataAbstract(); DataTable categories = DA.returnCategories(userID).Tables[0]; DataTable accounts = DA.returnAccounts(userID).Tables[0]; //Set sources for the dropdowns and associate the text and value // based on the datatable fields CategorySelect.DataSource = categories; CategorySelect.DataTextField = "Name"; CategorySelect.DataValueField = "CategoryID"; CategorySelect.DataBind(); AccountList.DataSource = accounts; AccountList.DataTextField = "AcctNumber"; AccountList.DataValueField = "AcctNumber"; AccountList.DataBind(); CategorySelect.Items.Insert(0, new ListItem("Select Category", "0")); AccountList.Items.Insert(0, new ListItem("Select Account", "0")); }
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); }
//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; } } } } }