Example #1
0
    private void PopulateGrid()
    {
        ExpenseClaims allClaims = ExpenseClaims.FromClaimingPerson(_currentUser);

        ExpenseClaims gridData   = new ExpenseClaims();
        DateTime      oneYearAgo = DateTime.Today.AddYears(-1);

        foreach (ExpenseClaim claim in allClaims)
        {
            // Add those that are less than a year old AND/OR not repaid yet.

            if (claim.ExpenseDate > oneYearAgo || claim.Open)
            {
                gridData.Add(claim);
            }
        }

        gridData.Sort(SortGridItems);

        this.GridExpenseClaims.DataSource = gridData;
        this.GridExpenseClaims.Rebind();
    }
Example #2
0
 public static ExpenseClaim[] SelectOpenByClaimer(int personId)
 {
     return(ExpenseClaims.FromClaimingPerson(Person.FromIdentity(personId)).WhereOpen.ToArray());
 }
Example #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int    currentUserId = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
        Person currentUser   = Person.FromIdentity(currentUserId);

        this.ListOpenExpenses.PersonId = currentUserId;

        // Get currently expensed amount

        ExpenseClaims expenseClaims = ExpenseClaims.FromClaimingPerson(currentUser);

        decimal totalOpen = 0.0m;

        foreach (ExpenseClaim expense in expenseClaims)
        {
            if (expense.Open)
            {
                totalOpen += expense.Amount;
            }
        }

        if (totalOpen > 0)
        {
            this.LabelOpenExpensesParagraph.Text = String.Format(LocalizationManager.GetLocalString("Interface.Pages.ActivePirate.Expenses.Open.IntroParagraph",
                                                                                                    "This is a list of your filed but still open expenses, currently totalling {0:N2}. They will be removed from this list when the treasurer has received your receipts and reimbursed the amount."),
                                                                 totalOpen);
        }
        else
        {
            this.LabelOpenExpensesParagraph.Text = LocalizationManager.GetLocalString("Interface.Pages.ActivePirate.Expenses.Open.IntroParagraph",
                                                                                      "When you have open expenses, this section lists them.");
        }

        if (!Page.IsPostBack)
        {
            // Init

            this.TextExpenseBy.Text = currentUser.Name;

            // Populate list of organizations (initial population)

            Organizations organizationList = currentUser.GetAuthority().GetOrganizations(RoleTypes.AllRoleTypes);
            organizationList = organizationList.RemoveRedundant();
            organizationList.Add(Organization.Sandbox);

            foreach (Organization organization in organizationList)
            {
                Organizations organizationTree = organization.GetTree();

                foreach (Organization organizationOption in organizationTree)
                {
                    DropOrganizations.Items.Add(new ListItem(organizationOption.NameShort, organizationOption.OrganizationId.ToString()));
                }
            }

            PopulateGeographies();

            // Localize

            this.LabelNewExpenseParagraph.Text = LocalizationManager.GetLocalString("Interface.Pages.ActivePirate.Expenses.New.IntroParagraph",
                                                                                    "To file an expense:<ul><li>Take the receipt and affix it to an A4 size paper. </li><li>Select the organization and geography that should be charged</li><li>Write the receipt date and a good short description</li><li>Press Claim Expense. </li><li>You will be asked to mark the receipt with a number and send it to the treasurer.<br><b>Note the number and the address, they will only be shown at this time!</B> </li></ul>Don't forget to specify your bank account details (in your member profile).");

            this.LabelExpenseBy.Text    = LocalizationManager.GetLocalString("Interface.Pages.ActivePirate.Expenses.New.ExpensingPersonName", "Expensed By") + "&nbsp;&nbsp;";
            this.LabelOrganization.Text = LocalizationManager.GetLocalString("Interface.Pages.ActivePirate.Expenses.New.Organization", "Organization") + "&nbsp;&nbsp;";
            this.LabelGeography.Text    = LocalizationManager.GetLocalString("Interface.Pages.ActivePirate.Expenses.New.Geography", "Geography") + "&nbsp;&nbsp;";
            this.LabelDate.Text         = LocalizationManager.GetLocalString("Interface.Pages.ActivePirate.Expenses.New.Date", "Expense Date") + "&nbsp;&nbsp;";
            this.LabelDescription.Text  = LocalizationManager.GetLocalString("Interface.Pages.ActivePirate.Expenses.New.Description", "Description") + "&nbsp;&nbsp;";
            this.LabelAmount.Text       = LocalizationManager.GetLocalString("Interface.Pages.ActivePirate.Expenses.New.Amount", "Amount (incl VAT)") + "&nbsp;&nbsp;";

            this.ButtonClaimExpense.Text = LocalizationManager.GetLocalString("Interface.Pages.ActivePirate.Expenses.New.ButtonClaim", "Claim Expense");

            // Set focus

            this.TextDate.Focus();
        }
    }