Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Alexander Scharfenberg
Raumverwaltung_HMWK
Commits
1d3fb9a6
Commit
1d3fb9a6
authored
Oct 01, 2021
by
Alexander Scharfenberg
Browse files
old status reached
parent
dd941fdb
Changes
16
Hide whitespace changes
Inline
Side-by-side
Raumverwaltung_HMWK/AddUserToRoomWindow.xaml
View file @
1d3fb9a6
...
...
@@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Raumverwaltung_HMWK"
mc:Ignorable="d"
Title="
AddUserForRoomWindow
" Height="200" Width="300" ResizeMode="NoResize">
Title="
Nutzer auswählen
" Height="200" Width="300" ResizeMode="NoResize">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
...
...
Raumverwaltung_HMWK/AddUserToRoomWindow.xaml.cs
View file @
1d3fb9a6
...
...
@@ -32,8 +32,13 @@ namespace Raumverwaltung_HMWK
users
.
RemoveAt
(
i
);
}
}
}
for
(
int
i
=
0
;
i
<
users
.
Count
;
i
++)
{
AllUsers
.
Items
.
Add
(
users
[
i
]);
}
}
...
...
Raumverwaltung_HMWK/AddUserWindow.xaml
0 → 100644
View file @
1d3fb9a6
<Window x:Class="Raumverwaltung_HMWK.AddUserWindow"
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="Benutzer anlegen" Height="600" Width="270" ResizeMode="NoResize">
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="300"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="125"></ColumnDefinition>
<ColumnDefinition Width="125"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel HorizontalAlignment="Center" Grid.Row="0" Grid.ColumnSpan="2">
<TextBlock Margin="15">Nutzername:</TextBlock>
<TextBox Name="NameInput" BorderBrush="Black" Width="200" Height="30"></TextBox>
<TextBlock Margin="15">Abteilung:</TextBlock>
<TextBox Name="DepartmentInput" BorderBrush="Black" Width="200" Height="30"></TextBox>
<TextBlock Margin="15">Referat:</TextBlock>
<TextBox Name="ReferatInput" BorderBrush="Black" Width="200" Height="30"></TextBox>
</StackPanel>
<Button Grid.Row="1" Grid.Column="0" Click="Add_Clicked" Content="Hinzufügen" Width="100" Height="30" Margin="10"></Button>
<Button Grid.Row="1" Grid.Column="1" Click="Abort_Clicked" Content="Abbrechen" Width="100" Height="30" Margin="10"></Button>
</Grid>
</Window>
Raumverwaltung_HMWK/AddUserWindow.xaml.cs
0 → 100644
View file @
1d3fb9a6
using
System.Windows
;
namespace
Raumverwaltung_HMWK
{
public
partial
class
AddUserWindow
:
Window
{
public
AddUserWindow
()
{
InitializeComponent
();
}
private
void
Add_Clicked
(
object
sender
,
RoutedEventArgs
e
)
{
}
private
void
Abort_Clicked
(
object
sender
,
RoutedEventArgs
e
)
{
Close
();
}
}
}
\ No newline at end of file
Raumverwaltung_HMWK/DeleteUserWindow.xaml
0 → 100644
View file @
1d3fb9a6
<Window x:Class="Raumverwaltung_HMWK.DeleteUserWindow"
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="Benutzer löschen" Height="220" Width="285" ResizeMode="NoResize">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="150"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Center">
<TextBlock Margin="5,20,20,20" HorizontalAlignment="Left" FontSize="15">Nutzername:</TextBlock>
<ComboBox Name="allUsers" IsEditable="True" Width="200" Height="30"></ComboBox>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="0">
<Button Content="Löschen" Click="Click_Delete" Width="100" Height="30"></Button>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1">
<Button Click="Click_Abort" Content="Abbrechen" Width="100" Height="30"></Button>
</StackPanel>
</Grid>
</Window>
Raumverwaltung_HMWK/DeleteUserWindow.xaml.cs
0 → 100644
View file @
1d3fb9a6
using
System.Windows
;
namespace
Raumverwaltung_HMWK
{
public
partial
class
DeleteUserWindow
:
Window
{
public
DeleteUserWindow
()
{
InitializeComponent
();
}
private
void
Click_Delete
(
object
sender
,
RoutedEventArgs
e
)
{
}
private
void
Click_Abort
(
object
sender
,
RoutedEventArgs
e
)
{
}
}
}
\ No newline at end of file
Raumverwaltung_HMWK/Floor.cs
View file @
1d3fb9a6
...
...
@@ -9,7 +9,7 @@ namespace Raumverwaltung_HMWK
private
string
image
;
private
int
buildingId
;
private
List
<
Room
>
rooms
=
new
List
<
Room
>();
private
string
note
;
public
Floor
()
{
...
...
@@ -48,6 +48,12 @@ namespace Raumverwaltung_HMWK
set
{
rooms
=
value
;
}
}
public
string
Note
{
get
{
return
note
;
}
set
{
note
=
value
;
}
}
public
override
string
ToString
()
{
return
name
;
...
...
Raumverwaltung_HMWK/FloorWindow.xaml
View file @
1d3fb9a6
...
...
@@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Raumverwaltung_HMWK"
mc:Ignorable="d"
Title="
FloorWindow
" Height="950" Width="1100" ResizeMode="NoResize">
Title="
Stockwerkansicht
" Height="950" Width="1100" ResizeMode="NoResize">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
...
...
@@ -29,7 +29,7 @@
<TextBox Name="Notefield" Margin="10" Height="70" Width="850"></TextBox>
</StackPanel>
<StackPanel VerticalAlignment="Bottom" HorizontalAlignment="Center" Width="80" Height="50">
<Button Content="Speichern" ></Button>
<Button Content="Speichern"
Click="SaveNote"
></Button>
</StackPanel>
</StackPanel>
</Grid>
...
...
Raumverwaltung_HMWK/FloorWindow.xaml.cs
View file @
1d3fb9a6
...
...
@@ -21,6 +21,7 @@ namespace Raumverwaltung_HMWK
CurrentFloor
.
Rooms
=
SqLiteDataAccess
.
GetRooms
(
floorid
);
InitializeComponent
();
Ueberschrift
.
Text
=
CurrentFloor
.
Name
;
Notefield
.
Text
=
CurrentFloor
.
Note
;
if
(
String
.
IsNullOrEmpty
(
CurrentFloor
.
Image
))
{
GUI
.
Background
=
new
ImageBrush
(
new
BitmapImage
(
new
Uri
(
"../../Images/schwarz.png"
,
UriKind
.
Relative
)));
...
...
@@ -73,6 +74,7 @@ namespace Raumverwaltung_HMWK
newBtn
.
Name
=
"_"
+
room
.
Id
;
newBtn
.
FontSize
=
15
;
newBtn
.
Click
+=
ClickRoomButton
;
SetButtonColour
(
room
,
newBtn
);
GUI
.
Children
.
Add
(
newBtn
);
Canvas
.
SetLeft
(
newBtn
,
room
.
X
);
Canvas
.
SetTop
(
newBtn
,
room
.
Y
);
...
...
@@ -82,7 +84,7 @@ namespace Raumverwaltung_HMWK
public
void
ClickRoomButton
(
object
sender
,
RoutedEventArgs
e
)
{
Button
btn
=
(
Button
)
sender
;
var
window
=
new
RoomWindow
(
int
.
Parse
(
btn
.
Name
.
Remove
(
0
,
1
)));
var
window
=
new
RoomWindow
(
int
.
Parse
(
btn
.
Name
.
Remove
(
0
,
1
))
,
btn
);
window
.
Show
();
}
...
...
@@ -112,5 +114,41 @@ namespace Raumverwaltung_HMWK
MessageBox
.
Show
(
"Buttonpositionen gespeichert."
,
"Erfolgreich:"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Information
);
}
private
void
SetButtonColour
(
Room
room
,
Button
btn
)
{
int
belegt
=
SqLiteDataAccess
.
GetUserAnzahlToRoom
(
room
.
Id
);
int
gesamt
=
room
.
MaxWp
;
if
(
gesamt
==
0
)
{
btn
.
Background
=
Brushes
.
CornflowerBlue
;
}
else
{
int
differenz
=
gesamt
-
belegt
;
if
(
differenz
>
1
)
{
btn
.
Background
=
Brushes
.
SpringGreen
;
}
if
(
differenz
==
1
)
{
btn
.
Background
=
Brushes
.
Yellow
;
}
if
(
differenz
<
1
)
{
btn
.
Background
=
Brushes
.
Red
;
}
}
}
private
void
SaveNote
(
object
sender
,
RoutedEventArgs
e
)
{
SqLiteDataAccess
.
SaveNote
(
CurrentFloor
.
Id
,
Notefield
.
Text
);
MessageBox
.
Show
(
"Notiz wurde verändert."
,
"Erfolgreich:"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Information
);
}
}
}
\ No newline at end of file
Raumverwaltung_HMWK/MainWindow.xaml
View file @
1d3fb9a6
...
...
@@ -31,8 +31,8 @@
<MenuItem Header="Löschen"/>
</MenuItem>
<MenuItem Header="Benutzer">
<MenuItem Header="Anlegen"/>
<MenuItem Header="Löschen"/>
<MenuItem Header="Anlegen"
Click="AddUser"
/>
<MenuItem Header="Löschen"
Click="DeleteUser"
/>
</MenuItem>
<MenuItem Header="Hilfe"></MenuItem>
</Menu>
...
...
@@ -52,7 +52,7 @@
</StackPanel>
<StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3">
<TextBlock Text="Raumüberblick:" FontSize="15" HorizontalAlignment="Center"></TextBlock>
<ListBox Height="260" Name="RoomList">
<ListBox Height="260" Name="RoomList"
x:FieldModifier="public"
>
<ListBox.ItemTemplate>
<DataTemplate>
<WrapPanel>
...
...
Raumverwaltung_HMWK/MainWindow.xaml.cs
View file @
1d3fb9a6
...
...
@@ -9,7 +9,7 @@ namespace Raumverwaltung_HMWK
public
partial
class
MainWindow
{
p
rivate
List
<
Building
>
buildings
;
p
ublic
static
List
<
Building
>
buildings
;
public
MainWindow
()
{
buildings
=
GetBuildings
();
...
...
@@ -43,7 +43,7 @@ namespace Raumverwaltung_HMWK
}
public
List
<
Building
>
GetBuildings
()
public
static
List
<
Building
>
GetBuildings
()
{
return
SqLiteDataAccess
.
GetBuildings
();
}
...
...
@@ -88,7 +88,9 @@ namespace Raumverwaltung_HMWK
}
}
}
var
window
=
new
FloorWindow
(
floorid
);
window
.
Show
();
}
...
...
@@ -115,7 +117,7 @@ namespace Raumverwaltung_HMWK
{
Room
currentRoom
=
currentFloor
.
Rooms
[
x
];
OverViewItem
overViewItem
=
new
OverViewItem
(
currentRoom
.
Id
,
currentRoom
.
Name
,
currentRoom
.
Size
,
currentRoom
.
MaxWp
);
currentRoom
.
Size
);
overViewItems
.
Add
(
overViewItem
);
}
}
...
...
@@ -123,9 +125,21 @@ namespace Raumverwaltung_HMWK
}
RoomList
.
ItemsSource
=
overViewItems
;
}
public
void
ReloadRoomList
(
int
floorId
)
{
RoomList
.
ItemsSource
=
null
;
FillOverview
(
SqLiteDataAccess
.
GetFloor
(
floorId
).
Name
);
}
private
void
AddUser
(
object
sender
,
RoutedEventArgs
e
)
{
}
private
void
DeleteUser
(
object
sender
,
RoutedEventArgs
e
)
{
}
}
}
\ No newline at end of file
Raumverwaltung_HMWK/OverViewItem.cs
View file @
1d3fb9a6
...
...
@@ -16,12 +16,12 @@ namespace Raumverwaltung_HMWK
public
int
RealAmountUsers
{
get
;
set
;
}
public
OverViewItem
(
int
id
,
string
name
,
double
roomSize
,
int
maxWp
)
public
OverViewItem
(
int
id
,
string
name
,
double
roomSize
)
{
Id
=
id
;
RoomName
=
name
;
RoomSize
=
roomSize
;
MaxWp
=
m
axWp
;
MaxWp
=
SqLiteDataAccess
.
LoadRoom
(
id
).
M
axWp
;
RealAmountUsers
=
SqLiteDataAccess
.
GetUserAnzahlToRoom
(
id
);
if
(
MaxWp
!=
0
)
...
...
@@ -49,5 +49,6 @@ namespace Raumverwaltung_HMWK
}
}
}
\ No newline at end of file
Raumverwaltung_HMWK/Raumverwaltung_HMWK.csproj
View file @
1d3fb9a6
...
...
@@ -87,8 +87,14 @@
<Compile
Include=
"AddUserToRoomWindow.xaml.cs"
>
<DependentUpon>
AddUserToRoomWindow.xaml
</DependentUpon>
</Compile>
<Compile
Include=
"AddUserWindow.xaml.cs"
>
<DependentUpon>
AddUserWindow.xaml
</DependentUpon>
</Compile>
<Compile
Include=
"Asset.cs"
/>
<Compile
Include=
"Building.cs"
/>
<Compile
Include=
"DeleteUserWindow.xaml.cs"
>
<DependentUpon>
DeleteUserWindow.xaml
</DependentUpon>
</Compile>
<Compile
Include=
"Floor.cs"
/>
<Compile
Include=
"FloorWindow.xaml.cs"
>
<DependentUpon>
FloorWindow.xaml
</DependentUpon>
...
...
@@ -103,6 +109,8 @@
<Compile
Include=
"User.cs"
/>
<Page
Include=
"AddAssetWindow.xaml"
/>
<Page
Include=
"AddUserToRoomWindow.xaml"
/>
<Page
Include=
"AddUserWindow.xaml"
/>
<Page
Include=
"DeleteUserWindow.xaml"
/>
<Page
Include=
"FloorWindow.xaml"
/>
<Page
Include=
"MainWindow.xaml"
>
<Generator>
MSBuild:Compile
</Generator>
...
...
Raumverwaltung_HMWK/Room.cs
View file @
1d3fb9a6
...
...
@@ -9,6 +9,7 @@
private
double
y
;
private
int
maxWP
;
private
int
floorId
;
private
string
status
;
public
Room
()
...
...
@@ -57,6 +58,12 @@
get
{
return
floorId
;
}
set
{
floorId
=
value
;
}
}
public
string
Status
{
get
{
return
status
;
}
set
{
status
=
value
;
}
}
...
...
Raumverwaltung_HMWK/RoomWindow.xaml.cs
View file @
1d3fb9a6
using
System
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.Collections.Specialized
;
using
System.Windows
;
using
System.Windows.Controls
;
using
System.Windows.Media
;
namespace
Raumverwaltung_HMWK
{
public
partial
class
RoomWindow
:
Window
{
private
Button
myBtn
;
private
Room
CurrentRoom
;
private
ObservableCollection
<
User
>
MyUsers
;
private
ObservableCollection
<
Asset
>
Assets
;
public
RoomWindow
(
int
roomId
)
public
RoomWindow
(
int
roomId
,
Button
btn
)
{
CurrentRoom
=
SqLiteDataAccess
.
LoadRoom
(
roomId
);
myBtn
=
btn
;
InitializeComponent
();
RoomName
.
Text
=
CurrentRoom
.
Name
;
RoomSize
.
Text
=
CurrentRoom
.
Size
+
"m²"
;
Workplace
.
Text
=
CurrentRoom
.
MaxWp
.
ToString
();
//Fill Users
MyUsers
=
SqLiteDataAccess
.
LoadUsersToRoom
(
roomId
);
MyUsers
.
CollectionChanged
+=
OnCollectionChanged
;
Users
.
ItemsSource
=
MyUsers
;
//Fill Assets
Assets
=
SqLiteDataAccess
.
LoadAssetsToRoom
(
roomId
);
...
...
@@ -31,6 +36,8 @@ namespace Raumverwaltung_HMWK
try
{
SqLiteDataAccess
.
UpdateWorkplaces
(
CurrentRoom
.
Id
,
int
.
Parse
(
Workplace
.
Text
));
CurrentRoom
.
MaxWp
=
int
.
Parse
(
Workplace
.
Text
);
ChangeButtonColour
();
MessageBox
.
Show
(
"Obergrenze neu gesetzt."
,
"Erfolgreich:"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Information
);
}
...
...
@@ -101,5 +108,59 @@ namespace Raumverwaltung_HMWK
}
}
private
void
ChangeButtonColour
()
{
int
belegt
=
MyUsers
.
Count
;
int
gesamt
=
CurrentRoom
.
MaxWp
;
if
(
gesamt
==
0
)
{
myBtn
.
Background
=
Brushes
.
CornflowerBlue
;
SqLiteDataAccess
.
UpdateStatusForRoom
(
"../../Images.blau.png"
,
CurrentRoom
.
Id
);
}
else
{
int
differenz
=
gesamt
-
belegt
;
if
(
differenz
>
1
)
{
myBtn
.
Background
=
Brushes
.
SpringGreen
;
SqLiteDataAccess
.
UpdateStatusForRoom
(
"../../Images.grün.png"
,
CurrentRoom
.
Id
);
}
if
(
differenz
==
1
)
{
myBtn
.
Background
=
Brushes
.
Yellow
;
SqLiteDataAccess
.
UpdateStatusForRoom
(
"../../Images.gelb.png"
,
CurrentRoom
.
Id
);
}
if
(
differenz
<
1
)
{
myBtn
.
Background
=
Brushes
.
Red
;
SqLiteDataAccess
.
UpdateStatusForRoom
(
"../../Images.rot.png"
,
CurrentRoom
.
Id
);
}
}
foreach
(
Window
window
in
Application
.
Current
.
Windows
)
{
if
(
window
.
GetType
()
==
typeof
(
MainWindow
))
{
(
window
as
MainWindow
).
ReloadRoomList
(
CurrentRoom
.
FloorId
);
}
}
}
void
OnCollectionChanged
(
object
sender
,
NotifyCollectionChangedEventArgs
e
)
{
//Get the sender observable collection
NotifyCollectionChangedAction
action
=
e
.
Action
;
if
(
action
==
NotifyCollectionChangedAction
.
Add
||
action
==
NotifyCollectionChangedAction
.
Remove
)
{
ChangeButtonColour
();
}
}
}
}
\ No newline at end of file
Raumverwaltung_HMWK/SqLiteDataAccess.cs
View file @
1d3fb9a6
...
...
@@ -23,7 +23,7 @@ namespace Raumverwaltung_HMWK
{
using
(
IDbConnection
cnn
=
new
SQLiteConnection
(
new
SQLiteConnection
(
LoadConnectionString
())))
{
var
roomoutput
=
cnn
.
Query
<
Room
>(
"select Id, Name, Size, MaxWP, FloorId from Room"
,
var
roomoutput
=
cnn
.
Query
<
Room
>(
"select Id, Name, Size, MaxWP, FloorId
, Status
from Room"
,
new
DynamicParameters
());
var
flooroutput
=
cnn
.
Query
<
Floor
>(
"select Id, Name, BuildingId from Floor"
,
new
DynamicParameters
());
...
...
@@ -75,7 +75,7 @@ namespace Raumverwaltung_HMWK
{
using
(
IDbConnection
cnn
=
new
SQLiteConnection
(
new
SQLiteConnection
(
LoadConnectionString
())))
{
string
sql
=
"select Id, Name, Image, BuildingId from Floor where Id = @floorId"
;
string
sql
=
"select Id, Name, Image, BuildingId
, Note
from Floor where Id = @floorId"
;
Floor
floor
=
cnn
.
Query
<
Floor
>(
sql
,
new
{
floorId
}).
First
();
return
floor
;
}
...
...
@@ -216,6 +216,30 @@ namespace Raumverwaltung_HMWK
return
Convert
.
ToInt32
(
cnn
.
ExecuteScalar
(
sql
));
}
}
public
static
void
UpdateStatusForRoom
(
string
status
,
int
roomId
)
{
using
(
IDbConnection
cnn
=
new
SQLiteConnection
(
new
SQLiteConnection
(
LoadConnectionString
())))
{
string
sql
=
"update Room set Status=@status where Id=@roomId"
;
var
dynamicParameters
=
new
DynamicParameters
();
dynamicParameters
.
Add
(
"status"
,
status
);
dynamicParameters
.
Add
(
"roomId"
,
roomId
);
cnn
.
Execute
(
sql
,
dynamicParameters
);
}
}
public
static
void
SaveNote
(
int
floorId
,
string
text
)
{
using
(
IDbConnection
cnn
=
new
SQLiteConnection
(
new
SQLiteConnection
(
LoadConnectionString
())))
{
string
sql
=
"update Floor set Note=@text where Id=@floorId"
;
var
dynamicParameters
=
new
DynamicParameters
();
dynamicParameters
.
Add
(
"text"
,
text
);
dynamicParameters
.
Add
(
"floorId"
,
floorId
);
cnn
.
Execute
(
sql
,
dynamicParameters
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment