You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
237 lines
13 KiB
237 lines
13 KiB
Imports System.IO
|
|
|
|
Imports System.Data
|
|
Imports System.Data.SqlTypes
|
|
Imports System.Data.SqlClient
|
|
Imports System.ComponentModel
|
|
|
|
|
|
Namespace EDOKA
|
|
|
|
#Region "Deklarationen"
|
|
|
|
#End Region
|
|
|
|
Public Class clsarchivfnkt
|
|
|
|
' 2004-12-06
|
|
Public Sub copy_indexdata(ByVal dokumentid As String, ByVal Status As String)
|
|
Dim sda As New SqlDataAdapter("select * from dokumentcoldindexwert where (indextyp=1 or indextyp=2) and dokumentid='" & dokumentid & "'", Globals.conn_edoka.scoDBConnection)
|
|
Dim sda1 As New SqlDataAdapter("select * from dokumentcoldindexwert where dokumentid='" & dokumentid & "'", Globals.conn_edoka.scoDBConnection)
|
|
Dim sda3 As New SqlDataAdapter("select max(indextyp) from dokumentcoldindexwert where dokumentid='" & dokumentid & "'", Globals.conn_edoka.scoDBConnection)
|
|
Dim ds As New DataSet()
|
|
Dim gds As New DataSet()
|
|
sda.Fill(ds, "Dokumentcoldindexwert")
|
|
sda1.Fill(gds, "Dokumentcoldindexwert")
|
|
sda.Fill(ds, "DokumentcoldindexwertNeu")
|
|
sda3.Fill(ds, "Maxwert")
|
|
Dim i As Integer
|
|
Dim Maxwert As Integer
|
|
Maxwert = ds.Tables(2).Rows(0).Item(0)
|
|
If Maxwert < 2 Then Maxwert = 2
|
|
Dim i1 As Integer
|
|
Dim i2 As Integer
|
|
i1 = 0
|
|
i2 = 0
|
|
For i = 0 To ds.Tables(0).Rows.Count - 1
|
|
If Not ds.Tables(0).Rows(i).Item("wert") Is System.DBNull.Value Then
|
|
If ds.Tables(0).Rows(i).Item("cold_indexfeldnr") = 7 And (ds.Tables(0).Rows(i).Item("wert") = "Aktuell" Or ds.Tables(0).Rows(i).Item("wert") = "Alt") Then
|
|
If ds.Tables(0).Rows(i).Item("indextyp") = 1 Then i1 = 1
|
|
If ds.Tables(0).Rows(i).Item("indextyp") = 2 Then i2 = 1
|
|
End If
|
|
End If
|
|
Next
|
|
For i = 0 To ds.Tables(0).Rows.Count - 1
|
|
If Not ds.Tables(0).Rows(i).Item("wert") Is System.DBNull.Value Then
|
|
If i1 = 1 And ds.Tables(0).Rows(i).Item("indextyp") = 1 Then
|
|
ds.Tables(0).Rows(i).Item("indextyp") = Maxwert + 1
|
|
If ds.Tables(0).Rows(i).Item("cold_indexfeldnr") = 7 Then ds.Tables(0).Rows(i).Item("wert") = Status
|
|
End If
|
|
If i2 = 1 And ds.Tables(0).Rows(i).Item("indextyp") = 2 Then
|
|
ds.Tables(0).Rows(i).Item("indextyp") = Maxwert + 2
|
|
If ds.Tables(0).Rows(i).Item("cold_indexfeldnr") = 7 Then ds.Tables(0).Rows(i).Item("wert") = Status
|
|
End If
|
|
End If
|
|
Next
|
|
For i = 0 To ds.Tables(1).Rows.Count - 1
|
|
If Not ds.Tables(0).Rows(i).Item("wert") Is System.DBNull.Value Then
|
|
If i1 = 1 And ds.Tables(1).Rows(i).Item("indextyp") = 1 Then
|
|
If ds.Tables(1).Rows(i).Item("cold_indexfeldnr") = 7 Or ds.Tables(1).Rows(i).Item("cold_indexfeldnr") = 7 Or ds.Tables(1).Rows(i).Item("cold_indexfeldnr") = 10 Then ds.Tables(1).Rows(i).Item("wert") = ""
|
|
End If
|
|
If i2 = 1 And ds.Tables(1).Rows(i).Item("indextyp") = 2 Then
|
|
If ds.Tables(1).Rows(i).Item("cold_indexfeldnr") = 5 Or ds.Tables(1).Rows(i).Item("cold_indexfeldnr") = 7 Or ds.Tables(1).Rows(i).Item("cold_indexfeldnr") = 10 Then ds.Tables(1).Rows(i).Item("wert") = ""
|
|
End If
|
|
End If
|
|
Next
|
|
Dim cd As New SqlCommandBuilder(sda)
|
|
sda.Update(ds, "Dokumentcoldindexwert")
|
|
|
|
Dim dw As New edokadb.clsDokumentcoldindexwert()
|
|
dw.cpMainConnectionProvider = Globals.conn_edoka
|
|
For i = 0 To ds.Tables(1).Rows.Count - 1
|
|
If i1 = 1 And ds.Tables(1).Rows(i).Item("indextyp") = 1 Then
|
|
dw.iIndextyp = New SqlInt32(CType(ds.Tables(1).Rows(i).Item(1), Int32))
|
|
If Not ds.Tables(1).Rows(i).Item(2) Is System.DBNull.Value Then
|
|
dw.sWert = New SqlString(CType(ds.Tables(1).Rows(i).Item(2), String))
|
|
Else
|
|
dw.sWert = New SqlString(CType("", String))
|
|
End If
|
|
dw.iMandantnr = New SqlInt32(CType(ds.Tables(1).Rows(i).Item(3), Int32))
|
|
dw.bAktiv = New SqlBoolean(CType(ds.Tables(1).Rows(i).Item(4), Boolean))
|
|
dw.daErstellt_am = New SqlDateTime(CType(Now, DateTime))
|
|
dw.daMutiert_am = New SqlDateTime(CType(Now, DateTime))
|
|
dw.iMutierer = New SqlInt32(CType(9999, Int32))
|
|
dw.sDokumentid = New SqlString(CType(ds.Tables(1).Rows(i).Item(8), String))
|
|
dw.iCold_indexfeldnr = New SqlInt32(CType(ds.Tables(1).Rows(i).Item(9), Int32))
|
|
Globals.conn_edoka.OpenConnection()
|
|
dw.Insert()
|
|
Globals.conn_edoka.CloseConnection(True)
|
|
End If
|
|
If i2 = 1 And ds.Tables(1).Rows(i).Item("indextyp") = 2 Then
|
|
dw.iIndextyp = New SqlInt32(CType(ds.Tables(1).Rows(i).Item(1), Int32))
|
|
If Not ds.Tables(1).Rows(i).Item(2) Is System.DBNull.Value Then
|
|
dw.sWert = New SqlString(CType(ds.Tables(1).Rows(i).Item(2), String))
|
|
Else
|
|
dw.sWert = New SqlString(CType("", String))
|
|
End If
|
|
' dw.sWert = New SqlString(CType(ds.Tables(1).Rows(i).Item(2), String))
|
|
dw.iMandantnr = New SqlInt32(CType(ds.Tables(1).Rows(i).Item(3), Int32))
|
|
dw.bAktiv = New SqlBoolean(CType(ds.Tables(1).Rows(i).Item(4), Boolean))
|
|
dw.daErstellt_am = New SqlDateTime(CType(Now, DateTime))
|
|
dw.daMutiert_am = New SqlDateTime(CType(Now, DateTime))
|
|
dw.iMutierer = New SqlInt32(CType(9999, Int32))
|
|
dw.sDokumentid = New SqlString(CType(ds.Tables(1).Rows(i).Item(8), String))
|
|
dw.iCold_indexfeldnr = New SqlInt32(CType(ds.Tables(1).Rows(i).Item(9), Int32))
|
|
Globals.conn_edoka.OpenConnection()
|
|
dw.Insert()
|
|
Globals.conn_edoka.CloseConnection(True)
|
|
End If
|
|
Next
|
|
dw.Dispose()
|
|
sda.Dispose()
|
|
sda1.Dispose()
|
|
sda3.Dispose()
|
|
End Sub
|
|
|
|
Public Sub insert_coldupdate_status(ByVal dt As DataTable, ByVal dokumentid As String, ByVal neuerstatus As String)
|
|
Dim i As Integer
|
|
Dim colddokumentid As String
|
|
Dim indextyp As Integer
|
|
indextyp = 1
|
|
colddokumentid = ""
|
|
For i = 0 To dt.Rows.Count - 1
|
|
If dt.Rows(i).Item("cold_indexfeldnr") = 10 Then colddokumentid = dt.Rows(i).Item("wert")
|
|
If dt.Rows(i).Item("indextyp") <> indextyp Then
|
|
insert_coldupdate("BESTA00", colddokumentid, dokumentid, "Aktuell", neuerstatus)
|
|
indextyp = dt.Rows(i).Item("indextyp")
|
|
End If
|
|
Next
|
|
insert_coldupdate("BESTA00", colddokumentid, dokumentid, "Aktuell", neuerstatus)
|
|
End Sub
|
|
|
|
Public Sub insert_coldupdate(ByVal feldname As String, ByVal colddokumentid As String, ByVal dokumentid As String, ByVal alterwert As String, ByVal neuerwert As String)
|
|
If colddokumentid = "" Then Exit Sub
|
|
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
|
Dim dtToReturn As DataTable = New DataTable()
|
|
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
|
scmCmdToExecute.CommandText = "dbo.sp_insert_coldupdate"
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
|
scmCmdToExecute.Connection = Globals.conn_edoka.scoDBConnection
|
|
Try
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@feldname", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, feldname))
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@colddokumentid", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, colddokumentid))
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@dokumentid", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, dokumentid))
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@alterwert", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, alterwert))
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@neuerwert", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, neuerwert))
|
|
sdaAdapter.Fill(dtToReturn)
|
|
Catch ex As Exception
|
|
Finally
|
|
scmCmdToExecute.Dispose()
|
|
sdaAdapter.Dispose()
|
|
End Try
|
|
End Sub
|
|
|
|
Public Function set_aufgehoben(ByVal dokumentid As String) As DataTable
|
|
Dim dt As DataTable
|
|
dt = get_coldindex_and_statusnr(dokumentid, True)
|
|
insert_coldupdate_status(dt, dokumentid, "Alt")
|
|
Return dt
|
|
End Function
|
|
|
|
Public Function get_coldindex_and_statusnr(ByVal dokumentid As String, ByVal aufheben As Boolean) As DataTable
|
|
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
|
Dim i As Integer
|
|
Dim dtToReturn As DataTable = New DataTable()
|
|
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
|
scmCmdToExecute.CommandText = "dbo.sp_get_coldindex_and_aufhebungsstatus"
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
|
Try
|
|
scmCmdToExecute.Connection = Globals.conn_edoka.scoDBConnection
|
|
Catch
|
|
End Try
|
|
Globals.Aufgehoben = False
|
|
Try
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@dokumentid", SqlDbType.VarChar, 22, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, dokumentid))
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@aufhebungsstatus", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, 0))
|
|
sdaAdapter.Fill(dtToReturn)
|
|
i = scmCmdToExecute.Parameters.Item("@aufhebungsstatus").Value
|
|
If i <> 0 And aufheben Then
|
|
insert_history_status(i, dokumentid, 9999)
|
|
Dim d As New edokadb.clsDokument()
|
|
d.cpMainConnectionProvider = Globals.conn_edoka
|
|
d.sDokumentid = New SqlString(CType(dokumentid, String))
|
|
d.SelectOne()
|
|
d.iStatusnr = New SqlInt32(CType(i, Int32))
|
|
Try
|
|
conn_edoka.OpenConnection()
|
|
Catch
|
|
End Try
|
|
d.Update()
|
|
conn_edoka.CloseConnection(True)
|
|
d.Dispose()
|
|
Globals.Aufgehoben = True
|
|
End If
|
|
Return dtToReturn
|
|
Catch ex As Exception
|
|
Return Nothing
|
|
Finally
|
|
scmCmdToExecute.Dispose()
|
|
sdaAdapter.Dispose()
|
|
End Try
|
|
End Function
|
|
|
|
Public Sub insert_history_status(ByVal statusnr As Integer, ByVal dokumentid As String, ByVal Verantwortlicher As Integer)
|
|
Dim sh As New edokadb.clsStatushistory()
|
|
sh.cpMainConnectionProvider = conn_edoka
|
|
Dim dbkey As New edokadb.clsMyKey_Tabelle()
|
|
Dim key As Long
|
|
dbkey.cpMainConnectionProvider = conn_edoka
|
|
Try
|
|
conn_edoka.OpenConnection()
|
|
Catch
|
|
End Try
|
|
key = dbkey.get_dbkey("statushistory")
|
|
sh.iStatushistorynr = New SqlInt32(CType(key, Int32))
|
|
sh.iStatus = New SqlInt32(CType(statusnr, Int32))
|
|
sh.iMandantnr = New SqlInt32(CType(9999, Int32))
|
|
sh.iMutierer = New SqlInt32(CType(9999, Int32))
|
|
sh.bAktiv = New SqlBoolean(True)
|
|
sh.daErstellt_am = New SqlDateTime(CType(Now, DateTime))
|
|
sh.daMutiert_am = New SqlDateTime(CType(Now, DateTime))
|
|
sh.sDokumentid = New SqlString(CType(dokumentid, String))
|
|
sh.iVerantwortlich = New SqlInt32(CType(Verantwortlicher, Int32))
|
|
Try
|
|
conn_edoka.OpenConnection()
|
|
Catch
|
|
End Try
|
|
sh.Insert()
|
|
conn_edoka.CloseConnection(True)
|
|
dbkey.Dispose()
|
|
sh.Dispose()
|
|
End Sub
|
|
|
|
|
|
End Class
|
|
End Namespace
|
|
|