7,763
社区成员
发帖
与我相关
我的任务
分享
Public Function Reg(flg As Integer) As Boolean
Dim rs As ADODB.Recordset
Dim intTrans As Integer
Dim m_rs As ADODB.Recordset
On Error GoTo Err_Handler
Registry = False
Set rs = m_rsDirect.Clone
Set m_rs = m_rsDirect.Clone(adLockReadOnly)
intTrans = m_clsData.Connection.BeginTrans
If flg = 1 Then
Call m_clsData.DeleteProductionHavingData 'm_clsData As clsPCDatabase
Do Until m_rs.EOF = True
If m_clsData.Correct1(txtBin.Text, txtProdCode.Text, m_rs) = False Then
If intTrans > 0 Then
m_clsData.Connection.RollbackTrans
End If
Exit Function
End If
m_rs.MoveNext
Loop
Call ReleaseRecordset(m_rs)
Else
If m_clsData.Correct2(txtBin.Text, txtProdCode.Text, rs) = False Then
If intTrans > 0 Then
m_clsData.Connection.RollbackTrans
End If
Exit Function
End If
End If
If intTrans > 0 Then
m_clsData.Connection.CommitTrans
End If
Registry = True
Exit Function
Err_Handler:
Dim lngErr As Long
Dim strErr As String
lngErr = Err.Number
strErr = Err.Description
If intTrans > 0 Then
m_clsData.Connection.RollbackTrans
End If
Call RaiseError(lngErr, TypeName(Me) & "::Reg", strErr)
End Function 'Reg
Public Function Correct2(ByVal intBin As Integer, _
ByVal strProdCode As String, _
ByRef rs As ADODB.Recordset) As Boolean
Dim strSQL As String
On Error GoTo Err_Handler
Correct2 = False
With rs
strSQL = ""
strSQL = strSQL & "EXEC Correct2 " & vbCrLf
strSQL = strSQL & " @intBin =" & intBin & vbCrLf
strSQL = strSQL & " ,@intBranch =" & .Fields("CD").Value & vbCrLf
strSQL = strSQL & " ,@strProdCode = '" & strProdCode & "'" & vbCrLf
strSQL = strSQL & " ,@intDirectNum =" & Nz(.Fields("数量").Value, 0) & vbCrLf
strSQL = strSQL & " ,@fltWeight =" & Nz(.Fields("重量").Value, 0) & vbCrLf
If IsNull(.Fields("数量").Value) And IsNull(.Fields("重量").Value) Then
strSQL = strSQL & " ,@bytDeleteFlg = 1" & vbCrLf
End If
End With
Call ExecuteSQL(m_cn, strSQL)
Correct2 = True
Exit Function
Err_Handler:
Call RaiseError(Err.Number, TypeName(Me) & "::Correct2", Err.Description)
End Function 'Correct2