protected void ButtonSubmitClaim_Click(object sender, EventArgs e) { // First, if there's an upload that the user hasn't processed, process it first. if (this.Upload.UploadedFiles.Count > 0) { ProcessUpload(); } // If args were invalid, abort if (!Page.IsValid) { return; } // Set bank details _currentUser.BankName = this.TextBank.Text.Trim(); _currentUser.BankClearing = Formatting.CleanNumber(this.TextBankClearing.Text.Trim()); _currentUser.BankAccount = Formatting.CleanNumber(this.TextAccount.Text.Trim()); // Read the form data int temporaryId = Int32.Parse(this.TemporaryDocumentIdentity.Text); int organizationId = Int32.Parse(this.DropOrganizations.SelectedValue); Organization organization = Organization.FromIdentity(organizationId); Int64 amountCents = (Int64)(Double.Parse(this.TextAmount.Text, new CultureInfo("sv-SE")) * 100); FinancialAccount account = this.DropBudgets.SelectedFinancialAccount; DateTime created = DateTime.Now; DateTime expenseDate = (DateTime)this.DatePicker.SelectedDate; string description = this.TextDescription.Text; int claimId = 0; if (this.RadioNewClaim.Checked) { // Create the expense claim record ExpenseClaim newClaim = ExpenseClaim.Create(_currentUser, organization, account, expenseDate, description, amountCents); claimId = newClaim.Identity; // Move documents to the new expense claim Documents.ForObject(new TemporaryIdentity(temporaryId)).SetForeignObjectForAll(newClaim); } else { // This was a pre-approved claim: modify the existing claim and transaction ExpenseClaim claim = ExpenseClaim.FromIdentity(Int32.Parse(this.DropPreattested.SelectedValue)); FinancialTransaction transaction = claim.FinancialTransaction; claimId = claim.Identity; claim.Claimed = true; // If claimed amount exceeds attested amount, unattest if (amountCents > claim.AmountCents) { claim.Deattest(_currentUser); } // Change amount and date claim.SetAmountCents(amountCents, _currentUser); claim.ExpenseDate = expenseDate; // Move documents to the expense claim Documents.ForObject(new TemporaryIdentity(temporaryId)).SetForeignObjectForAll(claim); } // Create the event for PirateBot-Mono to send off mails Activizr.Logic.Support.PWEvents.CreateEvent(EventSource.PirateWeb, EventType.ExpenseCreated, _currentUser.Identity, organizationId, Geography.RootIdentity, _currentUser.Identity, claimId, string.Empty); Page.ClientScript.RegisterStartupScript(typeof(Page), "OkMessage", @"alert ('Your expense claim has been submitted.');", true); // Clear the text fields this.TextDescription.Text = string.Empty; this.TextAmount.Text = "0,00"; // TODO: LOCALIZE BY CULTURE this.TemporaryDocumentIdentity.Text = "0"; PopulateGrid(); PopulatePreattested(); }