protected void btnVoid_Click(object sender, EventArgs e) { try { var list = contractProvider.GetActiveInvoices(lblContractNo.Text).ToList(); string invoices = String.Empty; list.ForEach(inv => invoices += @"<li>" + inv.InvoiceNo + @"</li"); if (list.Any()) { WebFormHelper.SetLabelTextWithCssClass( lblMessageAddEdit, @"This contract has invoice already, please void invoice first: <ul>" + invoices + "</ul>", LabelStyleNames.ErrorMessage); } else { contractProvider.VoidContract(lblContractNo.Text); mvwForm.SetActiveView(viwRead); WebFormHelper.SetLabelTextWithCssClass( lblMessage, @"Contract <b> " + lblContractNo.Text + "</b> has been processed as VOID", LabelStyleNames.AlternateMessage); btnVoid.Enabled = false; btnCloseContract.Enabled = false; } } catch (Exception ex) { mvwForm.SetActiveView(viwRead); WebFormHelper.SetLabelTextWithCssClass(lblMessage, ex.Message, LabelStyleNames.ErrorMessage); } }