Modules/GUIs.ZooFlow/Administration/frmAdmin_Globix.vb

340 lines
15 KiB
VB.net

Imports DevExpress.XtraLayout
Imports DigitalData.Modules.Logging
Public Class frmAdmin_Globix
Implements IAdminForm
Public Property HasChanges As Boolean = False Implements IAdminForm.HasChanges
Public Property IsInsert As Boolean = False Implements IAdminForm.IsInsert
Public Property PrimaryKey As Integer Implements IAdminForm.PrimaryKey
Private Pages As ClassDetailPages
Public Sub New(PrimaryKey As Integer, Optional IsInsert As Boolean = False)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
Me.PrimaryKey = PrimaryKey
Me.IsInsert = IsInsert
End Sub
Private Sub frmAdmin_Globix_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: Diese Codezeile lädt Daten in die Tabelle "DSIDB_Stammdaten.VWIDB_OBJECT_STORE". Sie können sie bei Bedarf verschieben oder entfernen.
InitializeBaseForm(My.LogConfig)
Try
TBDD_DOKUMENTARTTableAdapter.Connection.ConnectionString = My.DatabaseECM.CurrentSQLConnectionString
TBDD_DOKUMENTARTTableAdapter.Fill(Me.GlobixDataset.TBDD_DOKUMENTART, PrimaryKey)
TBDD_INDEX_MANTableAdapter.Connection.ConnectionString = My.DatabaseECM.CurrentSQLConnectionString
Me.VWIDB_OBJECT_STORETableAdapter.Connection.ConnectionString = My.DatabaseIDB.CurrentSQLConnectionString
Me.VWIDB_OBJECT_STORETableAdapter.Fill(Me.DSIDB_Stammdaten.VWIDB_OBJECT_STORE)
Me.VWIDB_BE_ATTRIBUTETableAdapter.Connection.ConnectionString = My.DatabaseIDB.CurrentSQLConnectionString
Me.VWIDB_BE_ATTRIBUTETableAdapter.Fill(Me.DSIDB_Stammdaten.VWIDB_BE_ATTRIBUTE, My.Application.User.Language)
Load_TabData()
' Add Focus Handler to all controls in all LayoutControls
Dim oLayoutControls = New List(Of LayoutControl) From {LayoutControlProfile, LayoutControlManIndexe, LayoutControlAutoIndexe, LayoutControlRework}
Pages = New ClassDetailPages(My.LogConfig, Me, oLayoutControls)
Pages.AddRange({
New ClassDetailPages.PrimaryPage(IsInsert) With {
.Name = "Profile Globix",
.TabPage = XtraTabPageProfile,
.BindingSource = TBDD_DOKUMENTARTBindingSource,
.DataTable = GlobixDataset.TBDD_DOKUMENTART,
.AddedWhoEdit = TextEditErstelltWer,
.ChangedWhoEdit = TextEditGeandertWer
},
New ClassDetailPages.DetailPage With {
.Name = "Manual Attributes",
.TabPage = XtraTabPageManIndexe,
.BindingSource = TBDD_INDEX_MANBindingSource,
.DataTable = GlobixDataset.TBDD_INDEX_MAN,
.AddedWhoEdit = TextEditAddedWho_ManIndex,
.ChangedWhoEdit = TextEditChangedWho_ManIndex
},
New ClassDetailPages.DetailPage With {
.Name = "Auto Attributes",
.TabPage = XtraTabPageAutoIndexe,
.BindingSource = TBDD_INDEX_AUTOMBindingSource,
.DataTable = GlobixDataset.TBDD_INDEX_AUTOM,
.AddedWhoEdit = ADDED_WHOTextBoxAutoAttribut,
.ChangedWhoEdit = CHANGED_WHOTextEditAutoAttribut
}
})
Pages.PrepareLoad()
AddHandler Pages.CurrentPage_Changed, AddressOf CurrentPage_Changed
If IsInsert Then
TextEditErstelltWer.EditValue = My.Application.User.UserName
Else
TextEditChangedWho_ManIndex.EditValue = My.Application.User.UserName
End If
Catch ex As Exception
ShowErrorMessage(ex)
End Try
End Sub
Sub Load_TabData()
Load_INDEXMAN()
End Sub
Private Sub Load_INDEXMAN()
Try
Me.TBDD_INDEX_MANTableAdapter.Fill(Me.GlobixDataset.TBDD_INDEX_MAN, PrimaryKey)
Catch ex As System.Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error in Load IndexeManuell: ")
End Try
End Sub
Private Sub CurrentPage_Changed(sender As Object, e As ClassDetailPages.DetailPageEventArgs)
If Not IsNothing(e.Page) Then
If e.Page.IsPrimary = True Then
BarButtonNew.Enabled = False
Else
BarButtonNew.Enabled = True
End If
RibbonPageGroup1.Text = e.Page.Name
End If
End Sub
Private Sub ResetMessages()
labelStatus.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
End Sub
Private Sub ShowStatus(Message As String)
labelStatus.Caption = Message
labelStatus.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
End Sub
Public Function DeleteData() As Boolean Implements IAdminForm.DeleteData
Throw New NotImplementedException()
End Function
Private Sub SimpleButton2_Click(sender As Object, e As EventArgs)
End Sub
Private Sub XtraTabControl1_Click(sender As Object, e As EventArgs) Handles XtraTabControl1.Click
End Sub
Private Sub BarButtonSave_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonSave.ItemClick
ResetMessages()
' If Pages.PrepareSave() = True Then
Try
Dim oPage = Pages.Current
Select Case oPage.TabPage.Name
Case XtraTabPageProfile.Name
If IsInsert Then
Insert_Doctype()
Else
Update_Doctype()
End If
Case XtraTabPageManIndexe.Name
Try
Save_manIndexe(oPage)
Load_INDEXMAN()
Catch ex As Exception
End Try
Case XtraTabPageAutoIndexe.Name
Save_AutoIndexe(oPage)
Load_Attribute_Auto()
End Select
oPage.IsInsert = False
ShowStatus($"{oPage.Name} saved!")
Catch ex As Exception
ShowErrorMessage(ex)
End Try
'Else
' ShowStatus("Keine Änderungen!")
'End If
End Sub
Private Function Save_manIndexe(oPage As ClassDetailPages.DetailPage) As Boolean
Try
TBDD_INDEX_MANBindingSource.EndEdit()
If GlobixDataset.TBDD_INDEX_MAN.GetChanges() IsNot Nothing Then
If Pages.Current.IsInsert Then
TextEditAddedWho_ManIndex.Text = My.Application.User.UserName
Else
TextEditChangedWho_ManIndex.Text = My.Application.User.UserName
End If
TBDD_INDEX_MANBindingSource.EndEdit()
TBDD_INDEX_MANTableAdapter.Update(Pages.Current.DataTable)
End If
Return True
Catch ex As Exception
Return False
End Try
End Function
Private Function Save_AutoIndexe(oPage As ClassDetailPages.DetailPage) As Boolean
Try
TBDD_INDEX_AUTOMBindingSource.EndEdit()
If GlobixDataset.TBDD_INDEX_AUTOM.GetChanges() IsNot Nothing Then
If Pages.Current.IsInsert Then
TextEditAddedWho_ManIndex.Text = My.Application.User.UserName
Else
TextEditChangedWho_ManIndex.Text = My.Application.User.UserName
End If
TBDD_INDEX_AUTOMBindingSource.EndEdit()
TBDD_INDEX_AUTOMTableAdapter.Update(Pages.Current.DataTable)
End If
Return True
Catch ex As Exception
Return False
End Try
End Function
Private Function Insert_Doctype() As Boolean
Try
Dim oIns = $"INSERT INTO [TBDD_DOKUMENTART] ([BEZEICHNUNG] ,[OBJEKTTYP] ,[EINGANGSART_ID] ,[KURZNAME] ,[ZIEL_PFAD] ,[BESCHREIBUNG]
,[WINDREAM_DIRECT] ,[FOLDER_FOR_INDEX] ,[DUPLICATE_HANDLING],[AKTIV],[LANGUAGE],
[SEQUENCE],[NAMENKONVENTION],[ERSTELLTWER],IDB_OBJECT_STORE_ID) VALUES
('{TextEditBezeichnung.Text}','IDB_DRIVEN',1,'{TextEditKurzname.Text}','IDB_STORE','{TextEditBeschreibung.Text}'
,'False','','{ComboBoxEditDupl_handling.EditValue}' ,'{AKTIVCheckBox.Checked}','{My.Application.User.Language}'
, {SEQUENCENumericUpDown.Value},'{TextEditNamenkonvention.Text}','{My.Application.User.UserName}',{IDB_OBJECT_STORE_IDComboBox.SelectedValue})"
If My.DatabaseECM.ExecuteNonQuery(oIns) = True Then
Dim oSQL = $"SELECT GUID FROM TBDD_DOKUMENTART WHERE BEZEICHNUNG = '{TextEditBezeichnung.Text}'"
PrimaryKey = My.DatabaseECM.GetScalarValue(oSQL)
oSQL = $"INSERT INTO TBDD_DOKUMENTART_MODULE (DOKART_ID,MODULE_ID) VALUES ({PrimaryKey},(SELECT GUID FROM TBDD_MODULES WHERE SHORT_NAME = 'GLOBIX'))"
My.DatabaseECM.ExecuteNonQuery(oIns)
IsInsert = False
TBDD_DOKUMENTARTTableAdapter.Fill(Me.GlobixDataset.TBDD_DOKUMENTART, PrimaryKey)
Return True
Else
Return False
End If
Catch ex As Exception
ShowErrorMessage(ex)
Return False
End Try
End Function
Private Function Update_Doctype() As Boolean
Try
Dim oUpd = $"UPDATE TBDD_DOKUMENTART SET [BEZEICHNUNG] = '{TextEditBezeichnung.Text}' ,[KURZNAME] = '{TextEditKurzname.Text}' ,[BESCHREIBUNG] = '{TextEditBeschreibung.Text}'
,[DUPLICATE_HANDLING] = '{ComboBoxEditDupl_handling.EditValue}',[AKTIV] = '{AKTIVCheckBox.Checked}',[SEQUENCE] = {SEQUENCENumericUpDown.Value}
,[NAMENKONVENTION] = '{TextEditNamenkonvention.Text}',[GEANDERTWER] = '{My.Application.User.UserName}',IDB_OBJECT_STORE_ID = {IDB_OBJECT_STORE_IDComboBox.SelectedValue} WHERE GUID = {TextEditDoctypeID.Text}"
Return My.DatabaseECM.ExecuteNonQuery(oUpd)
Catch ex As Exception
ShowErrorMessage(ex)
Return False
End Try
End Function
Private Sub BarButtonNew_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonNew.ItemClick
Pages.Current.IsInsert = True
AddData()
End Sub
Public Function AddData() As Boolean
Dim oPage = Pages.Current
If Pages.Current Is Nothing Then
Return False
End If
If oPage.IsPrimary = False Then
Select Case oPage.TabPage.Name
Case XtraTabPageAutoIndexe.Name
oPage.DataTable.Columns.Item("DOCTYPE_ID").DefaultValue = PrimaryKey
Case Else
oPage.DataTable.Columns.Item("DOK_ID").DefaultValue = PrimaryKey
End Select
oPage.DataTable.Columns.Item("ADDED_WHO").DefaultValue = My.Application.User.UserName
End If
Select Case oPage.TabPage.Name
Case XtraTabPageProfile.Name
Case XtraTabPageManIndexe.Name
TextEditAddedWho_ManIndex.Text = My.Application.User.UserName
Case XtraTabPageAutoIndexe.Name
ADDED_WHOTextBoxAutoAttribut.Text = My.Application.User.UserName
End Select
Dim oNewRecord As DataRowView = oPage.BindingSource.AddNew()
Return True
End Function
Private Sub btneditSQLmanIndex_Click(sender As Object, e As EventArgs) Handles btneditSQLmanIndex.Click
If Save_manIndexe(Pages.Current) = True Then
Dim oSQLbefore = SQL_RESULTTextBox.Text
Dim oForm As New frmSQLDesigner() With {.SQLCommand = SQL_RESULTTextBox.Text, .DesignType = "GI_ATTRIBUTE_MAN", .ConnectionID = CONNECTION_IDTextBox.Text}
Dim oResult = oForm.ShowDialog()
If oSQLbefore <> oForm.SQLCommand Then
CONNECTION_IDTextBox.Text = oForm.ConnectionID
SQL_RESULTTextBox.Text = oForm.SQLCommand
'TBDD_INDEX_MANTableAdapter.Adapter.UpdateCommand.Parameters("@SQL_RESULT").Value = oForm.SQLCommand
'TBDD_INDEX_MANTableAdapter.Adapter.UpdateCommand.Parameters("@CONNECTION_ID").Value = oForm.ConnectionID
TextEditChangedWho_ManIndex.Text = My.Application.User.UserName
End If
End If
End Sub
Private Sub SimpleButtonNameconvention_Click(sender As Object, e As EventArgs) Handles SimpleButtonNameconvention.Click
Dim oForm As New frmGlobixNameconvention() With {.Nameconvention = TextEditNamenkonvention.Text, .DoctypeID = TextEditDoctypeID.Text}
Dim oResult = oForm.ShowDialog()
TextEditNamenkonvention.Text = oForm.Nameconvention
End Sub
Private Sub Load_Attribute_Auto()
Try
Me.TBDD_INDEX_AUTOMTableAdapter.Fill(Me.GlobixDataset.TBDD_INDEX_AUTOM, TextEditDoctypeID.Text)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub XtraTabControl2_SelectedPageChanged(sender As Object, e As DevExpress.XtraTab.TabPageChangedEventArgs) Handles XtraTabControl2.SelectedPageChanged
Dim oPage = Pages.GetDetailPage(e.Page)
If oPage IsNot Nothing Then
Pages.Current = oPage
End If
Select Case oPage.TabPage.Name
Case XtraTabPageAutoIndexe.Name
Load_Attribute_Auto()
Case XtraTabPageManIndexe.Name
Load_INDEXMAN()
End Select
End Sub
Private Sub SimpleButton2_Click_1(sender As Object, e As EventArgs) Handles SimpleButton2.Click
If Save_AutoIndexe(Pages.Current) = True Then
Dim oSQLbefore = SQL_RESULTTextBox1.Text
Dim oForm As New frmSQLDesigner() With {
.SQLCommand = oSQLbefore, .DesignType = "GI_ATTRIBUTE_AUTO",
.ConnectionID = CONNECTION_IDTextBox1.Text,
.AutoAttributID = GUID_AUTOATTRIBUTETextBox.Text
}
Dim oResult = oForm.ShowDialog()
If oSQLbefore <> oForm.SQLCommand Then
CONNECTION_IDTextBox1.Text = oForm.ConnectionID
SQL_RESULTTextBox1.Text = oForm.SQLCommand
'TBDD_INDEX_MANTableAdapter.Adapter.UpdateCommand.Parameters("@SQL_RESULT").Value = oForm.SQLCommand
'TBDD_INDEX_MANTableAdapter.Adapter.UpdateCommand.Parameters("@CONNECTION_ID").Value = oForm.ConnectionID
CHANGED_WHOTextEditAutoAttribut.Text = My.Application.User.UserName
End If
End If
End Sub
End Class