'有可能是多个财务ID
CMD_CW.Connection = CN.get_c(Str_Connection)
CMD_CW.CommandText = "select * from cwb where id in(select cwid from cwb_fz where xmid like'" & XMID.Trim & "')"
REA_CW = CMD_CW.ExecuteReader
Dim i As Integer
i = 0
Dim C(i) As CW
Dim CMD_FZ_CX As New SqlCommand
Dim REA_CX As SqlDataReader
Dim CN_FZ As New CN_ZW
CMD_FZ_CX.Connection = CN_FZ.get_c(Str_Connection)
CMD_FZ_CX.CommandText = "select * from CWB_FZ where CWID=" & Trim(REA_CW.Item("id"))
REA_CX = CMD_FZ_CX.ExecuteReader
CMD_FZ_CX.Dispose()
CMD_FZ_CX = Nothing
CN_FZ.lost_c()
CN_FZ = Nothing
Public Function DEL_ADD_CW(ByRef CON_DE As SqlConnection, ByRef myTrans_DE As SqlTransaction, ByVal ID_DE As Integer, ByVal REA_CX As SqlDataReader) As String
'此函数用于删除财务
'检索------------------------------------------
'删除数量的变量
Dim XH_SL As Integer
While REA_CX.Read
'0财务id 1 项目id 2 bh 3 jdm 4 hymc 5 je (6)是表名 7 rq 8 id
If Trim(REA_CX.Item(6)) = "ZWB" Then
'删除展位表中相应的纪录的金额
Dim ZW_DE As New ZW
XH_SL += ZW_DE.DEL_ZSS(CON_DE, myTrans_DE, Trim(REA_CX.Item(2)), Trim(REA_CX.Item(4)), Trim(REA_CX.Item(1)), Trim(REA_CX.Item(5)))
ElseIf Trim(REA_CX.Item(6)) = "HWB" Then
Dim HW_DE As New HW
XH_SL += HW_DE.DEL_ZSS(CON_DE, myTrans_DE, Trim(REA_CX.Item(1)), Trim(REA_CX.Item(4)), Trim(REA_CX.Item(2)), Trim(REA_CX.Item(5)))
ElseIf Trim(REA_CX.Item(6)) = "GGB" Then
Dim GG_DE As New GG
XH_SL += GG_DE.DEL_ZSS(CON_DE, myTrans_DE, Trim(REA_CX.Item(2)), Trim(REA_CX.Item(4)), Trim(REA_CX.Item(1)), Trim(REA_CX.Item(5)))
ElseIf Trim(REA_CX.Item(6)) = "JDB" Then
Dim JD_DE As New JD
XH_SL += JD_DE.DEL_ZSS(CON_DE, myTrans_DE, Trim(REA_CX.Item(2)), Trim(REA_CX.Item(3)), Trim(REA_CX.Item(4)), Trim(REA_CX.Item(1)), _
Trim(REA_CX.Item(5)))
ElseIf Trim(REA_CX.Item(6)) = "HMD" Then
Dim HMD_DE As New HMD
XH_SL += HMD_DE.DEL_ZSS(CON_DE, myTrans_DE, Trim(REA_CX.Item(1)), Trim(REA_CX.Item(2)), Trim(REA_CX.Item(4)), Trim(REA_CX.Item(5)), ID_DE)
Else
MsgBox("表名错误,请联系管理员,数据库中的数据产生了严重的错误!可能是人为更改了数据库中的字段值!", 32, "提示")
DEL_ADD_CW = "表名错误,请联系管理员,数据库中的数据产生了严重的错误!"
Exit Function
End If
End While
'------------------------------------end
Dim CMD_DE_CW As New SqlCommand
Dim DE_SL As Integer
Dim CMD_FZ As New SqlCommand
Dim FZ_SL As Integer
Try
CMD_DE_CW.Connection = CON_DE
CMD_DE_CW.Transaction = myTrans_DE
CMD_DE_CW.CommandText = "delete from CWB where id=" & ID_DE
DE_SL = CMD_DE_CW.ExecuteNonQuery
CMD_FZ.Connection = CON_DE
CMD_FZ.Transaction = myTrans_DE
CMD_FZ.CommandText = "delete from CWB_FZ where cwid=" & ID_DE
FZ_SL = CMD_FZ.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message.ToString & "cw del_cw", 48, "系统提示")
DE_SL = 0
Finally
CMD_DE_CW.Dispose()
CMD_FZ.Dispose()
CMD_DE_CW = Nothing
CMD_FZ = Nothing
If FZ_SL >= 1 And DE_SL = 1 And XH_SL = 1 Then
DEL_ADD_CW = "操作成功,删除了" & DE_SL & " 条财务记录," & FZ_SL & "条财务辅助记录,更新了" & XH_SL & "条业务记录的实收!"
Else
DEL_ADD_CW = "操作失败"
End If
End Try
End Function
End While
REA_CW.Close()
CN.lost_c() '关闭连接,释放资源
CN = Nothing