protected void ButtonSaveChanges_Click(object sender, EventArgs e) { // If the values in the controls are not valid, abort: if (!Page.IsValid) { return; } // Move on and parse values. Int64 newAmountCents = (Int64)(Double.Parse(this.TextAmount.Text, new CultureInfo("sv-SE")) * 100); FinancialAccount newAccount = this.DropAccounts.SelectedFinancialAccount; DateTime newDueDate = (DateTime)this.DateInvoiceDue.SelectedDate; if (newAccount.Identity != _invoice.BudgetId) { // TODO: Reset pre-attestation amount (which is not valid if budget changes) if (_invoice.Attested) { _invoice.Deattest(_currentUser); } _invoice.SetBudget(newAccount, _currentUser); } if (newAmountCents != _invoice.AmountCents) { if (_invoice.Attested) { if (newAmountCents > _invoice.AmountCents) { _invoice.Deattest(_currentUser); } } _invoice.SetAmountCents(newAmountCents, _currentUser); } if (newDueDate != _invoice.DueDate) { _invoice.DueDate = newDueDate; } // Close and rebind ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true); }