Initial commit
This commit is contained in:
408
EDKB01DB2/Testprogramm/WindowsApplication1/Form1.vb
Normal file
408
EDKB01DB2/Testprogramm/WindowsApplication1/Form1.vb
Normal file
@@ -0,0 +1,408 @@
|
||||
Imports IBM.Data.DB2
|
||||
Imports IBM.Data.DB2.DB2Type
|
||||
Imports System.Data
|
||||
Imports System.Data.SqlClient
|
||||
|
||||
Imports System.IO.File
|
||||
Imports System.Data.SqlTypes
|
||||
Imports System.ComponentModel
|
||||
Imports System.IO
|
||||
Imports System.SystemException
|
||||
Imports System.Reflection
|
||||
Imports System.Configuration
|
||||
|
||||
Public Class Form1
|
||||
Dim dt As New DataTable
|
||||
|
||||
Dim ds As New DataSet
|
||||
|
||||
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
|
||||
ds.ReadXml(My.Settings.ConfigFile.ToString)
|
||||
For Each r As DataRow In ds.Tables(My.Settings.TableName).Rows
|
||||
If r.Item(1) = My.Settings.Name Then
|
||||
Me.TextBox1.Text = r.Item(0)
|
||||
End If
|
||||
Next
|
||||
Me.ComboBox1.Items.Clear()
|
||||
For Each value As Configuration.SettingsPropertyValue In My.Settings.PropertyValues
|
||||
If UCase(value.Name.Substring(0, 3)) = "SQL" Then Me.ComboBox1.Items.Add(value.PropertyValue.ToString)
|
||||
Next
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub Button1_Click(sender As Object, e As EventArgs)
|
||||
Try
|
||||
MsgBox("Start")
|
||||
Dim con As New IBM.Data.DB2.DB2Connection(Me.TextBox1.Text)
|
||||
con.Open()
|
||||
con.Close()
|
||||
MsgBox("Open / Close OK")
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
||||
Try
|
||||
MsgBox("Start")
|
||||
Dim d As New Odbc.OdbcConnection(Me.TextBox1.Text)
|
||||
d.Open()
|
||||
d.Close()
|
||||
MsgBox("OK")
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
End Try
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub Button3_Click(sender As Object, e As EventArgs)
|
||||
Try
|
||||
MsgBox("Start")
|
||||
Dim con As New OleDb.OleDbConnection(Me.TextBox1.Text)
|
||||
con.Open()
|
||||
con.Close()
|
||||
MsgBox("Open / Close OK")
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
End Try
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
|
||||
Try
|
||||
MsgBox("Start")
|
||||
dt.Rows.Clear()
|
||||
dt.Columns.Clear()
|
||||
Dim SQLconnect As New Odbc.OdbcConnection()
|
||||
Dim ds As New DataSet
|
||||
SQLconnect.ConnectionString = Me.TextBox1.Text
|
||||
SQLconnect.Open()
|
||||
Dim da As New Odbc.OdbcDataAdapter("", SQLconnect)
|
||||
Dim sqlcmd As New Odbc.OdbcCommand
|
||||
sqlcmd.Connection = SQLconnect
|
||||
sqlcmd.CommandType = CommandType.Text
|
||||
sqlcmd.CommandText = Me.TextBox2.Text
|
||||
da.SelectCommand = sqlcmd
|
||||
da.Fill(dt)
|
||||
Me.DataGridView1.DataSource = dt
|
||||
SQLconnect.Close()
|
||||
MsgBox("OK")
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
|
||||
Try
|
||||
MsgBox("Start")
|
||||
|
||||
Dim SQLconnect As New Odbc.OdbcConnection()
|
||||
SQLconnect.ConnectionString = Me.TextBox1.Text
|
||||
Dim sqlcmd As New Odbc.OdbcCommand
|
||||
sqlcmd.Connection = SQLconnect
|
||||
sqlcmd.CommandType = CommandType.Text
|
||||
sqlcmd.CommandText = Me.TextBox2.Text
|
||||
SQLconnect.Open()
|
||||
sqlcmd.ExecuteNonQuery()
|
||||
SQLconnect.Close()
|
||||
MsgBox("OK")
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
|
||||
Dim f As New SaveFileDialog
|
||||
f.ShowDialog()
|
||||
If f.FileName <> "" Then
|
||||
Dim dsn As New DataSet
|
||||
dsn.Tables.Add(dt.Copy)
|
||||
dsn.WriteXml(f.FileName)
|
||||
'ds.Tables.Clear()
|
||||
'ds.Tables.Add(dt.Copy)
|
||||
'ds.WriteXml(f.FileName)
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Private Sub Button7_Click(sender As Object, e As EventArgs)
|
||||
' Dim f As New OpenFileDialog
|
||||
' f.ShowDialog()
|
||||
' If Microsoft.VisualBasic.Right(f.FileName, 11) = "blindex.xml" Then
|
||||
' Dim ds As New DataSet
|
||||
' ds.ReadXml(f.FileName)
|
||||
' copatodb(ds, "BL")
|
||||
' End If
|
||||
' If Microsoft.VisualBasic.Right(f.FileName, 11) = "zvindex.xml" Then
|
||||
' Dim ds As New DataSet
|
||||
' ds.ReadXml(f.FileName)
|
||||
' copatodb(ds, "ZV")
|
||||
' End If
|
||||
' If Microsoft.VisualBasic.Right(f.FileName, 13) = "hostindex.xml" Then
|
||||
' Dim ds As New DataSet
|
||||
' ds.ReadXml(f.FileName)
|
||||
' copatodb(ds, "HOST")
|
||||
' End If
|
||||
'End Sub
|
||||
|
||||
'Sub copatodb(ByVal ds As DataSet, type As String)
|
||||
' Dim cs As String = "Data Source=shu00;Initial Catalog=odadm;Persist Security Info=True;User ID=sa;password=*shu29;"
|
||||
' Dim connection As SqlConnection
|
||||
' Dim command As SqlCommand
|
||||
' Dim adpter As New SqlDataAdapter
|
||||
' connection = New SqlConnection(cs)
|
||||
|
||||
' Select Case type
|
||||
' Case "ZV"
|
||||
' Dim DA As New SqlDataAdapter("select * from zvindex ", cs)
|
||||
' Dim cb As SqlCommandBuilder = New SqlCommandBuilder(DA)
|
||||
' Dim dso As New DataSet()
|
||||
' connection.Open()
|
||||
' Dim ii As Integer = 0
|
||||
' DA.Fill(dso, "ZV")
|
||||
' For Each r As DataRow In ds.Tables(0).Rows
|
||||
' Dim myrow As DataRow
|
||||
' myrow = dso.Tables(0).NewRow
|
||||
' ii = ii + 1
|
||||
' For i = 0 To ds.Tables(0).Columns.Count - 2
|
||||
' myrow.Item(i) = r.Item(i).ToString
|
||||
|
||||
' Next
|
||||
' dso.Tables(0).Rows.Add(myrow)
|
||||
' Next
|
||||
' DA.Update(dso, "ZV")
|
||||
' Case "BL"
|
||||
' Dim DA As New SqlDataAdapter("select * from blindex ", cs)
|
||||
' Dim cb As SqlCommandBuilder = New SqlCommandBuilder(DA)
|
||||
' Dim dso As New DataSet()
|
||||
' connection.Open()
|
||||
' DA.Fill(dso, "ZV")
|
||||
' For Each r As DataRow In ds.Tables(0).Rows
|
||||
' Dim myrow As DataRow
|
||||
' myrow = dso.Tables(0).NewRow
|
||||
' For i = 0 To ds.Tables(0).Columns.Count - 1
|
||||
' myrow.Item(i) = r.Item(i)
|
||||
|
||||
' Next
|
||||
' dso.Tables(0).Rows.Add(myrow)
|
||||
' Next
|
||||
' DA.Update(dso, "ZV")
|
||||
' Case "HOST"
|
||||
' Dim DA As New SqlDataAdapter("select * from hostindex ", cs)
|
||||
' Dim cb As SqlCommandBuilder = New SqlCommandBuilder(DA)
|
||||
' Dim dso As New DataSet()
|
||||
' connection.Open()
|
||||
' DA.Fill(dso, "ZV")
|
||||
' For Each r As DataRow In ds.Tables(0).Rows
|
||||
' Dim myrow As DataRow
|
||||
' myrow = dso.Tables(0).NewRow
|
||||
' For i = 0 To ds.Tables(0).Columns.Count - 1
|
||||
' myrow.Item(i) = r.Item(i)
|
||||
|
||||
' Next
|
||||
' dso.Tables(0).Rows.Add(myrow)
|
||||
' Next
|
||||
' DA.Update(dso, "ZV")
|
||||
' End Select
|
||||
'End Sub
|
||||
|
||||
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
|
||||
Me.TextBox2.Text = Me.ComboBox1.Text
|
||||
End Sub
|
||||
|
||||
Private Sub btnXMLCheck_Click(sender As Object, e As EventArgs) Handles btnXMLCheck.Click
|
||||
If Not Panel1.Visible Then
|
||||
Me.Panel1.Visible = True
|
||||
Me.Panel1.Dock = DockStyle.Fill
|
||||
Else
|
||||
Panel1.Visible = False
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
|
||||
OpenFileDialog2.ShowDialog()
|
||||
If OpenFileDialog2.FileName <> "" Then Me.lblxmlfile.text = OpenFileDialog2.FileName
|
||||
|
||||
End Sub
|
||||
|
||||
Dim Verarbeitungstyp As String
|
||||
Dim sqlconn As New SqlConnection(My.Settings.HostConnection)
|
||||
Dim Odata As New DataTable
|
||||
Dim odata1 As New DataTable
|
||||
|
||||
Dim resultdata As New DataTable
|
||||
|
||||
Private Sub Button3_Click_1(sender As Object, e As EventArgs) Handles Button3.Click
|
||||
Verarbeitungstyp = "HOST"
|
||||
resultdata.Columns.Clear()
|
||||
resultdata.Columns.Add("Mailid")
|
||||
Dim ds As New DataSet
|
||||
ds.ReadXml(Me.lblxmlfile.Text)
|
||||
|
||||
Me.ProgressBar1.Minimum = 0
|
||||
Me.ProgressBar1.Maximum = ds.Tables(0).Rows.Count
|
||||
Me.ProgressBar1.Value = 0
|
||||
Dim cnt As Integer = 0
|
||||
For Each r As DataRow In ds.Tables(0).Rows
|
||||
Check_Dokumentid(r)
|
||||
cnt = cnt + 1
|
||||
Me.lblprogress.Text = cnt.ToString + " / " + ds.Tables(0).Rows.Count.ToString
|
||||
Me.ProgressBar1.Value = cnt
|
||||
Application.DoEvents()
|
||||
Next
|
||||
Me.DataGridView1.DataSource = resultdata
|
||||
|
||||
End Sub
|
||||
|
||||
Function Check_Dokumentid(r As DataRow) As Boolean
|
||||
Dim sql As String
|
||||
Dim sqlcmd As New SqlCommand
|
||||
Select Case Verarbeitungstyp
|
||||
Case "HOST"
|
||||
sql = My.Settings.SQL_HOST_Check_Dokumentid
|
||||
sql = sql.Replace("&MailingID&", r("MailingID"))
|
||||
Case "ZV"
|
||||
'sql = My.Settings.SQL_ZV_Check_Dokumentid
|
||||
'sql = sql.Replace("&nrdoc00&", r("nrdoc00"))
|
||||
Case "BL"
|
||||
'sql = My.Settings.SQL_BL_Check_Dokumentid
|
||||
'sql = sql.Replace("&mailingid&", r("mailingid"))
|
||||
End Select
|
||||
Dim da As New SqlDataAdapter(sql, sqlconn)
|
||||
sqlcmd.Connection = sqlconn
|
||||
sqlcmd.CommandType = CommandType.Text
|
||||
sqlcmd.CommandText = sql
|
||||
da.SelectCommand = sqlcmd
|
||||
odata1.Rows.Clear()
|
||||
da.Fill(odata1)
|
||||
If odata1.Rows.Count < 1 Then
|
||||
Get_SQLDB(Verarbeitungstyp)
|
||||
Dim r1 As DataRow = resultdata.NewRow
|
||||
r1.Item(0) = r.Item("Mailingid")
|
||||
resultdata.Rows.Add(r1)
|
||||
If chkUpdateHost.Checked Then
|
||||
Odata.Rows.Clear()
|
||||
Mapping_host(r)
|
||||
Insert_rec(Odata)
|
||||
End If
|
||||
Return False
|
||||
Else
|
||||
Return True
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function Get_SQLDB(Type As String)
|
||||
Dim sql As String
|
||||
Dim sqlcmd As New SqlCommand
|
||||
|
||||
Select Case Type
|
||||
Case "HOST"
|
||||
sql = My.Settings.SQL_Empty_HOST
|
||||
Case "ZV"
|
||||
'sql = My.Settings.SQL_Empty_ZV
|
||||
Case "BL"
|
||||
'sql = My.Settings.SQL_Empty_BL
|
||||
End Select
|
||||
|
||||
|
||||
Dim da As New SqlDataAdapter(sql, sqlconn)
|
||||
sqlcmd.Connection = sqlconn
|
||||
sqlcmd.CommandType = CommandType.Text
|
||||
sqlcmd.CommandText = sql
|
||||
da.SelectCommand = sqlcmd
|
||||
Odata.Rows.Clear()
|
||||
da.Fill(Odata)
|
||||
End Function
|
||||
|
||||
Sub Insert_rec(dt As DataTable)
|
||||
'Insert Import
|
||||
Dim sql As String
|
||||
Select Case Verarbeitungstyp
|
||||
Case "HOST"
|
||||
sql = My.Settings.SQL_Empty_HOST
|
||||
Case "ZV"
|
||||
'sql = My.Settings.SQL_Empty_ZV
|
||||
Case "BL"
|
||||
'sql = My.Settings.SQL_Empty_BL
|
||||
End Select
|
||||
Using adapter1 = New SqlDataAdapter(sql, sqlconn)
|
||||
Using builder = New SqlCommandBuilder(adapter1)
|
||||
adapter1.InsertCommand = builder.GetInsertCommand()
|
||||
adapter1.Update(Odata)
|
||||
builder.Dispose()
|
||||
End Using
|
||||
adapter1.Dispose()
|
||||
End Using
|
||||
End Sub
|
||||
|
||||
Public Sub Mapping_host(ByRef r As DataRow)
|
||||
Dim newrow As DataRow = Odata.NewRow
|
||||
newrow("anzahlseiten") = r("Pages")
|
||||
newrow("dokumentid") = r("mailingid")
|
||||
newrow("nachvollziehbarkeit") = r("traceability")
|
||||
newrow("xomadocid") = r("xomadocid")
|
||||
newrow("MailingProduct") = r("codemailintlid")
|
||||
newrow("MailingProductBezeichnung") = r("Mailingproduct")
|
||||
newrow("Valutadatum") = Microsoft.VisualBasic.Format(CDate(r("Creationdate")), "yyyyMMdd")
|
||||
newrow("Archivdatum") = (r("dmerst00"))
|
||||
newrow("valutadatum1") = Microsoft.VisualBasic.Format(CDate(r("valutadate")), "yyyyMMdd")
|
||||
newrow("betreffzeile") = r("arctitle")
|
||||
valor_isin(newrow, r)
|
||||
newrow("standamdatum") = ""
|
||||
newrow("ex") = r("copycode")
|
||||
newrow("partnernr_inhaber") = r("bpkeynrinhab")
|
||||
newrow("partnername_inhaber") = r("bpnameinhab")
|
||||
newrow("partnernr_zusteller") = r("bpkeynrsend")
|
||||
newrow("partnername_zusteller") = r("bpnamesend")
|
||||
newrow("manr") = r("userid")
|
||||
newrow("metatype") = r("metatype")
|
||||
newrow("ordertype") = r("ordertyp")
|
||||
newrow("loadid") = r("udokid00")
|
||||
newrow("vvextern1") = r("macckeynr")
|
||||
newrow("vvextern2") = r("contkeynr")
|
||||
newrow("referenzzeile1") = ""
|
||||
newrow("Referenzzeile2") = ""
|
||||
newrow("transactnr") = r("ordernr")
|
||||
|
||||
newrow("inserttimestamp") = Now
|
||||
|
||||
Odata.Rows.Add(newrow)
|
||||
End Sub
|
||||
|
||||
Sub valor_isin(newrow As DataRow, r As DataRow)
|
||||
Try
|
||||
Dim tmpvalor As String = ""
|
||||
Dim xvalor As String = ""
|
||||
Dim xisin As String = ""
|
||||
Dim x As String = ""
|
||||
newrow("valorennr") = ""
|
||||
newrow("isinnr") = ""
|
||||
tmpvalor = r("valoridr")
|
||||
If tmpvalor.Length < 12 Then
|
||||
newrow("valorennr") = r("valorid")
|
||||
Else
|
||||
xvalor = Microsoft.VisualBasic.Left(tmpvalor, Len(tmpvalor) - 12)
|
||||
xisin = Microsoft.VisualBasic.Right(tmpvalor, 12)
|
||||
x = Microsoft.VisualBasic.Left(xisin, 1)
|
||||
If x <> "1" And x <> "2" And x <> "3" And x <> "4" And x <> "5" And x <> "6" And x <> "7" And x <> "8" And x <> "9" And x <> "0" Then
|
||||
newrow("Valorennr") = xvalor
|
||||
newrow("IsinNr") = xisin
|
||||
Else
|
||||
newrow("Valorennr") = tmpvalor
|
||||
End If
|
||||
End If
|
||||
Catch
|
||||
newrow("Valorennr") = r("Valorid")
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
Reference in New Issue
Block a user