Commit 0a08ad3f authored by Alexander Scharfenberg's avatar Alexander Scharfenberg
Browse files

last changes, app to be finished

parent 7735f02f
......@@ -90,8 +90,29 @@ namespace Raumverwaltung_HMWK
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;
if (openFileDialog.ShowDialog() == true)
{
if (openFileDialog.FileName.Contains("Images"))
{
string relative = "../../";
int startindex = openFileDialog.FileName.IndexOf("Images");
string substring = openFileDialog.FileName.Substring(startindex);
string result = relative + substring;
ImageInput.Text = result;
}
else
{
MessageBox.Show("Bild bitte aus dem Images-Ordner entnehmen", "Fehler:", MessageBoxButton.OK,
MessageBoxImage.Error);
}
}
else
{
MessageBox.Show("Einfügen fehlgeschlagen.", "Fehler:", MessageBoxButton.OK,
MessageBoxImage.Error);
}
}
}
}
\ No newline at end of file
......@@ -20,8 +20,9 @@ namespace Raumverwaltung_HMWK
string department = DepartmentInput.Text;
string referat = ReferatInput.Text;
string orga = OrgaInput.Text;
string number = NumberInput.Text;
if (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(vorname) && !String.IsNullOrEmpty(department) && !String.IsNullOrEmpty(referat) && !String.IsNullOrEmpty(orga))
if (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(vorname))
{
List<User> users = SqLiteDataAccess.LoadUsers();
bool found = false;
......@@ -37,7 +38,7 @@ namespace Raumverwaltung_HMWK
{
try
{
SqLiteDataAccess.AddUser(username, vorname, department, referat, orga);
SqLiteDataAccess.AddUser(username, vorname, department, referat, orga, number);
MessageBox.Show("Nutzer wurde angelegt!", "Erfolgreich:", MessageBoxButton.OK,
MessageBoxImage.Information);
Close();
......@@ -56,7 +57,7 @@ namespace Raumverwaltung_HMWK
}
else
{
MessageBox.Show("Ein Feld wurde nicht befüllt, Anlegen fehlgeschlagen", "Fehler:", MessageBoxButton.OK,
MessageBox.Show("Der Nutzer hat mindestens einen Vor- und Nachnamen.", "Fehler:", MessageBoxButton.OK,
MessageBoxImage.Error);
}
}
......
......@@ -26,6 +26,7 @@ namespace Raumverwaltung_HMWK
DepartmentInput.Text = selected.Department;
ReferatInput.Text = selected.Referat;
OrgaInput.Text = selected.Orga;
NumberInput.Text = selected.Number;
}
......@@ -44,7 +45,7 @@ namespace Raumverwaltung_HMWK
try
{
SqLiteDataAccess.ChangeUser(NameInput.Text, VorNameInput.Text, DepartmentInput.Text,
ReferatInput.Text, OrgaInput.Text, users[AllUsers.SelectedIndex].Id);
ReferatInput.Text, OrgaInput.Text, NumberInput.Text, users[AllUsers.SelectedIndex].Id);
MessageBox.Show("Änderung durchgeführt", "Erfolgreich:", MessageBoxButton.OK,
MessageBoxImage.Information);
foreach (Window w in Application.Current.Windows)
......
......@@ -24,7 +24,7 @@
</StackPanel>
</MenuItem.Header>
</MenuItem>
<MenuItem Header="Button" Margin="10,0" FontSize="15" BorderBrush="Black" Background="Thistle">
<MenuItem Header="Buttons" Margin="10,0" FontSize="15" BorderBrush="Black" Background="Thistle">
<MenuItem Header="Verschieben" Click="MoveButtons_OnClick"/>
<MenuItem Header="Position speichern" Click="SavePositions_OnClick"/>
</MenuItem>
......
......@@ -173,16 +173,28 @@ namespace Raumverwaltung_HMWK
openFileDialog.InitialDirectory = Path.GetFullPath(CombinedPath);
if (openFileDialog.ShowDialog() == true)
{
SqLiteDataAccess.ChangeImage(CurrentFloor.Id,openFileDialog.FileName);
MessageBox.Show("Neues Bild eingefügt!", "Erfolgreich:", MessageBoxButton.OK,
MessageBoxImage.Information);
Close();
var window = new FloorWindow(CurrentFloor.Id);
window.Show();
if (openFileDialog.FileName.Contains("Images"))
{
string relative = "../../";
int startindex = openFileDialog.FileName.IndexOf("Images");
string substring = openFileDialog.FileName.Substring(startindex);
string result = relative + substring;
SqLiteDataAccess.ChangeImage(CurrentFloor.Id,result);
MessageBox.Show("Neues Bild eingefügt!", "Erfolgreich:", MessageBoxButton.OK,
MessageBoxImage.Information);
Close();
var window = new FloorWindow(CurrentFloor.Id);
window.Show();
}
else
{
MessageBox.Show("Bild bitte aus dem Images-Ordner entnehmen", "Fehler:", MessageBoxButton.OK,
MessageBoxImage.Error);
}
}
else
{
MessageBox.Show("Einfügen hat nicht geklappt", "Fehler:", MessageBoxButton.OK,
MessageBox.Show("Einfügen fehlgeschlagen.", "Fehler:", MessageBoxButton.OK,
MessageBoxImage.Error);
}
......
......@@ -9,7 +9,6 @@
private double y;
private int maxWP;
private int floorId;
private string status;
public Room()
......@@ -58,14 +57,8 @@
get { return floorId; }
set { floorId = value; }
}
public string Status
{
get { return status; }
set { status = value; }
}
public override string ToString()
{
return name;
......
......@@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Raumverwaltung_HMWK"
mc:Ignorable="d"
Title="Raumansicht" Height="400" Width="500" ResizeMode="NoResize">
Title="Raumansicht" Height="400" Width="600" ResizeMode="NoResize">
<Grid Background="Thistle">
<Grid.RowDefinitions>
<RowDefinition Height="75"></RowDefinition>
......@@ -14,11 +14,11 @@
<RowDefinition Height="100"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="120"></ColumnDefinition>
</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>
......
......@@ -21,7 +21,7 @@ namespace Raumverwaltung_HMWK
{
using (IDbConnection cnn = new SQLiteConnection(new SQLiteConnection(LoadConnectionString())))
{
var roomoutput = cnn.Query<Room>("select Id, Name, Size, MaxWP, FloorId, Status from Room",
var roomoutput = cnn.Query<Room>("select Id, Name, Size, MaxWP, FloorId from Room",
new DynamicParameters());
var flooroutput = cnn.Query<Floor>("select Id, Name, BuildingId from Floor", new DynamicParameters());
......@@ -117,7 +117,7 @@ namespace Raumverwaltung_HMWK
using (IDbConnection cnn = new SQLiteConnection(new SQLiteConnection(LoadConnectionString())))
{
string sql =
"select Id, Vorname, Nachname, Department, Referat, Orga from User INNER JOIN Room_User ON User.Id = Room_User.UId where RId=@roomId";
"select Id, Vorname, Nachname, Department, Referat, Orga, Number from User INNER JOIN Room_User ON User.Id = Room_User.UId where RId=@roomId";
var output = cnn.Query<User>(sql, new {roomId});
ObservableCollection<User> UserList = new ObservableCollection<User>(output.ToList());
return UserList;
......@@ -163,7 +163,7 @@ namespace Raumverwaltung_HMWK
using (IDbConnection cnn = new SQLiteConnection(new SQLiteConnection(LoadConnectionString())))
{
string sql =
"select Id, Vorname, Nachname, Department, Referat, Orga from User";
"select Id, Vorname, Nachname, Department, Referat, Orga, Number from User";
var output = cnn.Query<User>(sql);
return output.ToList();
}
......@@ -250,18 +250,19 @@ namespace Raumverwaltung_HMWK
}
}
public static void AddUser(string name, string vorname, string department, string referat, string orga)
public static void AddUser(string name, string vorname, string department, string referat, string orga, string number)
{
using (IDbConnection cnn = new SQLiteConnection(new SQLiteConnection(LoadConnectionString())))
{
string sql =
"insert into User (Vorname, Nachname, Department, Referat, Orga) VALUES (@Vorname, @Nachname, @Department, @Referat, @Orga)";
"insert into User (Vorname, Nachname, Department, Referat, Orga, Number) VALUES (@Vorname, @Nachname, @Department, @Referat, @Orga, @Number)";
var dynamicParameters = new DynamicParameters();
dynamicParameters.Add("Vorname", vorname);
dynamicParameters.Add("Nachname", name);
dynamicParameters.Add("Department", department);
dynamicParameters.Add("Referat", referat);
dynamicParameters.Add("Orga", orga);
dynamicParameters.Add("Number", number);
cnn.Execute(sql, dynamicParameters);
}
......@@ -437,7 +438,7 @@ namespace Raumverwaltung_HMWK
}
public static void ChangeUser(string Nachname, string Vorname, string Department, string Referat, string Orga, int UserId)
public static void ChangeUser(string Nachname, string Vorname, string Department, string Referat, string Orga, string Number, int UserId)
{
using (IDbConnection cnn = new SQLiteConnection(new SQLiteConnection(LoadConnectionString())))
{
......@@ -447,10 +448,11 @@ namespace Raumverwaltung_HMWK
dynamicParameters.Add("Department", Department);
dynamicParameters.Add("Referat", Referat);
dynamicParameters.Add("Orga", Orga);
dynamicParameters.Add("Number", Number);
dynamicParameters.Add("UserId", UserId);
string sql =
"UPDATE User SET Vorname=@Vorname, Nachname=@Nachname, Department=@Department, Referat=@Referat, Orga=@Orga WHERE Id=@UserId";
"UPDATE User SET Vorname=@Vorname, Nachname=@Nachname, Department=@Department, Referat=@Referat, Orga=@Orga , Number=@Number WHERE Id=@UserId";
cnn.Execute(sql, dynamicParameters);
......
......@@ -57,7 +57,7 @@
public override string ToString()
{
return Nachnname+", "+Vorname+", "+Department+", "+Referat+", "+Orga;
return Nachnname+", "+Vorname+", "+Department+", "+Referat+", "+Orga+", "+Number;
}
}
}
\ No newline at end of file
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