Benutzer können erstellt werden
This commit is contained in:
@@ -57,6 +57,32 @@ namespace Casino
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void InsertUser(User user)
|
||||||
|
{
|
||||||
|
using (MySqlConnection conn = new MySqlConnection(myConnectionString))
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
using (MySqlCommand cmd = new MySqlCommand(
|
||||||
|
@"INSERT INTO Nutzer
|
||||||
|
(id, name, age, passwort, geld)
|
||||||
|
VALUES
|
||||||
|
(@id, @name, @alter, @passwort, @geld)",
|
||||||
|
conn))
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddWithValue("@id", user.ID);
|
||||||
|
cmd.Parameters.AddWithValue("@name", user.Name);
|
||||||
|
cmd.Parameters.AddWithValue("@alter", user.Alter);
|
||||||
|
cmd.Parameters.AddWithValue("@passwort", user.Passwort);
|
||||||
|
cmd.Parameters.AddWithValue("@geld", user.Geld);
|
||||||
|
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public byte[] GetCardImage(int id)
|
public byte[] GetCardImage(int id)
|
||||||
{
|
{
|
||||||
byte[] imageBytes = null;
|
byte[] imageBytes = null;
|
||||||
|
|||||||
@@ -31,7 +31,9 @@
|
|||||||
<Label Content="Passwort" FontSize="18" FontWeight="SemiBold" FontFamily="Palatino Linotype" Foreground="DarkGray"/>
|
<Label Content="Passwort" FontSize="18" FontWeight="SemiBold" FontFamily="Palatino Linotype" Foreground="DarkGray"/>
|
||||||
<PasswordBox x:Name="TxtPasswort" Margin="0,0,0,10" Background="#BD9208" />
|
<PasswordBox x:Name="TxtPasswort" Margin="0,0,0,10" Background="#BD9208" />
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
|
<Button Content="Neues Konto" Width="80" Click="Erstellen_Click" Background="#BD9208" FontFamily="Palatino Linotype" FontWeight="SemiBold" Margin="0,0,100,0"/>
|
||||||
<Button Content="Anmelden" Width="80" Click="Anmelden_Click" Background="#BD9208" FontFamily="Palatino Linotype" FontWeight="SemiBold"/>
|
<Button Content="Anmelden" Width="80" Click="Anmelden_Click" Background="#BD9208" FontFamily="Palatino Linotype" FontWeight="SemiBold"/>
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<MediaElement Name="player"
|
<MediaElement Name="player"
|
||||||
LoadedBehavior="Manual"
|
LoadedBehavior="Manual"
|
||||||
|
|||||||
+28
-2
@@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Security.Policy;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -13,8 +15,8 @@ using System.Windows.Input;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using System.Xml.Linq;
|
||||||
using Mysqlx.Cursor;
|
using Mysqlx.Cursor;
|
||||||
using System.Security.Cryptography;
|
|
||||||
|
|
||||||
|
|
||||||
namespace Casino
|
namespace Casino
|
||||||
@@ -90,6 +92,30 @@ namespace Casino
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Erstellen_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Database db = new Database();
|
||||||
|
ObservableCollection<User> users = new ObservableCollection<User>();
|
||||||
|
users = db.GetUser();
|
||||||
|
string hash = HashPassword(TxtPasswort.Password);
|
||||||
|
|
||||||
}
|
for (int i = 0; i < users.Count(); i++)
|
||||||
|
{
|
||||||
|
if (users[i].Name.Equals(TxtName))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
User NewUser = new User(TxtName.Text, 18, hash);
|
||||||
|
db.InsertUser(NewUser);
|
||||||
|
TxtName.Text = "";
|
||||||
|
TxtPasswort.Password = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-9
@@ -13,21 +13,21 @@ namespace Casino
|
|||||||
public int Alter { get; set; }
|
public int Alter { get; set; }
|
||||||
public string Passwort { get; set; }
|
public string Passwort { get; set; }
|
||||||
public decimal Geld { get; set; }
|
public decimal Geld { get; set; }
|
||||||
public User(string n, int a, string p)
|
public User(string name, int age, string passwort)
|
||||||
{
|
{
|
||||||
ID = ID_Generation();
|
ID = ID_Generation();
|
||||||
Name = n;
|
Name = name;
|
||||||
Alter = a;
|
Alter = age;
|
||||||
Passwort = p;
|
Passwort = passwort;
|
||||||
Geld = 1000;
|
Geld = 1000;
|
||||||
}
|
}
|
||||||
public User(string id, string n, int a,string p, int g)
|
public User(string id, string name, int age,string passwort, int geld)
|
||||||
{
|
{
|
||||||
ID = id;
|
ID = id;
|
||||||
Name = n;
|
Name = name;
|
||||||
Alter = a;
|
Alter = age;
|
||||||
Passwort = p;
|
Passwort = passwort;
|
||||||
Geld = g;
|
Geld = geld;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string ID_Generation()
|
private string ID_Generation()
|
||||||
|
|||||||
Reference in New Issue
Block a user