From 871392396a404bd808d2fb4847dc9091e2c22462 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Mon, 10 Feb 2020 10:37:03 +0100 Subject: [PATCH] move control stuff to classcontrol --- Global_Indexer/ClassControls.vb | 322 +++++++++++- Global_Indexer/ModuleCURRENT.vb | 2 + Global_Indexer/frmIndex.designer.vb | 12 +- Global_Indexer/frmIndex.vb | 768 +++------------------------- 4 files changed, 386 insertions(+), 718 deletions(-) diff --git a/Global_Indexer/ClassControls.vb b/Global_Indexer/ClassControls.vb index 4e33aed..a1ff0c0 100644 --- a/Global_Indexer/ClassControls.vb +++ b/Global_Indexer/ClassControls.vb @@ -1,5 +1,16 @@ -Public Class ClassControls - Public Shared Function AddCheckBox(indexname As String, y As Integer, vorbelegung As String, caption As String) +Imports System.Data.SqlClient +Imports Oracle.ManagedDataAccess.Client + +Public Class ClassControls + Private Property Form As frmIndex + Private Property Panel As Panel + + Public Sub New(Panel As Panel, Form As frmIndex) + Me.Form = Form + Me.Panel = Panel + End Sub + + Public Function AddCheckBox(indexname As String, y As Integer, vorbelegung As String, caption As String) Try Dim value As Boolean = False Dim chk As New CheckBox @@ -27,6 +38,313 @@ ClassLogger.Add("Unhandled Exception in AddCheckBox: " & ex.Message, True) Return Nothing End Try + End Function + + Public Function AddVorschlag_ComboBox(indexname As String, y As Integer, conid As Integer, sql_Vorschlag As String, Multiselect As Boolean, Optional Vorgabe As String = "", Optional AddNewValues As Boolean = False, Optional PreventDuplicateValues As Boolean = False) As Control + 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 = ClassFormFunctions.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("Initial Catalog=") 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 + + + If runinLZ = True Then + 'Die Standardcombobox anlegen + Dim oCombobox As ComboBox + oCombobox = AddCombobox(indexname, y) + oCombobox.Size = New Size(300, 27) + Return oCombobox + Else + Dim table As DataTable = NewDataset.Tables(0) + Dim oControl As New DigitalData.Controls.LookupGrid.LookupControl2 With { + .DataSource = table, + .MultiSelect = Multiselect, + .AllowAddNewValues = AddNewValues, + .PreventDuplicates = PreventDuplicateValues, + .Location = New Point(11, y), + .Size = New Size(300, 27), + .Name = "cmbMulti" & indexname + } + + If connectionString.Contains("Initial Catalog=") 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 + + Return oControl + 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 Function + + Function AddCombobox(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.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 + AddHandler cmb.KeyDown, AddressOf OncmbKeyDown + Return cmb + End Function + + Public Sub OncmbKeyDown(sender As System.Object, e As System.EventArgs) + Dim cmb As ComboBox = sender + + ' Verhindert, dass Auswahlliste und Autocompleteliste übereinander liegen + If cmb.DroppedDown = True Then + cmb.DroppedDown = False + End If + End Sub + + Public Sub OncmbGotFocus(sender As System.Object, e As System.EventArgs) + Dim cmb As ComboBox = sender + cmb.BackColor = Color.Lime + End Sub + + Public Sub OncmbLostFocus(sender As System.Object, e As System.EventArgs) + Dim cmb As ComboBox = sender + cmb.BackColor = Color.White + End Sub + + Public Sub OncmbSIndexChanged(sender As System.Object, e As System.EventArgs) + If Form.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 + + Private Sub Get_NextComboBoxResults(cmb As ComboBox) + Try + Dim indexname = cmb.Name.Replace("cmb", "") + Dim sql = "SELECT GUID,NAME,SQL_RESULT FROM TBDD_INDEX_MAN where SUGGESTION = 1 AND SQL_RESULT like '%@" & indexname & "%' and DOK_ID = " & CURRENT_DOKART_ID & " 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 TBDD_INDEX_MAN WHERE GUID = " & INDEX_GUID, True) + If IsNothing(DT_INDEX) Then + Exit Sub + End If + + Dim conid = DT_INDEX.Rows(0).Item("CONNECTION_ID") + Dim sql_result = DT_INDEX.Rows(0).Item("SQL_RESULT") + Dim 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.Panel.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 = ClassFormFunctions.GetConnectionString(conid) + If connectionString Is Nothing = False Then + 'SQL Befehl füllt die Auswahlliste + + If connectionString.Contains("Initial Catalog=") 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)) + cmb.Items.Add(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("Initial Catalog=") 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 + + Public Function AddTextBox(indexname As String, y As Integer, text As String) As TextBox + Dim txt As New TextBox + txt.Name = "txt" & indexname + + txt.Size = New Size(260, 27) + 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 oTextbox As TextBox = sender + oTextbox.BackColor = Color.Lime + oTextbox.SelectAll() + End Sub + + Public Sub OnTextBoxTextChanged(sender As System.Object, e As System.EventArgs) + Dim oTextbox As TextBox = sender + Using oGraphics As Graphics = oTextbox.CreateGraphics() + oTextbox.Width = oGraphics.MeasureString(oTextbox.Text, oTextbox.Font).Width + 15 + End Using + End Sub + + Public Sub OnTextBoxLostFocus(sender As System.Object, e As System.EventArgs) + Dim oTextbox As TextBox = sender + oTextbox.BackColor = Color.White + End Sub + + Public Sub OnTextBoxKeyUp(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) + Dim oTextbox As TextBox = sender + If (e.KeyCode = Keys.Return) Then + SendKeys.Send("{TAB}") + End If + End Sub End Class diff --git a/Global_Indexer/ModuleCURRENT.vb b/Global_Indexer/ModuleCURRENT.vb index 344009c..167e2ff 100644 --- a/Global_Indexer/ModuleCURRENT.vb +++ b/Global_Indexer/ModuleCURRENT.vb @@ -76,6 +76,8 @@ Module ModuleCURRENT Public CURRENT_DROPTYPE Public VIEWER_LICENSE As String = "" + + Public INDEX_FORM_LOADED As Boolean End Module diff --git a/Global_Indexer/frmIndex.designer.vb b/Global_Indexer/frmIndex.designer.vb index 174432d..015742c 100644 --- a/Global_Indexer/frmIndex.designer.vb +++ b/Global_Indexer/frmIndex.designer.vb @@ -40,6 +40,7 @@ Partial Class frmIndex Me.Label2 = New System.Windows.Forms.Label() Me.txtIndexfilepath = New System.Windows.Forms.TextBox() Me.btnOK = New System.Windows.Forms.Button() + Me.DocumentViewer1 = New DigitalData.Controls.DocumentViewer.DocumentViewer() Me.StatusStrip1 = New System.Windows.Forms.StatusStrip() Me.lblhinweis = New System.Windows.Forms.ToolStripStatusLabel() Me.tslblVorschau = New System.Windows.Forms.ToolStripStatusLabel() @@ -51,7 +52,6 @@ Partial Class frmIndex Me.VWINDEX_AUTOMTableAdapter = New Global_Indexer.MyDatasetTableAdapters.VWDDINDEX_AUTOMTableAdapter() Me.PdfBarController1 = New DevExpress.XtraPdfViewer.Bars.PdfBarController(Me.components) Me.PdfBarController2 = New DevExpress.XtraPdfViewer.Bars.PdfBarController(Me.components) - Me.DocumentViewer1 = New DigitalData.Controls.DocumentViewer.DocumentViewer() CType(Me.SplitContainer1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SplitContainer1.Panel1.SuspendLayout() Me.SplitContainer1.Panel2.SuspendLayout() @@ -189,6 +189,11 @@ Partial Class frmIndex Me.btnOK.Image = Global.Global_Indexer.My.Resources.Resources.Go Me.btnOK.Name = "btnOK" ' + 'DocumentViewer1 + ' + resources.ApplyResources(Me.DocumentViewer1, "DocumentViewer1") + Me.DocumentViewer1.Name = "DocumentViewer1" + ' 'StatusStrip1 ' Me.StatusStrip1.ImageScalingSize = New System.Drawing.Size(20, 20) @@ -252,11 +257,6 @@ Partial Class frmIndex ' Me.VWINDEX_AUTOMTableAdapter.ClearBeforeFill = True ' - 'DocumentViewer1 - ' - resources.ApplyResources(Me.DocumentViewer1, "DocumentViewer1") - Me.DocumentViewer1.Name = "DocumentViewer1" - ' 'frmIndex ' resources.ApplyResources(Me, "$this") diff --git a/Global_Indexer/frmIndex.vb b/Global_Indexer/frmIndex.vb index d358b27..54c2ec5 100644 --- a/Global_Indexer/frmIndex.vb +++ b/Global_Indexer/frmIndex.vb @@ -17,18 +17,17 @@ Public Class frmIndex Private akttxtbox As TextBox Dim DT_INDEXEMAN As DataTable Dim DT_DOKART As DataTable - Private formloaded As Boolean = False + Public FormLoaded As Boolean = False Private Shared _Instance As frmIndex = Nothing Dim DropType As String Private Shared WDDirect As Boolean = False Dim sql_history_INSERT_INTO As String Dim sql_history_Index_Values As String - Dim NewFileString As String + Private NewFileString As String Private CancelAttempts As Integer = 0 - - Private Property viewer_string As String + Private Property ViewerString As String 'Dim DocView 'Dim viewer_string As String @@ -62,52 +61,7 @@ Public Class frmIndex pnlIndex.Controls.Add(lbl) lbl.Location = New Point(11, ylbl) End Sub - Function AddTextBox(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 - - pnlIndex.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(indexname As String, y As Integer) Dim dtp As New DateTimePicker dtp.Name = "dtp" & indexname @@ -121,120 +75,6 @@ Public Class frmIndex 'offen was hier zu tun ist End Sub - ' _ - Function addCombobox(indexname As String, y As Integer) - Dim cmb As New ComboBox - cmb.Name = "cmb" & indexname - cmb.AutoSize = True - cmb.Size = New Size(300, 27) - pnlIndex.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 - AddHandler cmb.KeyDown, AddressOf OncmbKeyDown - Return cmb - End Function - - ' _ - Public Sub OncmbKeyDown(sender As System.Object, e As System.EventArgs) - Dim cmb As ComboBox = sender - - ' Verhindert, dass Auswahlliste und Autocompleteliste übereinander liegen - If cmb.DroppedDown = True Then - cmb.DroppedDown = False - End If - End Sub - - ' _ - Public Sub OncmbGotFocus(sender As System.Object, e As System.EventArgs) - Dim cmb As ComboBox = sender - cmb.BackColor = Color.Lime - End Sub - ' _ - Public Sub OncmbLostFocus(sender As System.Object, e As System.EventArgs) - Dim cmb As ComboBox = sender - cmb.BackColor = Color.White - 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 TBDD_INDEX_MAN where SUGGESTION = 1 AND SQL_RESULT like '%@" & indexname & "%' and DOK_ID = " & CURRENT_DOKART_ID & " 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 - ' 'Public Sub AutoCompleteCombo_KeyUp(ByVal cbo As ComboBox, ByVal e As KeyEventArgs) - ' ' System.Threading.Thread.Sleep(400) - ' ' Dim sTypedText As String - ' ' Dim iFoundIndex As Integer - ' ' Dim oFoundItem As Object - ' ' Dim sFoundText As String - ' ' Dim sAppendText As String - ' ' 'Allow select keys without Autocompleting - ' ' Select Case e.KeyCode - ' ' Case Keys.Left, Keys.Right, Keys.Up, Keys.Delete, Keys.Down, Keys.Enter, Keys.Tab - ' ' Return - ' ' Case Keys.Escape, Keys.Back - ' ' Return - ' ' End Select - ' ' 'Get the Typed Text and Find it in the list - ' ' sTypedText = cbo.Text - ' ' iFoundIndex = cbo.FindString(sTypedText) - ' ' 'If we found the Typed Text in the list then Autocomplete - ' ' If iFoundIndex >= 0 Then - ' ' 'Get the Item from the list (Return Type depends if Datasource was bound - ' ' ' or List Created) - ' ' oFoundItem = cbo.Items(iFoundIndex) - ' ' 'Use the ListControl.GetItemText to resolve the Name in case the Combo - ' ' ' was Data bound - ' ' sFoundText = cbo.GetItemText(oFoundItem) - ' ' 'Append then found text to the typed text to preserve case - ' ' sAppendText = sFoundText.Substring(sTypedText.Length) - ' ' cbo.Text = sTypedText & sAppendText - ' ' 'Select the Appended Text - ' ' cbo.SelectionStart = sTypedText.Length - ' ' cbo.SelectionLength = sAppendText.Length - ' ' cbo.DroppedDown = True - ' ' Else - ' ' cbo.DroppedDown = False - ' ' End If - ' ' Me.Cursor = Cursors.Default - ' 'End Sub - '#End Region - '#Region "+++++ Datenbankfunktionen (CS, GetValues, CheckValues) ++++++" - ' _ Function Indexwert_checkValueDB(indexname As String, wert As String) Try @@ -288,71 +128,6 @@ Public Class frmIndex End Try End Function - ' Function Execute_Scalar_SQLServer(vsql_statement As String, vconnectionString As String, check As Boolean) - ' Try - ' Dim cnn As SqlConnection - ' cnn = New SqlConnection(vconnectionString) - ' Dim cmd As SqlCommand - ' cnn.Open() - ' cmd = New SqlCommand(vsql_statement, cnn) - ' If check = True Then - ' 'ERgebnis muss immer 1 oder mehr ergeben - ' Dim count As Int32 = Convert.ToInt32(cmd.ExecuteScalar()) - ' If count = 1 Then - ' cmd.Dispose() - ' cnn.Close() - ' Return 1 - ' Else - ' cmd.Dispose() - ' cnn.Close() - ' Return 2 - ' End If - ' Else - ' 'Ergebnis - ' Dim ergebnis As String = cmd.ExecuteScalar() - ' Return ergebnis - ' End If - - ' Catch ex As Exception - ' MsgBox("Unvorhergesehener Unexpected error in Execute_Scalar_SQLServer" & vbNewLine & "Automatischer Index (j/n): " & check.ToString & vbNewLine & "Fehler:" & vbNewLine & ex.Message, MsgBoxStyle.Critical, "Unexpected error in Ausführen sql:") - ' ClassLogger.Add(" - Unvorhergesehener Unexpected error in Execute_Scalar_SQLServer" & vbNewLine & "Automatischer Index (j/n): " & check.ToString & vbNewLine & "Fehler: " & vbNewLine & ex.Message) - ' ClassLogger.Add(" - SQL: " & vsql_statement, False) - ' ClassLogger.Add(" - Connection: " & vconnectionString, False) - ' Return 99 - ' End Try - ' End Function - ' Function Execute_Scalar_Oracle(vsql_statement As String, vconnectionString As String, check As Boolean) - ' Try - ' Dim cnn As OracleConnection - ' cnn = New OracleConnection(vconnectionString) - ' Dim cmd As OracleCommand - ' cnn.Open() - ' cmd = New OracleCommand(vsql_statement, cnn) - - ' If check = True Then - ' 'Ergebnis muss immer 1 oder mehr ergeben - ' Dim count As Int32 = Convert.ToInt32(cmd.ExecuteScalar()) - ' If count = 1 Then - ' Return 1 - ' Else - ' Return 2 - ' End If - ' Else - ' 'Ergebnis - ' Dim ergebnis As String = cmd.ExecuteScalar() - ' Return ergebnis - ' End If - - ' cmd.Dispose() - ' cnn.Close() - ' Catch ex As Exception - ' MsgBox("Unvorhergesehener Unexpected error in Execute_Scalar_Oracle" & vbNewLine & "Automatischer Index (j/n): " & check.ToString & vbNewLine & "Fehler:" & vbNewLine & ex.Message, MsgBoxStyle.Critical, "Unexpected error in Ausführen sql:") - ' ClassLogger.Add(" - Unvorhergesehener Unexpected error in Execute_Scalar_Oracle" & vbNewLine & "Automatischer Index (j/n): " & check.ToString & vbNewLine & "Fehler: " & vbNewLine & ex.Message) - ' ClassLogger.Add(" - SQL: " & vsql_statement, False) - ' ClassLogger.Add(" - Connection: " & vconnectionString, False) - ' Return 99 - ' End Try - ' End Function Function GetManIndex_Value(indexname As String, RequestFor As String, opt As Boolean) Try Dim DT As DataTable @@ -449,29 +224,30 @@ Public Class frmIndex Return "" End Try End Function - Function GetAutomaticIndexSQLValue(vsqlstatement As String, vconnectionID As Integer, vProvider As String) + + Function GetAutomaticIndexSQLValue(vsqlstatement As String, vconnectionID As Integer, vProvider As String) As String Try - Dim connectionString As String - connectionString = ClassFormFunctions.GetConnectionString(vconnectionID) - If connectionString <> "" Then + Dim oConnectionString As String + oConnectionString = ClassFormFunctions.GetConnectionString(vconnectionID) + If oConnectionString <> "" Then 'NEU - Dim ergebnis + Dim oErgebnis 'Welcher Provider? If vProvider.ToLower = "oracle" Then - ergebnis = ClassDatabase.OracleExecute_Scalar(vsqlstatement, connectionString) + oErgebnis = ClassDatabase.OracleExecute_Scalar(vsqlstatement, oConnectionString) Else 'im Moment nur SQL-Server - ergebnis = ClassDatabase.Execute_Scalar(vsqlstatement, connectionString) + oErgebnis = ClassDatabase.Execute_Scalar(vsqlstatement, oConnectionString) End If If LogErrorsOnly = False Then - ClassLogger.Add(" >>SQL-ConnectionString: " & connectionString.Substring(0, connectionString.LastIndexOf("=")), False) + ClassLogger.Add(" >>SQL-ConnectionString: " & oConnectionString.Substring(0, oConnectionString.LastIndexOf("=")), False) End If - If ergebnis Is Nothing Then + If oErgebnis Is Nothing Then 'showlblhinweis("Kein Ergebnis für automatisches SQL: " & vsqlstatement) Return "" Else - Return ergebnis + Return oErgebnis End If End If @@ -481,433 +257,7 @@ Public Class frmIndex Return "" End Try End Function - ' _ - Private Sub AddVorschlag_ComboBox(indexname As String, y As Integer, conid As Integer, sql_Vorschlag As String, Multiselect As Boolean, Optional Vorgabe As String = "", Optional AddNewValues As Boolean = False, Optional PreventDuplicateValues As Boolean = False) - 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 = ClassFormFunctions.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("Initial Catalog=") 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(indexname, y) - newCMB.Size = New Size(300, 27) - Else - Dim table As DataTable = NewDataset.Tables(0) - - 'If table.Rows.Count > 0 Then - ' Dim columnCount = 1 - - ' ' Alle bis auf die erste Spalte der Tabelle entfernen - ' While (table.Columns.Count > columnCount) - ' table.Columns.RemoveAt(columnCount) - ' End While - ' 'table.Columns.Item(0).ReadOnly = True - - ' If Multiselect Then - ' ' Neue Spalte für Selektion einfügen - ' Dim selectedColumn As New DataColumn() With { - ' .ColumnName = "SELECTED", - ' .DataType = GetType(Boolean), - ' .DefaultValue = False - ' } - ' table.Columns.Add(selectedColumn) - ' ' Spalte an erste Stelle verschieben - ' selectedColumn.SetOrdinal(0) - ' End If - - ' Const LOOKUP_NO_RECORDS As String = "Keine Datensätze ausgewählt" - ' Const LOOKUP_N_RECORDS As String = "{0} Datensätze ausgewählt" - ' Const LOOKUP_CONTROL_HEIGHT As Integer = 24 - - ' Dim lookupButton As New Button() - ' lookupButton.Name = "btnLookup" & indexname - ' lookupButton.Location = New Point(311, y - 1) - ' lookupButton.Size = New Size(LOOKUP_CONTROL_HEIGHT, LOOKUP_CONTROL_HEIGHT) - ' lookupButton.Image = My.Resources.gear_32xSM - - ' pnlIndex.Controls.Add(lookupButton) - - ' If Multiselect Then - ' Dim listbox As New ListBox() - ' Dim gridLookup As New DevExpress.XtraEditors.GridLookUpEdit() - - ' gridLookup.Name = "cmbMulti" & indexname - ' gridLookup.Font = New Font(gridLookup.Font.FontFamily, 10) - ' gridLookup.Location = New Point(11, y) - ' gridLookup.Size = New Size(300, LOOKUP_CONTROL_HEIGHT) - - ' ' TODO: Hier noch die Vorbelegung für Vektor Indexe einfügen - ' gridLookup.Properties.PopupFormSize = New Size(gridLookup.Properties.PopupFormSize.Width, 100) - ' gridLookup.Properties.NullText = LOOKUP_NO_RECORDS - ' If Vorgabe.Length > 0 Then - ' gridLookup.Properties.DataSource = New List(Of String) From {Vorgabe} - ' gridLookup.Properties.NullText = String.Format(LOOKUP_N_RECORDS, 1) - ' Else - ' gridLookup.Properties.DataSource = Nothing - ' gridLookup.Properties.NullText = LOOKUP_NO_RECORDS - ' End If - - - ' ' Da das gridLookup ein Readonly Control sein soll, - ' ' sich aber trotzdem öffnen lassen soll, müssen wir so das setzen eines neuen Werts verhindern - ' AddHandler gridLookup.EditValueChanging, Sub(sender As Object, e As ChangingEventArgs) - ' e.Cancel = True - ' End Sub - - ' With gridLookup.Properties.View - ' .OptionsBehavior.ReadOnly = True - ' .OptionsBehavior.Editable = False - ' .OptionsView.ShowColumnHeaders = False - ' End With - - ' AddHandler lookupButton.Click, Sub() - ' Dim frm As New frmLookupGrid() - ' frm.MultiSelect = True - ' frm.DataSource = table - ' frm.AddNewValues = AddNewValues - ' frm.PreventDuplicates = PreventDuplicateValues - ' frm.StartPosition = FormStartPosition.Manual - ' frm.SelectedValues = gridLookup.Properties.DataSource - ' frm.Location = pnlIndex.PointToScreen(New Point(340, y)) - - ' Dim result = frm.ShowDialog() - - ' If result = DialogResult.OK Then - ' Dim values As List(Of String) = frm.SelectedValues - ' gridLookup.Properties.DataSource = values - ' gridLookup.Properties.NullText = IIf(values.Count = 0, LOOKUP_NO_RECORDS, String.Format(LOOKUP_N_RECORDS, values.Count)) - ' End If - ' End Sub - - ' pnlIndex.Controls.Add(gridLookup) - ' Else - ' Dim textBox As New TextBox() - - ' textBox.Name = "cmbSingle" & indexname - ' textBox.Font = New Font(textBox.Font.FontFamily, 9) - ' textBox.Location = New Point(11, y) - ' textBox.Size = New Size(300, LOOKUP_CONTROL_HEIGHT) - ' textBox.ReadOnly = True - ' textBox.Text = Vorgabe - - ' AddHandler lookupButton.Click, Sub() - ' Dim frm As New frmLookupGrid() - ' frm.FormBorderStyle = FormBorderStyle.SizableToolWindow - ' frm.MultiSelect = False - ' frm.DataSource = table - ' frm.AddNewValues = AddNewValues - ' frm.StartPosition = FormStartPosition.Manual - ' frm.SelectedValues = New List(Of String) From {textBox.Text} - ' frm.Location = pnlIndex.PointToScreen(New Point(340, y)) - - ' Dim result = frm.ShowDialog() - - ' If result = DialogResult.OK Then - ' Dim value = frm.SelectedValues.FirstOrDefault() - ' textBox.Text = value - ' End If - ' End Sub - - ' pnlIndex.Controls.Add(textBox) - ' End If - - ' ' Für ergebnisse die kleiner/gleich MAX_COMBOBOX_ITEMS sind - ' ' die normale ComboBox verwenden - ' ' 'Die Standardcombobox anlegen - ' ' newCMB = addCombobox(indexname, y) - ' ' newCMB.DataSource = table - ' ' newCMB.DisplayMember = table.Columns(0).ColumnName - ' ' 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 - - Dim oControl As New DigitalData.Controls.LookupGrid.LookupControl2 With { - .DataSource = table, - .MultiSelect = Multiselect, - .AllowAddNewValues = AddNewValues, - .PreventDuplicates = PreventDuplicateValues, - .Location = New Point(11, y), - .Size = New Size(300, 27), - .Name = "cmbMulti" & indexname - } - - pnlIndex.Controls.Add(oControl) - - If connectionString.Contains("Initial Catalog=") 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 - Private Sub AddAutoSuggest_Textbox(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 = ClassFormFunctions.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("Initial Catalog=") 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 newASTextbox As TextBox - If runinLZ = True Then - 'Die Standardcombobox anlegen - newASTextbox = AddTextBox(indexname, y, "") - newASTextbox.Size = New Size(300, 27) - Else - If NewDataset.Tables(0).Rows.Count > 0 Then - 'Die Standardcombobox anlegen - newASTextbox = AddTextBox(indexname, y, "") - 'Die Standargrösse definieren - Dim newWidth As Integer = 300 - 'LOOPING THE ROW OF DATA IN THE DATATABLE - For Each r In NewDataset.Tables(0).Rows - 'ADDING THE DATA IN THE AUTO COMPLETE SOURCE OF THE TEXTBOX - newASTextbox.AutoCompleteCustomSource.Add(r.Item(0).ToString) - Next - With newASTextbox - .AutoCompleteMode = AutoCompleteMode.Suggest - .AutoCompleteSource = AutoCompleteSource.CustomSource - End With - Else - - End If - If connectionString.Contains("Initial Catalog=") 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 AddAutoSuggest_Textbox - Indexname: " & indexname & " - Fehler: " & vbNewLine & ex.Message) - MsgBox(ex.Message, MsgBoxStyle.Critical, "Unvorhergesehener Unexpected error in AddAutoSuggest_Textbox:") - 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 TBDD_INDEX_MAN WHERE GUID = " & INDEX_GUID, True) - If IsNothing(DT_INDEX) Then - Exit Sub - End If - - Dim conid = DT_INDEX.Rows(0).Item("CONNECTION_ID") - Dim sql_result = DT_INDEX.Rows(0).Item("SQL_RESULT") - Dim 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.pnlIndex.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 = ClassFormFunctions.GetConnectionString(conid) - If connectionString Is Nothing = False Then - 'SQL Befehl füllt die Auswahlliste - - If connectionString.Contains("Initial Catalog=") 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("Initial Catalog=") 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 '#End Region '#Region "+++++ Funktionen bei OK - schliessen ++++++" Function CheckWrite_IndexeMan(dokartid As Integer) @@ -915,10 +265,10 @@ Public Class frmIndex Try If LogErrorsOnly = False Then ClassLogger.Add(" >> In CheckWrite_IndexeMan", False) Dim result As Boolean = False - For Each ctrl As Control In Me.pnlIndex.Controls + For Each oControl As Control In Me.pnlIndex.Controls ' MsgBox(ctrl.Name) - If ctrl.Name.StartsWith("txt") Then - Dim box As TextBox = ctrl + If oControl.Name.StartsWith("txt") Then + Dim box As TextBox = oControl If box.Text = "" Then Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(box.Name, "txt", "") & "'", MyConnectionString, True) If optional_index = False Then @@ -942,8 +292,8 @@ Public Class frmIndex End If End If - If ctrl.Name.StartsWith("cmbMulti") Then - Dim oLookup = DirectCast(ctrl, DigitalData.Controls.LookupGrid.LookupControl2) + If oControl.Name.StartsWith("cmbMulti") Then + Dim oLookup = DirectCast(oControl, DigitalData.Controls.LookupGrid.LookupControl2) Dim values As List(Of String) = oLookup.SelectedValues If values.Count = 0 Then @@ -962,8 +312,8 @@ Public Class frmIndex Indexwert_Postprocessing(Replace(oLookup.Name, "cmbMulti", ""), vectorValue) result = True End If - ElseIf ctrl.Name.StartsWith("cmbSingle") Then - Dim cmbSingle As TextBox = ctrl + ElseIf oControl.Name.StartsWith("cmbSingle") Then + Dim cmbSingle As TextBox = oControl If cmbSingle.Text = "" Then Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(cmbSingle.Name, "cmbSingle", "") & "'", MyConnectionString, True) @@ -980,8 +330,8 @@ Public Class frmIndex Indexwert_Postprocessing(Replace(cmbSingle.Name, "cmbSingle", ""), cmbSingle.Text) result = True End If - ElseIf ctrl.Name.StartsWith("cmb") Then - Dim cmb As ComboBox = ctrl + ElseIf oControl.Name.StartsWith("cmb") Then + Dim cmb As ComboBox = oControl If cmb.Text = "" Then Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(cmb.Name, "cmb", "") & "'", MyConnectionString, True) If optional_index = False Then @@ -997,20 +347,20 @@ Public Class frmIndex result = True End If End If - If ctrl.Name.StartsWith("dtp") Then - Dim dtp As DateTimePicker = ctrl + If oControl.Name.StartsWith("dtp") Then + Dim dtp As DateTimePicker = oControl Indexwert_Postprocessing(Replace(dtp.Name, "dtp", ""), dtp.Text) result = True End If - If ctrl.Name.StartsWith("chk") Then - Dim chk As CheckBox = ctrl + If oControl.Name.StartsWith("chk") Then + Dim chk As CheckBox = oControl Indexwert_Postprocessing(Replace(chk.Name, "chk", ""), chk.Checked) result = True End If - If TypeOf (ctrl) Is Button Then + If TypeOf (oControl) Is Button Then Continue For End If - If ctrl.Name.StartsWith("lbl") = False And result = False Then + If oControl.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 @@ -1853,7 +1203,7 @@ Public Class frmIndex Do While File.Exists(neuername) version = version + 1 neuername = Stammname.Replace(extension, "") & _versionTz & version & extension - CURRENT_NEWFILENAME = neuername + CURRENT_NEWFILENAME = neuername Loop End If 'Die Datei wird nun verschoben @@ -2019,13 +1369,6 @@ Public Class frmIndex End Try End Sub - Private Sub frmIndex_LocationChanged(sender As Object, e As EventArgs) Handles Me.LocationChanged - - End Sub - - Private Sub frmIndex_LostFocus(sender As Object, e As EventArgs) Handles Me.LostFocus - - End Sub Private Sub frmIndex_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown 'Me.TopMost = True Me.BringToFront() @@ -2036,7 +1379,7 @@ Public Class frmIndex chkdelete_origin.Checked = CONFIG.Config.DeleteOriginalFile CURR_DELETE_ORIGIN = chkdelete_origin.Checked - formloaded = True + FormLoaded = True If My.Settings.DA_Vorauswahlaktiv = True Then If CURRENT_LASTDOKART <> "" Then cmbDokumentart.SelectedIndex = cmbDokumentart.FindStringExact(CURRENT_LASTDOKART) @@ -2077,7 +1420,7 @@ Public Class frmIndex End Try End Sub Private Sub cmbDokumentart_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbDokumentart.SelectedIndexChanged - If cmbDokumentart.SelectedIndex <> -1 And formloaded = True Then + If cmbDokumentart.SelectedIndex <> -1 And FormLoaded = True Then If cmbDokumentart.SelectedValue.GetType.ToString = "System.Int32" Then CURRENT_DOKART_ID = cmbDokumentart.SelectedValue lblhinweis.Visible = False @@ -2131,6 +1474,8 @@ Public Class frmIndex Dim anz As Integer = 1 Dim ylbl As Integer = 11 Dim y As Integer = 33 + Dim oControls As New ClassControls(pnlIndex, Me) + If DT_INDEXEMAN.Rows.Count = 0 Then ShowError("Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & cmbDokumentart.Text & " definiert") ClassLogger.Add(" - Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & cmbDokumentart.Text & " definiert") @@ -2151,31 +1496,41 @@ Public Class frmIndex End If Select Case type Case "BOOLEAN" - 'nur eine Textbox - Dim chk As CheckBox = ClassControls.AddCheckBox(DR.Item("NAME"), y, DefaultValue, DR.Item("COMMENT").ToString) + Dim chk As CheckBox = oControls.AddCheckBox(DR.Item("NAME"), y, DefaultValue, DR.Item("COMMENT").ToString) If Not IsNothing(chk) Then pnlIndex.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("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), MultiSelect, DefaultValue, AddNewItems, PreventDuplicates) - 'AddAutoSuggest_Textbox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), DefaultValue) + Dim oControl = oControls.AddVorschlag_ComboBox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), MultiSelect, DefaultValue, AddNewItems, PreventDuplicates) + If Not IsNothing(oControl) Then + pnlIndex.Controls.Add(oControl) + End If Else 'nur eine Textbox - AddTextBox(DR.Item("NAME"), y, DefaultValue) + Dim oControl = oControls.AddTextBox(DR.Item("NAME"), y, DefaultValue) + If Not IsNothing(oControl) Then + pnlIndex.Controls.Add(oControl) + End If End If Case "VARCHAR" If DR.Item("SUGGESTION") = True And DR.Item("SQL_RESULT").ToString.Length > 0 Then - AddVorschlag_ComboBox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), MultiSelect, DefaultValue, AddNewItems, PreventDuplicates) - 'AddAutoSuggest_Textbox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), DefaultValue) + Dim oControl = oControls.AddVorschlag_ComboBox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), MultiSelect, DefaultValue, AddNewItems, PreventDuplicates) + If Not IsNothing(oControl) Then + pnlIndex.Controls.Add(oControl) + End If Else If DR.Item("NAME").ToString.ToLower = "dateiname" Then - 'Übergibt den Dateinamen um diesen Vorzuschlagen - AddTextBox(DR.Item("NAME"), y, System.IO.Path.GetFileNameWithoutExtension(CURRENT_WORKFILE)) + Dim oControl = oControls.AddTextBox(DR.Item("NAME"), y, System.IO.Path.GetFileNameWithoutExtension(CURRENT_WORKFILE)) + If Not IsNothing(oControl) Then + pnlIndex.Controls.Add(oControl) + End If Else Dim VORBELGUNG As String = DefaultValue - 'nur eine Textbox - AddTextBox(DR.Item("NAME"), y, VORBELGUNG) + Dim oControl = oControls.AddTextBox(DR.Item("NAME"), y, VORBELGUNG) + If Not IsNothing(oControl) Then + pnlIndex.Controls.Add(oControl) + End If End If End If Case "DATE" @@ -2187,7 +1542,7 @@ Public Class frmIndex MsgBox("Please check Datatype of Indexvalue!", MsgBoxStyle.Critical, "Warning:") End If - ClassLogger.Add(" - Datentyp nicht hinterlegt - LoadIndexe_Man") + LOGGER.Warn(" - Datentyp nicht hinterlegt - LoadIndexe_Man") End Select anz += 1 @@ -2206,14 +1561,9 @@ Public Class frmIndex SendKeys.Send("{TAB}") Catch ex As Exception - ClassLogger.Add(" - Unexpected error in LoadIndexe_Man - Fehler: " & vbNewLine & ex.Message) + LOGGER.Error(ex) MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in LoadIndexe_Man:") End Try - - End Sub - - Sub AddComboBoxValue(cmbName As ComboBox, Value As String) - cmbName.Items.Add(Value) End Sub Function GetPlaceholderValue(InputValue As String, FileName As String, UserShortName As String) @@ -2261,8 +1611,6 @@ Public Class frmIndex Function FillIndexe_Autom(dokart_id As Integer) Try - - VWINDEX_AUTOMTableAdapter.Fill(MyDataset.VWDDINDEX_AUTOM, CURRENT_DOKART_ID) Dim oDatatable = MyDataset.VWDDINDEX_AUTOM @@ -2993,7 +2341,7 @@ Public Class frmIndex End Sub Private Sub chkdelete_origin_CheckedChanged(sender As Object, e As EventArgs) Handles chkdelete_origin.CheckedChanged - If formloaded = True Then + If FormLoaded = True Then CURR_DELETE_ORIGIN = chkdelete_origin.Checked CONFIG.Config.DeleteOriginalFile = chkdelete_origin.Checked CONFIG.Save()