Commit 066a9c59 authored by Alexander Scharfenberg's avatar Alexander Scharfenberg
Browse files

RoomSize changeable

parent 487c937a
......@@ -22,19 +22,20 @@
</Grid.ColumnDefinitions>
<TextBlock FontSize="15" TextAlignment="Center" VerticalAlignment="Center" Background="Lavender" Grid.Column="0" Grid.Row="0">Raum:</TextBlock>
<TextBlock FontSize="15" TextAlignment="Center" VerticalAlignment="Center" Background="Lavender" Grid.Column="1" Grid.Row="0" Name="RoomName"></TextBlock>
<TextBlock FontSize="15" TextAlignment="Center" VerticalAlignment="Center" Background="Lavender" Grid.Column="2" Grid.Row="0">Größe:</TextBlock>
<TextBlock FontSize="15" TextAlignment="Center" VerticalAlignment="Center" Background="Lavender" Grid.Column="3" Grid.Row="0" Name="RoomSize"></TextBlock>
<TextBlock FontSize="15" TextAlignment="Center" VerticalAlignment="Center" Background="Lavender" Grid.Column="2" Grid.Row="0">Größe(m²):</TextBlock>
<TextBox FontSize="15" TextAlignment="Center" VerticalAlignment="Center" Background="GhostWhite" BorderBrush="Black" Grid.Column="3" Grid.Row="0" Name="RoomSize"></TextBox>
<Button Click="ChangeSize" Grid.Column="4" Grid.Row="0" Height="30" Width="80">Größe setzen</Button>
<TextBlock FontSize="15" TextAlignment="Center" VerticalAlignment="Center" Background="Lavender" Grid.Column="0" Grid.Row="1">Arbeitsplätze:</TextBlock>
<Button Click="SetWorkplaceValue" Grid.Column="2" Grid.ColumnSpan="2" Grid.Row="1" Height="20" Width="130" Margin="30,0,0,0">Arbeitsplätze setzen</Button>
<Button Click="SetWorkplaceValue" Grid.Column="3" Grid.ColumnSpan="2" Grid.Row="1" Height="30" Width="130">Arbeitsplätze setzen</Button>
<TextBox FontSize="15" Margin="30,0,0,0" BorderBrush="Black" TextAlignment="Center" VerticalAlignment="Center" Background="GhostWhite" Grid.Column="1" Grid.Row="1" Name="Workplace"></TextBox>
<TextBlock FontSize="15" TextAlignment="Center" VerticalAlignment="Top" Background="Lavender" Grid.Column="0" Grid.Row="2" >Benutzer:</TextBlock>
<ListView Grid.Column="1" Grid.ColumnSpan="2" VerticalAlignment="Top" Grid.Row="2" Height="100" BorderBrush="Black" Name="Users"></ListView>
<Button Click="AddUser" Grid.Column="3" Grid.ColumnSpan="2" Grid.Row="2" Height="30" Width="120" Content="Benutzer hinzufügen" VerticalAlignment="Top" Margin="0,15,0,0"></Button>
<Button Click="DeleteUser" Grid.Column="3" Grid.ColumnSpan="2" Grid.Row="2" Height="30" Width="120" Content="Benutzer löschen" VerticalAlignment="Bottom" Margin="0,0,0,15"></Button>
<Button Click="AddUser" Grid.Column="3" Grid.ColumnSpan="2" Grid.Row="2" Height="30" Width="130" Content="Benutzer hinzufügen" VerticalAlignment="Top" Margin="0,15,0,0"></Button>
<Button Click="DeleteUser" Grid.Column="3" Grid.ColumnSpan="2" Grid.Row="2" Height="30" Width="130" Content="Benutzer löschen" VerticalAlignment="Bottom" Margin="0,0,0,15"></Button>
<TextBlock Grid.Column="0" Grid.Row="3" FontSize="15" TextAlignment="Center" VerticalAlignment="Top" Background="Lavender">Assets:</TextBlock>
<ListView Grid.Column="1" Grid.ColumnSpan="2" VerticalAlignment="Top" Grid.Row="3" Height="100" BorderBrush="Black" Name="Materials"></ListView>
<Button Click="AddAsset" Grid.Column="3" Grid.ColumnSpan="2" Grid.Row="3" Height="30" Width="100" Content="Asset hinzufügen" VerticalAlignment="Top" Margin="0,15,0,0"></Button>
<Button Click="DeleteAsset" Grid.Column="3" Grid.ColumnSpan="2" Grid.Row="3" Height="30" Width="100" Content="Asset löschen" VerticalAlignment="Bottom" Margin="0,0,0,15"></Button>
<Button Click="AddAsset" Grid.Column="3" Grid.ColumnSpan="2" Grid.Row="3" Height="30" Width="130" Content="Asset hinzufügen" VerticalAlignment="Top" Margin="0,15,0,0"></Button>
<Button Click="DeleteAsset" Grid.Column="3" Grid.ColumnSpan="2" Grid.Row="3" Height="30" Width="130" Content="Asset löschen" VerticalAlignment="Bottom" Margin="0,0,0,15"></Button>
</Grid>
</Window>
......@@ -59,7 +59,7 @@ namespace Raumverwaltung_HMWK
myBtn = btn;
InitializeComponent();
RoomName.Text = CurrentRoom.Name;
RoomSize.Text = CurrentRoom.Size + "m²";
RoomSize.Text = CurrentRoom.Size.ToString();
Workplace.Text = CurrentRoom.MaxWp.ToString();
//Fill Users
MyUsers = SqLiteDataAccess.LoadUsersToRoom(roomId);
......@@ -237,5 +237,31 @@ namespace Raumverwaltung_HMWK
}
}
// ändert die Raumgröße im RoomWindow. Bei Eingabe von Sonderzeichen oder Buchstaben entsteht eine Fehlermeldung.
private void ChangeSize(object sender, RoutedEventArgs e)
{
try
{
if (RoomSize.Text.Contains("."))
{
MessageBox.Show("Für Nachkommastellen bitte Komma statt Punkt verwenden.", "Fehler:",
MessageBoxButton.OK, MessageBoxImage.Error);
}
else
{
double roomsize = Double.Parse(RoomSize.Text);
SqLiteDataAccess.UpdateRoomSize(roomsize, CurrentRoom.Id);
MessageBox.Show("Raumgröße geändert!", "Erfolgreich:", MessageBoxButton.OK,
MessageBoxImage.Information);
}
}
catch (Exception)
{
MessageBox.Show("Raumgröße konnte nicht geändert werden.", "Fehler", MessageBoxButton.OK,
MessageBoxImage.Error);
}
}
}
}
\ No newline at end of file
......@@ -618,7 +618,24 @@ namespace Raumverwaltung_HMWK
}
}
/**
* <summary>
* ändert die Raumgröße zu einem bestimmten Raum
* </summary>
*/
public static void UpdateRoomSize(double roomsize, int roomId)
{
using (IDbConnection cnn = new SQLiteConnection(new SQLiteConnection(LoadConnectionString())))
{
var dynamicParameters = new DynamicParameters();
dynamicParameters.Add("roomsize", roomsize);
dynamicParameters.Add("roomId", roomId);
string sql = "UPDATE Room SET Size=@roomsize where Id=@roomId";
cnn.Execute(sql, dynamicParameters);
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment