protected void btnSendToAccounts_Click(object sender, System.EventArgs e)
        {
            bool retVal = false;

            chkPostToExchequer.Checked = true;

            if (m_invoiceExtra == null)
            {
                PopulateInvoiceExtra();
            }

            Facade.IInvoiceExtra facInvoiceExtra = new Facade.Invoice();

            lblConfirmation.Text = string.Empty;

            if (m_isUpdate)
            {
                string applicationExceptionErrorMessage = string.Empty;
                bool   postSuccess = false;

                try
                {
                    postSuccess = facInvoiceExtra.UpdateInvoiceExtra(m_invoiceExtra, this.txtAmountNet.Culture.LCID, ((Entities.CustomPrincipal)Page.User).UserName);
                }
                catch (ApplicationException aex)
                {
                    if (aex.InnerException.Message.ToLower().Contains("client account") && aex.InnerException.Message.ToLower().Contains("does not exist"))
                    {
                        applicationExceptionErrorMessage = aex.InnerException.Message;
                    }
                    else
                    {
                        throw;
                    }
                }

                if (postSuccess)
                {
                    lblConfirmation.Text = CONFIRMATION_UPDATE_MESSAGE;
                    retVal = true;
                }
                else
                {
                    if (applicationExceptionErrorMessage != string.Empty)
                    {
                        lblConfirmation.Text = applicationExceptionErrorMessage;
                    }
                    else
                    {
                        lblConfirmation.Text = CONFIRMATION_ERROR_MESSAGE;
                    }
                }
            }

            if (retVal)
            {
                if (lblConfirmation.Text == string.Empty)
                {
                    lblConfirmation.Text = "The Invoice has been posted to accounts.";
                }

                chkPostToExchequer.Visible = true;
                chkPostToExchequer.Checked = true;

                // Disable all buttons now that the invoice has been posted
                btnAddUpdateInvoice.Enabled = false;
                btnSendToAccounts.Enabled   = false;
            }
            else
            {
                if (lblConfirmation.Text == string.Empty)
                {
                    lblConfirmation.Text = "The Invoice has not been posted to accounts.";
                }

                chkPostToExchequer.Checked = false;
            }

            LoadInvoiceExtra();
            ViewInvoice();

            lblConfirmation.Visible = true;
        }
        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();
                }
            }
        }