Problem to class

Hi,
I get these
Error	1	Type 'ExportInterComSalesDataToSunAccountDataSource' is not defined.	C:\Kts Projects\KongTai\AccountingAgent\AccountingAgent\Reports\GeneralExportInterComSalesDataToSunAccount.vb	12	15	AccountingAgent
Error	2	Type 'ExportInterComSalesDataToSunAccountDataSource' is not defined.	C:\Kts Projects\KongTai\AccountingAgent\AccountingAgent\Reports\GeneralExportInterComSalesDataToSunAccount.vb	56	18	AccountingAgent

Open in new window

using these codes
Imports System.ComponentModel
Imports System.Data
Imports MySql.Data.MySqlClient
Imports OfficeOpenXml
Imports Kts.Agent.Support.ExcelReportBase
Imports Kts.Agent.Support.MySql
Imports Kts.Agent.Core.Globals
Imports OfficeOpenXml.Style

Public Class GeneralExportInterComSalesDataToSunAccount : Inherits GeneralExportDataToSunAccountBase

    Dim ds As ExportInterComSalesDataToSunAccountDataSource

    Public Sub New(task As TaskEntry, options As ReportOption, outputFolder As String, Optional ByVal conn As MySqlConnection = Nothing)
        MyBase.New(task, options, outputFolder, conn)
    End Sub

    Public Overrides Sub CreateReport()

        If CheckUserRunOption() = False Then Exit Sub
        If FromDate = #1/1/1900# Then FromDate = Now.AddDays(-1).Date
        If ToDate = #1/1/1900# Then ToDate = FromDate

        Dim conn As MySqlConnection = Kts.Agent.Support.MySql.Database.OpenConnection()
        'Dim dataRange As New DataRangeOption With {.FromDate = FromDate.Date, .ToDate = ToDate.Date,
        '                  .IsAllBrands = True, .IsAllShops = False, .ShopLine = ALL_LOCATIONS_NOMOCKUP,
        '                  .IsShopFilterByLine = True, .ShopLineCode = "", .IsAllShopInLine = True,
        '                  .IsAllProductCodes = True, .ShoesProduct = True, .AccessoriesProduct = True, .OthersProduct = True, .IsTransfer = False}

        Dim dataRange As New DataRangeOption With {.FromDate = FromDate.Date, .ToDate = ToDate.Date,
                  .IsAllBrands = True, .IsAllShops = False,
                  .IsShopFilterByLine = True, .ShopLineCode = ALL_LOCATIONS_NOMOCKUP, .IsAllShopInLine = True,
                  .IsAllProductCodes = True, .ShoesProduct = True, .AccessoriesProduct = True, .OthersProduct = True, .IsTransfer = False}

        'Start - Added by CHI 20150723

        If SelectedShopCodes IsNot Nothing AndAlso SelectedShopCodes.Count > 0 Then
            With dataRange
                .Shops = SelectedShopCodes
                .IsAllShops = False
                .IsShopFilterByLine = False
                .IsAllShopInLine = False
            End With
        End If
        'End - Added by CHI 20150723

        dataRange.ClearExcludes()
        If ReportOption.SalesExcludeShops.Count > 0 Then dataRange.ExcludeShops.AddRange(ReportOption.SalesExcludeShops)
        If ReportOption.SalesExcludeWareTypes.Count > 0 Then dataRange.ExcludeWarehouseTypes.AddRange(ReportOption.SalesExcludeWareTypes)

        Dim dataRangeCollection As New DataRangeOptionCollection
        dataRangeCollection.Add(dataRange)

        Task.SubDescription = "正在讀取數據..."

        ds = New ExportInterComSalesDataToSunAccountDataSource(dataRangeCollection, ReportOption.GetDatabases, conn)
        TotalLoadedRows += ds.LoadReportData
        CloseConnection(conn)

        For Each companyCode In ds.Select(Function(x) x.CompanyCode).Distinct
            For Each journalCode In ds.Where(Function(x) x.CompanyCode.Equals(companyCode, StringComparison.OrdinalIgnoreCase)).Select(Function(x) x.JournalCode).Distinct
                GenerateFile(companyCode, journalCode, dataRangeCollection)
            Next
        Next
    End Sub

    Public Sub GenerateFile(companyCode As String, journalCode As String, dataRangeCollection As DataRangeOptionCollection)
        Dim fileName As String = String.Format("{0}/{1}_{2}_{3}.txt", OutputFolder, ds.DocumentCode, companyCode, journalCode)
        If System.IO.File.Exists(fileName) Then System.IO.File.Delete(fileName)
        Dim fw As New System.IO.StreamWriter(fileName)
        'Header
        fw.WriteLine(String.Join(",", FileHeader))
        'Detail
        For Each item In ds.Where(Function(x) x.CompanyCode.Equals(companyCode, StringComparison.OrdinalIgnoreCase) And x.JournalCode.Equals(journalCode, StringComparison.OrdinalIgnoreCase)).
                                                                                                                                                            OrderBy(Function(x) x.TransactionDate).
                                                                                                                                                            ThenBy(Function(x) x.ShopCode).
                                                                                                                                                            ThenBy(Function(x) x.BrandCode).
                                                                                                                                                            ThenBy(Function(x) x.ProductTypeCodeText(2))
            'fw.WriteLine(String.Join(",", {item.AccountCode, String.Format("""{0}""", item.Description), String.Format("""{0}""", item.TransactionRef), _
            '                  item.AccountingPeriod, item.TransactionDate, Math.Abs(Math.Round(item.Amount, 2)), item.DebitCredit, item.Department, _
            '                   item.BrandCode, "", item.ShopCode, item.Stakeholder, item.ProductTypeCodeText(2), "END"}))
            fw.WriteLine(String.Join(",", {item.AccountCode, String.Format("""{0}""", item.Description), String.Format("""{0}""", item.TransactionRef), _
                              item.AccountingPeriod, item.TransactionDate, Math.Abs(Math.Round(item.Amount, 2)), item.DebitCredit, item.Department, _
                              item.ShopCode, item.BrandCode, item.ProductTypeCodeText(2), item.StaffNo, item.Stakeholder, "END"}))
        Next
        fw.Close()
        fw.Dispose()
    End Sub
End Class

Imports OfficeOpenXml

Public Class ExportInterComSalesDataToSunAccount : Inherits SendExcelTask

    Public Sub New()
    End Sub

    Private fReportOption As ReportOption
    Public Overloads Property ReportOption() As ReportOption
        Get
            Return fReportOption
        End Get
        Set(ByVal value As ReportOption)
            fReportOption = value
        End Set
    End Property

    Public Overrides Sub OnTaskCreated(task As Kts.Agent.Core.TaskEntry)
        MyBase.OnTaskCreated(task)
        fReportOption = New ReportOption(task.ConfigNode.Node.SelectSingleNode("ReportOptions"))
    End Sub

    Protected Overrides Sub GenerateReport(dataConn As MySql.Data.MySqlClient.MySqlConnection, ParamArray args() As Object)
        Dim path As String = String.Format(OutputFolder, Now)
        Dim di As New IO.DirectoryInfo(path) : If Not di.Exists Then di.Create()
        Dim exportData As New GeneralExportInterComSalesDataToSunAccount(TheTask, ReportOption, di.FullName, dataConn)
        exportData.CreateReport()
    End Sub
End Class

Open in new window

LVL 12
HuaMin ChenProblem resolverAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSystems and Integration DeveloperCommented:
My initial guess would be that you are missing an Imports declaration for the namespace in which your class resides.
HuaMin ChenProblem resolverAuthor Commented:
What to adjust?
Carl TawnSystems and Integration DeveloperCommented:
You would need to add another Imports statement at the top of your class to include the relevant namespace. I can't tell you what that namespace is as there is nothing in your code to indicate what it might be.

If you don't know what it is, right-click on ExportInterComSalesDataToSunAccountDataSource in your code and select "Go to definition"; look for the line starting with "Namespace", and that should tell you what the Imports statement needs to be.

If in doubt you can post a screenshot of the ExportInterComSalesDataToSunAccountDataSource definition here.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

