private StringBuilder PopulateFeePendingDataInStringBuilder() { var stringBuilder = new StringBuilder(); stringBuilder.Append(DoubleQuote + "Student Name" + DoubleQuoteAndComa); stringBuilder.Append(DoubleQuote + "Class Name" + DoubleQuoteAndComa); stringBuilder.Append(DoubleQuote + "Section Name" + DoubleQuoteAndComa); stringBuilder.Append(DoubleQuote + "Medium Name" + DoubleQuoteAndComa); stringBuilder.Append(DoubleQuote + "Academic Year" + DoubleQuoteAndComa); stringBuilder.Append(DoubleQuote + "Fee Paid" + DoubleQuoteAndComa); stringBuilder.Append(DoubleQuote + "Fee Due" + DoubleQuoteAndComa); stringBuilder.AppendLine(); var accounts = PageDataService.GetFeePendingDetailsByMediumIdByClassIdAdoNet(Convert.ToInt32(ddlMediumForGridView.SelectedValue), Convert.ToInt32(ddlClassForGridView.SelectedValue)); var feeDetails = PageDataService.GetCurrentYearFeeMasterByMediumIdAndClassIdAdoNet( Convert.ToInt32(ddlMediumForGridView.SelectedValue), Convert.ToInt32(ddlClassForGridView.SelectedValue)); var currentAcademicYear = PageDataService.GetActiveAcademicYearAdoNet(); foreach (var account in accounts) { var scholarShipDetailsOfCurrentYear = PageDataService.GetScholarShipDetailsByStudentIdAndAcademicYearIdAdoNet(account.Student.StudentId, currentAcademicYear. AcademicYearId); var scholarShipToatlAmountSanctioned = scholarShipDetailsOfCurrentYear.Aggregate(0, (current, scholarShipDetail) => current + Convert.ToInt32( scholarShipDetail. AmountSanctioned)); var feePending = Convert.ToInt32(feeDetails.Fee) - Convert.ToInt32(account.FeePaid) - Convert.ToInt32(account.CarryFarwordFee) - Convert.ToInt32(scholarShipToatlAmountSanctioned); if (feePending > 0) { stringBuilder.Append(DoubleQuote + account.Student.StudentName + DoubleQuoteAndComa); stringBuilder.Append(DoubleQuote + account.Class.ClassName + DoubleQuoteAndComa); stringBuilder.Append(DoubleQuote + account.Student.Section.SectionName + DoubleQuoteAndComa); stringBuilder.Append(DoubleQuote + account.Medium.MediumName + DoubleQuoteAndComa); stringBuilder.Append(DoubleQuote + account.AcademicYear.AcademicYearStart + "-" + account.AcademicYear.AcademicYearEnd + DoubleQuoteAndComa); stringBuilder.Append(DoubleQuote + Convert.ToInt32(account.FeePaid) + DoubleQuoteAndComa); stringBuilder.Append(DoubleQuote + feePending + DoubleQuoteAndComa); stringBuilder.AppendLine(); } } return(stringBuilder); }