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);
    }
Example #2
0
    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();
    }
Example #3
0
    public void getCategories(object sender, EventArgs e)
    {
        DataAbstract DA         = new DataAbstract();
        DataTable    categories = DA.returnCategories(userID).Tables[0];
        DropDownList DDL        = CategorySelect;

        DDL = (DropDownList)sender;
        DDL.Items.Insert(0, new ListItem("Select Category", "0"));
        DDL.DataSource     = categories;
        DDL.DataTextField  = "Name";
        DDL.DataValueField = "CategoryID";

        //DDL.DataBind();
        DDL.ID = "EditCategorySelect";
    }
Example #4
0
    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;
            }
        }
    }
Example #5
0
    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"));
    }