95 lines
3.9 KiB
VB.net
95 lines
3.9 KiB
VB.net
Imports System.Text.RegularExpressions
|
|
|
|
Public Class frmDIRegex
|
|
Private Sub TBTC_DI_REGEX_MATCHBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
|
|
Me.Validate()
|
|
Me.TBTC_DI_REGEX_MATCHBindingSource.EndEdit()
|
|
Me.TableAdapterManager.UpdateAll(Me.MyDataset)
|
|
|
|
End Sub
|
|
Sub LoadData()
|
|
Try
|
|
TBTC_DI_REGEX_MATCHTableAdapter.Connection.ConnectionString = My.Settings.DDECMConString
|
|
Me.TBTC_DI_REGEX_MATCHTableAdapter.Fill(Me.MyDataset.TBTC_DI_REGEX_MATCH, CURRENT_PROFILENAME)
|
|
If Me.MyDataset.TBTC_DI_REGEX_MATCH.Rows.Count = 1 Then
|
|
tsbtnAdd.Enabled = False
|
|
tsbtnSave.Enabled = True
|
|
tsbtnDelete.Enabled = True
|
|
REGEXTextBox.Enabled = True
|
|
PROFILE_NAMETextBox.Enabled = True
|
|
Button1.Enabled = True
|
|
|
|
Else
|
|
tsbtnAdd.Enabled = True
|
|
tsbtnSave.Enabled = False
|
|
tsbtnDelete.Enabled = False
|
|
REGEXTextBox.Enabled = False
|
|
PROFILE_NAMETextBox.Enabled = False
|
|
Button1.Enabled = False
|
|
|
|
End If
|
|
Catch ex As System.Exception
|
|
|
|
MsgBox("Unexpected error in Loading Regex Fileimport: " & vbNewLine & ex.Message & vbNewLine & "ConnectionString: " & My.Settings.DDECMConString, MsgBoxStyle.Critical)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub tsbtnSave_Click(sender As Object, e As EventArgs) Handles tsbtnSave.Click
|
|
Try
|
|
Me.TBTC_DI_REGEX_MATCHBindingSource.EndEdit()
|
|
Me.MyDataset.TBTC_DI_REGEX_MATCH.CHANGED_WHOColumn.DefaultValue = Environment.UserName
|
|
If Not IsNothing(MyDataset.TBTC_DI_REGEX_MATCH.GetChanges) Then
|
|
Me.CHANGED_WHOTextBox.Text = Environment.UserName
|
|
Me.TBTC_DI_REGEX_MATCHBindingSource.EndEdit()
|
|
TBTC_DI_REGEX_MATCHTableAdapter.Update(MyDataset.TBTC_DI_REGEX_MATCH)
|
|
LoadData()
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
MsgBox("Unexpected error in Saving Regex Fileimport: " & ex.Message, MsgBoxStyle.Critical)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub frmDIRegex_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
LoadData()
|
|
End Sub
|
|
|
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
|
My.Settings.Save()
|
|
|
|
Try
|
|
If Regex.IsMatch(txtFilenameTest.Text, REGEXTextBox.Text) Then
|
|
MsgBox("The RegEx resulted in a proper match!", MsgBoxStyle.Information, "Perfect:")
|
|
Else
|
|
MsgBox("No Match- There might be an error in the RegEx!", MsgBoxStyle.Information, "Something wrong:")
|
|
End If
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error in Testing Regex: ")
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub tsbtnAdd_Click(sender As Object, e As EventArgs) Handles tsbtnAdd.Click
|
|
Try
|
|
Me.MyDataset.TBTC_DI_REGEX_MATCH.CREATED_WHOColumn.DefaultValue = Environment.UserName
|
|
Me.MyDataset.TBTC_DI_REGEX_MATCH.PROFILE_NAMEColumn.DefaultValue = CURRENT_PROFILENAME
|
|
TBTC_DI_REGEX_MATCHBindingSource.AddNew()
|
|
tsbtnDelete.Enabled = True
|
|
REGEXTextBox.Enabled = True
|
|
PROFILE_NAMETextBox.Enabled = True
|
|
Button1.Enabled = True
|
|
tsbtnSave.Enabled = True
|
|
Catch ex As Exception
|
|
MsgBox("Unexpected error in tsbtnAdd.Click: " & ex.Message, MsgBoxStyle.Critical)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub tsbtnDelete_Click(sender As Object, e As EventArgs) Handles tsbtnDelete.Click
|
|
Try
|
|
TBTC_DI_REGEX_MATCHTableAdapter.DeleteQuery(PROFILE_NAMETextBox.Text)
|
|
LoadData()
|
|
Catch ex As Exception
|
|
MsgBox("Unexpected error in deletingRegex: " & ex.Message, MsgBoxStyle.Critical)
|
|
End Try
|
|
|
|
End Sub
|
|
End Class |