protected void btnAddUpdateInvoice_Click(object sender, EventArgs e) { if (Page.IsValid) { bool addUpdateSuccess = false; if (m_invoiceExtra == null) { PopulateInvoiceExtra(); } Facade.IInvoiceExtra facInvoiceExtra = new Facade.Invoice(); if (m_isUpdate) { #region Update UpdateInvoiceExtra(); using (TransactionScope ts = new TransactionScope()) { if (facInvoiceExtra.UpdateInvoiceExtra(m_invoiceExtra, this.txtAmountNet.Culture.LCID, ((Entities.CustomPrincipal)Page.User).UserName)) { lblConfirmation.Text = CONFIRMATION_UPDATE_MESSAGE; addUpdateSuccess = true; rdiInvoiceDate.Enabled = !m_invoiceExtra.Posted; } else { lblConfirmation.Text = CONFIRMATION_ERROR_MESSAGE; } ts.Complete(); } #endregion } else { #region Create m_extraIdCSV = (string)ViewState["ExtraIdCSV"]; Entities.FacadeResult result = facInvoiceExtra.CreateInvoiceExtra(m_invoiceExtra, this.txtAmountNet.Culture.LCID, Convert.ToInt32(ViewState["IdentityId"]), ((Entities.CustomPrincipal)Page.User).UserName, m_extraIdCSV); if (result.Success) { lblConfirmation.Text = CONFIRMATION_ADD_MESSAGE; btnAddUpdateInvoice.Text = "Update invoice"; addUpdateSuccess = true; m_isUpdate = true; ViewState["InvoiceId"] = result.ObjectId; // InvoiceId; ViewState["InvoiceExtra"] = null; //PopulateStaticControls(); LoadInvoiceExtra(); } else { infringementDisplay.Infringements = result.Infringements; infringementDisplay.DisplayInfringments(); lblConfirmation.Text = CONFIRMATION_ERROR_MESSAGE; } #endregion } lblConfirmation.Visible = true; if (addUpdateSuccess) { ViewInvoice(); } } }