internal string FormatErrorOutput(EmployeePayslip employeePaySlip) { String title = @"Unable to Generate Payslip. The following errors occured:\n\n"; StringBuilder errorMessage = new StringBuilder(); employeePaySlip.Errors.Take(10).ForEach(error => errorMessage.Append(string.Format(@"{0}\n\t{1}\n\n", error.ErrorHeader, error.ErrorBody))); return(title + errorMessage.ToString()); }
internal void CreatOutputFile(EmployeePayslip employeePaySlips) { FileName = string.Format("EmployeeMonthlyPayslips{0}.csv", DateTime.Now.ToString("yyyyMMdd")); FilePath = string.Format(@"{0}\ServerDocs\{1}", Server.MapPath("~"), FileName); // Write the string array to a new file named "WriteLines.txt". using (StreamWriter outputFile = new StreamWriter(FilePath)) { foreach (string line in employeePaySlips.PayslipRecords) { outputFile.WriteLine(line); } } }
internal void StartGeneratingPayslips(List <ImportFileDetail> fileRecordDetails) { EmployeePayslip employeePaySlip = new EmployeePayslip(); employeePaySlip.Initialise(fileRecordDetails); employeePaySlip.Generate(); if (employeePaySlip.FileHasErrors()) { string errorMessage = FormatErrorOutput(employeePaySlip); MessageBox.Show(this, errorMessage); } else { CreatOutputFile(employeePaySlip); PromptUserToSaveFile(); } }
public static void GenerateTestPayslips(this EmployeePayslip employeePaySlip, List <ImportFileDetail> importFileDetails) { employeePaySlip.Initialise(importFileDetails); employeePaySlip.Generate(); }