这是一个管理信息系统中控件grid的源代码,高手们百忙之中能不能帮着看看,给个注解越详细越好,小弟我真是看不明白,拜托了!
Dim t As Integer
Dim CZYname As String
Dim RS1 As ADODB.Recordset
Private Sub GridIni(OrdSql As String, t As Integer)
Set RS1 = New ADODB.Recordset
On Error GoTo errorhandle
grid.Clear
grid.Rows = 2
grid.FormatString = ">序号|<出库编号|<入库编号|<药品编号|<药品名称|<药品规格|出库数量|<价格|<出库日期|<出库发票号|>出库操作员工号|>出库操作日期"
grid.TextMatrix(1, 1) = "CKBH"
grid.TextMatrix(1, 2) = "RKBH"
grid.TextMatrix(1, 3) = "YPBH"
grid.TextMatrix(1, 4) = "YPMC"
grid.TextMatrix(1, 5) = "YPGG"
grid.TextMatrix(1, 6) = "CKSL"
grid.TextMatrix(1, 7) = "JG"
grid.TextMatrix(1, 8) = "CKRQ"
grid.TextMatrix(1, 9) = "CKFPHM"
grid.TextMatrix(1, 10) = "CKCZYGH"
grid.TextMatrix(1, 11) = "CKCZRQ"
grid.RowHeight(1) = 0
grid.ColWidth(1) = 0
SQL = "select * from CKMXZB AS Z INNER JOIN CKMXCB AS C ON Z.CKBH=C.CKBH where RFRQ IS NULL and YYJGBH='" & TemYYJGBH & "'"
If OrdSql <> "" Then
SQL = SQL & " order by " & OrdSql
If t = 1 Then
SQL = SQL & " asc"
Else
SQL = SQL & " desc"
End If
End If
RS.Open SQL, myConn
If Not RS.EOF Then
With RS
.MoveFirst
While Not .EOF
grid.Rows = grid.Rows + 1
grid.Row = grid.Rows - 1
grid.TextMatrix(grid.Row, 0) = grid.Row - 1
SQL = "select * from YPZD where YPBH='" & .Fields("YPBH") & "'"
RS1.Open SQL, myConn
If RS1.EOF Then
MsgBox "无药品编号为" & .Fields("YPBH") & "的药品信息,请检查药品字典", , "注意"
RS.Close
RS1.Close
End
Exit Sub
End If
For i = 1 To grid.Cols - 1
Select Case i
Case 4
grid.TextMatrix(grid.Row, i) = RS1.Fields("YPMC")
Case 5
grid.TextMatrix(grid.Row, i) = RS1.Fields("YPGG")
Case Else
grid.TextMatrix(grid.Row, i) = IIf(IsNull(.Fields(grid.TextMatrix(1, i))), "", .Fields(grid.TextMatrix(1, i)))
End Select
Next i
RS1.Close
.MoveNext
Wend
End With
End If
RS.Close
grid.Rows = grid.Rows + 1
grid.TextMatrix(grid.Rows - 1, 0) = grid.Rows - 2
Exit Sub
errorhandle:
myErrorHandle
End Sub