//Show the summary in the message box private void BtnSummary_Click(object sender, EventArgs e) { string outputString = ""; //check data exists in the repo if (salesPersonRepo.Count > 0) { //if individual information is not cleared the show the appropriate result to messagebox if (individualSalesPersonInfoCleared) { outputString = "Current sales person's information removed or cleared"; } else { //Check current sales person exists or not if (!SalesPersonUtility.IsEmpty(aSalesPerson.FirstName) && !SalesPersonUtility.IsEmpty(aSalesPerson.LastName) && SalesPersonUtility.IsSalesPersonFound(aSalesPerson, salesPersonRepo)) { outputString = ""; outputString = aSalesPerson.Display(); richTextBoxForResult.Text = outputString; } else { outputString = "Current sales person's information removed or cleared"; } } //grab and hold the value from displaySummary and also pass outputString extracted from above logic outputString = DisplaySummary(outputString); MessageBox.Show(outputString); richTextBoxForResult.Text = outputString; } //if no data found in the repo display appropriate message else { richTextBoxForResult.Text = "No data found to display"; MessageBox.Show("No data found to display"); } Clear_Error_Message(); individualSalesPersonInfoCleared = false; }