Bild aus datenbank hinzufügen
This commit is contained in:
@@ -56,5 +56,29 @@ namespace Casino
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
public byte[] GetCardImage(int id)
|
||||
{
|
||||
byte[] imageBytes = null;
|
||||
|
||||
using (MySqlConnection conn = new MySqlConnection(myConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (MySqlCommand cmd = new MySqlCommand("SELECT bild FROM Karten WHERE kartenid = @id", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@id", id);
|
||||
|
||||
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
imageBytes = (byte[])reader["bild"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return imageBytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,11 @@ namespace Casino
|
||||
{
|
||||
DialogResult = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Login fehlgeschlagen!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool checkLogin(string name, string passwort)
|
||||
{
|
||||
@@ -45,9 +48,9 @@ namespace Casino
|
||||
users = db.SelectTask();
|
||||
for (int i = 0; i < users.Count(); i++)
|
||||
{
|
||||
if (name.Equals(users[0].Name))
|
||||
if (name.Equals(users[i].Name))
|
||||
{
|
||||
if(passwort.Equals(users[0].Passwort)) {
|
||||
if(passwort.Equals(users[i].Passwort)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -22,21 +22,22 @@ namespace Casino
|
||||
|
||||
|
||||
//copilot hilfe
|
||||
Loaded += (_, _) =>
|
||||
var login = new Login();
|
||||
bool? result = login.ShowDialog();
|
||||
|
||||
if (result == true)
|
||||
{
|
||||
var window = new Login();
|
||||
|
||||
window.Owner = this;
|
||||
window.ShowDialog();
|
||||
if(window.DialogResult == false)
|
||||
var main = new MainWindow();
|
||||
main.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Close();
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -29,5 +29,7 @@
|
||||
<RowDefinition Height="270"></RowDefinition>
|
||||
<RowDefinition Height="200"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Image Grid.Column="1" Grid.Row="1" x:Name="kartenBild"/>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -19,9 +20,33 @@ namespace Casino
|
||||
/// </summary>
|
||||
public partial class Slots : Window
|
||||
{
|
||||
private BitmapImage ByteArrayToImage(byte[] bytes)
|
||||
{
|
||||
BitmapImage image = new BitmapImage();
|
||||
using (MemoryStream ms = new MemoryStream(bytes))
|
||||
{
|
||||
image.BeginInit();
|
||||
image.CacheOption = BitmapCacheOption.OnLoad;
|
||||
image.StreamSource = ms;
|
||||
image.EndInit();
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
public Slots()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
|
||||
}
|
||||
private void LoadCard()
|
||||
{
|
||||
Database db = new Database();
|
||||
byte[] img = db.GetCardImage(1);
|
||||
|
||||
kartenBild.Source = ByteArrayToImage(img);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user