这是算料主料报表截图:主要用到报表相同单元格合并,怎么用网络路径显示图片等技术.
这是算料五金报表:同理用到上面的技术之外,报表根据每行物料编码搜索数据库中相对应的供应商,要最新的,和我们厂业务多的排前三名的供应商以及价格
以下是算料副料报表:因为根据实际需要,采购根据不同的料类分派给相对应的采购员去采购,而我们的仓库也相应分三个料类仓库,分别根据这三个单据进行备料和发料.所以要分别显示分别设计相应报表
设计步骤:
设计步骤:
1,数据源:此数据源为几张数据表合并而成的数据视图,同时可以只显示一次的报表表头数据,以及循环表示的明细条(我不知道有没有更好的方法)
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Threading
Public Class 算料报表
Public ds As New DataSet '明细数据ds
Public hthid As Int16
Dim myDataSet As New DataSet '图片ds
Dim cgDataSet As New DataSet '五金采购备注
Public strimage As String
Public strHth As String
Public strlb As String
Dim SQLCG As String
Dim SQLCommand As String
Public strbz As String
Private Sub 算料报表_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.MdiParent = mainfrm
Data()
If strlb = "五金" Then
SQLCommand = "select * from 算料表 where id='" & hthid & "' and 排序 LIKE '[F]__' order by 排序 "
SQLCG = "select * from 采购备注 where id='" & hthid & "' order by 次数 desc"
Dim dacg As SqlDataAdapter = New SqlDataAdapter(SQLCG, cn)
dacg.Fill(cgDataSet, "采购备注")
ElseIf strlb = "副料" Then
SQLCommand = "select * from 算料表 where id='" & hthid & "' and 排序 LIKE '[E]__' order by 排序 "
Else
'图片显示区域
myDataSet.Tables.Add("雇员")
myDataSet.Tables(0).Columns.Add("版单号", System.Type.GetType("System.String"))
myDataSet.Tables(0).Columns.Add("算料备注", System.Type.GetType("System.String"))
myDataSet.Tables(0).Columns.Add("雇员照片", System.Type.GetType("System.Byte[]"))
2,报表窗口:
窗口就只有一个报表显示控件,很简单
主要是代码:
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Threading
Public Class 算料报表
Public ds As New DataSet '明细数据ds
Public hthid As Int16
Dim myDataSet As New DataSet '图片ds
Dim cgDataSet As New DataSet '五金采购备注
Public strimage As String
Public strHth As String
Public strlb As String
Dim SQLCG As String
Dim SQLCommand As String
Public strbz As String
Private Sub 算料报表_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.MdiParent = mainfrm
Data()
If strlb = "五金" Then
SQLCommand = "select * from 算料表 where id='" & hthid & "' and 排序 LIKE '[F]__' order by 排序 "
SQLCG = "select * from 采购备注 where id='" & hthid & "' order by 次数 desc"
Dim dacg As SqlDataAdapter = New SqlDataAdapter(SQLCG, cn)
dacg.Fill(cgDataSet, "采购备注")
ElseIf strlb = "副料" Then
SQLCommand = "select * from 算料表 where id='" & hthid & "' and 排序 LIKE '[E]__' order by 排序 "
Else
SQLCommand = "select * from 算料表 where id='" & hthid & "' and 排序 LIKE '[A-D]__' order by 排序 "
End If
Dim da As SqlDataAdapter = New SqlDataAdapter(SQLCommand, cn)
da.Fill(ds, "算料表")
da.Fill(ds, "算料表")
'图片显示区域
myDataSet.Tables.Add("雇员")
myDataSet.Tables(0).Columns.Add("版单号", System.Type.GetType("System.String"))
myDataSet.Tables(0).Columns.Add("算料备注", System.Type.GetType("System.String"))
myDataSet.Tables(0).Columns.Add("雇员照片", System.Type.GetType("System.Byte[]"))
AddOneRow(myDataSet.Tables(0), strHth, strbz, strimage)
If strlb = "五金" Then
Dim oRpt As New crt_wjsl()
'图片子报表
oRpt.Subreports(1).SetDataSource(myDataSet.Tables("雇员"))
'采购子报表
oRpt.Subreports(0).SetDataSource(cgDataSet.Tables("采购备注"))
Dim oRpt As New crt_wjsl()
'图片子报表
oRpt.Subreports(1).SetDataSource(myDataSet.Tables("雇员"))
'采购子报表
oRpt.Subreports(0).SetDataSource(cgDataSet.Tables("采购备注"))
oRpt.SetDataSource(ds.Tables("算料表"))
CrystalReportViewer1.ReportSource = oRpt
ElseIf strlb = "副料" Then
Dim oRpt As New crt_flsl()
'图片子报表
oRpt.Subreports(0).SetDataSource(myDataSet.Tables("雇员"))
CrystalReportViewer1.ReportSource = oRpt
ElseIf strlb = "副料" Then
Dim oRpt As New crt_flsl()
'图片子报表
oRpt.Subreports(0).SetDataSource(myDataSet.Tables("雇员"))
oRpt.SetDataSource(ds.Tables("算料表"))
CrystalReportViewer1.ReportSource = oRpt
Else
Dim oRpt As New crt_sl()
'图片子报表
oRpt.Subreports(0).SetDataSource(myDataSet.Tables("雇员"))
CrystalReportViewer1.ReportSource = oRpt
Else
Dim oRpt As New crt_sl()
'图片子报表
oRpt.Subreports(0).SetDataSource(myDataSet.Tables("雇员"))
oRpt.SetDataSource(ds.Tables("算料表"))
CrystalReportViewer1.ReportSource = oRpt
End If
CrystalReportViewer1.ReportSource = oRpt
End If
End Sub
Public Sub AddOneRow(ByRef tbl As DataTable, ByVal c1 As String, ByVal c2 As String, ByVal c3 As String)
Public Sub AddOneRow(ByRef tbl As DataTable, ByVal c1 As String, ByVal c2 As String, ByVal c3 As String)
Try
Dim fs As New FileStream(c3, FileMode.Open, FileAccess.Read, FileShare.Read) ' 获取文本流
Dim fs As New FileStream(c3, FileMode.Open, FileAccess.Read, FileShare.Read) ' 获取文本流
Dim br As New BinaryReader(fs) ' 创建Binary Reader
Dim row As DataRow
'创建一个新行
row = tbl.NewRow()
Dim row As DataRow
'创建一个新行
row = tbl.NewRow()
'赋值
row(0) = c1
row(1) = c2
'注意此处的写入方式
row(2) = br.ReadBytes(br.BaseStream.Length)
row(0) = c1
row(1) = c2
'注意此处的写入方式
row(2) = br.ReadBytes(br.BaseStream.Length)
'将该行增加到目标表
tbl.Rows.Add(row)
tbl.Rows.Add(row)
' 释放
br = Nothing
fs = Nothing
Catch ex As Exception
MessageBox.Show("图片路径太 长 ,请 改用服务器 的 图片 路径 ")
End Try
End Sub
End Class
br = Nothing
fs = Nothing
Catch ex As Exception
MessageBox.Show("图片路径太 长 ,请 改用服务器 的 图片 路径 ")
End Try
End Sub
End Class
特别解释怎么用路径显示图片:
建立相对应报表数据源:用XML
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="myTableData" targetNamespace=" http://tempuri.org/myTableData.xsd" elementFormDefault="qualified"
xmlns=" http://tempuri.org/myTableData.xsd" xmlns:mstns=" http://tempuri.org/myTableData.xsd"
xmlns:xs=" http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Document" msdata:Locale="zh-CN">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="雇员">
<xs:complexType>
<xs:sequence>
<xs:element name="版单号" type="xs:string" minOccurs="0" />
<xs:element name="雇员照片" type="xs:base64Binary" minOccurs="0" />
<xs:element name="算料备注" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="DocumentKey1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:雇员" />
<xs:field xpath="mstns:版单号" />
</xs:unique>
</xs:element>
</xs:schema>
报表整体设计样图
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="myTableData" targetNamespace=" http://tempuri.org/myTableData.xsd" elementFormDefault="qualified"
xmlns=" http://tempuri.org/myTableData.xsd" xmlns:mstns=" http://tempuri.org/myTableData.xsd"
xmlns:xs=" http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Document" msdata:Locale="zh-CN">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="雇员">
<xs:complexType>
<xs:sequence>
<xs:element name="版单号" type="xs:string" minOccurs="0" />
<xs:element name="雇员照片" type="xs:base64Binary" minOccurs="0" />
<xs:element name="算料备注" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="DocumentKey1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:雇员" />
<xs:field xpath="mstns:版单号" />
</xs:unique>
</xs:element>
</xs:schema>
报表整体设计样图
在报表尾插入图片子报表
在子报表点右健编辑图片子报表:
关键字连接
子报表具体编辑:
OK,图片子报表设计完成.
下一个,相同单元格合并:选报表设计节专家属性,在要合并的组里勾上延伸到后续节即可
合并组表设计:
具体设计要仔细分布.OK,完工.
以上都是用子报表来单独显示相关重要的信息的,sql语句也很简单,只要设计子报表关键字连接就OK了.
在子报表点右健编辑图片子报表:
关键字连接
子报表具体编辑:
下一个,相同单元格合并:选报表设计节专家属性,在要合并的组里勾上延伸到后续节即可
合并组表设计:
具体设计要仔细分布.OK,完工.
以上都是用子报表来单独显示相关重要的信息的,sql语句也很简单,只要设计子报表关键字连接就OK了.
关于五金报表采购一览:我刚开始束手无策,那么多的条件, SQLCG = "select * from 采购备注 where id='" & hthid & "' order by 次数 desc"
就这个条件还不行,以下根据每个条目的物料编码来连接,进一步过滤得到所需要,
这样也还没有满足一个条件,只显示3个,其实:看下图
不勾上"可以增大",控件多大就只显示多少数据,技巧,没有什么技术性,但是在图片子报表需要勾上"可以增大"这个属性哦.
附注:以上参考网上其他同类技术,再加以利用改装!
就这个条件还不行,以下根据每个条目的物料编码来连接,进一步过滤得到所需要,