level 1
代码:
Dim con As New ADODB.Connection
Dim rs1, rs2 As New ADODB.Recordset
Dim Sql, Sql1 As String
Private Sub Command1_Click()
con.ConnectionString = "DRIVER=SQL Server;SERVER=A-201603021730;UID=sa;PWD= ;DATABASE=AIS20160331192354"
If con.State = 1 Then con.Close
con.Open
fdate = DTPicker1
Sql = "SELECT identity(int,1,1) as id,t1.FBillNo as '单据编号', t3.fname as '客户' , t1.FDate as '日期'," _
& " t4.fname as '商品', t2.FQty as '数量',T2.FAMOUNT AS '总金额' " _
& "into #tmp " _
& "FROM SEOrder AS t1 " _
& "INNER JOIN SEOrderEntry AS t2 ON t1.FInterID = t2.FInterID " _
& " left join t_Organization as t3 on t1.FCustID = t3.FItemID " _
& " left join t_ICItem as t4 on t2.FItemID = t4.FItemID " _
& "where t1.fdate= ' " & fdate & " '"
Sql1 = "select * from #tmp"
con.CursorLocation = adUseClient
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
rs1.Open Sql, con, 1
rs2.Open Sql1, con, 1
If rs2.BOF Then
MsgBox "没有符合条件的订单!"
Else
Set DataGrid1.DataSource = rs2
DataGrid1.Columns(0).Width = 1200
DataGrid1.Columns(1).Width = 700
DataGrid1.Columns(2).Width = 1000
DataGrid1.Columns(3).Width = 600
DataGrid1.Columns(4).Width = 800
DataGrid1.Columns(5).Width = 900
Text3.SetFocus
End If
Command1.Enabled = False
Command2.Enabled = True
End Sub
Private Sub Command2_Click()
Command1.Enabled = True
Command2.Enabled = False
rs2.Close
con.Close
End Sub
2016年05月13日 03点05分
