如题,求解决方案或代码
email:[email protected]
email:[email protected]
解决方案 »
- 为什么sqlserver.commandshellwithresults "sqlcmd -U sa -P 123 -ida.sql"中da.sql文件没执行?
- 关于时间输入后的类型转化及增加的问题。。。想的脑袋都快炸了!!
- ?另:通过互联网访问数据库应怎么做?
- 诚邀在北京的Excel/VB高手加盟项目开发
- 指定 databasename 的问题.
- 字符转换的问题!
- Data Report错误
- 扩展通用对话框
- 哪里有 ActiveListBar 和 True DB 控件下载?
- 如何在VB窗体的系统菜单中添加自定义菜单?
- 手头有项目,需求开发伙伴,限乌鲁木齐市,VB数据库
- 在vb中access 数据库中表 的列表!
你可以建立两个表单,一个存储凭证头,一个存储分录部分,两者用凭单编号索引,(保证凭证编号不得重复),然后就可以进行分录的编辑,建议使用MSFLEXGRID的控件。用ENTERCELL事件配合TEXT的控件可以完成编辑和录入的功能!
If ASK = vbYes Then
Text2.Visible = False
CM3.Visible = False
Cb1.Visible = False
MFG1.SelectionMode = flexSelectionByRow
If Len(Trim(Text1(9).text)) = 0 Then
MsgBox "对不起,请选择领料单位!", vbOKOnly + vbInformation
Exit Sub
End If
If Len(Trim(Text1(2).text)) = 0 Then
MsgBox "对不起,请选择仓库名称!", vbOKOnly + vbInformation
Exit Sub
End If
If Len(Trim(Text1(5).text)) = 0 Then
MsgBox "对不起,请选择预算编号!", vbOKOnly + vbInformation
Exit Sub
End If
Set CNRS = New ADODB.Recordset
SQL = "SELECT COUNT(*) FROM BSDT WHERE BH='" & Text1(0).text & "'"
CNRS.CursorLocation = adUseServer
CNRS.LockType = adLockPessimistic
CNRS.Open SQL, Conn, , , adCmdText
If CNRS.Fields(0).value = 0 Then
CNRS.Close
Set CNRS = Nothing
SQL = "INSERT INTO BSDT(BH,CBH,RQ,LLDWBH,LLDW,XBH,XMM,YSH,LLR,FLR,ZY,ZN,XZ,XZRQ) VALUES('" & Text1(0).text & "','" & Text1(2).text & "','" & DTP1.value & "','" & Text1(9).text & "','" & Text1(1).text & "','" & Text1(6).text & "','" & Text1(4).text & "','" & Text1(5).text & "','" & Text1(7).text & "','" & Text1(8).text & "','" & ZY & "','" & ZN & "','0','" & Date & "')"
Conn.Execute SQL
Else
CNRS.Close
Set CNRS = Nothing
MsgBox "对不起,该凭单编号已经存在,请重新输入!", vbOKOnly + vbInformation
Exit Sub
End If
For K = 1 To MFG1.rows - 1
If Len(Trim(MFG1.TextMatrix(K, 6))) = 0 Then
Sl = 0
Else
Sl = Val(MFG1.TextMatrix(K, 6))
End If
If Len(Trim(MFG1.TextMatrix(K, 7))) = 0 Then
dj = 0
Else
dj = Val(MFG1.TextMatrix(K, 7))
End If
If Len(Trim(MFG1.TextMatrix(K, 8))) = 0 Then
JE = 0
Else
JE = Val(MFG1.TextMatrix(K, 8))
End If
If Len(Trim(MFG1.TextMatrix(K, 9))) = 0 Then
JJE = 0
Else
JJE = Val(MFG1.TextMatrix(K, 9))
End If
If Val(MFG1.TextMatrix(K, 12)) < Sl Then
MsgBox "对不起," & MFG1.TextMatrix(K, 2) & " 超出库存 " & Sl - Val(MFG1.TextMatrix(K, 12)) & "!", vbOKOnly + vbInformation
End If
Set CNRS = New ADODB.Recordset
SQL = "SELECT dbo.BSDT.YSH, dbo.BSDM.WZBM, dbo.BSDM.KPSL FROM dbo.BSDT INNER JOIN dbo.BSDM ON dbo.BSDT.BH = dbo.BSDM.BH " _
& "wHERE WZBM='" & MFG1.TextMatrix(K, 2) & "' AND YSH='" & Text1(5).text & "'"
CNRS.CursorLocation = adUseServer
CNRS.LockType = adLockPessimistic
CNRS.Open SQL, Conn, , , adCmdText
JC = 0
Do Until CNRS.EOF
JC = JC + Val(CNRS.Fields("KPSL").value)
CNRS.MoveNext
Loop
CNRS.Close
Set CNRS = Nothing
If Val(MFG1.TextMatrix(K, 11)) < JC + Sl Then
MsgBox "对不起,物资 " & MFG1.TextMatrix(K, 2) & " 超出预算 " & (JC + Sl) - Val(MFG1.TextMatrix(K, 11)) & "!", vbOKOnly + vbInformation
End If
SQL = "INSERT INTO BSDM(BH,WZBM,KPSL,KPDJ,KPJE,YSJE) VALUES('" & Text1(0).text & "','" & MFG1.TextMatrix(K, 2) & "'," & Sl & "," & dj & "," & JE & "," & JJE & ")"
Conn.Execute SQL
Next K
SQL = "DELETE FROM BSDM WHERE LEN(WZBM)=0"
Conn.Execute SQL
Call BSMFGREF1' 刷新MSFLEXGRID的控件
Set CRS = New ADODB.Recordset
SQL = "SELECT * FROM BSDM WHERE BH='" & Text1(0).text & "' ORDER BY WZBM ASC"
CRS.CursorLocation = adUseServer
CRS.LockType = adLockPessimistic
CRS.Open SQL, Conn, , , adCmdText
Do Until CRS.EOF
Set CNS = New ADODB.Recordset
SQL = "SELECT * FROM JCXX_WZ WHERE WZBM='" & CRS.Fields("WZBM").value & "' ORDER BY WZBM ASC"
CNS.CursorLocation = adUseServer
CNS.LockType = adLockPessimistic
CNS.Open SQL, ConnZT, , , adCmdText
MFG1.AddItem vbTab & CRS.Fields("ID").value & vbTab & CRS!wzbm & vbTab & CNS!wzmc & vbTab & CNS!wzgg & vbTab & CNS!jldw & vbTab & Format(CRS!KPSL, "0.000") & vbTab & Format(CRS!KPDJ, "0.0000") & vbTab & Format(CRS!KPJE, "0.00") & vbTab & Format(CRS!YSJE, "0.00")
CNS.Close
Set CNS = Nothing
CRS.MoveNext
Loop
CRS.Close
Set CRS = Nothing
End If