Zooflow: Reorganize administration, prepare for user admin section
This commit is contained in:
132
GUIs.ZooFlow/Administration/IDB/frmAdmin_IDBAttribute.vb
Normal file
132
GUIs.ZooFlow/Administration/IDB/frmAdmin_IDBAttribute.vb
Normal file
@@ -0,0 +1,132 @@
|
||||
Public Class frmAdmin_IDBAttribute
|
||||
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
|
||||
|
||||
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.
|
||||
InitializeBaseForm(My.LogConfig)
|
||||
Me.PrimaryKey = PrimaryKey
|
||||
Me.IsInsert = IsInsert
|
||||
End Sub
|
||||
|
||||
Private Sub frmAdmin_Attribute_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
Try
|
||||
TBWH_ATTRIBUTE_TYPETableAdapter.Connection.ConnectionString = My.DatabaseIDB.CurrentSQLConnectionString
|
||||
TBWH_ATTRIBUTE_TYPETableAdapter.Fill(DSIDB_Stammdaten.TBWH_ATTRIBUTE_TYPE)
|
||||
VWIDB_BE_ATTRIBUTETableAdapter.Connection.ConnectionString = My.DatabaseIDB.CurrentSQLConnectionString
|
||||
FillAttribute()
|
||||
|
||||
If IsInsert Then
|
||||
VWIDB_BE_ATTRIBUTEBindingSource.AddNew()
|
||||
DSIDB_Stammdaten.VWIDB_BE_ATTRIBUTE.ADDED_WHOColumn.DefaultValue = My.Application.User.UserName
|
||||
End If
|
||||
Catch ex As Exception
|
||||
ShowErrorMessage(ex)
|
||||
End Try
|
||||
End Sub
|
||||
Private Sub FillAttribute()
|
||||
VWIDB_BE_ATTRIBUTETableAdapter.FillByAttributeId(DSIDB_Stammdaten.VWIDB_BE_ATTRIBUTE, PrimaryKey, 1)
|
||||
End Sub
|
||||
Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
|
||||
ResetMessages()
|
||||
If SaveData() And HasChanges Then
|
||||
ShowStatus("Attribute saved!")
|
||||
FillAttribute()
|
||||
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
|
||||
|
||||
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
|
||||
ResetMessages()
|
||||
|
||||
If SaveData() Then
|
||||
Close()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Function SaveData() As Boolean
|
||||
Try
|
||||
VWIDB_BE_ATTRIBUTEBindingSource.EndEdit()
|
||||
|
||||
If DSIDB_Stammdaten.VWIDB_BE_ATTRIBUTE.GetChanges() IsNot Nothing Or IsInsert Then
|
||||
HasChanges = True
|
||||
|
||||
If IsInsert Then
|
||||
txtAddedWho.EditValue = My.Application.User.UserName
|
||||
Else
|
||||
txtChangedWho.EditValue = My.Application.User.UserName
|
||||
End If
|
||||
|
||||
VWIDB_BE_ATTRIBUTEBindingSource.EndEdit()
|
||||
|
||||
' TODO: Update Database
|
||||
If Not IsInsert Then
|
||||
Dim oUpdate As String = $"UPDATE TBIDB_ATTRIBUTE " &
|
||||
$"SET TITLE = '{TextEdit2.Text}', TYP_ID = {ComboBoxEdit1.EditValue}, VIEW_SEQUENCE = {SpinEdit1.Value}, VIEW_VISIBLE = '{CheckEdit2.Checked}'" &
|
||||
$",MULTI_CONTEXT = '{CheckEditMulticontext.Checked}', COMMENT = '{TextEdit3.Text}', CHANGED_WHO = '{My.Application.User.UserName}' " &
|
||||
$"WHERE (GUID = {TextEdit1.Text})"
|
||||
|
||||
If My.DatabaseIDB.ExecuteNonQuery(oUpdate) = False Then
|
||||
Return False
|
||||
End If
|
||||
Else
|
||||
Dim oInsert As String = $"INSERT INTO TBIDB_ATTRIBUTE " &
|
||||
"(TITLE, TYP_ID, VIEW_SEQUENCE, VIEW_VISIBLE, ADDED_WHO,COMMENT,MULTI_CONTEXT) " &
|
||||
$"VALUES ('{TextEdit2.Text}',{ComboBoxEdit1.EditValue},{SpinEdit1.Value},'{CheckEdit2.Checked}','{My.Application.User.UserName}', '{TextEdit3.Text}','{CheckEditMulticontext.Checked}')"
|
||||
|
||||
If My.DatabaseIDB.ExecuteNonQuery(oInsert) = True Then
|
||||
IsInsert = False
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
' VWIDB_BE_ATTRIBUTETableAdapter.Update(DSIDB_Stammdaten.VWIDB_BE_ATTRIBUTE)
|
||||
End If
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
ShowErrorMessage(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
Public Function DeleteAttribute() As Boolean Implements IAdminForm.DeleteData
|
||||
Try
|
||||
Dim oproc = $"EXEC PRIDB_DELETE_ATTRIBUTE {PrimaryKey}, '{My.Application.User.UserName}' "
|
||||
If My.DatabaseIDB.ExecuteNonQuery(oproc) = True Then
|
||||
Return True
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
ShowErrorMessage(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem3.ItemClick
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick
|
||||
If MsgBox($"Do You really want to delete the attribute [{PrimaryKey}]? All Metadata related to the Attribute will be deleted!", MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text) = MsgBoxResult.Yes Then
|
||||
If DeleteAttribute() Then
|
||||
Close()
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user