如何在Smartdevice中使用VB.NET和MySQL创建报告? [英] How to Create Report with VB.NET and MySQL in Smartdevice?

查看:76
本文介绍了如何在Smartdevice中使用VB.NET和MySQL创建报告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想问一下如何使用smartdevice项目在VB.Net中创建报表(如Crystal报表)吗?

我有一个关于买卖的数据集和数据库交易(如PoS).
所以我需要在:
上创建报告 -谁购买了我的产品(姓名,地址等)
-他们购买什么产品
-日期时间
-总成本,价格等.

我需要此报告可通过带有热敏打印机的PDA打印.

非常感谢advnced.

Hi,

I wanted to ask on how to create Report (like a Crystal Report) in VB.Net with smartdevice project?

I have a dataset and a database transaction about sell and buy (like a PoS).
So I need to create report on :
- who bought my product (Name,Address and so on)
- what product they buy
- Date time
- Total Cost, price, and so on.

I need this report available to be printed via PDA with thermal printer.

Thanks a lot in advnced.

推荐答案



如果有帮助,请尝试以下示例:

在此示例中,我创建了一个名为customer
的类 代码如下:

Hi,

Just try this sample if this could help:

In this sample i created class called customer
code as follows:

Imports Microsoft.VisualBasic
Public Class customer
    Private _cust_name As String
    Private _cust_addr1 As String
    Public Property Cust_Name() As String
        Get
            Return _cust_name
        End Get
        Set(ByVal value As String)
            _cust_name = value
        End Set
    End Property
    Public Property Cust_addr1() As String
        Get
            Return _cust_addr1
        End Get
        Set(ByVal value As String)
            _cust_addr1 = value
        End Set
    End Property

    
    Public Sub New( ByVal cust_name As String,ByVal cust_addr1 As String)
        _cust_name = cust_name
        _cust_addr1 = cust_addr1
    End Sub
End Class




在您的客户端中,说default.aspx源,
将CrystalReportViewer拖动到工具箱中并放置
在< div>之间标签.

例如:




In your client side let say default.aspx Source,
Drag CrystalReportViewer in your Toolbox and place
between the <div> tag.

example:

<div>
  '' Drag it and place here...
</div>




在我的代码中隐藏.aspx.vb
如下:




In my code behid .aspx.vb
as follows:

Imports System.Data
Imports System.Configuration
Imports CrystalDecisions.CrystalReports.Engine
Imports System.Data.SqlClient
Imports System.Collections.Generic
Imports System.Reflection
Partial Class _Default
    Inherits System.Web.UI.Page
    Public ConnStr As String = _
    ConfigurationManager.ConnectionStrings("ClaimsSQLConnection").ConnectionString.ToString()
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim rptLoc As String = Server.MapPath("") + "\Reports\AspSample.rpt"
        Dim crpt As ReportDocument = New ReportDocument()
        Dim dt2 As New DataTable
        Dim ds As New DataSet1
        Dim query As String = "select * from dbo.Customer"
        Dim dt1 As List(Of customer) = GetCustomer(query, ConnStr)
        crpt.Load(rptLoc)
        crpt.SetDataSource(ds)
        ds.MyDatasetTable.Clear()
        For index As Integer = 0 To dt1.Count - 1
            Dim drt As DataRow
            drt = ds.MyDatasetTable.NewRow()
            drt("Customer Name") = dt1(index).Cust_Name
            drt("Customer Address1") = dt1(index).Cust_addr1
            ds.MyDatasetTable.Rows.Add(drt)
        Next
        CrystalReportViewer1.ReportSource = crpt
    End Sub
    Public Shared Function GetCustomer(ByVal query As String, _
        ByVal connStr As String) As List(Of customer)
        Dim lst As List(Of customer) = New List(Of customer)
        Dim sb As StringBuilder = New StringBuilder()
        Dim conn As SqlConnection = New SqlConnection(connStr)
        sb.Append("select * from dbo.customer ")
        Dim qry As String = sb.ToString()
        Try
            Dim cmd As New SqlCommand(qry, conn)
            conn.Open()
            Using (cmd)
                cmd.CommandType = CommandType.Text
                Dim dr As SqlDataReader = cmd.ExecuteReader()
                Using (dr)
                    While (dr.Read())
                        Dim temp As New customer( _
                            Convert.ToString(dr.Item("cust_name")), _
                            Convert.ToString(dr.Item("cust_add1")))
                        lst.Add(temp)
                    End While
                End Using
            End Using
        Catch ex As Exception
            Throw ex
        Finally
            conn.Close()
        End Try
        Return lst
    End Function
End Class




问候




Regards,


这篇关于如何在Smartdevice中使用VB.NET和MySQL创建报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