01.
Imports
CrystalDecisions.CrystalReports.Engine
02.
Imports
CrystalDecisions.
Shared
03.
Imports
System.Data.OleDb
04.
Imports
System.IO
05.
Imports
System.Data
06.
07.
Public
Class
FmrptSellGas
08.
Friend
_sellgassid
As
String
=
""
09.
Private
Sub
FmrptSellGas_Load(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
MyBase
.Load
10.
Dim
Ico
As
New
System.Drawing.Icon(
"1376639548_Sales-by-Payment-Method-rep.ico"
)
11.
Me
.Icon = Ico
12.
Try
13.
SellGass()
14.
Me
.WindowState = FormWindowState.Maximized
15.
Catch
ex
As
Exception
16.
17.
End
Try
18.
End
Sub
19.
Private
Sub
SellGass()
20.
21.
22.
Dim
objConn
As
New
OleDbConnection
23.
Dim
objCmd
As
New
OleDbCommand
24.
Dim
dtAdapter
As
New
OleDbDataAdapter
25.
Dim
objCmdCompany
As
New
OleDbCommand
26.
Dim
dtAdapterCompany
As
New
OleDbDataAdapter
27.
Dim
Conn
As
New
OleDbConnection(ConnectDB.ConnectDB)
28.
Conn.Open()
29.
Dim
ds
As
New
DataSet
30.
Dim
strSQL
As
String
31.
Dim
dsCompany
As
New
DataSet
32.
Dim
strSQLCompany
As
String
33.
Dim
dtsellgass, dtcompany
As
DataTable
34.
35.
strSQL =
"select tbsellgass.sellgassid,tbgoods.goodsname,tbsellgass.goodsnum,tbsellgass.price,tbsellprice.sellprice,(tbsellgass.price*tbsellgass.goodsnum) as total,tbcustomers.cs_name,tbcustomers.cs_address,tbcustomers.cs_phone from((("
36.
strSQL &=
"tbsellgass) left outer join tbgoods on tbsellgass.goodsid=tbgoods.goodsid) left outer join tbcustomers on tbsellgass.cs_id = tbcustomers.cs_id) left outer join tbsellprice on tbsellgass.sellgassid=tbsellprice.sellgassid where tbsellgass.sellgassid= '"
&
Me
._sellgassid &
"' "
37.
38.
strSQLCompany =
"select companyname,address,phone,fax from tbcompany"
39.
40.
With
objCmd
41.
.Connection = Conn
42.
.CommandText = strSQL
43.
.CommandType = CommandType.Text
44.
End
With
45.
dtAdapter.SelectCommand = objCmd
46.
dtAdapter.Fill(ds)
47.
dtsellgass = ds.Tables(0)
48.
With
objCmdCompany
49.
.Connection = Conn
50.
.CommandText = strSQLCompany
51.
.CommandType = CommandType.Text
52.
End
With
53.
dtAdapterCompany.SelectCommand = objCmdCompany
54.
dtAdapterCompany.Fill(dsCompany)
55.
dtcompany = dsCompany.Tables(0)
56.
57.
58.
59.
60.
61.
Dim
rptSellGass
As
New
ReportDocument
62.
Dim
directory
As
String
= My.Application.Info.DirectoryPath
63.
Dim
companyname, address, phone, fax
As
String
64.
Dim
p
As
New
PrintDialog
65.
66.
67.
companyname = dtcompany.Rows(0)(
"companyname"
).ToString
68.
address = dtcompany.Rows(0)(
"address"
).ToString
69.
phone = dtcompany.Rows(0)(
"phone"
).ToString
70.
fax = dtcompany.Rows(0)(
"fax"
).ToString
71.
rptSellGass.Load(Application.StartupPath &
"\rptSellGas.rpt"
)
72.
73.
74.
rptSellGass.SetDataSource(dtsellgass)
75.
rptSellGass.SetParameterValue(
"companyname"
, companyname)
76.
rptSellGass.SetParameterValue(
"address"
, address)
77.
rptSellGass.SetParameterValue(
"phone"
, phone)
78.
rptSellGass.SetParameterValue(
"fax"
, fax)
79.
80.
81.
82.
83.
84.
Me
.CrystalReportViewer1.ReportSource = rptSellGass
85.
Me
.CrystalReportViewer1.Refresh()
86.
dtAdapter =
Nothing
87.
Conn.Close()
88.
Conn =
Nothing
89.
End
Sub
90.
End
Class