diff --git a/ProjectHotel/ProjectHotel/Forms/FormAthlete.cs b/ProjectHotel/ProjectHotel/Forms/FormAthlete.cs
index 8ed43b9..c17ea06 100644
--- a/ProjectHotel/ProjectHotel/Forms/FormAthlete.cs
+++ b/ProjectHotel/ProjectHotel/Forms/FormAthlete.cs
@@ -38,7 +38,7 @@ public partial class FormAthlete : Form
checkedListBoxSport.SetItemChecked(checkedListBoxSport.Items.IndexOf(elem), true);
}
}
-
+ _athleteId = value;
textBoxFirstName.Text = athlete.FirstName;
textBoxLastName.Text = athlete.LastName;
textBoxFatherName.Text = athlete.FatherName;
diff --git a/ProjectHotel/ProjectHotel/Forms/FormRoom.Designer.cs b/ProjectHotel/ProjectHotel/Forms/FormRoom.Designer.cs
index 6972411..09a9f94 100644
--- a/ProjectHotel/ProjectHotel/Forms/FormRoom.Designer.cs
+++ b/ProjectHotel/ProjectHotel/Forms/FormRoom.Designer.cs
@@ -38,8 +38,10 @@
buttonCancel = new Button();
buttonSave = new Button();
comboBoxHotel = new ComboBox();
+ hotelBindingSource1 = new BindingSource(components);
((System.ComponentModel.ISupportInitialize)hotelBindingSource).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownCapacity).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)hotelBindingSource1).BeginInit();
SuspendLayout();
//
// labelHotelName
@@ -114,6 +116,10 @@
comboBoxHotel.Size = new Size(197, 23);
comboBoxHotel.TabIndex = 9;
//
+ // hotelBindingSource1
+ //
+ hotelBindingSource1.DataSource = typeof(Entities.Hotel);
+ //
// FormRoom
//
AutoScaleDimensions = new SizeF(7F, 15F);
@@ -132,6 +138,7 @@
Text = "Комната";
((System.ComponentModel.ISupportInitialize)hotelBindingSource).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownCapacity).EndInit();
+ ((System.ComponentModel.ISupportInitialize)hotelBindingSource1).EndInit();
ResumeLayout(false);
PerformLayout();
}
@@ -146,5 +153,6 @@
private Button buttonCancel;
private Button buttonSave;
private ComboBox comboBoxHotel;
+ private BindingSource hotelBindingSource1;
}
}
\ No newline at end of file
diff --git a/ProjectHotel/ProjectHotel/Forms/FormRoom.cs b/ProjectHotel/ProjectHotel/Forms/FormRoom.cs
index 8b866aa..33fc4e9 100644
--- a/ProjectHotel/ProjectHotel/Forms/FormRoom.cs
+++ b/ProjectHotel/ProjectHotel/Forms/FormRoom.cs
@@ -30,6 +30,7 @@ namespace ProjectHotel.Forms
}
textBoxRoomName.Text = room.Name;
numericUpDownCapacity.Value = room.Capacity;
+ comboBoxHotel.SelectedValue = room.HotelId;
_roomId = value;
}
catch (Exception ex)
diff --git a/ProjectHotel/ProjectHotel/Forms/FormRoom.resx b/ProjectHotel/ProjectHotel/Forms/FormRoom.resx
index b922c5b..4967353 100644
--- a/ProjectHotel/ProjectHotel/Forms/FormRoom.resx
+++ b/ProjectHotel/ProjectHotel/Forms/FormRoom.resx
@@ -141,6 +141,9 @@
True
+
+ 175, 17
+
True
diff --git a/ProjectHotel/ProjectHotel/Repositories/Implementations/AthleteRepository.cs b/ProjectHotel/ProjectHotel/Repositories/Implementations/AthleteRepository.cs
index 6a55349..8da6c5e 100644
--- a/ProjectHotel/ProjectHotel/Repositories/Implementations/AthleteRepository.cs
+++ b/ProjectHotel/ProjectHotel/Repositories/Implementations/AthleteRepository.cs
@@ -114,7 +114,7 @@ public class AthleteRepository : IAthleteRepository
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Athletes
- SET FirstName = @FirstName, LastName = @LastName, FatherName = @FatherName, @Sport = Sport, @AthleteClass = AthleteClass
+ SET FirstName = @FirstName, LastName = @LastName, FatherName = @FatherName, Sport = @Sport, AthleteClass = @AthleteClass
WHERE Id = @Id;
";
connection.Execute(queryUpdate, athlete);
diff --git a/ProjectHotel/ProjectHotel/Repositories/Implementations/RoomRepository.cs b/ProjectHotel/ProjectHotel/Repositories/Implementations/RoomRepository.cs
index 958200b..8996240 100644
--- a/ProjectHotel/ProjectHotel/Repositories/Implementations/RoomRepository.cs
+++ b/ProjectHotel/ProjectHotel/Repositories/Implementations/RoomRepository.cs
@@ -83,7 +83,24 @@ namespace ProjectHotel.Repositories.Implementations
}
public void UpdateRoom(Room rooms)
{
+ _logger.LogInformation("Редактирование объекта");
+ _logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(rooms));
+ try
+ {
+ using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
+ var queryUpdate = @"
+ UPDATE Rooms
+ SET HotelId = @HotelId, Name = @Name, Capacity = @Capacity
+ WHERE Id = @Id;
+ ";
+ connection.Execute(queryUpdate, rooms);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка при редактировании объекта");
+ throw;
+ }
}
public void DeleteRoom(int id)
{