예제 #1
0
        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
        }
예제 #2
0
    protected void Page_PreRender()
    {
        if (!IsPostBack)
        {
            DataAbstract DA = new DataAbstract();


            if (Convert.ToInt32(Session["userID"]) != 0)
            {
                userID = Convert.ToInt32(Session["userID"]);
                DataSet   userData  = DA.returnUser(userID); //gets the user
                DataTable userTable = userData.Tables[0];
                object    goal      = userTable.Rows[0].Field <object>("GoalsNotifications");
                object    budget    = userTable.Rows[0].Field <object>("BudgetsNotifications");
                goal_notify.Checked   = Convert.ToBoolean(goal);
                budget_notify.Checked = Convert.ToBoolean(budget);
                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
                }
            }
            else
            {
                Session["userID"]  = 1;                      //temporary solution for demo 3/19/2017
                Session["account"] = 211111110;
                DataSet   userData  = DA.returnUser(userID); //gets the user
                DataTable userTable = userData.Tables[0];
                object    goal      = userTable.Rows[0].Field <object>("GoalsNotifications");
                object    budget    = userTable.Rows[0].Field <object>("BudgetsNotifications");
                object    email     = userTable.Rows[0].Field <object>("EmailNotifications");
                object    text      = userTable.Rows[0].Field <object>("TextNotifications");
                goal_notify.Checked         = Convert.ToBoolean(goal);
                budget_notify.Checked       = Convert.ToBoolean(budget);
                email_notifications.Checked = Convert.ToBoolean(email);
                text_notifications.Checked  = Convert.ToBoolean(text);
            }



            DataTable    accounts = DA.returnAccounts(userID).Tables[0];
            DropDownList DDL      = acctSelect;

            DDL.Items.Insert(0, new ListItem("Select Account", "0"));
            DDL.DataSource     = accounts;
            DDL.DataTextField  = "AcctNumber";
            DDL.DataValueField = "AcctNumber";

            DDL.DataBind();

            ListItem LVI = DDL.Items.FindByValue(Convert.ToString(Session["account"]));
            if (LVI != null)
            {
                int index = DDL.Items.IndexOf(LVI);
                acctSelect.SelectedIndex = index;
            }
            currAcct.Text = "Current account: " + Session["account"].ToString();
        }
    }