Protected Function CreateRpts(ByVal ReportID As String, _
ByVal cQuery As clsQuery, ByVal fileName As String, _
ByVal fileType As ReportFileType, _
ByVal cnString As String) As String Implements iABMRpts.CreateRpts
'
' generate the excel file
'
Dim CD As New APLNetShared2.clsSQLData(cnString)
Dim cPB As New APLNetShared2.clsDataParameterListBuilder
Dim ds As New System.Data.DataSet
Dim xlApp As New Microsoft.Office.Interop.Excel.Application
Dim bk As Microsoft.Office.Interop.Excel.Workbook
Dim sh As Microsoft.Office.Interop.Excel.Worksheet
Dim nRow As Integer
Dim sSQL As New System.Text.StringBuilder
sSQL.Append("SELECT Policy.SocialSecurityNo,")
sSQL.Append(" PolicyHolder.FirstName+' '+PolicyHolder.LastName AS FullName,")
sSQL.Append(" BillingInfo.Type, PaymentMethod.PaymentMethod, Policy.PolicyStatus,")
sSQL.Append(" Policy.NewBusinessPeriod, Policy.Premium6, Policy.NextBillAmount,")
sSQL.Append(" Policy.RenewalPeriod, Policy.NextBillDate, Policy.Premium2,")
sSQL.Append(" MAX(TransactionHistory.TransactionDate) AS MaxTransactionDate,")
sSQL.Append(" PolicyHolder.LastName, Policy.Active")
sSQL.Append(" FROM Policy")
sSQL.Append(" LEFT JOIN PolicyHolder ON Policy.SocialSecurityNo=PolicyHolder.SocialSecurityNo")
sSQL.Append(" LEFT JOIN TransactionHistory ON Policy.PolicyNo=TransactionHistory.SourceFile")
sSQL.Append(" LEFT JOIN BillingInfo on Policy.RecordID=BillingInfo.PolicyID")
sSQL.Append(" LEFT JOIN PaymentMethod ON Policy.PaymentMethodID=PaymentMethod.RecordID")
cQuery.CreateQueryString()
If cQuery.QueryString.Trim.Length > 0 Then
sSQL.Append(" WHERE " & cQuery.CreateQueryString)
cPB = cQuery.ParameterBuilder
End If