HuaMin ChenProblem resolverAuthor Commented:
Here is the definition of that

Imports System.ComponentModel
Imports System.Data
Imports MySql.Data.MySqlClient
Imports OfficeOpenXml
Imports Kts.Agent.Support.ExcelReportBase
Imports Kts.Agent.Support.MySql
Imports Kts.Agent.Core.Globals
Imports OfficeOpenXml.Style

Public Class GeneralExportInterComSalesDataToSunAccount : Inherits GeneralExportDataToSunAccountBase

    Dim ds As ExportInterComSalesDataToSunAccountDataSource

    Public Sub New(task As TaskEntry, options As ReportOption, outputFolder As String, Optional ByVal conn As MySqlConnection = Nothing)
        MyBase.New(task, options, outputFolder, conn)
    End Sub

    Public Overrides Sub CreateReport()

        If CheckUserRunOption() = False Then Exit Sub
        If FromDate = #1/1/1900# Then FromDate = Now.AddDays(-1).Date
        If ToDate = #1/1/1900# Then ToDate = FromDate

        Dim conn As MySqlConnection = Kts.Agent.Support.MySql.Database.OpenConnection()
        'Dim dataRange As New DataRangeOption With {.FromDate = FromDate.Date, .ToDate = ToDate.Date,
        '                  .IsAllBrands = True, .IsAllShops = False, .ShopLine = ALL_LOCATIONS_NOMOCKUP,
        '                  .IsShopFilterByLine = True, .ShopLineCode = "", .IsAllShopInLine = True,
        '                  .IsAllProductCodes = True, .ShoesProduct = True, .AccessoriesProduct = True, .OthersProduct = True, .IsTransfer = False}

        Dim dataRange As New DataRangeOption With {.FromDate = FromDate.Date, .ToDate = ToDate.Date,
                  .IsAllBrands = True, .IsAllShops = False,
                  .IsShopFilterByLine = True, .ShopLineCode = ALL_LOCATIONS_NOMOCKUP, .IsAllShopInLine = True,
                  .IsAllProductCodes = True, .ShoesProduct = True, .AccessoriesProduct = True, .OthersProduct = True, .IsTransfer = False}

        'Start - Added by CHI 20150723

        If SelectedShopCodes IsNot Nothing AndAlso SelectedShopCodes.Count > 0 Then
            With dataRange
                .Shops = SelectedShopCodes
                .IsAllShops = False
                .IsShopFilterByLine = False
                .IsAllShopInLine = False
            End With
        End If
        'End - Added by CHI 20150723

        dataRange.ClearExcludes()
        If ReportOption.SalesExcludeShops.Count > 0 Then dataRange.ExcludeShops.AddRange(ReportOption.SalesExcludeShops)
        If ReportOption.SalesExcludeWareTypes.Count > 0 Then dataRange.ExcludeWarehouseTypes.AddRange(ReportOption.SalesExcludeWareTypes)

        Dim dataRangeCollection As New DataRangeOptionCollection
        dataRangeCollection.Add(dataRange)

        Task.SubDescription = "正在讀取數據..."

        ds = New ExportInterComSalesDataToSunAccountDataSource(dataRangeCollection, ReportOption.GetDatabases, conn)
        TotalLoadedRows += ds.LoadReportData
        CloseConnection(conn)

        For Each companyCode In ds.Select(Function(x) x.CompanyCode).Distinct
            For Each journalCode In ds.Where(Function(x) x.CompanyCode.Equals(companyCode, StringComparison.OrdinalIgnoreCase)).Select(Function(x) x.JournalCode).Distinct
                GenerateFile(companyCode, journalCode, dataRangeCollection)
            Next
        Next
    End Sub

    Public Sub GenerateFile(companyCode As String, journalCode As String, dataRangeCollection As DataRangeOptionCollection)
        Dim fileName As String = String.Format("{0}/{1}_{2}_{3}.txt", OutputFolder, ds.DocumentCode, companyCode, journalCode)
        If System.IO.File.Exists(fileName) Then System.IO.File.Delete(fileName)
        Dim fw As New System.IO.StreamWriter(fileName)
        'Header
        fw.WriteLine(String.Join(",", FileHeader))
        'Detail
        For Each item In ds.Where(Function(x) x.CompanyCode.Equals(companyCode, StringComparison.OrdinalIgnoreCase) And x.JournalCode.Equals(journalCode, StringComparison.OrdinalIgnoreCase)).
                                                                                                                                                            OrderBy(Function(x) x.TransactionDate).
                                                                                                                                                            ThenBy(Function(x) x.ShopCode).
                                                                                                                                                            ThenBy(Function(x) x.BrandCode).
                                                                                                                                                            ThenBy(Function(x) x.ProductTypeCodeText(2))
            'fw.WriteLine(String.Join(",", {item.AccountCode, String.Format("""{0}""", item.Description), String.Format("""{0}""", item.TransactionRef), _
            '                  item.AccountingPeriod, item.TransactionDate, Math.Abs(Math.Round(item.Amount, 2)), item.DebitCredit, item.Department, _
            '                   item.BrandCode, "", item.ShopCode, item.Stakeholder, item.ProductTypeCodeText(2), "END"}))
            fw.WriteLine(String.Join(",", {item.AccountCode, String.Format("""{0}""", item.Description), String.Format("""{0}""", item.TransactionRef), _
                              item.AccountingPeriod, item.TransactionDate, Math.Abs(Math.Round(item.Amount, 2)), item.DebitCredit, item.Department, _
                              item.ShopCode, item.BrandCode, item.ProductTypeCodeText(2), item.StaffNo, item.Stakeholder, "END"}))
        Next
        fw.Close()
        fw.Dispose()
    End Sub
