Admin view hinzugefügt
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
<Window x:Class="Casino.AdminView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Casino"
|
||||
mc:Ignorable="d"
|
||||
Title="Adminbereich"
|
||||
Height="700"
|
||||
Width="1100"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
|
||||
<Grid Margin="20">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Überschrift -->
|
||||
<TextBlock Grid.Row="0"
|
||||
Text="Adminbereich"
|
||||
FontSize="30"
|
||||
FontWeight="Bold"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,0,0,20"/>
|
||||
|
||||
<!-- Nutzerliste -->
|
||||
<DataGrid x:Name="UserDataGrid"
|
||||
Grid.Row="1"
|
||||
AutoGenerateColumns="False"
|
||||
IsReadOnly="True"
|
||||
SelectionMode="Single"
|
||||
CanUserAddRows="False"
|
||||
Margin="0,0,0,20">
|
||||
|
||||
<DataGrid.Columns>
|
||||
|
||||
<DataGridTextColumn Header="ID"
|
||||
Binding="{Binding ID}"
|
||||
Width="220"/>
|
||||
|
||||
<DataGridTextColumn Header="Name"
|
||||
Binding="{Binding Name}"
|
||||
Width="150"/>
|
||||
|
||||
<DataGridTextColumn Header="Alter"
|
||||
Binding="{Binding Age}"
|
||||
Width="80"/>
|
||||
|
||||
<DataGridTextColumn Header="Passwort"
|
||||
Binding="{Binding Passwort}"
|
||||
Width="280"/>
|
||||
|
||||
<DataGridTextColumn Header="Geld"
|
||||
Binding="{Binding Geld}"
|
||||
Width="100"/>
|
||||
|
||||
<DataGridTextColumn Header="Rolle"
|
||||
Binding="{Binding Rolle}"
|
||||
Width="100"/>
|
||||
|
||||
</DataGrid.Columns>
|
||||
|
||||
</DataGrid>
|
||||
|
||||
<!-- Buttons -->
|
||||
<StackPanel Grid.Row="2"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Center">
|
||||
|
||||
<Button x:Name="BtnBearbeiten"
|
||||
Content="Bearbeiten"
|
||||
Width="150"
|
||||
Height="45"
|
||||
Margin="10"
|
||||
Click="BtnBearbeiten_Click"/>
|
||||
|
||||
<Button x:Name="BtnLoeschen"
|
||||
Content="Löschen"
|
||||
Width="150"
|
||||
Height="45"
|
||||
Margin="10"
|
||||
Click="BtnLoeschen_Click"/>
|
||||
|
||||
<Button Content="Aktualisieren"
|
||||
Width="150"
|
||||
Height="45"
|
||||
Margin="10"
|
||||
Click="BtnAktualisieren_Click"/>
|
||||
|
||||
<Button Content="Schließen"
|
||||
Width="150"
|
||||
Height="45"
|
||||
Margin="10"
|
||||
Click="BtnSchliessen_Click"/>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,148 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
|
||||
namespace Casino
|
||||
{
|
||||
public partial class AdminView : Window
|
||||
{
|
||||
private readonly Database db = new Database();
|
||||
|
||||
private ObservableCollection<User> users;
|
||||
|
||||
public AdminView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// Prüfen, ob der aktuell eingeloggte Benutzer Admin ist
|
||||
if (MainWindow.currentUser < 0)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Es ist kein Benutzer eingeloggt.",
|
||||
"Fehler",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
users = db.GetUser();
|
||||
|
||||
// Sicherheitsprüfung über die Datenbank
|
||||
if (MainWindow.currentUser >= users.Count ||
|
||||
!db.SelectAdmin(users[MainWindow.currentUser].ID))
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Du hast keine Admin-Rechte.",
|
||||
"Zugriff verweigert",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
UserDataGrid.ItemsSource = users;
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// BEARBEITEN
|
||||
// ==========================================
|
||||
|
||||
private void BtnBearbeiten_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (UserDataGrid.SelectedItem is not User selectedUser)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Bitte wähle zuerst einen Benutzer aus.",
|
||||
"Kein Benutzer ausgewählt",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
EditUserView editView = new EditUserView(selectedUser);
|
||||
|
||||
// Eigenes Fenster öffnen
|
||||
editView.ShowDialog();
|
||||
|
||||
// Nach dem Schließen Daten neu laden
|
||||
users = db.GetUser();
|
||||
UserDataGrid.ItemsSource = users;
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// LÖSCHEN
|
||||
// ==========================================
|
||||
|
||||
private void BtnLoeschen_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (UserDataGrid.SelectedItem is not User selectedUser)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Bitte wähle zuerst einen Benutzer aus.",
|
||||
"Kein Benutzer ausgewählt",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Sicherheitsabfrage
|
||||
MessageBoxResult result = MessageBox.Show(
|
||||
$"Möchtest du den Benutzer '{selectedUser.Name}' wirklich löschen?",
|
||||
"Benutzer löschen",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Warning);
|
||||
|
||||
if (result != MessageBoxResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Benutzer aus Datenbank löschen
|
||||
bool success = db.DeleteUser(selectedUser.ID);
|
||||
|
||||
if (success)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Benutzer wurde erfolgreich gelöscht.",
|
||||
"Erfolgreich",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Information);
|
||||
|
||||
// Tabelle aktualisieren
|
||||
users = db.GetUser();
|
||||
UserDataGrid.ItemsSource = users;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Der Benutzer konnte nicht gelöscht werden.",
|
||||
"Fehler",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// AKTUALISIEREN
|
||||
// ==========================================
|
||||
|
||||
private void BtnAktualisieren_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
users = db.GetUser();
|
||||
UserDataGrid.ItemsSource = users;
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// SCHLIESSEN
|
||||
// ==========================================
|
||||
|
||||
private void BtnSchliessen_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
+117
-1
@@ -5,6 +5,7 @@ using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
namespace Casino
|
||||
@@ -40,7 +41,8 @@ namespace Casino
|
||||
Name = myReader.GetString("name"),
|
||||
Alter = myReader.GetInt32("age"),
|
||||
Passwort = myReader.GetString("passwort"),
|
||||
Geld = myReader.GetDecimal("geld")
|
||||
Geld = myReader.GetDecimal("geld"),
|
||||
Rolle = myReader.GetString("Rolle")
|
||||
};
|
||||
|
||||
user.Add(u);
|
||||
@@ -200,5 +202,119 @@ namespace Casino
|
||||
}
|
||||
}
|
||||
|
||||
public bool SelectAdmin(string userId)
|
||||
{
|
||||
using MySqlConnection connection = new MySqlConnection(myConnectionString);
|
||||
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
string sql = @"
|
||||
SELECT COUNT(*)
|
||||
FROM Nutzer
|
||||
WHERE id = @id
|
||||
AND Rolle = 'Admin'";
|
||||
|
||||
using MySqlCommand command = new MySqlCommand(sql, connection);
|
||||
|
||||
command.Parameters.AddWithValue("@id", userId);
|
||||
|
||||
int count = Convert.ToInt32(command.ExecuteScalar());
|
||||
|
||||
return count > 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Fehler bei der Admin-Abfrage:\n" + ex.Message,
|
||||
"Datenbankfehler",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool DeleteUser(string userId)
|
||||
{
|
||||
using MySqlConnection connection = new MySqlConnection(myConnectionString);
|
||||
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
string sql = @"
|
||||
DELETE FROM Nutzer
|
||||
WHERE id = @id";
|
||||
|
||||
using MySqlCommand command = new MySqlCommand(sql, connection);
|
||||
|
||||
command.Parameters.AddWithValue("@id", userId);
|
||||
|
||||
int affectedRows = command.ExecuteNonQuery();
|
||||
|
||||
return affectedRows > 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Fehler beim Löschen des Benutzers:\n" + ex.Message,
|
||||
"Datenbankfehler",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpdateUser(
|
||||
string userId,
|
||||
string name,
|
||||
int age,
|
||||
string passwort,
|
||||
decimal geld,
|
||||
string rolle)
|
||||
{
|
||||
using MySqlConnection connection = new MySqlConnection(myConnectionString);
|
||||
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
string sql = @"
|
||||
UPDATE Nutzer
|
||||
SET name = @name,
|
||||
age = @age,
|
||||
passwort = @passwort,
|
||||
geld = @geld,
|
||||
Rolle = @rolle
|
||||
WHERE id = @id";
|
||||
|
||||
using MySqlCommand command = new MySqlCommand(sql, connection);
|
||||
|
||||
command.Parameters.AddWithValue("@name", name);
|
||||
command.Parameters.AddWithValue("@age", age);
|
||||
command.Parameters.AddWithValue("@passwort", passwort);
|
||||
command.Parameters.AddWithValue("@geld", geld);
|
||||
command.Parameters.AddWithValue("@rolle", rolle);
|
||||
command.Parameters.AddWithValue("@id", userId);
|
||||
|
||||
int affectedRows = command.ExecuteNonQuery();
|
||||
|
||||
return affectedRows > 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Fehler beim Aktualisieren des Benutzers:\n" + ex.Message,
|
||||
"Datenbankfehler",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
<Window x:Class="Casino.EditUserView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="Benutzer bearbeiten"
|
||||
Height="550"
|
||||
Width="500"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
|
||||
<Grid Margin="25">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Überschrift -->
|
||||
|
||||
<TextBlock Grid.Row="0"
|
||||
Text="Benutzer bearbeiten"
|
||||
FontSize="28"
|
||||
FontWeight="Bold"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,0,0,25"/>
|
||||
|
||||
<!-- Name -->
|
||||
|
||||
<StackPanel Grid.Row="1"
|
||||
Margin="0,5">
|
||||
|
||||
<TextBlock Text="Name"
|
||||
FontWeight="Bold"/>
|
||||
|
||||
<TextBox x:Name="TxtName"
|
||||
Height="35"/>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<!-- Alter -->
|
||||
|
||||
<StackPanel Grid.Row="2"
|
||||
Margin="0,5">
|
||||
|
||||
<TextBlock Text="Alter"
|
||||
FontWeight="Bold"/>
|
||||
|
||||
<TextBox x:Name="TxtAge"
|
||||
Height="35"/>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<!-- Passwort -->
|
||||
|
||||
<StackPanel Grid.Row="3"
|
||||
Margin="0,5">
|
||||
|
||||
<TextBlock Text="Neues Passwort"
|
||||
FontWeight="Bold"/>
|
||||
|
||||
<PasswordBox x:Name="TxtPasswort"
|
||||
Height="35"/>
|
||||
|
||||
<TextBlock Text="Leer lassen = Passwort nicht ändern"
|
||||
FontSize="12"
|
||||
Foreground="Gray"/>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<!-- Geld -->
|
||||
|
||||
<StackPanel Grid.Row="4"
|
||||
Margin="0,5">
|
||||
|
||||
<TextBlock Text="Geld"
|
||||
FontWeight="Bold"/>
|
||||
|
||||
<TextBox x:Name="TxtGeld"
|
||||
Height="35"/>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<!-- Rolle -->
|
||||
|
||||
<StackPanel Grid.Row="5"
|
||||
Margin="0,5">
|
||||
|
||||
<TextBlock Text="Rolle"
|
||||
FontWeight="Bold"/>
|
||||
|
||||
<ComboBox x:Name="CmbRolle"
|
||||
Height="35">
|
||||
|
||||
<ComboBoxItem Content="User"/>
|
||||
<ComboBoxItem Content="Admin"/>
|
||||
|
||||
</ComboBox>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<!-- Buttons -->
|
||||
|
||||
<StackPanel Grid.Row="6"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Bottom"
|
||||
Margin="0,25,0,0">
|
||||
|
||||
<Button Content="Speichern"
|
||||
Width="140"
|
||||
Height="40"
|
||||
Margin="10"
|
||||
Click="BtnSpeichern_Click"/>
|
||||
|
||||
<Button Content="Abbrechen"
|
||||
Width="140"
|
||||
Height="40"
|
||||
Margin="10"
|
||||
Click="BtnAbbrechen_Click"/>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,163 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Casino
|
||||
{
|
||||
public partial class EditUserView : Window
|
||||
{
|
||||
private readonly Database db = new Database();
|
||||
|
||||
private readonly User selectedUser;
|
||||
|
||||
public EditUserView(User user)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
selectedUser = user;
|
||||
|
||||
// Bestehende Werte anzeigen
|
||||
TxtName.Text = selectedUser.Name;
|
||||
TxtAge.Text = selectedUser.Alter.ToString();
|
||||
TxtGeld.Text = selectedUser.Geld.ToString();
|
||||
|
||||
// Rolle auswählen
|
||||
foreach (ComboBoxItem item in CmbRolle.Items)
|
||||
{
|
||||
if (item.Content?.ToString() == selectedUser.Rolle)
|
||||
{
|
||||
CmbRolle.SelectedItem = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// SPEICHERN
|
||||
// ==========================================
|
||||
|
||||
private void BtnSpeichern_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Name prüfen
|
||||
if (string.IsNullOrWhiteSpace(TxtName.Text))
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Bitte gib einen Namen ein.",
|
||||
"Fehler",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Alter prüfen
|
||||
if (!int.TryParse(TxtAge.Text, out int age) ||
|
||||
age < 0 ||
|
||||
age > 150)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Bitte gib ein gültiges Alter ein.",
|
||||
"Fehler",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Geld prüfen
|
||||
if (!decimal.TryParse(TxtGeld.Text, out decimal geld))
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Bitte gib einen gültigen Geldbetrag ein.",
|
||||
"Fehler",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Rolle prüfen
|
||||
if (CmbRolle.SelectedItem is not ComboBoxItem selectedRoleItem)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Bitte wähle eine Rolle aus.",
|
||||
"Fehler",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
string rolle = selectedRoleItem.Content?.ToString() ?? "User";
|
||||
|
||||
// Passwort:
|
||||
// leer = altes Passwort behalten
|
||||
string passwort = selectedUser.Passwort;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(TxtPasswort.Password))
|
||||
{
|
||||
passwort = HashPassword(TxtPasswort.Password);
|
||||
}
|
||||
|
||||
// Datenbank aktualisieren
|
||||
bool success = db.UpdateUser(
|
||||
selectedUser.ID,
|
||||
TxtName.Text.Trim(),
|
||||
age,
|
||||
passwort,
|
||||
geld,
|
||||
rolle);
|
||||
|
||||
if (success)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Benutzer wurde erfolgreich aktualisiert.",
|
||||
"Erfolgreich",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Information);
|
||||
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Die Änderungen konnten nicht gespeichert werden.",
|
||||
"Fehler",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// ABBRECHEN
|
||||
// ==========================================
|
||||
|
||||
private void BtnAbbrechen_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// PASSWORT HASHEN
|
||||
// ==========================================
|
||||
|
||||
private static string HashPassword(string password)
|
||||
{
|
||||
using SHA256 sha256 = SHA256.Create();
|
||||
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(password);
|
||||
byte[] hash = sha256.ComputeHash(bytes);
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
foreach (byte b in hash)
|
||||
{
|
||||
builder.Append(b.ToString("X2"));
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
-5
@@ -26,11 +26,14 @@ namespace Casino
|
||||
/// </summary>
|
||||
public partial class Login : Window
|
||||
{
|
||||
Database db = new Database();
|
||||
ObservableCollection<User> users = new ObservableCollection<User>();
|
||||
|
||||
|
||||
public Login()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
users = db.GetUser();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,10 +42,19 @@ namespace Casino
|
||||
{
|
||||
if (checkLogin(TxtName.Text, TxtPasswort.Password))
|
||||
{
|
||||
|
||||
Console.WriteLine(users[MainWindow.currentUser].Rolle);
|
||||
if (users[MainWindow.currentUser].Rolle.Equals("Admin"))
|
||||
{
|
||||
AdminView adminView = new AdminView();
|
||||
adminView.Show();
|
||||
Close();
|
||||
}else
|
||||
{
|
||||
MainWindow mainWindow = new MainWindow();
|
||||
mainWindow.Show();
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
@@ -53,9 +65,7 @@ namespace Casino
|
||||
|
||||
private bool checkLogin(string name, string passwort)
|
||||
{
|
||||
Database db = new Database();
|
||||
ObservableCollection<User> users = new ObservableCollection<User>();
|
||||
users = db.GetUser();
|
||||
|
||||
string hash = HashPassword(passwort);
|
||||
|
||||
for (int i = 0; i < users.Count(); i++)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
Name/Passwort
|
||||
Test User:
|
||||
(Günter/123)
|
||||
(Nutzer/Test)
|
||||
(Gerdi/Mast)
|
||||
|
||||
|
||||
Admin:
|
||||
(Admin/nimda)
|
||||
+5
-1
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -13,6 +14,7 @@ namespace Casino
|
||||
public int Alter { get; set; }
|
||||
public string Passwort { get; set; }
|
||||
public decimal Geld { get; set; }
|
||||
public string Rolle { get; set; }
|
||||
public User(string name, int age, string passwort)
|
||||
{
|
||||
ID = ID_Generation();
|
||||
@@ -20,14 +22,16 @@ namespace Casino
|
||||
Alter = age;
|
||||
Passwort = passwort;
|
||||
Geld = 1000;
|
||||
Rolle = "User";
|
||||
}
|
||||
public User(string id, string name, int age,string passwort, int geld)
|
||||
public User(string id, string name, int age,string passwort, int geld, string rolle)
|
||||
{
|
||||
ID = id;
|
||||
Name = name;
|
||||
Alter = age;
|
||||
Passwort = passwort;
|
||||
Geld = geld;
|
||||
Rolle = rolle;
|
||||
}
|
||||
|
||||
private string ID_Generation()
|
||||
|
||||
Reference in New Issue
Block a user