This commit is contained in:
SchreiberM
2016-07-18 14:29:33 +02:00
parent b9388d045a
commit b089c68613
37 changed files with 5975 additions and 2701 deletions

View File

@@ -1,11 +1,15 @@
Imports System.IO
Imports System.Security.AccessControl
Imports System.Security.Principal
Imports System.Data.SqlClient
Imports Oracle.ManagedDataAccess.Client
Public Class frmWD_IndexFile
Dim droptype As String
Dim aktFiledropped As String
Dim MULTIFILES As Integer = 0
Dim formloaded As Boolean = False
Private Sub FillToolStripButton_Click(sender As Object, e As EventArgs)
Try
Me.VWPMO_DOKUMENTTYPESTableAdapter.Fill(Me.DD_DMSDataSet.VWPMO_DOKUMENTTYPES, CURRENT_FORMVIEW_ID)
@@ -24,7 +28,7 @@ Public Class frmWD_IndexFile
Dim streamresult = ClassWindream.Stream_File(Filepath, Targetpath)
'Dim type = streamresult.GetType
If streamresult = True Then
Dim sql = "SELECT * FROM TBDD_INDEX_AUTOM WHERE ACTIVE = 1 AND UPPER(INDEXNAME) NOT LIKE UPPER('%ONLY %') AND DOCTYPE_ID = " & vDokart_ID
Dim sql = "SELECT * FROM TBDD_INDEX_AUTOM WHERE ACTIVE = 1 AND UPPER(INDEXNAME) NOT LIKE UPPER('%ONLY %') AND SQL_ACTIVE = 0 AND DOCTYPE_ID = " & vDokart_ID
Dim dt As DataTable = ClassDatabase.Return_Datatable(sql)
Dim indexierung_erfolgreich As Boolean = False
'Einbauen dass auch Konfigurationen erlaubt sind wo der Doktyp und der Record fest gestzt sind
@@ -171,7 +175,13 @@ Public Class frmWD_IndexFile
'Die temporäre Datei löschen
File.Delete(aktFiledropped)
End If
Return True
Class_DOC_SEARCH.REFRESH_DOC_TABLE_RESULTS()
sql = String.Format("SELECT DocID FROM VWPMO_WD_DOC_SYNC WHERE UPPER(FULL_FILENAME) = UPPER('{0}') AND CONVERT(DATE,Change_DateTime) = CONVERT(DATE,GETDATE())", CURRENT_FILEIN_WD)
CURRENT_DOC_ID = ClassDatabase.Execute_Scalar(sql)
If Not IsNothing(CURRENT_DOC_ID) Then
ClassFileResult.DocID = CURRENT_DOC_ID
ClassFileResult.SET_DOCID_INDICES()
End If
Else
MsgBox("An unexpected error occured while indexing file. Please check the log!", MsgBoxStyle.Exclamation)
Return False
@@ -184,6 +194,8 @@ Public Class frmWD_IndexFile
MsgBox("Attention in Work-File:" & vbNewLine & "No indices were defined (0)!", MsgBoxStyle.Critical)
Return False
End If
Return True
Else
Return False
End If
@@ -301,6 +313,11 @@ Public Class frmWD_IndexFile
MsgBox("Please choose a documenttxpe!", MsgBoxStyle.Information)
Exit Sub
End If
If CURRENT_TBPMO_INDEX_MAN.Rows.Count > 0 Then
If CheckWrite_IndexeMan() = False Then
Exit Sub
End If
End If
If cmbDokumentart.SelectedIndex <> -1 Then
My.Settings.WD_INDEXDOKART_SAVE = cmbDokumentart.Text
My.Settings.Save()
@@ -308,6 +325,125 @@ Public Class frmWD_IndexFile
End If
End Sub
Function Return_CURRENT_TBPMO_INDEX_MAN_VALUE(CONTROL_GUID As Integer, COL_NAME As String)
Try
' Presuming the DataTable has a column named ENTITY_ID and TYPE_NODE.
Dim expression As String
expression = "GUID = " & CONTROL_GUID
Dim foundRowsLevel0() As DataRow
' Use the Select method to find all rows matching the filter.
foundRowsLevel0 = CURRENT_TBPMO_INDEX_MAN.Select(expression)
Dim i As Integer
' For each row create a Node
For i = 0 To foundRowsLevel0.GetUpperBound(0)
Return foundRowsLevel0(i)(COL_NAME)
Next
Catch ex As Exception
ClassLogger.Add(" - Unvorhergesehener Fehler in Return_CURRENT_TBPMO_INDEX_MAN_VALUE - Fehler: " & vbNewLine & ex.Message)
Return Nothing
End Try
End Function
Function SET_CURRENT_TBPMO_INDEX_MAN_VALUE(CONTROL_GUID As Integer, VALUE As String)
Try
For Each row As DataRow In CURRENT_TBPMO_INDEX_MAN.Rows
If row.Item("GUID") = CONTROL_GUID Then
row.Item("MAN_VALUE") = VALUE
Return True
End If
Next
Catch ex As Exception
ClassLogger.Add(" - Unvorhergesehener Fehler in SET_CURRENT_TBPMO_INDEX_MAN_VALUE - Fehler: " & vbNewLine & ex.Message)
Return Nothing
End Try
End Function
Function CheckWrite_IndexeMan()
'#### Zuerst manuelle Werte indexieren ####
Try
If LogErrorsOnly = False Then ClassLogger.Add(" >>In CheckWrite_IndexeMan", False)
Dim result As Boolean = False
For Each ctrl As Control In Me.grbxControls.Controls
' ' MsgBox(ctrl.Name)
If ctrl.Name.StartsWith("txt") Then
Dim box As TextBox = ctrl
If box.Text = "" Then
Dim optional_index = Return_CURRENT_TBPMO_INDEX_MAN_VALUE(box.Tag, "OPTIONAL") 'ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBPMO_INDEX_MAN WHERE GUID = " & box.Tag, True)
If Not IsNothing(optional_index) Then
If CBool(optional_index) = False Then
MsgBox("Please insert a value!", MsgBoxStyle.Exclamation, "Missing input:")
box.Focus()
Return False
Else
SET_CURRENT_TBPMO_INDEX_MAN_VALUE(box.Tag, "")
'Indexwert_Postprocessing(Replace(box.Name, "txt", ""), "")
result = True
End If
Else
Return False
End If
Else
'If Indexwert_checkValueDB(Replace(box.Name, "txt", ""), box.Text) = False Then
' ClassLogger.Add(" - Der eingegebene Wert wurde nicht in der Datenbank gefunden", False)
' MsgBox("Der eingegebene Wert wurde nicht in der Datenbank gefunden!", MsgBoxStyle.Exclamation, "Fehlerhafte Indexierung:")
' box.Focus()
' Return False
'Else
' 'Indexwert_Postprocessing(Replace(box.Name, "txt", ""), box.Text)
SET_CURRENT_TBPMO_INDEX_MAN_VALUE(box.Tag, "")
result = True
'End If
End If
End If
If ctrl.Name.StartsWith("cmb") Then
Dim cmb As ComboBox = ctrl
If cmb.Text = "" Then
Dim optional_index = Return_CURRENT_TBPMO_INDEX_MAN_VALUE(cmb.Tag, "OPTIONAL") 'ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBPMO_INDEX_MAN WHERE GUID = " & box.Tag, True)
If Not IsNothing(optional_index) Then
If CBool(optional_index) = False Then
MsgBox("Please choose a value!", MsgBoxStyle.Exclamation, "Missing input:")
cmb.Focus()
Return False
Else
SET_CURRENT_TBPMO_INDEX_MAN_VALUE(cmb.Tag, "")
'Indexwert_Postprocessing(Replace(box.Name, "txt", ""), "")
result = True
End If
End If
Else
SET_CURRENT_TBPMO_INDEX_MAN_VALUE(cmb.Tag, cmb.Text)
' Indexwert_Postprocessing(Replace(cmb.Name, "cmb", ""), cmb.Text)
result = True
End If
End If
If ctrl.Name.StartsWith("dtp") Then
Dim dtp As DateTimePicker = ctrl
SET_CURRENT_TBPMO_INDEX_MAN_VALUE(dtp.Tag, dtp.Value)
'Indexwert_Postprocessing(Replace(dtp.Name, "dtp", ""), dtp.Text)
result = True
End If
If ctrl.Name.StartsWith("chk") Then
Dim chk As CheckBox = ctrl
SET_CURRENT_TBPMO_INDEX_MAN_VALUE(chk.Tag, chk.Checked)
'Indexwert_Postprocessing(Replace(chk.Name, "chk", ""), chk.Checked)
result = True
End If
If ctrl.Name.StartsWith("lbl") = False And result = False Then
ClassLogger.Add("Die Überprüfung der manuellen Indices ist fehlerhaft. Bitte informieren Sie den Systembetreuer", True)
Return False
End If
Next
Return True
Catch ex As Exception
ClassLogger.Add(" - Unvorhergesehener Fehler in CheckWrite_IndexeMan - Fehler: " & vbNewLine & ex.Message)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unerwarteter Unexpected error in CheckWrite_IndexeMan:")
Return False
End Try
End Function
Sub Indexing_File(doctype_id As Integer)
Try
Me.Cursor = Cursors.WaitCursor
@@ -339,12 +475,14 @@ Public Class frmWD_IndexFile
Next
Me.Cursor = Cursors.Default
If err = False Then
NEW_FILES_ADDED = True
Dim stg As String = "Alle Dateien wurden mit Multiindexing erfolgreich nach windream übertragen!"
Dim stg1 As String = "Erfolgsmeldung"
If USER_LANGUAGE <> "de-DE" Then
stg = "All files were transferred via Multiindexing to windream"
stg1 = "Success:"
End If
Class_DOC_SEARCH.REFRESH_DOC_TABLE_RESULTS()
MsgBox(stg, MsgBoxStyle.Information, stg1)
Me.Close()
End If
@@ -353,7 +491,11 @@ Public Class frmWD_IndexFile
End If
Else
If WORK_FILE(Me.txtFilepath.Text, Me.PATHTextBox.Text, doctype_id, My.Settings.WD_INDEXDOKART_SAVE, False) = True Then Me.Close()
If WORK_FILE(Me.txtFilepath.Text, Me.PATHTextBox.Text, doctype_id, My.Settings.WD_INDEXDOKART_SAVE, False) = True Then
NEW_FILES_ADDED = True
Me.Close()
End If
End If
Me.Cursor = Cursors.Default
@@ -368,12 +510,454 @@ Public Class frmWD_IndexFile
CURRENT_DOKARTID = cmbDokumentart.SelectedValue
CURRENT_DOKARTSTRING = cmbDokumentart.Text
Refresh_indices()
Refresh_Indices_Manual()
Check_Subfolder()
End If
Catch ex As Exception
MsgBox("Error in cmbDokumentart SelectedIndex:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Sub Refresh_Indices_Manual()
Try
ClassFileResult.GET_DATATABLE_INDICES_PMO()
If CURRENT_TBPMO_INDEX_MAN.Rows.Count > 0 Then
'Der Tabelle eine Splate für den idnexwert hinzufügen
Dim MAN_VALUE As DataColumn = CURRENT_TBPMO_INDEX_MAN.Columns.Add("MAN_VALUE", Type.GetType("System.String"))
grbxControls.Visible = True
grbxControls.Controls.Clear()
Me.Size = New Size(605, 700)
Dim anz As Integer = 1
Dim ylbl As Integer = 20
Dim y As Integer = 38
For Each DR As DataRow In CURRENT_TBPMO_INDEX_MAN.Rows
Dim type = DR.Item("DATATYPE")
If type <> "BOOLEAN" Then
addLabel(DR.Item("GUID"), DR.Item("NAME"), DR.Item("COMMENT").ToString, ylbl)
End If
Dim DefaultValue = DR.Item("DEFAULT_VALUE")
Select Case type
Case "BOOLEAN"
Dim VORBELGUNG As Integer = DefaultValue
'nur eine Textbox
Dim chk As CheckBox = ClassControls_Manual.AddCheckBox(DR.Item("GUID"), DR.Item("NAME"), y, VORBELGUNG, DR.Item("COMMENT").ToString)
If Not IsNothing(chk) Then
grbxControls.Controls.Add(chk)
End If
Case "INTEGER"
If DR.Item("SUGGESTION") = True And DR.Item("SQL_RESULT").ToString.Length > 0 Then
AddVorschlag_ComboBox(DR.Item("GUID"), DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), DefaultValue)
'AddAutoSuggest_Textbox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), DefaultValue)
Else
Dim VORBELGUNG As Integer = DefaultValue
'nur eine Textbox
AddTextBox(DR.Item("GUID"), DR.Item("NAME"), y, VORBELGUNG)
End If
Case "VARCHAR"
If DR.Item("SUGGESTION") = True And DR.Item("SQL_RESULT").ToString.Length > 0 Then
AddVorschlag_ComboBox(DR.Item("GUID"), DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), DefaultValue)
'AddAutoSuggest_Textbox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), DefaultValue)
Else
If DR.Item("NAME").ToString.ToLower = "dateiname" Then
'Übergibt den Dateinamen um diesen Vorzuschlagen
AddTextBox(DR.Item("GUID"), DR.Item("NAME"), y, System.IO.Path.GetFileNameWithoutExtension(txtFilepath.Text))
Else
Dim VORBELGUNG As String = DefaultValue
'nur eine Textbox
AddTextBox(DR.Item("GUID"), DR.Item("NAME"), y, VORBELGUNG)
End If
End If
Case "DATE"
AddDateTimePicker(DR.Item("GUID"), DR.Item("NAME"), y)
Case Else
MsgBox("Bitte überprüfen Sie den Datentyp des hinterlegten Indexwertes!", MsgBoxStyle.Critical, "Achtung:")
ClassLogger.Add(" - Datentyp nicht hinterlegt - LoadIndexe_Man")
End Select
anz += 1
ylbl += 60
y += 60
Next
SendKeys.Send("{TAB}")
Else
grbxControls.Visible = False
Me.Size = New Size(605, 430)
End If
Catch ex As Exception
MsgBox("Error in Refresh_Indices_Manual:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Sub Check_Subfolder()
Try
Dim sel = "select MANUAL_SUBFOLDER FROM TBPMO_WD_FORMVIEW_DOKTYPES WHERE FORMVIEW_ID = (SELECT GUID FROM TBPMO_FORM_VIEW WHERE FORM_ID = " & CURRENT_FORM_ID & " and SCREEN_ID = " & CURRENT_SCREEN_ID & ")"
Dim chk = ClassDatabase.Execute_Scalar(sel)
If Not IsNothing(chk) Then
If CBool(chk) = True Then
lblSubfolder.Visible = True
txtSubfolder.Visible = True
CURRENT_CHECK_SUBFOLDER = True
CURRENT_SUBFOLDER = ""
Else
lblSubfolder.Visible = False
txtSubfolder.Visible = False
CURRENT_CHECK_SUBFOLDER = False
End If
End If
Catch ex As Exception
MsgBox("Error in Check_Subfolder:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
lblSubfolder.Visible = False
txtSubfolder.Visible = False
CURRENT_CHECK_SUBFOLDER = False
End Try
End Sub
Sub addLabel(ID As Integer, indexname As String, hinweis As String, ylbl As Integer)
Dim lbl As New Label
lbl.Name = "lbl" & indexname
lbl.Size = New Size(CInt(hinweis.Length * 15), 18) 'CInt(hinweis.Length * 9)
lbl.Text = hinweis
lbl.Tag = ID
grbxControls.Controls.Add(lbl)
lbl.Location = New Point(11, ylbl)
End Sub
Sub AddComboBoxValue(cmbName As ComboBox, Value As String)
cmbName.Items.Add(Value)
End Sub
' <STAThread()> _
Function addCombobox(ID As Integer, indexname As String, y As Integer)
Dim cmb As New ComboBox
cmb.Name = "cmb" & indexname
cmb.AutoSize = True
cmb.Size = New Size(300, 27)
cmb.Tag = ID
grbxControls.Controls.Add(cmb)
cmb.Location = New Point(11, y)
'cmb.AutoCompleteMode = AutoCompleteMode.SuggestAppend
'cmb.AutoCompleteSource = AutoCompleteSource.ListItems
'AddHandler cmb.KeyUp, AddressOf AutoCompleteCombo_KeyUp
AddHandler cmb.SelectedIndexChanged, AddressOf OncmbSIndexChanged
AddHandler cmb.GotFocus, AddressOf OncmbGotFocus
AddHandler cmb.LostFocus, AddressOf OncmbLostFocus
Return cmb
End Function
Public Sub OncmbGotFocus(sender As System.Object, e As System.EventArgs)
Dim cmb As ComboBox = sender
cmb.BackColor = Color.Lime
End Sub
' <STAThread()> _
Public Sub OncmbLostFocus(sender As System.Object, e As System.EventArgs)
Dim cmb As ComboBox = sender
cmb.BackColor = Color.White
End Sub
Function AddTextBox(ID As Integer, indexname As String, y As Integer, text As String)
Dim txt As New TextBox
txt.Name = "txt" & indexname
txt.Size = New Size(260, 27)
'txt.AutoSize = True
txt.Tag = ID
grbxControls.Controls.Add(txt)
txt.Location = New Point(11, y)
If text <> "" Then
txt.Text = text
txt.Size = New Size(CInt(text.Length * 15), 27)
txt.SelectAll()
End If
AddHandler txt.GotFocus, AddressOf OnTextBoxFocus
AddHandler txt.LostFocus, AddressOf OnTextBoxLostFocus
AddHandler txt.KeyUp, AddressOf OnTextBoxKeyUp
AddHandler txt.TextChanged, AddressOf OnTextBoxTextChanged
Return txt
End Function
Public Sub OnTextBoxFocus(sender As System.Object, e As System.EventArgs)
Dim box As TextBox = sender
box.BackColor = Color.Lime
box.SelectAll()
End Sub
Public Sub OnTextBoxTextChanged(sender As System.Object, e As System.EventArgs)
Dim box As TextBox = sender
'If box.Text.Length > 15 Then
Dim g As Graphics = box.CreateGraphics
box.Width = g.MeasureString(box.Text, box.Font).Width + 15
g.Dispose()
' End If
End Sub
Public Sub OnTextBoxLostFocus(sender As System.Object, e As System.EventArgs)
Dim box As TextBox = sender
box.BackColor = Color.White
End Sub
Public Sub OnTextBoxKeyUp(sender As System.Object, e As System.Windows.Forms.KeyEventArgs)
Dim box As TextBox = sender
If (e.KeyCode = Keys.Return) Then
SendKeys.Send("{TAB}")
End If
End Sub
Sub AddDateTimePicker(ID As Integer, indexname As String, y As Integer)
Dim dtp As New DateTimePicker
dtp.Name = "dtp" & indexname
dtp.Format = DateTimePickerFormat.Short
dtp.Size = New Size(133, 27)
dtp.Tag = ID
dtp.Location = New Point(11, y)
grbxControls.Controls.Add(dtp)
AddHandler dtp.ValueChanged, AddressOf OndtpChanged
End Sub
Sub OndtpChanged()
'offen was hier zu tun ist
End Sub
Public Sub OncmbSIndexChanged(sender As System.Object, e As System.EventArgs)
If formloaded = False Then
Exit Sub
End If
Dim cmb As ComboBox = sender
If cmb.SelectedIndex <> -1 Then
If cmb.Text.Length > 15 Then
Dim g As Graphics = cmb.CreateGraphics
cmb.Width = g.MeasureString(cmb.Text, cmb.Font).Width + 30
g.Dispose()
End If
Get_NextComboBoxResults(cmb)
SendKeys.Send("{TAB}")
End If
End Sub
Sub Get_NextComboBoxResults(cmb As ComboBox)
Try
Dim indexname = cmb.Name.Replace("cmb", "")
Dim sql = "SELECT GUID,NAME,SQL_RESULT FROM TBPMO_INDEX_MAN where SUGGESTION = 1 AND SQL_RESULT like '%@" & indexname & "%' and DOCTYPE_ID = " & CURRENT_DOKARTID & " ORDER BY SEQUENCE"
Dim DT As DataTable = ClassDatabase.Return_Datatable(sql, True)
If Not IsNothing(DT) Then
If DT.Rows.Count > 0 Then
Dim cmbname = "cmb" & DT.Rows(0).Item("NAME")
Renew_ComboboxResults(DT.Rows(0).Item("GUID"), indexname, cmb.Text)
End If
End If
Catch ex As Exception
MsgBox("Error in Get_NextComboBoxResults:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Private Sub Renew_ComboboxResults(INDEX_GUID As Integer, SearchString As String, Resultvalue As String)
Try
Dim connectionString As String
Dim sqlCnn As SqlConnection
Dim sqlCmd As SqlCommand
Dim adapter As New SqlDataAdapter
Dim oracleConn As OracleConnection
Dim oracleCmd As OracleCommand
Dim oracleadapter As New OracleDataAdapter
Dim NewDataset As New DataSet
Dim i As Integer
'Dim DT_INDEX As DataTable = ClassDatabase.Return_Datatable("select * FROM TBPMO_INDEX_MAN WHERE GUID = " & INDEX_GUID, True)
'If IsNothing(DT_INDEX) Then
' Exit Sub
'End If
Dim conid = Return_CURRENT_TBPMO_INDEX_MAN_VALUE(INDEX_GUID, "CONNECTION_ID") ' DT_INDEX.Rows(0).Item("CONNECTION_ID")
Dim sql_result = Return_CURRENT_TBPMO_INDEX_MAN_VALUE(INDEX_GUID, "SQL_RESULT") 'DT_INDEX.Rows(0).Item("SQL_RESULT")
Dim NAME = Return_CURRENT_TBPMO_INDEX_MAN_VALUE(INDEX_GUID, "NAME") 'DT_INDEX.Rows(0).Item("NAME")
If Not IsNothing(conid) And Not IsNothing(sql_result) And Not IsNothing(NAME) Then
For Each ctrl As Control In Me.grbxControls.Controls
If ctrl.Name = "cmb" & NAME.ToString Then
Dim cmb As ComboBox = ctrl
Dim sql As String = sql_result.ToString.ToUpper.Replace("@" & SearchString.ToUpper, Resultvalue)
connectionString = ClassDatabase.GetConnectionString(conid)
If connectionString Is Nothing = False Then
'SQL Befehl füllt die Auswahlliste
If connectionString.Contains("Server=") And connectionString.Contains("Database=") Then
sqlCnn = New SqlConnection(connectionString)
sqlCnn.Open()
sqlCmd = New SqlCommand(sql, sqlCnn)
adapter.SelectCommand = sqlCmd
adapter.Fill(NewDataset)
ElseIf connectionString.StartsWith("Data Source=") And connectionString.Contains("SERVICE_NAME") Then
oracleConn = New OracleConnection(connectionString)
' Try
oracleConn.Open()
oracleCmd = New OracleCommand(sql, oracleConn)
oracleadapter.SelectCommand = oracleCmd
oracleadapter.Fill(NewDataset)
End If
If NewDataset.Tables(0).Rows.Count > 0 Then
cmb.Items.Clear()
'Die Standargrösse definieren
Dim newWidth As Integer = 300
For i = 0 To NewDataset.Tables(0).Rows.Count - 1
'MsgBox(NewDataset.Tables(0).Rows(i).Item(0))
AddComboBoxValue(cmb, NewDataset.Tables(0).Rows(i).Item(0))
Try
Dim text As String = NewDataset.Tables(0).Rows(i).Item(0)
If text.Length > 15 Then
Dim g As Graphics = cmb.CreateGraphics
If g.MeasureString(text, cmb.Font).Width + 30 > newWidth Then
newWidth = g.MeasureString(text, cmb.Font).Width + 30
End If
g.Dispose()
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in Anpassung Breite ComboBox:")
End Try
Next
cmb.Size = New Size(newWidth, 27)
cmb.AutoCompleteSource = AutoCompleteSource.ListItems
cmb.AutoCompleteMode = AutoCompleteMode.Suggest
End If
If connectionString.Contains("Server=") And connectionString.Contains("Database=") Then
Try
adapter.Dispose()
sqlCmd.Dispose()
sqlCnn.Close()
Catch ex As Exception
End Try
Else
Try
oracleadapter.Dispose()
oracleCmd.Dispose()
oracleConn.Close()
Catch ex As Exception
End Try
End If
End If
End If
Next
End If
Catch ex As Exception
ClassLogger.Add(" - Unvorhergesehener Unexpected error in Renew_ComboboxResults - Fehler: " & vbNewLine & ex.Message)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unvorhergesehener Unexpected error in Renew_ComboboxResults:")
End Try
End Sub
Private Sub AddVorschlag_ComboBox(ID As Integer, indexname As String, y As Integer, conid As Integer, sql_Vorschlag As String, Optional Vorgabe As String = "")
Try
Dim connectionString As String
Dim sqlCnn As SqlConnection
Dim sqlCmd As SqlCommand
Dim adapter As New SqlDataAdapter
Dim oracleConn As OracleConnection
Dim oracleCmd As OracleCommand
Dim oracleadapter As New OracleDataAdapter
Dim NewDataset As New DataSet
Dim i As Integer
Dim sql As String
Dim runinLZ As Boolean = False
connectionString = ClassDatabase.GetConnectionString(conid)
If connectionString Is Nothing = False Then
'SQL Befehl füllt die Auswahlliste
sql = sql_Vorschlag
If Not sql.Contains("@") Then
If connectionString.Contains("Server=") And connectionString.Contains("Database=") Then
sqlCnn = New SqlConnection(connectionString)
sqlCnn.Open()
sqlCmd = New SqlCommand(sql, sqlCnn)
adapter.SelectCommand = sqlCmd
adapter.Fill(NewDataset)
ElseIf connectionString.StartsWith("Data Source=") And connectionString.Contains("SERVICE_NAME") Then
oracleConn = New OracleConnection(connectionString)
' Try
oracleConn.Open()
oracleCmd = New OracleCommand(sql_Vorschlag, oracleConn)
oracleadapter.SelectCommand = oracleCmd
oracleadapter.Fill(NewDataset)
End If
Else
runinLZ = True
If LogErrorsOnly = False Then ClassLogger.Add(" >>sql enthält Platzhalter und wird erst während der Laufzeit gefüllt!", False)
End If
Dim newCMB As ComboBox
If runinLZ = True Then
'Die Standardcombobox anlegen
newCMB = addCombobox(ID, indexname, y)
newCMB.Size = New Size(300, 27)
Else
If NewDataset.Tables(0).Rows.Count > 0 Then
'Die Standardcombobox anlegen
newCMB = addCombobox(ID, indexname, y)
'Die Standargrösse definieren
Dim newWidth As Integer = 300
For i = 0 To NewDataset.Tables(0).Rows.Count - 1
'MsgBox(NewDataset.Tables(0).Rows(i).Item(0))
AddComboBoxValue(newCMB, NewDataset.Tables(0).Rows(i).Item(0))
Try
Dim text As String = NewDataset.Tables(0).Rows(i).Item(0)
If text.Length > 15 Then
Dim g As Graphics = newCMB.CreateGraphics
If g.MeasureString(text, newCMB.Font).Width + 30 > newWidth Then
newWidth = g.MeasureString(text, newCMB.Font).Width + 30
End If
g.Dispose()
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in Anpassung Breite ComboBox:")
End Try
Next
newCMB.Size = New Size(newWidth, 27)
newCMB.AutoCompleteSource = AutoCompleteSource.ListItems
newCMB.AutoCompleteMode = AutoCompleteMode.Suggest
newCMB.DropDownHeight = (newCMB.ItemHeight + 0.2) * 25
If Vorgabe <> "" Then
newCMB.SelectedIndex = newCMB.FindStringExact(Vorgabe)
newCMB.Text = Vorgabe
Get_NextComboBoxResults(newCMB)
End If
Else
End If
If connectionString.Contains("Server=") And connectionString.Contains("Database=") Then
Try
adapter.Dispose()
sqlCmd.Dispose()
sqlCnn.Close()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
Else
Try
oracleadapter.Dispose()
oracleCmd.Dispose()
oracleConn.Close()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End If
End If
End If
Catch ex As Exception
ClassLogger.Add(" - Unvorhergesehener Unexpected error in AddVorschlag_ComboBox - Indexname: " & indexname & " - Fehler: " & vbNewLine & ex.Message)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unvorhergesehener Unexpected error in AddVorschlag_ComboBox:")
End Try
End Sub
Sub Refresh_indices()
Try
If CURRENT_DOKARTID > 0 Then
@@ -504,5 +1088,10 @@ Public Class frmWD_IndexFile
If CURRENT_CONTROL_DOCTYPE_MATCH <> "" Then
cmbDokumentart.SelectedIndex = cmbDokumentart.FindStringExact(CURRENT_CONTROL_DOCTYPE_MATCH)
End If
formloaded = True
End Sub
Private Sub txtSubfolder_TextChanged(sender As Object, e As EventArgs) Handles txtSubfolder.TextChanged
CURRENT_SUBFOLDER = txtSubfolder.Text
End Sub
End Class