Commit 95532245 authored by Alexander Scharfenberg's avatar Alexander Scharfenberg
Browse files

many very important changes

parent 3d14ea66
......@@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Raumverwaltung_HMWK"
mc:Ignorable="d"
Title="AddAssetWindow" Height="200" Width="300" ResizeMode="NoResize">
Title="Asset" Height="200" Width="300" ResizeMode="NoResize">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
......@@ -23,7 +23,7 @@
<Button Name="OK" Click="OK_OnClick" Height="30" Width="70">OK</Button>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1">
<Button Name="Abbruch" Click="Abbruch_OnClick" Height="30" Width="70">Abbruch</Button>
<Button Name="Abbruch" Click="Abbruch_OnClick" Height="30" Width="70">Abbrechen</Button>
</StackPanel>
</Grid>
</Window>
\ No newline at end of file
......@@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Raumverwaltung_HMWK"
mc:Ignorable="d"
Title="Stockwerk anlegen" Height="300" Width="300">
Title="Stockwerk anlegen" Height="300" Width="400">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
......@@ -34,13 +34,14 @@
<TextBlock FontSize="15">Bild einfügen:</TextBlock>
</StackPanel>
<StackPanel Grid.Row="2" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal">
<TextBox Name="ImageInput" Width="100"></TextBox>
<TextBox Name="ImageInput" Width="130"></TextBox>
<Button Click="SearchFile" Content="Suchen" Margin="5,0,0,0"></Button>
</StackPanel>
<StackPanel Grid.Row="3" Grid.Column="0">
<Button Click="AddFloor" Content="Hinzufügen" Width="100"/>
</StackPanel>
<StackPanel Grid.Row="3" Grid.Column="1">
<Button Click="Abbort" Content="Abbruch" Width="100"/>
<Button Click="Abbort" Content="Abbrechen" Width="100"/>
</StackPanel>
</Grid>
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows;
using Microsoft.Win32;
namespace Raumverwaltung_HMWK
{
......@@ -19,10 +21,11 @@ namespace Raumverwaltung_HMWK
{
string Floorname = StockwerkInput.Text;
string Imagepath = ImageInput.Text;
Building selected = buildings[StandortSelection.SelectedIndex];
if (!String.IsNullOrEmpty(Floorname) && selected!=null)
if (!String.IsNullOrEmpty(Floorname) && StandortSelection.SelectedItem != null)
{
Building selected = buildings[StandortSelection.SelectedIndex];
List<Floor> existingFloors = SqLiteDataAccess.GetFloorsToBuilding(selected);
bool found = false;
for (int i = 0; i < existingFloors.Count; i++)
......@@ -35,22 +38,32 @@ namespace Raumverwaltung_HMWK
if (!found)
{
SqLiteDataAccess.AddFloor(Floorname,Imagepath,selected);
MessageBox.Show("Stockwerk angelegt!", "Erfolgreich:", MessageBoxButton.OK,
MessageBoxImage.Information);
foreach (Window w in Application.Current.Windows)
if (Imagepath == "" || Imagepath.Contains("Images"))
{
if (w.Title!= "Raumverwaltung-HMWK")
SqLiteDataAccess.AddFloor(Floorname,Imagepath,selected);
MessageBox.Show("Stockwerk angelegt!", "Erfolgreich:", MessageBoxButton.OK,
MessageBoxImage.Information);
foreach (Window w in Application.Current.Windows)
{
w.Close();
}
else
{
w.Close();
MainWindow window = new MainWindow();
window.Show();
if (w.Title!= "Raumverwaltung-HMWK")
{
w.Close();
}
else
{
w.Close();
MainWindow window = new MainWindow();
window.Show();
}
}
}
else
{
MessageBox.Show("Das Bild muss aus dem Images-Ordner stammen.", "Fehler:", MessageBoxButton.OK,
MessageBoxImage.Error);
}
}
else
{
......@@ -70,5 +83,15 @@ namespace Raumverwaltung_HMWK
{
Close();
}
private void SearchFile(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Image Files|*.png;*.PNG";
string CombinedPath = Path.Combine(Directory.GetCurrentDirectory(), "../../Images");
openFileDialog.InitialDirectory = Path.GetFullPath(CombinedPath);
if(openFileDialog.ShowDialog() == true)
ImageInput.Text = openFileDialog.FileName;
}
}
}
\ No newline at end of file
......@@ -12,7 +12,7 @@
<TextBox Name="LocationInput" FontSize="15" HorizontalAlignment="Center" Width="150" Height="30" Margin="0,20"></TextBox>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="15">
<Button Click="AddLocation" Content="Hinzufügen" Margin="10,0" Width="70"></Button>
<Button Click="Abort" Content="Abbruch" Margin="10,0" Width="70"></Button>
<Button Click="Abort" Content="Abbrechen" Margin="10,0" Width="70"></Button>
</StackPanel>
</StackPanel>
</Grid>
......
......@@ -32,6 +32,19 @@ namespace Raumverwaltung_HMWK
SqLiteDataAccess.AddLocation(LocationInput.Text);
MessageBox.Show("Standort hinzugefügt", "Erfolgreich:", MessageBoxButton.OK,
MessageBoxImage.Information);
foreach (Window w in Application.Current.Windows)
{
if (w.Title != "Raumverwaltung-HMWK")
{
w.Close();
}
else
{
w.Close();
MainWindow window = new MainWindow();
window.Show();
}
}
}
catch (Exception)
{
......@@ -40,21 +53,7 @@ namespace Raumverwaltung_HMWK
Close();
}
foreach (Window w in Application.Current.Windows)
{
if (w.Title != "Raumverwaltung-HMWK")
{
w.Close();
}
else
{
w.Close();
MainWindow window = new MainWindow();
window.Show();
}
}
}
else
{
MessageBox.Show("Standort bereits vorhanden", "Fehler:", MessageBoxButton.OK,
......
<Window x:Class="Raumverwaltung_HMWK.AddRoomWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Raumverwaltung_HMWK"
mc:Ignorable="d"
Title="Raum erstellen" Height="400" Width="300">
<Grid Background="Thistle">
<Grid.RowDefinitions>
<RowDefinition Height="75"></RowDefinition>
<RowDefinition Height="75"></RowDefinition>
<RowDefinition Height="75"></RowDefinition>
<RowDefinition Height="75"></RowDefinition>
<RowDefinition Height="75"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Center">Raum erstellen:</TextBlock>
<TextBlock FontSize="15" TextAlignment="Center" VerticalAlignment="Center" Background="Lavender" Grid.Column="0" Grid.Row="1">Raum-Name:</TextBlock>
<TextBlock FontSize="15" TextAlignment="Center" VerticalAlignment="Center" Background="Lavender" Grid.Column="0" Grid.Row="2">Größe:</TextBlock>
<TextBlock FontSize="15" TextAlignment="Center" VerticalAlignment="Center" Background="Lavender" Grid.Column="0" Grid.Row="3">Arbeitsplätze:</TextBlock>
<TextBox BorderBrush="Black" FontSize="15" TextAlignment="Center" VerticalAlignment="Center" Grid.Column="3" Grid.Row="1" Name="RaumName"></TextBox>
<TextBox FontSize="15" BorderBrush="Black" TextAlignment="Center" VerticalAlignment="Center" Grid.Column="1" Grid.Row="2" Name="Größe"></TextBox>
<TextBox FontSize="15" BorderBrush="Black" TextAlignment="Center" VerticalAlignment="Center" Grid.Column="1" Grid.Row="3" Name="Arbeitsplätze"></TextBox>
<Button Click="AddRoom" Grid.Row="4" Grid.Column="0" Width="100" VerticalAlignment="Center">Hinzufügen</Button>
<Button Click="Abbort" Grid.Row="4" Grid.Column="1" Width="100" VerticalAlignment="Center">Abbrechen</Button>
</Grid>
</Window>
using System;
using System.Windows;
namespace Raumverwaltung_HMWK
{
public partial class AddRoomWindow : Window
{
private string name;
private double grösse;
private int arbeitsplätze;
private int floorId;
public AddRoomWindow(int floorId)
{
this.floorId = floorId;
InitializeComponent();
}
private void AddRoom(object sender, RoutedEventArgs e)
{
if (!String.IsNullOrEmpty(RaumName.Text) && !String.IsNullOrEmpty(Größe.Text) &&
!String.IsNullOrEmpty(Arbeitsplätze.Text))
{
try
{
name = RaumName.Text;
grösse = Double.Parse(Größe.Text);
arbeitsplätze = Int32.Parse(Arbeitsplätze.Text);
SqLiteDataAccess.AddRoom(name, grösse, arbeitsplätze, floorId);
MessageBox.Show("Raum angelegt!", "Erfolgreich:", MessageBoxButton.OK, MessageBoxImage.Information);
foreach (Window w in Application.Current.Windows)
{
if (w.Title != "Raumverwaltung-HMWK")
{
w.Close();
}
else
{
w.Close();
MainWindow window = new MainWindow();
window.Show();
FloorWindow floorWindow = new FloorWindow(floorId);
floorWindow.Show();
}
}
}
catch (Exception)
{
MessageBox.Show("Raum anlegen hat nicht geklappt!", "Fehler:", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
else
{
MessageBox.Show("Bitte alle Felder befüllen!", "Fehler:", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void Abbort(object sender, RoutedEventArgs e)
{
Close();
}
}
}
\ No newline at end of file
......@@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Raumverwaltung_HMWK"
mc:Ignorable="d"
Title="Stockwerk entfernen" Height="200" Width="200">
Title="Stockwerk entfernen" Height="300" Width="250">
<Grid>
<StackPanel Orientation="Vertical" Margin="0,0,0,0">
<TextBlock FontSize="15" HorizontalAlignment="Center">Standort wählen:</TextBlock>
......@@ -14,7 +14,7 @@
<ComboBox Name="FloorSelection" FontSize="15" HorizontalAlignment="Center" Width="150" Margin="0,10"></ComboBox>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="15">
<Button Content="Löschen" Click="DeleteFloor" Margin="10,0" Width="70"></Button>
<Button Content="Abbruch" Click="Abbort" Margin="10,0" Width="70"></Button>
<Button Content="Abbrechen" Click="Abbort" Margin="10,0" Width="70"></Button>
</StackPanel>
</StackPanel>
</Grid>
......
......@@ -8,6 +8,7 @@ namespace Raumverwaltung_HMWK
public partial class DeleteFloorWindow : Window
{
private List<Building> buildings;
private List<Floor> floors = new List<Floor>();
public DeleteFloorWindow()
{
......@@ -24,53 +25,65 @@ namespace Raumverwaltung_HMWK
private void DeleteFloor(object sender, RoutedEventArgs e)
{
MessageBoxResult result = MessageBox.Show("Möchten Sie das Stockwerk löschen?", "Achtung:",
MessageBoxButton.YesNo, MessageBoxImage.Question);
switch (result)
if (FloorSelection.SelectedItem != null)
{
case MessageBoxResult.Yes:
MessageBoxResult result = MessageBox.Show("Möchten Sie das Stockwerk löschen?", "Achtung:",
MessageBoxButton.YesNo, MessageBoxImage.Question);
switch (result)
{
try
{
Floor selected = (Floor) FloorSelection.SelectedItem;
SqLiteDataAccess.DeleteFloor(selected.Id);
}
catch (Exception)
case MessageBoxResult.Yes:
{
MessageBox.Show("Stockwerk konnte nicht gelöscht werden!", "Fehler:", MessageBoxButton.OK,
MessageBoxImage.Error);
}
MessageBox.Show("Stockwerk wurde gelöscht!", "Erfolgreich:", MessageBoxButton.OK,
MessageBoxImage.Information);
foreach (Window w in Application.Current.Windows)
{
if (w.Title!= "Raumverwaltung-HMWK")
try
{
w.Close();
Floor selected = floors[FloorSelection.SelectedIndex];
SqLiteDataAccess.DeleteFloor(selected.Id);
MessageBox.Show("Stockwerk wurde gelöscht!", "Erfolgreich:", MessageBoxButton.OK,
MessageBoxImage.Information);
foreach (Window w in Application.Current.Windows)
{
if (w.Title != "Raumverwaltung-HMWK")
{
w.Close();
}
else
{
w.Close();
MainWindow window = new MainWindow();
window.Show();
}
}
}
else
catch (Exception)
{
w.Close();
MainWindow window = new MainWindow();
window.Show();
MessageBox.Show("Stockwerk konnte nicht gelöscht werden!", "Fehler:", MessageBoxButton.OK,
MessageBoxImage.Error);
}
break;
}
case MessageBoxResult.No:
{
break;
}
break;
}
case MessageBoxResult.No:
{
break;
}
}
else
{
MessageBox.Show("Bitte Stockwerk auswählen!", "Fehler:", MessageBoxButton.OK,
MessageBoxImage.Error);
}
}
private void LocationSelection_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
floors.Clear();
FloorSelection.ItemsSource = null;
FloorSelection.ItemsSource = SqLiteDataAccess.GetFloorsToBuilding(buildings[LocationSelection.SelectedIndex]);
floors = SqLiteDataAccess.GetFloorsToBuilding(buildings[LocationSelection.SelectedIndex]);
}
}
......
......@@ -12,7 +12,7 @@
<ComboBox Name="LocationSelection" FontSize="15" HorizontalAlignment="Center" Width="150" Height="30" Margin="0,20"></ComboBox>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="15">
<Button Click="DeleteLocation" Content="Löschen" Margin="10,0" Width="70"></Button>
<Button Click="Abbort" Content="Abbruch" Margin="10,0" Width="70"></Button>
<Button Click="Abbort" Content="Abbrechen" Margin="10,0" Width="70"></Button>
</StackPanel>
</StackPanel>
</Grid>
......
......@@ -30,6 +30,22 @@ namespace Raumverwaltung_HMWK
try
{
SqLiteDataAccess.DeleteLocation(selected);
MessageBox.Show("Standort gelöscht!", "Erfolgreich:", MessageBoxButton.OK,
MessageBoxImage.Information);
foreach (Window w in Application.Current.Windows)
{
if (w.Title!= "Raumverwaltung-HMWK")
{
w.Close();
}
else
{
w.Close();
MainWindow window = new MainWindow();
window.Show();
}
}
}
catch (Exception)
{
......@@ -37,21 +53,6 @@ namespace Raumverwaltung_HMWK
MessageBoxImage.Information);
Close();
}
MessageBox.Show("Standort gelöscht!", "Erfolgreich:", MessageBoxButton.OK,
MessageBoxImage.Information);
foreach (Window w in Application.Current.Windows)
{
if (w.Title!= "Raumverwaltung-HMWK")
{
w.Close();
}
else
{
w.Close();
MainWindow window = new MainWindow();
window.Show();
}
}
break;
}
case MessageBoxResult.No:
......
<Window x:Class="Raumverwaltung_HMWK.DeleteRoomWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Raumverwaltung_HMWK"
mc:Ignorable="d"
Title="Raum löschen" Height="300" Width="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="75"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock FontSize="15">Wählen Sie einen Raum aus:</TextBlock>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center">
<ComboBox Width="150" Name="RoomSelection"></ComboBox>
</StackPanel>
<StackPanel Grid.Row="2" Grid.Column="0">
<Button Click="DeleteRoom" Width="100">Löschen</Button>
</StackPanel>
<StackPanel Grid.Column="1" Grid.Row="2">
<Button Click="Abbort" Width="100">Abbrechen</Button>
</StackPanel>
</Grid>
</Window>
using System.Collections.Generic;
using System.Windows;
namespace Raumverwaltung_HMWK
{
public partial class DeleteRoomWindow : Window
{
private int FloorId;
private List<Room> rooms;
public DeleteRoomWindow(int floorId)
{
FloorId = floorId;
rooms = SqLiteDataAccess.LoadRoomsToFloor(floorId);
InitializeComponent();
RoomSelection.ItemsSource = rooms;
}
private void Abbort(object sender, RoutedEventArgs e)
{
Close();
}
private void DeleteRoom(object sender, RoutedEventArgs e)
{
if (RoomSelection.SelectedItem != null)
{
MessageBoxResult result = MessageBox.Show("Sind Sie sicher, dass die den Raum löschen wollen?", "Achtung:",
MessageBoxButton.YesNo, MessageBoxImage.Question);
switch (result)
{
case MessageBoxResult.Yes:
{
Room selected = rooms[RoomSelection.SelectedIndex];
SqLiteDataAccess.DeleteRoom(selected.Id);
MessageBox.Show("Raum gelöscht!", "Erfolgreich:", MessageBoxButton.OK,
MessageBoxImage.Information);
foreach (Window w in Application.Current.Windows)
{
if (w.Title != "Raumverwaltung-HMWK")
{
w.Close();
}
else
{
w.Close();
MainWindow window = new MainWindow();
window.Show();
FloorWindow floorWindow = new FloorWindow(FloorId);
floorWindow.Show();
}
}
break;
}
case MessageBoxResult.No:
{
break;
}
}
}
else
{
MessageBox.Show("Bitte einen Raum auswählen", "Fehler:", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}
\ No newline at end of file
......@@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Raumverwaltung_HMWK"
mc:Ignorable="d"
Title="Stockwerkansicht" Height="950" Width="1100" ResizeMode="NoResize">
Height="950" Width="1100" ResizeMode="NoResize">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
......@@ -15,11 +15,25 @@
<Border Grid.Row="0" BorderThickness="1" BorderBrush="Gray"></Border>
<Border Grid.Row="1" BorderThickness="1" BorderBrush="Gray"></Border>
<Border Grid.Row="2" BorderThickness="1" BorderBrush="Gray"></Border>
<StackPanel Grid.Row="0" Orientation="Horizontal" Background="Thistle">
<Image Source="../Images/icon.PNG"/>
<TextBlock Background="Thistle" Name="Ueberschrift" FontSize="25" VerticalAlignment="Center" Margin="50,0,0,0"></TextBlock>
<Button Click="MoveButtons_OnClick" Width="130" Height="30" Margin="350,0,10,0">Buttons verschieben</Button>
<Button Click="SavePositions_OnClick" Width="130" Height="30">Positionen speichern</Button>
<StackPanel Grid.Row="0" Orientation="Horizontal" Background="Lavender">
<Menu Height="50" Width="350" Background="Lavender">
<MenuItem Height="50" Width="60">
<MenuItem.Header>
<StackPanel>
<Image Source="../Images/icon.png" Width="50" Height="50"/>
</StackPanel>
</MenuItem.Header>
</MenuItem>
<MenuItem Header="Button" Margin="10,0" FontSize="15" BorderBrush="Black" Background="Thistle">
<MenuItem Header="Verschieben" Click="MoveButtons_OnClick"/>
<MenuItem Header="Position speichern" Click="SavePositions_OnClick"/>
</MenuItem>
<MenuItem Header="Raum" Margin="10,0" FontSize="15" BorderBrush="Black" Background="Thistle">
<MenuItem Header="Anlegen" Click="AddRoom"/>
<MenuItem Header="Löschen" Click="DeleteRoom"/>
</MenuItem>
<MenuItem Header="Bild ändern" Click="ChangeImage" Margin="10,0" FontSize="15" BorderBrush="Black" Background="Thistle"></MenuItem>
</Menu>
</StackPanel>
<Canvas Name="GUI" Grid.Row="1" Margin="10" PreviewMouseMove="GUI_OnPreviewMouseMove" PreviewMouseUp="GUI_OnPreviewMouseUp">