private void SearchforPayRate() { try { if (Check_TextBox(wages_Employement_Hours.Text, 1, "Hours") && Check_TextBox(wages_Employement_Index.Text, 3, "Employee ID")) //call Check_TextBox to check whether context which user enters is valid. { Waga_Tax Rate_Data = new Waga_Tax(); SearchRateInFile(); //loading from Data File string em_id = wages_Employement_Index.Text; //get what index user enters. if (Rate_Data.CheckID(em_id)) //if the index has existed in the data file. Get the data from the file to finish it. { decimal rate_num = Convert.ToDecimal(Rate_Data.GetRateFromDictionary(em_id)); decimal hours_num = Convert.ToDecimal(wages_Employement_Hours.Text); decimal waga_num = Convert.ToDecimal(wages_Employement_Hours.Text) * rate_num; showResult_Text.Text = ""; showResult_Text.AppendText($"Employee {em_id} Wage Details:" + Environment.NewLine); showResult_Text.AppendText($"Pay rate is ${rate_num}" + Environment.NewLine); showResult_Text.AppendText($"Working hours is {hours_num}" + Environment.NewLine); showResult_Text.AppendText($"Wage is ${waga_num}"); } else { MessageBox.Show($"Sorry,Can not find the ID."); } } } catch (Exception e) { MessageBox.Show($"Sorry,seems something wrong:{Environment.NewLine}{e}", "Error"); } }