ADO对象,ADO控件,怎么查找一条记录?
解决方案 »
- 【问】如何由API直接载入图片?
- 为什么我取消了DataGrid的“允许调整大小”,里面的数据就显示不出来了呢?
- vb可以写控制台应用程序么?
- vb怎么访问microsoft project文件的作者,公司,项目开始何结束日期之类的属性啊?
- 关于用vb保存excel文件
- 使用VBA,ADO的参数化查询问题,在线等!
- 支持csdn健康发展的请签名。我们联名上书重整坛风!!!
- 关于DELPHI的动态调用窗体的问题:连我们经理也没有解决!!!!!!
- 怎么打开*.iso文件????
- 在RichTextBox控件中怎样才能像ZMUD或TELNET那样同时显示出不同色彩的文字?
- 用vb在excel中插入分页符后释放对象问题!
- 如何判断QQ上我的朋友是否在线?
Dim rst As ADODB.Recordset
Dim strSQL As String
Private Sub Command1_Click()
Set gConn = New ADODB.Connection
Set rst = New ADODB.Recordset
gConn.Open "DSN=FAB_WLPH;UID=sa;PWD="
rst.ActiveConnection = gConn
rst.CursorLocation = adUseClient
rst.CursorType = adOpenStatic
strSQL = "select ID as 编号 , CZYName " & _
"as 用户名 , czypwd as 密码 ,czylevel as 标识 from TblAdmin"
rst.Open strSQL, gConn, adOpenKeyset, adLockOptimistic
End Sub
On Error GoTo Err_DO
Dim StrSql As String
Dim strInStoreID As String '入库单号
Dim strJSR As String '经手人
Dim strSaleCompany As String '出品单位
Dim strKindName As String '类别
Dim strTypeName As String '类型
Dim strGoodsID As String '商品编码
Dim strGoodsName As String '商品名称
Dim strInStoreDate As String '入库日期
Dim strInStoreDateFrom As String
Dim strInStoreDateTo As String
StrSql = ""
CmdFind.Enabled = False
SngTotalMoney = 0
LngTotalCount = 0
Screen.MousePointer = vbHourglass
If OpDetail.Value = True Then '次明细
If frmMain.MenuUserRight.Enabled Then
StrSql = "select GoodsID as 商品编码,GoodsName as 商品名称,SaleCompany as 出品单位,PackageName as 包装," & _
"TypeName as 类型,KindName as 类别,UnitName as 单位,Quantity as 数量,InPrice as 进货单价," & _
"TotalMoney as 总金额,InStoreDate as 入库日期,JSR as 经手人,InStoreID as 入库单号" & _
" from TblInStoreDetail" & " where 1=1 "
Else
StrSql = "select GoodsID as 商品编码,GoodsName as 商品名称,SaleCompany as 出品单位,PackageName as 包装," & _
"TypeName as 类型,KindName as 类别,UnitName as 单位,Quantity as 数量,0 as 进货单价," & _
"0 as 总金额,InStoreDate as 入库日期,JSR as 经手人,InStoreID as 入库单号" & _
" from TblInStoreDetail" & " where 1=1 "
End If
ElseIf OpMaster.Value = True Then '主明细
StrSql = "select InStoreID as 入库单号,InStoreDate as 入库日期,TotalMoney as 总金额," & _
" JSR as 经手人,SHFlag as 是否审核 from TblTotalInStore" & " where 1=1 "
End If
If ChkInStoreID.Value Then
strInStoreID = " And InStoreID like '" & Trim(TxtInStoreID.Text) & "%'"
Else
strInStoreID = ""
End If
If ChkJSR.Value Then
strJSR = " And JSR like '" & Trim(CboJSR.Text) & "%'"
Else
strJSR = ""
End If
If OpDetail.Value Then
If ChkSaleCompany.Value Then
strSaleCompany = " And SaleCompany like '" & Trim(CboFindSaleCompany.Text) & "%'"
Else
strSaleCompany = ""
End If
If ChkKindName.Value Then
strKindName = " And KindName like '" & Trim(CboFindKindName.Text) & "%'"
Else
strKindName = ""
End If
If ChkTypeName.Value Then
strTypeName = " And TypeName like '" & Trim(CboFindTypeName.Text) & "%'"
Else
strTypeName = ""
End If
If ChkGoodsID.Value Then
strGoodsID = " And GoodsID like '" & Trim(TxtFindGoodsID.Text) & "%'"
Else
strGoodsID = ""
End If
If ChkGoodsName.Value Then
strGoodsName = " And GoodsName like '" & Trim(TxtFindGoodsName.Text) & "%'"
Else
strGoodsName = ""
End If
End If
If ChkInStoreDate.Value Then
strInStoreDateFrom = Format(DTInStoreDateFrom.Value, "YYYY-MM-DD") & " 00:00:00"
strInStoreDateTo = Format(DTInStoreDateTo.Value, "YYYY-MM-DD") & " 23:59:59"
strInStoreDate = " And InStoreDate>='" & strInStoreDateFrom & "' and InStoreDate<='" & strInStoreDateTo & "'"
Else
strInStoreDate = ""
End If
'总的SQL语句
If OpMaster.Value Then
StrSql = StrSql & strInStoreID & strJSR & strSaleCompany & strKindName & strTypeName & strInStoreDate
End If
If OpDetail.Value Then
StrSql = StrSql & strInStoreID & strJSR & strSaleCompany & strKindName & strTypeName & strInStoreDate & strGoodsID & strGoodsName
End If
If RstTblTotalInStore.State = adStateOpen Then RstTblTotalInStore.Close
RstTblTotalInStore.CursorLocation = adUseClient
RstTblTotalInStore.Open StrSql, conn, adOpenDynamic, adLockBatchOptimistic, 1
Set DataGrid1.DataSource = RstTblTotalInStore
Screen.MousePointer = vbDefault
If OpDetail.Value Then Call subSetDataGridWidth1
If OpMaster.Value Then Call subSetDataGridWidth2
If RstTblTotalInStore.EOF And RstTblTotalInStore.BOF Then
Screen.MousePointer = vbDefault
MsgBox "未找到数据,请重新选择查询条件!!!", vbInformation + vbOKOnly, gcstMsgTitle
CmdFind.Enabled = True
CmdFind.SetFocus
Exit Sub
End If
'求总金额
'求总金额
If OpMaster.Value = True Then
Do While Not RstTblTotalInStore.EOF
SngTotalMoney = SngTotalMoney + RstTblTotalInStore("总金额") '总金额(入库明细)
RstTblTotalInStore.MoveNext
Loop
End If
If OpDetail.Value = True Then
Do While Not RstTblTotalInStore.EOF
LngTotalCount = LngTotalCount + RstTblTotalInStore("数量")
SngTotalMoney = SngTotalMoney + RstTblTotalInStore("总金额") '总金额(入库明细)
RstTblTotalInStore.MoveNext
Loop
End If CmdFind.Enabled = True
CmdFind.SetFocus
Exit SubErr_DO:
CmdFind.Enabled = True Call subShowMessageEnd Sub
sFind = " wonumber like '" & s_gl_Massage & "'"
adoWO.Recordset.MoveFirst
adoWO.Recordset.Find sFind, , adSearchForward
If adoWO.Recordset.EOF Then
MsgBox "未发现工作单号!"
adoWO.Recordset.MoveFirst