MS Anpassungen Views und Spalten

This commit is contained in:
Developer01
2025-02-20 08:26:52 +01:00
parent 81b0e44d45
commit 6945585ca3
20 changed files with 901 additions and 741 deletions

View File

@@ -1,4 +1,6 @@
Imports System.Text.RegularExpressions
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid.Views.Grid.ViewInfo
Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Language
@@ -187,8 +189,15 @@ Public Class frmAdministration
Sub Refresh_ProfileData()
Try
VWCW_USER_PROFILETableAdapter.Connection.ConnectionString = MyConnectionString
VWCW_USER_PROFILETableAdapter.Fill(MyDataset.VWCW_USER_PROFILE, PROFILE_IDTextBox.Text)
Dim oSQL = $"SELECT GUID, USER_ID, USERNAME as Username, USER_SURNAME + ', ' + USER_PRENAME as Name FROM
VWCW_USER_PROFILE WHERE PROFIL_ID = {PROFILE_IDTextBox.Text}"
Dim oDT = MyDB_DDECM.GetDatatable(oSQL)
GridViewUserInProfile.Columns.Clear()
If Not IsNothing(oDT) Then
GridControlUserInProfile.DataSource = oDT
GridViewUserInProfile.Columns.Item("USER_ID").Visible = False
GridViewUserInProfile.Columns.Item("GUID").Visible = False
End If
VWCW_GROUP_PROFILETableAdapter.Connection.ConnectionString = MyConnectionString
VWCW_GROUP_PROFILETableAdapter.Fill(MyDataset.VWCW_GROUP_PROFILE, PROFILE_IDTextBox.Text)
@@ -223,7 +232,7 @@ Public Class frmAdministration
For Each row As DataRow In MyDataset.TBWH_User.Rows
If row.Item(0) = CBool(True) Then
Dim insert = String.Format("INSERT INTO TBCW_USER_PROFILE (PROFILE_ID,USER_ID) VALUES ({0},{1})", PROFILE_IDTextBox.Text, row.Item(5))
If Database.ExecuteNonQuery(insert) = False Then
If MyDB_DDECM.ExecuteNonQuery(insert) = False Then
MsgBox("Could not insert the User-Definition....Check the logfile!", MsgBoxStyle.Exclamation)
End If
End If
@@ -245,7 +254,7 @@ Public Class frmAdministration
Dim Sql = String.Format("SELECT DISTINCT * FROM VWDD_USER_MODULE_CW WHERE GUID NOT IN (SELECT USER_ID FROM TBCW_USER_PROFILE WHERE PROFILE_ID = {0}) ORDER BY USERNAME", PROFILE_ID)
Dim DT_USER = Database.GetDatatable(Sql)
Dim DT_USER = MyDB_DDECM.GetDatatable(Sql)
Try
MyDataset.TBWH_User.Clear()
@@ -273,7 +282,7 @@ Public Class frmAdministration
Sub Refresh_Free_Groups(PROFILE_ID As Integer)
Dim Sql = String.Format("SELECT DISTINCT * FROM TBDD_GROUPS WHERE INTERNAL = 0 AND GUID NOT IN (SELECT GROUP_ID FROM TBCW_GROUP_PROFILE WHERE PROFILE_ID = {0}) ORDER BY NAME", PROFILE_ID)
Dim oDataTable = Database.GetDatatable(Sql)
Dim oDataTable = MyDB_DDECM.GetDatatable(Sql)
Try
MyDataset.TBWH_GROUP.Clear()
@@ -281,7 +290,7 @@ Public Class frmAdministration
For Each row As DataRow In oDataTable.Rows
Dim oNewRow As MyDataset.TBWH_GROUPRow
oNewRow = MyDataset.TBWH_GROUP.NewTBWH_GROUPRow
oNewRow.NAME = row.Item("NAME")
oNewRow.Name = IIf(IsDBNull(row.Item("NAME")), "Null", row.Item("NAME"))
oNewRow.GUID = row.Item("GUID")
MyDataset.TBWH_GROUP.Rows.Add(oNewRow)
Next
@@ -290,27 +299,6 @@ Public Class frmAdministration
End Try
End Sub
Private Sub btndeleteUserConstructorRel_Click(sender As Object, e As EventArgs)
Try
Dim ID = GridViewUserInProfile.GetFocusedRowCellValue(GridViewUserInProfile.Columns("GUID"))
Try
Dim I As Integer = CInt(ID)
Catch ex As Exception
Exit Sub
End Try
Dim del = String.Format("DELETE FROM TBCW_USER_PROFILE WHERE GUID = {0}", ID)
If Database.ExecuteNonQuery(del) = True Then
Refresh_ProfileData()
If PROFILE_IDTextBox.Text <> "" Then
Refresh_Free_Users(PROFILE_IDTextBox.Text)
End If
End If
Catch ex As Exception
MsgBox("Unexpected Error in deleting ProfileUserRelation: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Private Sub Load_Profile_Process()
If IsNothing(PROFILE_IDTextBox.Text) Or PROFILE_IDTextBox.Text = "" Then
Exit Sub
@@ -390,7 +378,7 @@ Public Class frmAdministration
Dim result As MsgBoxResult = MsgBox("Sind Sie sicher, dass Sie das Profil löschen wollen?", MsgBoxStyle.YesNo Or MsgBoxStyle.Question, Text)
' wenn Speichern ja
If result = MsgBoxResult.Yes Then
If Database.ExecuteNonQuery(swl) = True Then
If MyDB_DDECM.ExecuteNonQuery(swl) = True Then
Refresh_ProfileScreen()
End If
End If
@@ -686,7 +674,7 @@ Public Class frmAdministration
Private Sub BarButtonItem26_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem26.ItemClick
Dim oSQL As String = $"EXEC PRCW_COPY_PROFILE {PROFILE_IDTextBox.Text}, '{USER_USERNAME}'"
If Database.ExecuteNonQuery(oSQL) = False Then
If MyDB_DDECM.ExecuteNonQuery(oSQL) = False Then
MsgBox("Profil konnte nicht kopiert werden! Mehr Informationen im Log.", MsgBoxStyle.Exclamation, Text)
Else
Refresh_ProfileScreen()
@@ -741,63 +729,6 @@ Public Class frmAdministration
End Sub
Private Sub GridControlUserNotInProfile_DragDrop(sender As Object, e As DragEventArgs) Handles GridControlUserNotInProfile.DragDrop
Try
If PROFILE_IDTextBox.Text = String.Empty Then
Exit Sub
End If
Dim oSelectedRows = GridViewUserInProfile.GetSelectedRows()
For Each oRowHandle As Integer In oSelectedRows
Dim oRow As DataRow = GridViewUserInProfile.GetDataRow(oRowHandle)
Dim oGuid As Integer = oRow.Item("GUID")
Dim del = String.Format("DELETE FROM TBCW_USER_PROFILE WHERE GUID = {0}", oGuid)
If Database.ExecuteNonQuery(del) = False Then
MsgBox("Error while adding user!", MsgBoxStyle.Exclamation)
End If
Next
Refresh_Free_Users(PROFILE_IDTextBox.Text)
Refresh_ProfileData()
GridViewUserInProfile.ClearSelection()
Status_Changed($"{oSelectedRows.Count} Benutzerzuordnungen gelöscht")
Catch ex As Exception
Logger.Error(ex)
MsgBox("Unexpected Error in deleting ProfileUserRelation: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Private Sub GridControlUserInProfile_DragDrop(sender As Object, e As DragEventArgs) Handles GridControlUserInProfile.DragDrop
Try
If PROFILE_IDTextBox.Text = String.Empty Then
Exit Sub
End If
Dim oSelectedRows = GridViewUserNotInProfile.GetSelectedRows()
For Each oRowHandle As Integer In oSelectedRows
Dim oRow As DataRow = GridViewUserNotInProfile.GetDataRow(oRowHandle)
Dim oGuid As Integer = oRow.Item("GUID")
Dim insert = String.Format("INSERT INTO TBCW_USER_PROFILE (PROFILE_ID,USER_ID) VALUES ({0},{1})", PROFILE_IDTextBox.Text, oGuid)
If Database.ExecuteNonQuery(insert) = False Then
MsgBox("Error while adding user!", MsgBoxStyle.Exclamation)
End If
Next
Refresh_Free_Users(PROFILE_IDTextBox.Text)
Refresh_ProfileData()
GridViewUserNotInProfile.ClearSelection()
Status_Changed($"{oSelectedRows.Count} Benutzer zugeordnet")
Catch ex As Exception
Logger.Error(ex)
MsgBox("Unexpected Error while adding user-rights: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Private Sub GridControlGroupNotInProfile_DragDrop(sender As Object, e As DragEventArgs) Handles GridControlGroupNotInProfile.DragDrop
Try
@@ -809,7 +740,7 @@ Public Class frmAdministration
Dim oGroupId As Integer = oRow.GROUP_ID
Dim oSQL As String = $"DELETE FROM TBCW_GROUP_PROFILE WHERE PROFILE_ID = {oProfileId} AND GROUP_ID = {oGroupId}"
If Database.ExecuteNonQuery(oSQL) = False Then
If MyDB_DDECM.ExecuteNonQuery(oSQL) = False Then
MsgBox("Could not delete the Group-Definition....Check the logfile!", MsgBoxStyle.Exclamation)
End If
Next
@@ -834,7 +765,7 @@ Public Class frmAdministration
Dim oGroupId As Integer = oRow.GUID
Dim oSQL As String = $"INSERT INTO TBCW_GROUP_PROFILE (PROFILE_ID,GROUP_ID) VALUES ({PROFILE_IDTextBox.Text},{oGroupId})"
If Database.ExecuteNonQuery(oSQL) = False Then
If MyDB_DDECM.ExecuteNonQuery(oSQL) = False Then
MsgBox("Could not insert the Group-Definition....Check the logfile!", MsgBoxStyle.Exclamation)
End If
Next
@@ -914,7 +845,7 @@ Public Class frmAdministration
Dim oGroupId As Integer = oRow.GROUP_ID
Dim oSQL As String = $"DELETE FROM TBCW_GROUP_PROFILE WHERE PROFILE_ID = {oProfileId} AND GROUP_ID = {oGroupId}"
If Database.ExecuteNonQuery(oSQL) = False Then
If MyDB_DDECM.ExecuteNonQuery(oSQL) = False Then
MsgBox("Could not delete the Group-Definition via contextmenu....Check the logfile!", MsgBoxStyle.Exclamation)
End If
Next
@@ -929,4 +860,146 @@ Public Class frmAdministration
MsgBox("Unexpected Error in deleting Group-Rights via cms: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Private Sub UserEntfernenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles UserEntfernenToolStripMenuItem.Click
FreeUserProfile
End Sub
Sub FreeUserProfile()
Try
If PROFILE_IDTextBox.Text = String.Empty Then
Exit Sub
End If
Dim oSelectedRows = GridViewUserInProfile.GetSelectedRows()
For Each oRowHandle As Integer In oSelectedRows
Dim oRow As DataRow = GridViewUserInProfile.GetDataRow(oRowHandle)
Dim oGuid As Integer = oRow.Item("USER_ID")
Dim del = String.Format("DELETE FROM TBCW_USER_PROFILE WHERE PROFILE_ID = {0} AND USER_ID = {1}", PROFILE_IDTextBox.Text, oGuid)
If MyDB_DDECM.ExecuteNonQuery(del) = False Then
MsgBox("Error while adding user!", MsgBoxStyle.Exclamation)
End If
Next
Refresh_Free_Users(PROFILE_IDTextBox.Text)
Refresh_ProfileData()
GridViewUserInProfile.ClearSelection()
Status_Changed($"{oSelectedRows.Count} Benutzerzuordnungen gelöscht")
Catch ex As Exception
Logger.Error(ex)
MsgBox("Unexpected Error in deleting ProfileUserRelation: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Private Sub GridControlUserInProfile_MouseDown(sender As Object, e As MouseEventArgs) Handles GridControlUserInProfile.MouseDown
'Dim view As GridView = CType(sender, GridView)
'Dim hitInfo As GridHitInfo = view.CalcHitInfo(e.Location)
'If hitInfo.InRow Then
' Dim rowHandle As Integer = hitInfo.RowHandle
' Dim data As Object = view.GetRow(rowHandle)
' If data IsNot Nothing Then
' GridControl1.DoDragDrop(data, DragDropEffects.Move)
' End If
'End If
End Sub
Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
End Sub
Private Sub GridControlUserNotInProfile_DragDrop(sender As Object, e As DragEventArgs) Handles GridControlUserNotInProfile.DragDrop
FreeUserProfile()
End Sub
Private Sub GridControlUserInProfile_DragDrop(sender As Object, e As DragEventArgs) Handles GridControlUserInProfile.DragDrop
Try
If PROFILE_IDTextBox.Text = String.Empty Then
Exit Sub
End If
Dim oSelectedRows = GridViewUserNotInProfile.GetSelectedRows()
For Each oRowHandle As Integer In oSelectedRows
Dim oRow As DataRow = GridViewUserNotInProfile.GetDataRow(oRowHandle)
Dim oGuid As Integer = oRow.Item("GUID")
Dim insert = String.Format("INSERT INTO TBCW_USER_PROFILE (PROFILE_ID,USER_ID) VALUES ({0},{1})", PROFILE_IDTextBox.Text, oGuid)
If MyDB_DDECM.ExecuteNonQuery(insert) = False Then
MsgBox("Error while adding user!", MsgBoxStyle.Exclamation)
End If
Next
Refresh_Free_Users(PROFILE_IDTextBox.Text)
Refresh_ProfileData()
GridViewUserNotInProfile.ClearSelection()
Status_Changed($"{oSelectedRows.Count} Benutzer zugeordnet")
Catch ex As Exception
Logger.Error(ex)
MsgBox("Unexpected Error while adding user-rights: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
'Private Sub GridControlUserInProfile_DragDrop(sender As Object, e As DragEventArgs) Handles GridControlUserInProfile.DragDrop
' Try
' If PROFILE_IDTextBox.Text = String.Empty Then
' Exit Sub
' End If
' Dim oSelectedRows = GridViewUserNotInProfile.GetSelectedRows()
' For Each oRowHandle As Integer In oSelectedRows
' Dim oRow As DataRow = GridViewUserNotInProfile.GetDataRow(oRowHandle)
' Dim oGuid As Integer = oRow.Item("GUID")
' Dim insert = String.Format("INSERT INTO TBCW_USER_PROFILE (PROFILE_ID,USER_ID) VALUES ({0},{1})", PROFILE_IDTextBox.Text, oGuid)
' If MyDB_DDECM.ExecuteNonQuery(insert) = False Then
' MsgBox("Error while adding user!", MsgBoxStyle.Exclamation)
' End If
' Next
' Refresh_Free_Users(PROFILE_IDTextBox.Text)
' Refresh_ProfileData()
' GridViewUserNotInProfile.ClearSelection()
' Status_Changed($"{oSelectedRows.Count} Benutzer zugeordnet")
' Catch ex As Exception
' Logger.Error(ex)
' MsgBox("Unexpected Error while adding user-rights: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
' End Try
'End Sub
'Private Sub GridControlUserNotInProfile_DragDrop(sender As Object, e As DragEventArgs) Handles GridControlUserNotInProfile.DragDrop
' Try
' If PROFILE_IDTextBox.Text = String.Empty Then
' Exit Sub
' End If
' Dim oSelectedRows = GridViewUserInProfile.GetSelectedRows()
' For Each oRowHandle As Integer In oSelectedRows
' Dim oRow As DataRow = GridViewUserInProfile.GetDataRow(oRowHandle)
' Dim oGuid As Integer = oRow.Item("GUID")
' Dim del = String.Format("DELETE FROM TBCW_USER_PROFILE WHERE GUID = {0}", oGuid)
' If MyDB_DDECM.ExecuteNonQuery(del) = False Then
' MsgBox("Error while adding user!", MsgBoxStyle.Exclamation)
' End If
' Next
' Refresh_Free_Users(PROFILE_IDTextBox.Text)
' Refresh_ProfileData()
' GridViewUserInProfile.ClearSelection()
' Status_Changed($"{oSelectedRows.Count} Benutzerzuordnungen gelöscht")
' Catch ex As Exception
' Logger.Error(ex)
' MsgBox("Unexpected Error in deleting ProfileUserRelation: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
' End Try
'End Sub
End Class