init
This commit is contained in:
11
SQL.sql
Normal file
11
SQL.sql
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
CREATE DATABASE IF NOT EXISTS FahrzeugDB;
|
||||||
|
GRANT ALL PRIVILEGES ON FahrzeugDB.* TO 'admin'@'%';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
USE FahrzeugDB;
|
||||||
|
DROP TABLE IF EXISTS fahrzeuge;
|
||||||
|
CREATE TABLE fahrzeuge (
|
||||||
|
id INT NOT NULL AUTO_INCREMENT,
|
||||||
|
fahrzeug_name VARCHAR(100) NOT NULL,
|
||||||
|
fahrzeug_typ VARCHAR(100) NOT NULL,
|
||||||
|
PRIMARY KEY ( id )
|
||||||
|
);
|
||||||
9
SQLMan/App.xaml
Normal file
9
SQLMan/App.xaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<Application x:Class="SQLMan.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:SQLMan"
|
||||||
|
StartupUri="MainWindow.xaml">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
||||||
14
SQLMan/App.xaml.cs
Normal file
14
SQLMan/App.xaml.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System.Configuration;
|
||||||
|
using System.Data;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace SQLMan
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for App.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
10
SQLMan/AssemblyInfo.cs
Normal file
10
SQLMan/AssemblyInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
[assembly: ThemeInfo(
|
||||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// or application resource dictionaries)
|
||||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// app, or any theme specific resource dictionaries)
|
||||||
|
)]
|
||||||
35
SQLMan/MainWindow.xaml
Normal file
35
SQLMan/MainWindow.xaml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<Window x:Class="SQLMan.MainWindow"
|
||||||
|
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:SQLMan"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="SQL Broo" Height="450" Width="800">
|
||||||
|
<Grid>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Button Grid.Row="0"
|
||||||
|
Content="Select SQL Script"
|
||||||
|
Click="SelectButonClick"/>
|
||||||
|
<TextBox Grid.Row="1"
|
||||||
|
Margin="3"
|
||||||
|
IsEnabled="False"
|
||||||
|
Name="SkriptTextBox"/>
|
||||||
|
<StackPanel Grid.Row="2"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<Label>Connection String</Label>
|
||||||
|
<TextBox Width="500"
|
||||||
|
Name="ConnectionTextBox"/>
|
||||||
|
</StackPanel>
|
||||||
|
<Button Grid.Row="3"
|
||||||
|
Content="Execute SQL Script"
|
||||||
|
Click="ExecuteButonClick"/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
67
SQLMan/MainWindow.xaml.cs
Normal file
67
SQLMan/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
using Microsoft.Win32;
|
||||||
|
using MySqlConnector;
|
||||||
|
using System.IO;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace SQLMan;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MainWindow.xaml.
|
||||||
|
/// </summary>
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.ConnectionTextBox.Text = "Server=localhost;User ID=root;Password=root";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SelectButonClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
FileInfo? datei = this.SkriptDateiWahlen();
|
||||||
|
string dateiInhalt = this.DateiEinlesen(datei);
|
||||||
|
this.SkriptTextBox.Text = dateiInhalt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FileInfo? SkriptDateiWahlen()
|
||||||
|
{
|
||||||
|
OpenFileDialog dateiDialog = new OpenFileDialog();
|
||||||
|
dateiDialog.Filter = "SQL files (*.sql)|*.sql";
|
||||||
|
if (dateiDialog.ShowDialog() == true)
|
||||||
|
{
|
||||||
|
return new FileInfo(dateiDialog.FileName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string DateiEinlesen(FileInfo? datei)
|
||||||
|
{
|
||||||
|
if (datei == null) return string.Empty;
|
||||||
|
string dateiInhalt = File.ReadAllText(datei.FullName);
|
||||||
|
return dateiInhalt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteButonClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
this.FuehreSkriptAus(this.SkriptTextBox.Text, this.ConnectionTextBox.Text);
|
||||||
|
MessageBox.Show("Das Skript wurde erfolgreich ausgeführt!");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FuehreSkriptAus(string sqlScript, string connectionString)
|
||||||
|
{
|
||||||
|
using var datenbankVerbindung = new MySqlConnection(connectionString);
|
||||||
|
datenbankVerbindung.Open();
|
||||||
|
|
||||||
|
using var kommando = new MySqlCommand(sqlScript, datenbankVerbindung);
|
||||||
|
kommando.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
15
SQLMan/SQLMan.csproj
Normal file
15
SQLMan/SQLMan.csproj
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net9.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="MySqlConnector" Version="2.4.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
31
Ubung.sln
Normal file
31
Ubung.sln
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.13.35919.96
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ubung", "Ubung\Ubung.csproj", "{3E59EB27-0ACB-40D5-A428-577BBEE50BC9}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLMan", "SQLMan\SQLMan.csproj", "{EBEED711-090F-4441-B51E-94F492E920D2}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{3E59EB27-0ACB-40D5-A428-577BBEE50BC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3E59EB27-0ACB-40D5-A428-577BBEE50BC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3E59EB27-0ACB-40D5-A428-577BBEE50BC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3E59EB27-0ACB-40D5-A428-577BBEE50BC9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{EBEED711-090F-4441-B51E-94F492E920D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{EBEED711-090F-4441-B51E-94F492E920D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{EBEED711-090F-4441-B51E-94F492E920D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{EBEED711-090F-4441-B51E-94F492E920D2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {730247B2-661F-4AE3-878C-6D160EF22F7F}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
15
Ubung/Auto.cs
Normal file
15
Ubung/Auto.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
namespace Ubung;
|
||||||
|
|
||||||
|
internal abstract class Auto
|
||||||
|
{
|
||||||
|
protected Auto(int countDors)
|
||||||
|
{
|
||||||
|
this.CountDors = countDors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CountDors { get; protected set; }
|
||||||
|
|
||||||
|
public string Color { get; set; } = "";
|
||||||
|
|
||||||
|
public string Type { get; set; } = "";
|
||||||
|
}
|
||||||
26
Ubung/GenTec.cs
Normal file
26
Ubung/GenTec.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
namespace Ubung;
|
||||||
|
|
||||||
|
internal class GenTec<T>
|
||||||
|
{
|
||||||
|
private T[] values;
|
||||||
|
|
||||||
|
public GenTec(int groesse)
|
||||||
|
{
|
||||||
|
values = new T[groesse];
|
||||||
|
}
|
||||||
|
|
||||||
|
public T GetValue(int index)
|
||||||
|
{
|
||||||
|
return values[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetValue(int index, T value)
|
||||||
|
{
|
||||||
|
values[index] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetType()
|
||||||
|
{
|
||||||
|
return typeof(T).Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
21
Ubung/GenTecList.cs
Normal file
21
Ubung/GenTecList.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
namespace Ubung;
|
||||||
|
|
||||||
|
internal class GenTecList<T>
|
||||||
|
{
|
||||||
|
List<T> list = new List<T>();
|
||||||
|
|
||||||
|
public T GetValue(int index)
|
||||||
|
{
|
||||||
|
return list[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddValue(T value)
|
||||||
|
{
|
||||||
|
list.Add(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetType()
|
||||||
|
{
|
||||||
|
return typeof(T).Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
8
Ubung/Kombi.cs
Normal file
8
Ubung/Kombi.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Ubung;
|
||||||
|
|
||||||
|
internal class Kombi : Auto
|
||||||
|
{
|
||||||
|
public Kombi() : base(5)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
8
Ubung/Limousine.cs
Normal file
8
Ubung/Limousine.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Ubung;
|
||||||
|
|
||||||
|
internal class Limousine : Auto
|
||||||
|
{
|
||||||
|
public Limousine(int countDors) : base(countDors)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
73
Ubung/Program.cs
Normal file
73
Ubung/Program.cs
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
|
||||||
|
|
||||||
|
using Ubung;
|
||||||
|
|
||||||
|
// Übung 1
|
||||||
|
Limousine limousine = new(4);
|
||||||
|
Kombi kombi = new();
|
||||||
|
Van van = new();
|
||||||
|
|
||||||
|
// Übung 3
|
||||||
|
var gentec = new GenTec<int>(5);
|
||||||
|
gentec.SetValue(3, 245);
|
||||||
|
gentec.SetValue(2, 45);
|
||||||
|
gentec.SetValue(1, 11);
|
||||||
|
gentec.SetValue(4, 34);
|
||||||
|
gentec.SetValue(0, 56);
|
||||||
|
|
||||||
|
Console.WriteLine(gentec.GetType());
|
||||||
|
Console.WriteLine(gentec.GetValue(4));
|
||||||
|
|
||||||
|
var gen = new GenTec<double>(5);
|
||||||
|
gen.SetValue(3, 245);
|
||||||
|
gen.SetValue(2, 45);
|
||||||
|
gen.SetValue(1, 11);
|
||||||
|
gen.SetValue(4, 34.9123);
|
||||||
|
gen.SetValue(0, 56);
|
||||||
|
|
||||||
|
Console.WriteLine(gen.GetType());
|
||||||
|
Console.WriteLine(gen.GetValue(4));
|
||||||
|
|
||||||
|
var genList = new GenTecList<int>();
|
||||||
|
genList.AddValue(245);
|
||||||
|
genList.AddValue(3);
|
||||||
|
genList.AddValue(25);
|
||||||
|
genList.AddValue(24);
|
||||||
|
|
||||||
|
Console.WriteLine(genList.GetType());
|
||||||
|
Console.WriteLine(genList.GetValue(0));
|
||||||
|
|
||||||
|
var genList2 = new GenTecList<int>();
|
||||||
|
genList2.AddValue(245);
|
||||||
|
genList2.AddValue(3);
|
||||||
|
genList2.AddValue(25);
|
||||||
|
genList2.AddValue(24);
|
||||||
|
|
||||||
|
Console.WriteLine(genList2.GetType());
|
||||||
|
Console.WriteLine(genList2.GetValue(1));
|
||||||
|
|
||||||
|
// Übung 4
|
||||||
|
var rand = new Random();
|
||||||
|
List<int> list = new();
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
list.Add(rand.Next(101));
|
||||||
|
}
|
||||||
|
|
||||||
|
var anzahl = list.Count(o => o < list.Average());
|
||||||
|
Console.WriteLine(anzahl);
|
||||||
|
|
||||||
|
|
||||||
|
var rooms = new Dictionary<string, string[]>
|
||||||
|
{
|
||||||
|
{ "618", new [] { "Tim", "Ute"} },
|
||||||
|
{ "621", new [] { "Hans", "Jakob"} },
|
||||||
|
};
|
||||||
|
|
||||||
|
Console.WriteLine(SearchStudent(rooms, "Jakob"));
|
||||||
|
|
||||||
|
string SearchStudent(Dictionary<string, string[]> studentInClasses, string student)
|
||||||
|
{
|
||||||
|
return studentInClasses.First(o => o.Value.Contains(student)).Key;
|
||||||
|
}
|
||||||
10
Ubung/Ubung.csproj
Normal file
10
Ubung/Ubung.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
17
Ubung/Van.cs
Normal file
17
Ubung/Van.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
namespace Ubung;
|
||||||
|
|
||||||
|
internal class Van : Kombi
|
||||||
|
{
|
||||||
|
private bool ladefläche = false;
|
||||||
|
|
||||||
|
public bool Ladefläche
|
||||||
|
{
|
||||||
|
get => ladefläche;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.CountDors = value ? 2 : 5;
|
||||||
|
|
||||||
|
ladefläche = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user