End Class

Open in new window


but I cannot find out "namespace" inside.
Carl TawnSystems and Integration DeveloperCommented:
You look to have reposted the GeneralExportInterComSalesDataToSunAccount class rather than the ExportInterComSalesDataToSunAccountDataSource class.
HuaMin ChenProblem resolverAuthor Commented:
Sorry, in above, I did currently post the class called "GeneralExportInterComSalesDataToSunAccount".
HuaMin ChenProblem resolverAuthor Commented:
Any other help?
Carl TawnSystems and Integration DeveloperCommented:
Sorry, I was waiting on you to post the declaration for the ExportInterComSalesDataToSunAccountDataSource class.
HuaMin ChenProblem resolverAuthor Commented:
Originally, I also have posted this

Imports OfficeOpenXml

Public Class ExportInterComSalesDataToSunAccount : Inherits SendExcelTask

    Public Sub New()
    End Sub

    Private fReportOption As ReportOption
    Public Overloads Property ReportOption() As ReportOption
        Get
            Return fReportOption
        End Get
        Set(ByVal value As ReportOption)
            fReportOption = value
        End Set
    End Property

    Public Overrides Sub OnTaskCreated(task As Kts.Agent.Core.TaskEntry)
        MyBase.OnTaskCreated(task)
        fReportOption = New ReportOption(task.ConfigNode.Node.SelectSingleNode("ReportOptions"))
    End Sub

    Protected Overrides Sub GenerateReport(dataConn As MySql.Data.MySqlClient.MySqlConnection, ParamArray args() As Object)
        Dim path As String = String.Format(OutputFolder, Now)
        Dim di As New IO.DirectoryInfo(path) : If Not di.Exists Then di.Create()
        Dim exportData As New GeneralExportInterComSalesDataToSunAccount(TheTask, ReportOption, di.FullName, dataConn)
        exportData.CreateReport()
    End Sub
End Class

Open in new window

HuaMin ChenProblem resolverAuthor Commented:
Any other help?
HuaMin ChenProblem resolverAuthor Commented:
Hi Carl,
In the following,
15
you can see how the 2 class appear within the project.
Carl TawnSystems and Integration DeveloperCommented:
OK, so, if you open up ExportInterComSalesDataToSunAccount.vb, what namespace is it in? Also, is it actually been included and compiled in your project? Are you using this class successfully anywhere else in your project, and is the class recognised by Intellisense?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.