Лаба 4
This commit is contained in:
parent
600333fc6d
commit
9a391bf270
37
Hotel/Hotel.sln
Normal file
37
Hotel/Hotel.sln
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.9.34728.123
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotelAbstractions", "HotelAbstractions\HotelAbstractions.csproj", "{AD9AAD7D-EC52-40B5-A34A-8B80AD8618C8}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotelDatabase", "HotelDatabase\HotelDatabase.csproj", "{AB783669-67D3-48DC-9930-D4A59F923E26}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotelView", "HotelView\HotelView.csproj", "{890038F3-3A65-4292-A852-E8536002E78E}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{AD9AAD7D-EC52-40B5-A34A-8B80AD8618C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{AD9AAD7D-EC52-40B5-A34A-8B80AD8618C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{AD9AAD7D-EC52-40B5-A34A-8B80AD8618C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{AD9AAD7D-EC52-40B5-A34A-8B80AD8618C8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{AB783669-67D3-48DC-9930-D4A59F923E26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{AB783669-67D3-48DC-9930-D4A59F923E26}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{AB783669-67D3-48DC-9930-D4A59F923E26}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{AB783669-67D3-48DC-9930-D4A59F923E26}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{890038F3-3A65-4292-A852-E8536002E78E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{890038F3-3A65-4292-A852-E8536002E78E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{890038F3-3A65-4292-A852-E8536002E78E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{890038F3-3A65-4292-A852-E8536002E78E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {B24EC819-5956-474C-AF03-0172E3CA0554}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
9
Hotel/HotelAbstractions/HotelAbstractions.csproj
Normal file
9
Hotel/HotelAbstractions/HotelAbstractions.csproj
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
22
Hotel/HotelAbstractions/Logic/IGuestLogic.cs
Normal file
22
Hotel/HotelAbstractions/Logic/IGuestLogic.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using HotelAbstractions.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelAbstractions.Logic
|
||||||
|
{
|
||||||
|
public interface IGuestLogic
|
||||||
|
{
|
||||||
|
List<Guest> GetAll();
|
||||||
|
|
||||||
|
Guest? Get(int id);
|
||||||
|
|
||||||
|
Guest? Create(Guest guest);
|
||||||
|
|
||||||
|
Guest? Update(Guest guest);
|
||||||
|
|
||||||
|
Guest? Delete(int id);
|
||||||
|
}
|
||||||
|
}
|
24
Hotel/HotelAbstractions/Logic/IHotelLogic.cs
Normal file
24
Hotel/HotelAbstractions/Logic/IHotelLogic.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using HotelAbstractions.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelAbstractions.Logic
|
||||||
|
{
|
||||||
|
public interface IHotelLogic
|
||||||
|
{
|
||||||
|
List<Hotel> GetAll();
|
||||||
|
|
||||||
|
Hotel? Get(int id);
|
||||||
|
|
||||||
|
Hotel? Create(Hotel hotel);
|
||||||
|
|
||||||
|
Hotel? CreateId(Hotel hotel);
|
||||||
|
|
||||||
|
Hotel? Update(Hotel hotel);
|
||||||
|
|
||||||
|
Hotel? Delete(int id);
|
||||||
|
}
|
||||||
|
}
|
22
Hotel/HotelAbstractions/Logic/IReservationLogic.cs
Normal file
22
Hotel/HotelAbstractions/Logic/IReservationLogic.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using HotelAbstractions.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelAbstractions.Logic
|
||||||
|
{
|
||||||
|
public interface IReservationLogic
|
||||||
|
{
|
||||||
|
List<Reservation> GetAll();
|
||||||
|
|
||||||
|
Reservation? Get(int id);
|
||||||
|
|
||||||
|
Reservation? Create(Reservation reservation);
|
||||||
|
|
||||||
|
Reservation? Update(Reservation reservation);
|
||||||
|
|
||||||
|
Reservation? Delete(int id);
|
||||||
|
}
|
||||||
|
}
|
22
Hotel/HotelAbstractions/Logic/IRoomLogic.cs
Normal file
22
Hotel/HotelAbstractions/Logic/IRoomLogic.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using HotelAbstractions.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelAbstractions.Logic
|
||||||
|
{
|
||||||
|
public interface IRoomLogic
|
||||||
|
{
|
||||||
|
List<Room> GetAll();
|
||||||
|
|
||||||
|
Room? Get(int id);
|
||||||
|
|
||||||
|
Room? Create(Room room);
|
||||||
|
|
||||||
|
Room? Update(Room room);
|
||||||
|
|
||||||
|
Room? Delete(int id);
|
||||||
|
}
|
||||||
|
}
|
22
Hotel/HotelAbstractions/Logic/IServiceCheckLogic.cs
Normal file
22
Hotel/HotelAbstractions/Logic/IServiceCheckLogic.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using HotelAbstractions.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelAbstractions.Logic
|
||||||
|
{
|
||||||
|
public interface IServiceCheckLogic
|
||||||
|
{
|
||||||
|
List<ServiceCheck> GetAll();
|
||||||
|
|
||||||
|
ServiceCheck? Get(int id);
|
||||||
|
|
||||||
|
ServiceCheck? Create(ServiceCheck serviceCheck);
|
||||||
|
|
||||||
|
ServiceCheck? Update(ServiceCheck serviceCheck);
|
||||||
|
|
||||||
|
ServiceCheck? Delete(int id);
|
||||||
|
}
|
||||||
|
}
|
22
Hotel/HotelAbstractions/Logic/IServiceLogic.cs
Normal file
22
Hotel/HotelAbstractions/Logic/IServiceLogic.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using HotelAbstractions.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelAbstractions.Logic
|
||||||
|
{
|
||||||
|
public interface IServiceLogic
|
||||||
|
{
|
||||||
|
List<Service> GetAll();
|
||||||
|
|
||||||
|
Service? Get(int id);
|
||||||
|
|
||||||
|
Service? Create(Service service);
|
||||||
|
|
||||||
|
Service? Update(Service service);
|
||||||
|
|
||||||
|
Service? Delete(int id);
|
||||||
|
}
|
||||||
|
}
|
15
Hotel/HotelAbstractions/Models/GenderEnum.cs
Normal file
15
Hotel/HotelAbstractions/Models/GenderEnum.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelAbstractions.Models
|
||||||
|
{
|
||||||
|
public enum GenderEnum
|
||||||
|
{
|
||||||
|
Мужской,
|
||||||
|
Женский,
|
||||||
|
Другое
|
||||||
|
}
|
||||||
|
}
|
18
Hotel/HotelAbstractions/Models/Guest.cs
Normal file
18
Hotel/HotelAbstractions/Models/Guest.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelAbstractions.Models
|
||||||
|
{
|
||||||
|
public class Guest
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string FIO { get; set; } = string.Empty;
|
||||||
|
public string PhoneNumber { get; set; } = string.Empty;
|
||||||
|
public DateOnly BirthDate { get; set; }
|
||||||
|
public string PassportId { get; set; } = string.Empty;
|
||||||
|
public GenderEnum Gender { get; set; }
|
||||||
|
}
|
||||||
|
}
|
17
Hotel/HotelAbstractions/Models/Hotel.cs
Normal file
17
Hotel/HotelAbstractions/Models/Hotel.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelAbstractions.Models
|
||||||
|
{
|
||||||
|
public class Hotel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string HotelName { get; set; } = string.Empty;
|
||||||
|
public string Address { get; set; } = string.Empty;
|
||||||
|
public int CountStar { get; set; }
|
||||||
|
public int CountRoom { get; set; }
|
||||||
|
}
|
||||||
|
}
|
18
Hotel/HotelAbstractions/Models/Reservation.cs
Normal file
18
Hotel/HotelAbstractions/Models/Reservation.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelAbstractions.Models
|
||||||
|
{
|
||||||
|
public class Reservation
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int GuestId { get; set; }
|
||||||
|
public int RoomId { get; set; }
|
||||||
|
public DateOnly ArrivalDate { get; set; }
|
||||||
|
public DateOnly DepartureDate { get; set; }
|
||||||
|
public double Price { get; set; }
|
||||||
|
}
|
||||||
|
}
|
25
Hotel/HotelAbstractions/Models/Room.cs
Normal file
25
Hotel/HotelAbstractions/Models/Room.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelAbstractions.Models
|
||||||
|
{
|
||||||
|
public class Room
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public int HotelId { get; set; }
|
||||||
|
|
||||||
|
public string Category { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int CountPlace { get; set; }
|
||||||
|
|
||||||
|
public int Flor { get; set; }
|
||||||
|
|
||||||
|
public string Number { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public double Price { get; set; }
|
||||||
|
}
|
||||||
|
}
|
15
Hotel/HotelAbstractions/Models/Service.cs
Normal file
15
Hotel/HotelAbstractions/Models/Service.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelAbstractions.Models
|
||||||
|
{
|
||||||
|
public class Service
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public double Price { get; set; }
|
||||||
|
}
|
||||||
|
}
|
17
Hotel/HotelAbstractions/Models/ServiceCheck.cs
Normal file
17
Hotel/HotelAbstractions/Models/ServiceCheck.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelAbstractions.Models
|
||||||
|
{
|
||||||
|
public class ServiceCheck
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int ReservationId { get; set; }
|
||||||
|
public int ServiceId { get; set; }
|
||||||
|
public int Count { get; set; }
|
||||||
|
public DateTime DateTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
17
Hotel/HotelDatabase/HotelDatabase.csproj
Normal file
17
Hotel/HotelDatabase/HotelDatabase.csproj
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Npgsql" Version="8.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\HotelAbstractions\HotelAbstractions.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
98
Hotel/HotelDatabase/Implement/GuestImplement.cs
Normal file
98
Hotel/HotelDatabase/Implement/GuestImplement.cs
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
using HotelAbstractions.Logic;
|
||||||
|
using HotelAbstractions.Models;
|
||||||
|
using Npgsql;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelDatabase.Implement
|
||||||
|
{
|
||||||
|
public class GuestImplement : IGuestLogic
|
||||||
|
{
|
||||||
|
public Guest? Create(Guest guest)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand("INSERT INTO guest (full_name, phone_number, birth_date, passport_id, gender) VALUES (@Full_name, @Phone_number, @Birth_date, @Passport_id, @Gender)", con);
|
||||||
|
cmd.Parameters.AddWithValue("@Full_name", guest.FIO);
|
||||||
|
cmd.Parameters.AddWithValue("@Phone_number", guest.PhoneNumber);
|
||||||
|
cmd.Parameters.AddWithValue("@Birth_date", guest.BirthDate);
|
||||||
|
cmd.Parameters.AddWithValue("@Passport_id", guest.PassportId);
|
||||||
|
cmd.Parameters.AddWithValue("@Gender", guest.Gender.ToString());
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
return guest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Guest? Delete(int id)
|
||||||
|
{
|
||||||
|
var element = Get(id);
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"DELETE FROM guest WHERE guest_id = {id}", con);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Guest? Get(int id)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"SELECT * FROM guest WHERE guest_id = {id}", con);
|
||||||
|
using var reader = cmd.ExecuteReader();
|
||||||
|
if (reader.Read())
|
||||||
|
{
|
||||||
|
return new Guest
|
||||||
|
{
|
||||||
|
Id = reader.GetInt32(0),
|
||||||
|
FIO = reader.GetString(1),
|
||||||
|
PhoneNumber = reader.GetString(2),
|
||||||
|
BirthDate = ToDateOnly(reader.GetDateTime(3)),
|
||||||
|
PassportId = reader.GetString(4),
|
||||||
|
Gender = (GenderEnum)Enum.Parse(typeof(GenderEnum), reader.GetString(5)),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Guest> GetAll()
|
||||||
|
{
|
||||||
|
var guests = new List<Guest>();
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand("SELECT * FROM guest order by guest_id", con);
|
||||||
|
using var reader = cmd.ExecuteReader();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
guests.Add(new Guest
|
||||||
|
{
|
||||||
|
Id = reader.GetInt32(0),
|
||||||
|
FIO = reader.GetString(1),
|
||||||
|
PhoneNumber = reader.GetString(2),
|
||||||
|
BirthDate = ToDateOnly(reader.GetDateTime(3)),
|
||||||
|
PassportId = reader.GetString(4),
|
||||||
|
Gender = (GenderEnum)Enum.Parse(typeof(GenderEnum), reader.GetString(5)),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return guests;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Guest? Update(Guest guest)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"UPDATE guest SET full_name = '{guest.FIO}', phone_number = '{guest.PhoneNumber}', birth_date = '{guest.BirthDate}', passport_id = '{guest.PassportId}', gender = '{guest.Gender}' WHERE guest_id = '{guest.Id}'", con);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
var element = Get(guest.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateOnly ToDateOnly (DateTime dateTime)
|
||||||
|
{
|
||||||
|
var DateTime = dateTime;
|
||||||
|
var Date = new DateOnly(DateTime.Year, DateTime.Month, DateTime.Day);
|
||||||
|
return Date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
102
Hotel/HotelDatabase/Implement/HotelImplement.cs
Normal file
102
Hotel/HotelDatabase/Implement/HotelImplement.cs
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
using HotelAbstractions.Logic;
|
||||||
|
using HotelAbstractions.Models;
|
||||||
|
using Npgsql;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelDatabase.Implement
|
||||||
|
{
|
||||||
|
public class HotelImplement : IHotelLogic
|
||||||
|
{
|
||||||
|
public Hotel? Create(Hotel hotel)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand("INSERT INTO hotel (name, address, count_star, count_room) VALUES (@Name, @Address, @Count_star, @Count_room)", con);
|
||||||
|
cmd.Parameters.AddWithValue("@Name", hotel.HotelName);
|
||||||
|
cmd.Parameters.AddWithValue("@Address", hotel.Address);
|
||||||
|
cmd.Parameters.AddWithValue("@Count_star", hotel.CountStar);
|
||||||
|
cmd.Parameters.AddWithValue("@Count_room", hotel.CountRoom);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
return hotel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Hotel? CreateId(Hotel hotel)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand("INSERT INTO hotel (hotel_id, name, address, count_star, count_room) VALUES (@Hotel_id, @Name, @Address, @Count_star, @Count_room)", con);
|
||||||
|
cmd.Parameters.AddWithValue("@Hotel_id", hotel.Id);
|
||||||
|
cmd.Parameters.AddWithValue("@Name", hotel.HotelName);
|
||||||
|
cmd.Parameters.AddWithValue("@Address", hotel.Address);
|
||||||
|
cmd.Parameters.AddWithValue("@Count_star", hotel.CountStar);
|
||||||
|
cmd.Parameters.AddWithValue("@Count_room", hotel.CountRoom);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
return hotel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Hotel? Delete(int id)
|
||||||
|
{
|
||||||
|
var element = Get(id);
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"DELETE FROM hotel WHERE hotel_id = {id}", con);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Hotel? Get(int id)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"SELECT * FROM hotel WHERE hotel_id = {id}", con);
|
||||||
|
using var reader = cmd.ExecuteReader();
|
||||||
|
if (reader.Read())
|
||||||
|
{
|
||||||
|
return new Hotel
|
||||||
|
{
|
||||||
|
Id = reader.GetInt32(0),
|
||||||
|
HotelName = reader.GetString(1),
|
||||||
|
Address = reader.GetString(2),
|
||||||
|
CountStar = reader.GetInt32(3),
|
||||||
|
CountRoom = reader.GetInt32(4),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Hotel> GetAll()
|
||||||
|
{
|
||||||
|
var hotels = new List<Hotel>();
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand("SELECT * FROM hotel order by hotel_id", con);
|
||||||
|
using var reader = cmd.ExecuteReader();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
hotels.Add(new Hotel
|
||||||
|
{
|
||||||
|
Id = reader.GetInt32(0),
|
||||||
|
HotelName = reader.GetString(1),
|
||||||
|
Address = reader.GetString(2),
|
||||||
|
CountStar = reader.GetInt32(3),
|
||||||
|
CountRoom = reader.GetInt32(4),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return hotels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Hotel? Update(Hotel hotel)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"UPDATE hotel SET name = '{hotel.HotelName}', address = '{hotel.Address}', count_star = '{hotel.CountStar}', count_room = '{hotel.CountRoom}' WHERE hotel_id = '{hotel.Id}'", con);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
var element = Get(hotel.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
110
Hotel/HotelDatabase/Implement/ReservationImplement.cs
Normal file
110
Hotel/HotelDatabase/Implement/ReservationImplement.cs
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
using HotelAbstractions.Logic;
|
||||||
|
using HotelAbstractions.Models;
|
||||||
|
using Npgsql;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelDatabase.Implement
|
||||||
|
{
|
||||||
|
public class ReservationImplement : IReservationLogic
|
||||||
|
{
|
||||||
|
public Reservation? Create(Reservation reservation)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand(
|
||||||
|
"INSERT INTO reservation (fk_room_id, fk_guest_id, arrival_date, departure_date, price)" +
|
||||||
|
" VALUES (@FKRoom_id, @FKGuest_id, @Arrival_date, @Departure_date, @Price)",
|
||||||
|
con
|
||||||
|
);
|
||||||
|
cmd.Parameters.AddWithValue("@FKRoom_id", reservation.RoomId == 0 ? DBNull.Value : reservation.RoomId);
|
||||||
|
cmd.Parameters.AddWithValue("@FKGuest_id", reservation.GuestId == 0 ? DBNull.Value : reservation.GuestId);
|
||||||
|
cmd.Parameters.AddWithValue("@Arrival_date", reservation.ArrivalDate);
|
||||||
|
cmd.Parameters.AddWithValue("@Departure_date", reservation.DepartureDate);
|
||||||
|
cmd.Parameters.AddWithValue("@Price", reservation.Price);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
return reservation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Reservation? Delete(int id)
|
||||||
|
{
|
||||||
|
var element = Get(id);
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"DELETE FROM reservation WHERE reservation_id = {id}", con);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Reservation? Get(int id)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"SELECT * FROM reservation WHERE reservation_id = {id}", con);
|
||||||
|
using var reader = cmd.ExecuteReader();
|
||||||
|
if (reader.Read())
|
||||||
|
{
|
||||||
|
return new Reservation
|
||||||
|
{
|
||||||
|
Id = reader.GetInt32(0),
|
||||||
|
RoomId = !reader.IsDBNull(1) ? reader.GetInt32(1) : 0,
|
||||||
|
GuestId = !reader.IsDBNull(2) ? reader.GetInt32(2) : 0,
|
||||||
|
ArrivalDate = ToDateOnly(reader.GetDateTime(3)),
|
||||||
|
DepartureDate = ToDateOnly(reader.GetDateTime(4)),
|
||||||
|
Price = reader.GetDouble(5),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Reservation> GetAll()
|
||||||
|
{
|
||||||
|
var reservations = new List<Reservation>();
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand("SELECT * FROM reservation order by reservation_id", con);
|
||||||
|
using var reader = cmd.ExecuteReader();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
reservations.Add(new Reservation
|
||||||
|
{
|
||||||
|
Id = reader.GetInt32(0),
|
||||||
|
RoomId = !reader.IsDBNull(1) ? reader.GetInt32(1) : 0,
|
||||||
|
GuestId = !reader.IsDBNull(2) ? reader.GetInt32(2) : 0,
|
||||||
|
ArrivalDate = ToDateOnly(reader.GetDateTime(3)),
|
||||||
|
DepartureDate = ToDateOnly(reader.GetDateTime(4)),
|
||||||
|
Price = reader.GetDouble(5),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return reservations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Reservation? Update(Reservation reservation)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"UPDATE reservation SET " +
|
||||||
|
$"fk_room_id = @FKHotel_Id, " +
|
||||||
|
$"fk_guest_id = @FKGuest_Id, " +
|
||||||
|
$"arrival_date = '{reservation.ArrivalDate}', " +
|
||||||
|
$"departure_date = '{reservation.DepartureDate}', " +
|
||||||
|
$"price = '{reservation.Price}' " +
|
||||||
|
$"WHERE reservation_id = {reservation.Id}", con);
|
||||||
|
cmd.Parameters.AddWithValue("@FKRoom_Id", reservation.RoomId == 0 ? DBNull.Value : reservation.RoomId);
|
||||||
|
cmd.Parameters.AddWithValue("@FKGuest_Id", reservation.GuestId == 0 ? DBNull.Value : reservation.GuestId);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
var element = Get(reservation.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateOnly ToDateOnly(DateTime dateTime)
|
||||||
|
{
|
||||||
|
var DateTime = dateTime;
|
||||||
|
var Date = new DateOnly(DateTime.Year, DateTime.Month, DateTime.Day);
|
||||||
|
return Date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
106
Hotel/HotelDatabase/Implement/RoomImplement.cs
Normal file
106
Hotel/HotelDatabase/Implement/RoomImplement.cs
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
using HotelAbstractions.Logic;
|
||||||
|
using HotelAbstractions.Models;
|
||||||
|
using Npgsql;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelDatabase.Implement
|
||||||
|
{
|
||||||
|
public class RoomImplement : IRoomLogic
|
||||||
|
{
|
||||||
|
public Room? Create(Room room)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand(
|
||||||
|
"INSERT INTO room (fk_hotel_id, category, count_place, flor, room_number, price)" +
|
||||||
|
" VALUES (@FKHotel_id, @Category, @Count_place, @Flor, @Room_number, @Price)",
|
||||||
|
con
|
||||||
|
);
|
||||||
|
cmd.Parameters.AddWithValue("@FKHotel_id", room.HotelId == 0 ? DBNull.Value : room.HotelId);
|
||||||
|
cmd.Parameters.AddWithValue("@Category", room.Category);
|
||||||
|
cmd.Parameters.AddWithValue("@Count_place", room.CountPlace);
|
||||||
|
cmd.Parameters.AddWithValue("@Flor", room.Flor);
|
||||||
|
cmd.Parameters.AddWithValue("@Room_number", room.Number);
|
||||||
|
cmd.Parameters.AddWithValue("@Price", room.Price);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
return room;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Room? Delete(int id)
|
||||||
|
{
|
||||||
|
var element = Get(id);
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"DELETE FROM room WHERE room_id = {id}", con);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Room? Get(int id)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"SELECT * FROM room WHERE room_id = {id}", con);
|
||||||
|
using var reader = cmd.ExecuteReader();
|
||||||
|
if (reader.Read())
|
||||||
|
{
|
||||||
|
return new Room
|
||||||
|
{
|
||||||
|
Id = reader.GetInt32(0),
|
||||||
|
HotelId = !reader.IsDBNull(1) ? reader.GetInt32(1) : 0,
|
||||||
|
Category = reader.GetString(2),
|
||||||
|
CountPlace = reader.GetInt32(3),
|
||||||
|
Flor = reader.GetInt32(4),
|
||||||
|
Number = reader.GetString(5),
|
||||||
|
Price = reader.GetDouble(6),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Room> GetAll()
|
||||||
|
{
|
||||||
|
var rooms = new List<Room>();
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand("SELECT * FROM room order by room_id", con);
|
||||||
|
using var reader = cmd.ExecuteReader();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
rooms.Add(new Room
|
||||||
|
{
|
||||||
|
Id = reader.GetInt32(0),
|
||||||
|
HotelId = !reader.IsDBNull(1) ? reader.GetInt32(1) : 0,
|
||||||
|
Category = reader.GetString(2),
|
||||||
|
CountPlace = reader.GetInt32(3),
|
||||||
|
Flor = reader.GetInt32(4),
|
||||||
|
Number = reader.GetString(5),
|
||||||
|
Price = reader.GetDouble(6),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return rooms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Room? Update(Room room)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"UPDATE room SET " +
|
||||||
|
$"fk_hotel_id = @FKHotel_Id, " +
|
||||||
|
$"category = '{room.Category}', " +
|
||||||
|
$"count_place = '{room.CountPlace}', " +
|
||||||
|
$"flor = '{room.Flor}', " +
|
||||||
|
$"room_number = '{room.Number}', " +
|
||||||
|
$"price = '{room.Price}' " +
|
||||||
|
$"WHERE room_id = {room.Id}", con);
|
||||||
|
cmd.Parameters.AddWithValue("@FKHotel_Id", room.HotelId == 0 ? DBNull.Value : room.HotelId);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
var element = Get(room.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
99
Hotel/HotelDatabase/Implement/ServiceCheckImplement.cs
Normal file
99
Hotel/HotelDatabase/Implement/ServiceCheckImplement.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using HotelAbstractions.Logic;
|
||||||
|
using HotelAbstractions.Models;
|
||||||
|
using Npgsql;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelDatabase.Implement
|
||||||
|
{
|
||||||
|
public class ServiceCheckImplement : IServiceCheckLogic
|
||||||
|
{
|
||||||
|
public ServiceCheck? Create(ServiceCheck serviceCheck)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand(
|
||||||
|
"INSERT INTO service_check (fk_reservation_id, fk_service_id, count, service_date)" +
|
||||||
|
" VALUES (@FKReservation_id, @FKService_id, @Count, @Service_date)",
|
||||||
|
con
|
||||||
|
);
|
||||||
|
cmd.Parameters.AddWithValue("@FKReservation_id", serviceCheck.ReservationId == 0 ? DBNull.Value : serviceCheck.ReservationId);
|
||||||
|
cmd.Parameters.AddWithValue("@FKService_id", serviceCheck.ServiceId == 0 ? DBNull.Value : serviceCheck.ServiceId);
|
||||||
|
cmd.Parameters.AddWithValue("@Count", serviceCheck.Count);
|
||||||
|
cmd.Parameters.AddWithValue("@Service_date", serviceCheck.DateTime);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
return serviceCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServiceCheck? Delete(int id)
|
||||||
|
{
|
||||||
|
var element = Get(id);
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"DELETE FROM service_check WHERE service_check_id = {id}", con);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServiceCheck? Get(int id)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"SELECT * FROM service_check WHERE service_check_id = {id}", con);
|
||||||
|
using var reader = cmd.ExecuteReader();
|
||||||
|
if (reader.Read())
|
||||||
|
{
|
||||||
|
return new ServiceCheck
|
||||||
|
{
|
||||||
|
Id = reader.GetInt32(0),
|
||||||
|
ReservationId = !reader.IsDBNull(1) ? reader.GetInt32(1) : 0,
|
||||||
|
ServiceId = !reader.IsDBNull(2) ? reader.GetInt32(2) : 0,
|
||||||
|
Count = reader.GetInt32(3),
|
||||||
|
DateTime = reader.GetDateTime(4),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ServiceCheck> GetAll()
|
||||||
|
{
|
||||||
|
var serviceChecks = new List<ServiceCheck>();
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand("SELECT * FROM service_check order by service_check_id", con);
|
||||||
|
using var reader = cmd.ExecuteReader();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
serviceChecks.Add(new ServiceCheck
|
||||||
|
{
|
||||||
|
Id = reader.GetInt32(0),
|
||||||
|
ReservationId = !reader.IsDBNull(1) ? reader.GetInt32(1) : 0,
|
||||||
|
ServiceId = !reader.IsDBNull(2) ? reader.GetInt32(2) : 0,
|
||||||
|
Count = reader.GetInt32(3),
|
||||||
|
DateTime = reader.GetDateTime(4),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return serviceChecks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServiceCheck? Update(ServiceCheck serviceCheck)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"UPDATE service_check SET " +
|
||||||
|
$"fk_reservation_id = @FKReservation_Id, " +
|
||||||
|
$"fk_service_id = @FKService_Id, " +
|
||||||
|
$"count = '{serviceCheck.Count}', " +
|
||||||
|
$"service_date = '{serviceCheck.DateTime}', " +
|
||||||
|
$"WHERE service_check_id = '{serviceCheck.Id}' ", con);
|
||||||
|
cmd.Parameters.AddWithValue("@FKReservation_Id", serviceCheck.ReservationId == 0 ? DBNull.Value : serviceCheck.ReservationId);
|
||||||
|
cmd.Parameters.AddWithValue("@FKService_Id", serviceCheck.ServiceId == 0 ? DBNull.Value : serviceCheck.ServiceId);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
var element = Get(serviceCheck.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
82
Hotel/HotelDatabase/Implement/ServiceImplement.cs
Normal file
82
Hotel/HotelDatabase/Implement/ServiceImplement.cs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
using HotelAbstractions.Logic;
|
||||||
|
using HotelAbstractions.Models;
|
||||||
|
using Npgsql;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HotelDatabase.Implement
|
||||||
|
{
|
||||||
|
public class ServiceImplement : IServiceLogic
|
||||||
|
{
|
||||||
|
public Service? Create(Service service)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand("INSERT INTO service (name, price) VALUES (@Name, @Price)", con);
|
||||||
|
cmd.Parameters.AddWithValue("@Name", service.Name);
|
||||||
|
cmd.Parameters.AddWithValue("@Price", service.Price);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Service? Delete(int id)
|
||||||
|
{
|
||||||
|
var element = Get(id);
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"DELETE FROM service WHERE service_id = {id}", con);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Service? Get(int id)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"SELECT * FROM service WHERE service_id = {id}", con);
|
||||||
|
using var reader = cmd.ExecuteReader();
|
||||||
|
if (reader.Read())
|
||||||
|
{
|
||||||
|
return new Service
|
||||||
|
{
|
||||||
|
Id = reader.GetInt32(0),
|
||||||
|
Name = reader.GetString(1),
|
||||||
|
Price = reader.GetDouble(2),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Service> GetAll()
|
||||||
|
{
|
||||||
|
var services = new List<Service>();
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand("SELECT * FROM service order by service_id", con);
|
||||||
|
using var reader = cmd.ExecuteReader();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
services.Add(new Service
|
||||||
|
{
|
||||||
|
Id = reader.GetInt32(0),
|
||||||
|
Name = reader.GetString(1),
|
||||||
|
Price = reader.GetDouble(2),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Service? Update(Service service)
|
||||||
|
{
|
||||||
|
using var con = SqlConnection.GetConnection();
|
||||||
|
con.Open();
|
||||||
|
using var cmd = new NpgsqlCommand($"UPDATE service SET name = '{service.Name}', price = '{service.Price}' WHERE service_id = {service.Id}", con);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
var element = Get(service.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
Hotel/HotelDatabase/SqlConnection.cs
Normal file
12
Hotel/HotelDatabase/SqlConnection.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using Npgsql;
|
||||||
|
|
||||||
|
namespace HotelDatabase
|
||||||
|
{
|
||||||
|
public class SqlConnection
|
||||||
|
{
|
||||||
|
public static NpgsqlConnection GetConnection()
|
||||||
|
{
|
||||||
|
return new NpgsqlConnection("Host=192.168.56.105;Port=5432;Username=postgres;Database=Hotel;Password=postgres");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
213
Hotel/HotelView/FormGuest.Designer.cs
generated
Normal file
213
Hotel/HotelView/FormGuest.Designer.cs
generated
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
namespace HotelView
|
||||||
|
{
|
||||||
|
partial class FormGuest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
label4 = new Label();
|
||||||
|
label3 = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
label1 = new Label();
|
||||||
|
textBoxPhone = new TextBox();
|
||||||
|
textBoxName = new TextBox();
|
||||||
|
button3 = new Button();
|
||||||
|
button2 = new Button();
|
||||||
|
button1 = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
comboBox1 = new ComboBox();
|
||||||
|
label5 = new Label();
|
||||||
|
dateTimePicker1 = new DateTimePicker();
|
||||||
|
textBoxPassport = new TextBox();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(529, 238);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(173, 20);
|
||||||
|
label4.TabIndex = 23;
|
||||||
|
label4.Text = "Серия номер Паспорта";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(529, 161);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(116, 20);
|
||||||
|
label3.TabIndex = 22;
|
||||||
|
label3.Text = "Дата рождения";
|
||||||
|
label3.Click += label3_Click;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(529, 91);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(127, 20);
|
||||||
|
label2.TabIndex = 21;
|
||||||
|
label2.Text = "Номер телефона";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(529, 21);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(174, 20);
|
||||||
|
label1.TabIndex = 20;
|
||||||
|
label1.Text = "Фамилия Имя Отчество";
|
||||||
|
//
|
||||||
|
// textBoxPhone
|
||||||
|
//
|
||||||
|
textBoxPhone.Location = new Point(514, 114);
|
||||||
|
textBoxPhone.Name = "textBoxPhone";
|
||||||
|
textBoxPhone.Size = new Size(280, 27);
|
||||||
|
textBoxPhone.TabIndex = 19;
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
textBoxName.Location = new Point(514, 44);
|
||||||
|
textBoxName.Name = "textBoxName";
|
||||||
|
textBoxName.Size = new Size(280, 27);
|
||||||
|
textBoxName.TabIndex = 18;
|
||||||
|
//
|
||||||
|
// button3
|
||||||
|
//
|
||||||
|
button3.Location = new Point(700, 410);
|
||||||
|
button3.Name = "button3";
|
||||||
|
button3.Size = new Size(94, 29);
|
||||||
|
button3.TabIndex = 17;
|
||||||
|
button3.Text = "Удалить";
|
||||||
|
button3.UseVisualStyleBackColor = true;
|
||||||
|
button3.Click += ButtonDelete_Click;
|
||||||
|
//
|
||||||
|
// button2
|
||||||
|
//
|
||||||
|
button2.Location = new Point(600, 410);
|
||||||
|
button2.Name = "button2";
|
||||||
|
button2.Size = new Size(94, 29);
|
||||||
|
button2.TabIndex = 16;
|
||||||
|
button2.Text = "Изменить";
|
||||||
|
button2.UseVisualStyleBackColor = true;
|
||||||
|
button2.Click += ButtonUpdate_Click;
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
button1.Location = new Point(500, 410);
|
||||||
|
button1.Name = "button1";
|
||||||
|
button1.Size = new Size(94, 29);
|
||||||
|
button1.TabIndex = 15;
|
||||||
|
button1.Text = "Добавить";
|
||||||
|
button1.UseVisualStyleBackColor = true;
|
||||||
|
button1.Click += ButtonCreate_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Location = new Point(6, 1);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.RowTemplate.Height = 29;
|
||||||
|
dataGridView.Size = new Size(478, 448);
|
||||||
|
dataGridView.TabIndex = 14;
|
||||||
|
//
|
||||||
|
// comboBox1
|
||||||
|
//
|
||||||
|
comboBox1.FormattingEnabled = true;
|
||||||
|
comboBox1.Location = new Point(514, 339);
|
||||||
|
comboBox1.Name = "comboBox1";
|
||||||
|
comboBox1.Size = new Size(280, 28);
|
||||||
|
comboBox1.TabIndex = 26;
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
label5.AutoSize = true;
|
||||||
|
label5.Location = new Point(529, 316);
|
||||||
|
label5.Name = "label5";
|
||||||
|
label5.Size = new Size(108, 20);
|
||||||
|
label5.TabIndex = 27;
|
||||||
|
label5.Text = "Выберите пол";
|
||||||
|
//
|
||||||
|
// dateTimePicker1
|
||||||
|
//
|
||||||
|
dateTimePicker1.Location = new Point(514, 184);
|
||||||
|
dateTimePicker1.Name = "dateTimePicker1";
|
||||||
|
dateTimePicker1.Size = new Size(280, 27);
|
||||||
|
dateTimePicker1.TabIndex = 28;
|
||||||
|
//
|
||||||
|
// textBoxPassport
|
||||||
|
//
|
||||||
|
textBoxPassport.Location = new Point(514, 261);
|
||||||
|
textBoxPassport.Name = "textBoxPassport";
|
||||||
|
textBoxPassport.Size = new Size(280, 27);
|
||||||
|
textBoxPassport.TabIndex = 29;
|
||||||
|
//
|
||||||
|
// FormGuest
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(textBoxPassport);
|
||||||
|
Controls.Add(dateTimePicker1);
|
||||||
|
Controls.Add(label5);
|
||||||
|
Controls.Add(comboBox1);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(textBoxPhone);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(button3);
|
||||||
|
Controls.Add(button2);
|
||||||
|
Controls.Add(button1);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormGuest";
|
||||||
|
Text = "FormGuest";
|
||||||
|
Load += FormGuest_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private Label label4;
|
||||||
|
private Label label3;
|
||||||
|
private Label label2;
|
||||||
|
private Label label1;
|
||||||
|
private TextBox textBoxPhone;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private Button button3;
|
||||||
|
private Button button2;
|
||||||
|
private Button button1;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private ComboBox comboBox1;
|
||||||
|
private Label label5;
|
||||||
|
private DateTimePicker dateTimePicker1;
|
||||||
|
private TextBox textBoxPassport;
|
||||||
|
}
|
||||||
|
}
|
144
Hotel/HotelView/FormGuest.cs
Normal file
144
Hotel/HotelView/FormGuest.cs
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
using HotelAbstractions.Logic;
|
||||||
|
using HotelAbstractions.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
|
||||||
|
namespace HotelView
|
||||||
|
{
|
||||||
|
public partial class FormGuest : Form
|
||||||
|
{
|
||||||
|
private readonly IGuestLogic _guestLogic;
|
||||||
|
public FormGuest(IGuestLogic guestLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_guestLogic = guestLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormGuest_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Guest newGuest = new()
|
||||||
|
{
|
||||||
|
FIO = textBoxName.Text,
|
||||||
|
PhoneNumber = textBoxPhone.Text,
|
||||||
|
BirthDate = ToDateOnly(dateTimePicker1.Value),
|
||||||
|
PassportId = textBoxPassport.Text,
|
||||||
|
Gender = (GenderEnum)Enum.Parse(typeof(GenderEnum), comboBox1.SelectedItem.ToString())
|
||||||
|
};
|
||||||
|
|
||||||
|
_guestLogic.Create(newGuest);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
comboBox1.DataSource = Enum.GetValues(typeof(GenderEnum));
|
||||||
|
var guests = _guestLogic.GetAll();
|
||||||
|
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
|
||||||
|
if (dataGridView.ColumnCount == 0)
|
||||||
|
{
|
||||||
|
dataGridView.Columns.Add("Id", "ID");
|
||||||
|
dataGridView.Columns.Add("FIO", "ФИО");
|
||||||
|
dataGridView.Columns.Add("PhoneNumber", "Номер телефона");
|
||||||
|
dataGridView.Columns.Add("BirthDate", "Дата рождения");
|
||||||
|
dataGridView.Columns.Add("PassportId", "Паспорт");
|
||||||
|
dataGridView.Columns.Add("Gender", "Пол");
|
||||||
|
}
|
||||||
|
|
||||||
|
dataGridView.Columns["Id"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["FIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["PhoneNumber"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["BirthDate"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["PassportId"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Gender"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
|
||||||
|
foreach (var guest in guests)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(guest.Id, guest.FIO, guest.PhoneNumber, guest.BirthDate, guest.PassportId, guest.Gender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||||
|
int guestId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||||
|
|
||||||
|
Guest updatedGuest = new()
|
||||||
|
{
|
||||||
|
Id = guestId,
|
||||||
|
FIO = textBoxName.Text,
|
||||||
|
PhoneNumber = textBoxPhone.Text,
|
||||||
|
BirthDate = ToDateOnly(dateTimePicker1.Value),
|
||||||
|
PassportId = textBoxPassport.Text,
|
||||||
|
Gender = (GenderEnum)Enum.Parse(typeof(GenderEnum), comboBox1.SelectedItem.ToString())
|
||||||
|
};
|
||||||
|
|
||||||
|
_guestLogic.Update(updatedGuest);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Пожалуйста, выберите гостинницу, информацию о которой необходимо обновить");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||||
|
int guestId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||||
|
|
||||||
|
_guestLogic.Delete(guestId);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Пожалуйста, выберите гостинницу, информацию о которой необходимо удалить");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.RowIndex >= 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||||
|
textBoxName.Text = row.Cells["FIO"].Value.ToString();
|
||||||
|
textBoxPhone.Text = row.Cells["PhoneNumber"].Value.ToString();
|
||||||
|
dateTimePicker1.Text = row.Cells["BirthDate"].Value.ToString();
|
||||||
|
textBoxPassport.Text = row.Cells["PassportId"].Value.ToString();
|
||||||
|
comboBox1.Text = row.Cells["Gender"].ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateOnly ToDateOnly(DateTime dateTime)
|
||||||
|
{
|
||||||
|
var DateTime = dateTime;
|
||||||
|
var Date = new DateOnly(DateTime.Year, DateTime.Month, DateTime.Day);
|
||||||
|
return Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void label3_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Hotel/HotelView/FormGuest.resx
Normal file
120
Hotel/HotelView/FormGuest.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
194
Hotel/HotelView/FormHotel.Designer.cs
generated
Normal file
194
Hotel/HotelView/FormHotel.Designer.cs
generated
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
namespace HotelView
|
||||||
|
{
|
||||||
|
partial class FormHotel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
button1 = new Button();
|
||||||
|
button2 = new Button();
|
||||||
|
button3 = new Button();
|
||||||
|
textBoxName = new TextBox();
|
||||||
|
textBoxAddress = new TextBox();
|
||||||
|
label1 = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
label3 = new Label();
|
||||||
|
label4 = new Label();
|
||||||
|
numericUpDownCountStar = new NumericUpDown();
|
||||||
|
numericUpDownCountRoom = new NumericUpDown();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownCountStar).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownCountRoom).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.RowTemplate.Height = 29;
|
||||||
|
dataGridView.Size = new Size(478, 448);
|
||||||
|
dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
button1.Location = new Point(494, 409);
|
||||||
|
button1.Name = "button1";
|
||||||
|
button1.Size = new Size(94, 29);
|
||||||
|
button1.TabIndex = 1;
|
||||||
|
button1.Text = "Добавить";
|
||||||
|
button1.UseVisualStyleBackColor = true;
|
||||||
|
button1.Click += ButtonCreate_Click;
|
||||||
|
//
|
||||||
|
// button2
|
||||||
|
//
|
||||||
|
button2.Location = new Point(594, 409);
|
||||||
|
button2.Name = "button2";
|
||||||
|
button2.Size = new Size(94, 29);
|
||||||
|
button2.TabIndex = 2;
|
||||||
|
button2.Text = "Изменить";
|
||||||
|
button2.UseVisualStyleBackColor = true;
|
||||||
|
button2.Click += ButtonUpdate_Click;
|
||||||
|
//
|
||||||
|
// button3
|
||||||
|
//
|
||||||
|
button3.Location = new Point(694, 409);
|
||||||
|
button3.Name = "button3";
|
||||||
|
button3.Size = new Size(94, 29);
|
||||||
|
button3.TabIndex = 3;
|
||||||
|
button3.Text = "Удалить";
|
||||||
|
button3.UseVisualStyleBackColor = true;
|
||||||
|
button3.Click += ButtonDelete_Click;
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
textBoxName.Location = new Point(508, 71);
|
||||||
|
textBoxName.Name = "textBoxName";
|
||||||
|
textBoxName.Size = new Size(280, 27);
|
||||||
|
textBoxName.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// textBoxAddress
|
||||||
|
//
|
||||||
|
textBoxAddress.Location = new Point(508, 158);
|
||||||
|
textBoxAddress.Name = "textBoxAddress";
|
||||||
|
textBoxAddress.Size = new Size(280, 27);
|
||||||
|
textBoxAddress.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(523, 48);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(156, 20);
|
||||||
|
label1.TabIndex = 8;
|
||||||
|
label1.Text = "Название гостиницы";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(523, 135);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(130, 20);
|
||||||
|
label2.TabIndex = 9;
|
||||||
|
label2.Text = "Адрес гостиницы";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(523, 226);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(132, 20);
|
||||||
|
label3.TabIndex = 10;
|
||||||
|
label3.Text = "Количество звезд";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(523, 310);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(144, 20);
|
||||||
|
label4.TabIndex = 11;
|
||||||
|
label4.Text = "Количество комнат";
|
||||||
|
//
|
||||||
|
// numericUpDownCountStar
|
||||||
|
//
|
||||||
|
numericUpDownCountStar.Location = new Point(508, 249);
|
||||||
|
numericUpDownCountStar.Name = "numericUpDownCountStar";
|
||||||
|
numericUpDownCountStar.Size = new Size(280, 27);
|
||||||
|
numericUpDownCountStar.TabIndex = 12;
|
||||||
|
//
|
||||||
|
// numericUpDownCountRoom
|
||||||
|
//
|
||||||
|
numericUpDownCountRoom.Location = new Point(508, 333);
|
||||||
|
numericUpDownCountRoom.Name = "numericUpDownCountRoom";
|
||||||
|
numericUpDownCountRoom.Size = new Size(280, 27);
|
||||||
|
numericUpDownCountRoom.TabIndex = 13;
|
||||||
|
//
|
||||||
|
// FormHotel
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(numericUpDownCountRoom);
|
||||||
|
Controls.Add(numericUpDownCountStar);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(textBoxAddress);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(button3);
|
||||||
|
Controls.Add(button2);
|
||||||
|
Controls.Add(button1);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormHotel";
|
||||||
|
Text = "FormHotel";
|
||||||
|
Load += FormHotel_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownCountStar).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownCountRoom).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button button1;
|
||||||
|
private Button button2;
|
||||||
|
private Button button3;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private TextBox textBoxAddress;
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private Label label3;
|
||||||
|
private Label label4;
|
||||||
|
private NumericUpDown numericUpDownCountStar;
|
||||||
|
private NumericUpDown numericUpDownCountRoom;
|
||||||
|
}
|
||||||
|
}
|
126
Hotel/HotelView/FormHotel.cs
Normal file
126
Hotel/HotelView/FormHotel.cs
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
using HotelAbstractions.Logic;
|
||||||
|
using HotelAbstractions.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace HotelView
|
||||||
|
{
|
||||||
|
public partial class FormHotel : Form
|
||||||
|
{
|
||||||
|
private readonly IHotelLogic _guestLogic;
|
||||||
|
public FormHotel(IHotelLogic guestLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_guestLogic = guestLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormHotel_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Hotel newHotel = new()
|
||||||
|
{
|
||||||
|
HotelName = textBoxName.Text,
|
||||||
|
Address = textBoxAddress.Text,
|
||||||
|
CountStar = (int)numericUpDownCountStar.Value,
|
||||||
|
CountRoom = (int)numericUpDownCountRoom.Value,
|
||||||
|
};
|
||||||
|
|
||||||
|
_guestLogic.Create(newHotel);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
var guests = _guestLogic.GetAll();
|
||||||
|
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
|
||||||
|
if (dataGridView.ColumnCount == 0)
|
||||||
|
{
|
||||||
|
dataGridView.Columns.Add("Id", "ID");
|
||||||
|
dataGridView.Columns.Add("HotelName", "Название");
|
||||||
|
dataGridView.Columns.Add("Address", "Адрес");
|
||||||
|
dataGridView.Columns.Add("CountStar", "Количество звезд");
|
||||||
|
dataGridView.Columns.Add("CountRoom", "Количество комнат");
|
||||||
|
}
|
||||||
|
|
||||||
|
dataGridView.Columns["Id"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["HotelName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Address"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["CountStar"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["CountRoom"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
|
||||||
|
foreach (var guest in guests)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(guest.Id, guest.HotelName, guest.Address, guest.CountStar, guest.CountRoom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||||
|
int guestId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||||
|
|
||||||
|
Hotel updatedHotel = new()
|
||||||
|
{
|
||||||
|
Id = guestId,
|
||||||
|
HotelName = textBoxName.Text,
|
||||||
|
Address = textBoxAddress.Text,
|
||||||
|
CountStar = (int)numericUpDownCountStar.Value,
|
||||||
|
CountRoom = (int)numericUpDownCountRoom.Value,
|
||||||
|
};
|
||||||
|
|
||||||
|
_guestLogic.Update(updatedHotel);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Пожалуйста, выберите гостинницу, информацию о которой необходимо обновить");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||||
|
int guestId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||||
|
|
||||||
|
_guestLogic.Delete(guestId);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Пожалуйста, выберите гостинницу, информацию о которой необходимо удалить");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.RowIndex >= 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||||
|
textBoxName.Text = row.Cells["HotelName"].Value.ToString();
|
||||||
|
textBoxAddress.Text = row.Cells["Address"].Value.ToString();
|
||||||
|
numericUpDownCountStar.Text = row.Cells["CountStar"].Value.ToString();
|
||||||
|
numericUpDownCountRoom.Text = row.Cells["CountRoom"].Value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Hotel/HotelView/FormHotel.resx
Normal file
120
Hotel/HotelView/FormHotel.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
183
Hotel/HotelView/FormMain.Designer.cs
generated
Normal file
183
Hotel/HotelView/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
namespace HotelView
|
||||||
|
{
|
||||||
|
partial class FormMain
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
labelTest = new Label();
|
||||||
|
menuStrip3 = new MenuStrip();
|
||||||
|
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
toolStripMenuItem1 = new ToolStripMenuItem();
|
||||||
|
guestToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
serviceToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
roomToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
reservationToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
serviceCheckToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
замерыВремениToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
get1000ToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
create1000ToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
update1000ToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
delete1000ToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
menuStrip3.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelTest
|
||||||
|
//
|
||||||
|
labelTest.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelTest.Font = new Font("Segoe UI", 30F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
|
labelTest.Location = new Point(12, 40);
|
||||||
|
labelTest.Name = "labelTest";
|
||||||
|
labelTest.Size = new Size(776, 401);
|
||||||
|
labelTest.TabIndex = 4;
|
||||||
|
labelTest.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
//
|
||||||
|
// menuStrip3
|
||||||
|
//
|
||||||
|
menuStrip3.ImageScalingSize = new Size(20, 20);
|
||||||
|
menuStrip3.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, замерыВремениToolStripMenuItem });
|
||||||
|
menuStrip3.Location = new Point(0, 0);
|
||||||
|
menuStrip3.Name = "menuStrip3";
|
||||||
|
menuStrip3.Size = new Size(800, 28);
|
||||||
|
menuStrip3.TabIndex = 7;
|
||||||
|
menuStrip3.Text = "menuStrip3";
|
||||||
|
//
|
||||||
|
// справочникиToolStripMenuItem
|
||||||
|
//
|
||||||
|
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItem1, guestToolStripMenuItem, serviceToolStripMenuItem, roomToolStripMenuItem, reservationToolStripMenuItem, serviceCheckToolStripMenuItem });
|
||||||
|
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||||
|
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||||
|
справочникиToolStripMenuItem.Text = "Справочники";
|
||||||
|
//
|
||||||
|
// toolStripMenuItem1
|
||||||
|
//
|
||||||
|
toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||||
|
toolStripMenuItem1.Size = new Size(178, 26);
|
||||||
|
toolStripMenuItem1.Text = "Hotel";
|
||||||
|
toolStripMenuItem1.Click += HotelToolStrip_Click;
|
||||||
|
//
|
||||||
|
// guestToolStripMenuItem
|
||||||
|
//
|
||||||
|
guestToolStripMenuItem.Name = "guestToolStripMenuItem";
|
||||||
|
guestToolStripMenuItem.Size = new Size(178, 26);
|
||||||
|
guestToolStripMenuItem.Text = "Guest";
|
||||||
|
guestToolStripMenuItem.Click += GuestToolStrip_Click;
|
||||||
|
//
|
||||||
|
// serviceToolStripMenuItem
|
||||||
|
//
|
||||||
|
serviceToolStripMenuItem.Name = "serviceToolStripMenuItem";
|
||||||
|
serviceToolStripMenuItem.Size = new Size(178, 26);
|
||||||
|
serviceToolStripMenuItem.Text = "Service";
|
||||||
|
serviceToolStripMenuItem.Click += ServiceToolStrip_Click;
|
||||||
|
//
|
||||||
|
// roomToolStripMenuItem
|
||||||
|
//
|
||||||
|
roomToolStripMenuItem.Name = "roomToolStripMenuItem";
|
||||||
|
roomToolStripMenuItem.Size = new Size(178, 26);
|
||||||
|
roomToolStripMenuItem.Text = "Room";
|
||||||
|
roomToolStripMenuItem.Click += RoomToolStrip_Click;
|
||||||
|
//
|
||||||
|
// reservationToolStripMenuItem
|
||||||
|
//
|
||||||
|
reservationToolStripMenuItem.Name = "reservationToolStripMenuItem";
|
||||||
|
reservationToolStripMenuItem.Size = new Size(178, 26);
|
||||||
|
reservationToolStripMenuItem.Text = "Reservation";
|
||||||
|
reservationToolStripMenuItem.Click += ReservationToolStrip_Click;
|
||||||
|
//
|
||||||
|
// serviceCheckToolStripMenuItem
|
||||||
|
//
|
||||||
|
serviceCheckToolStripMenuItem.Name = "serviceCheckToolStripMenuItem";
|
||||||
|
serviceCheckToolStripMenuItem.Size = new Size(178, 26);
|
||||||
|
serviceCheckToolStripMenuItem.Text = "ServiceCheck";
|
||||||
|
serviceCheckToolStripMenuItem.Click += ServiceCheckToolStrip_Click;
|
||||||
|
//
|
||||||
|
// замерыВремениToolStripMenuItem
|
||||||
|
//
|
||||||
|
замерыВремениToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { get1000ToolStripMenuItem, create1000ToolStripMenuItem, update1000ToolStripMenuItem, delete1000ToolStripMenuItem });
|
||||||
|
замерыВремениToolStripMenuItem.Name = "замерыВремениToolStripMenuItem";
|
||||||
|
замерыВремениToolStripMenuItem.Size = new Size(144, 24);
|
||||||
|
замерыВремениToolStripMenuItem.Text = "Замеры времени";
|
||||||
|
//
|
||||||
|
// get1000ToolStripMenuItem
|
||||||
|
//
|
||||||
|
get1000ToolStripMenuItem.Name = "get1000ToolStripMenuItem";
|
||||||
|
get1000ToolStripMenuItem.Size = new Size(177, 26);
|
||||||
|
get1000ToolStripMenuItem.Text = "Get 1000";
|
||||||
|
get1000ToolStripMenuItem.Click += get1000ToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// create1000ToolStripMenuItem
|
||||||
|
//
|
||||||
|
create1000ToolStripMenuItem.Name = "create1000ToolStripMenuItem";
|
||||||
|
create1000ToolStripMenuItem.Size = new Size(177, 26);
|
||||||
|
create1000ToolStripMenuItem.Text = "Create 1000";
|
||||||
|
create1000ToolStripMenuItem.Click += add1000ToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// update1000ToolStripMenuItem
|
||||||
|
//
|
||||||
|
update1000ToolStripMenuItem.Name = "update1000ToolStripMenuItem";
|
||||||
|
update1000ToolStripMenuItem.Size = new Size(177, 26);
|
||||||
|
update1000ToolStripMenuItem.Text = "Update 1000";
|
||||||
|
update1000ToolStripMenuItem.Click += update1000ToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// delete1000ToolStripMenuItem
|
||||||
|
//
|
||||||
|
delete1000ToolStripMenuItem.Name = "delete1000ToolStripMenuItem";
|
||||||
|
delete1000ToolStripMenuItem.Size = new Size(177, 26);
|
||||||
|
delete1000ToolStripMenuItem.Text = "Delete 1000";
|
||||||
|
delete1000ToolStripMenuItem.Click += delete1000ToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// FormMain
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(labelTest);
|
||||||
|
Controls.Add(menuStrip3);
|
||||||
|
Name = "FormMain";
|
||||||
|
Text = "Form1";
|
||||||
|
menuStrip3.ResumeLayout(false);
|
||||||
|
menuStrip3.PerformLayout();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private Label labelTest;
|
||||||
|
private MenuStrip menuStrip3;
|
||||||
|
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem toolStripMenuItem1;
|
||||||
|
private ToolStripMenuItem замерыВремениToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem get1000ToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem create1000ToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem update1000ToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem delete1000ToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem guestToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem serviceToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem roomToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem reservationToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem serviceCheckToolStripMenuItem;
|
||||||
|
}
|
||||||
|
}
|
146
Hotel/HotelView/FormMain.cs
Normal file
146
Hotel/HotelView/FormMain.cs
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
using HotelAbstractions.Logic;
|
||||||
|
using HotelAbstractions.Models;
|
||||||
|
|
||||||
|
namespace HotelView
|
||||||
|
{
|
||||||
|
public partial class FormMain : Form
|
||||||
|
{
|
||||||
|
public FormMain()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HotelToolStrip_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormHotel));
|
||||||
|
if (service is FormHotel form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RoomToolStrip_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormRoom));
|
||||||
|
if (service is FormRoom form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReservationToolStrip_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormReservation));
|
||||||
|
if (service is FormReservation form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GuestToolStrip_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormGuest));
|
||||||
|
if (service is FormGuest form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ServiceToolStrip_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormService));
|
||||||
|
if (service is FormService form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ServiceCheckToolStrip_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormServiceCheck));
|
||||||
|
if (service is FormServiceCheck form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void add1000ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(IHotelLogic));
|
||||||
|
if (service is IHotelLogic hotelLogic)
|
||||||
|
{
|
||||||
|
DateTime startTime = DateTime.Now;
|
||||||
|
for (int i = 0; i < 1000; i++)
|
||||||
|
{
|
||||||
|
Hotel hotel = new()
|
||||||
|
{
|
||||||
|
Id = i + 1000,
|
||||||
|
HotelName = "Íàçâàíèå ãîñòèíèöû " + i,
|
||||||
|
Address = "Àäðåñ " + i,
|
||||||
|
CountStar = i,
|
||||||
|
CountRoom = i
|
||||||
|
};
|
||||||
|
hotelLogic.CreateId(hotel);
|
||||||
|
}
|
||||||
|
DateTime endTime = DateTime.Now;
|
||||||
|
|
||||||
|
labelTest.Text = $"Äîáàâëåíèå 1000 ñòðîê âûïîëíåíî çà {(endTime - startTime).TotalMilliseconds} ìèëëèñåêóíä";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void get1000ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(IHotelLogic));
|
||||||
|
if (service is IHotelLogic hotelLogic)
|
||||||
|
{
|
||||||
|
DateTime startTime = DateTime.Now;
|
||||||
|
for (int i =0; i < 1000; i++)
|
||||||
|
hotelLogic.Get(i + 1000);
|
||||||
|
DateTime endTime = DateTime.Now;
|
||||||
|
|
||||||
|
labelTest.Text = $"Ïîëó÷åíèå 1000 ñòðîê âûïîëíåíî çà {(endTime - startTime).TotalMilliseconds} ìèëëèñåêóíä";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update1000ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(IHotelLogic));
|
||||||
|
if (service is IHotelLogic hoteLogic)
|
||||||
|
{
|
||||||
|
DateTime startTime = DateTime.Now;
|
||||||
|
for (int i = 0; i < 1000; i++)
|
||||||
|
{
|
||||||
|
Hotel hotel = new()
|
||||||
|
{
|
||||||
|
Id = i + 1000,
|
||||||
|
HotelName = "Íàçâàíèå ãîñòèíèöû " + i + 2000,
|
||||||
|
Address = "Àäðåñ " + i + 2000,
|
||||||
|
CountStar = i + 2000,
|
||||||
|
CountRoom = i + 2000
|
||||||
|
};
|
||||||
|
hoteLogic.Update(hotel);
|
||||||
|
}
|
||||||
|
DateTime endTime = DateTime.Now;
|
||||||
|
|
||||||
|
labelTest.Text = $"Îáíîâëåíèå 1000 ñòðîê âûïîëíåíî çà {(endTime - startTime).TotalMilliseconds} ìèëëèñåêóíä";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void delete1000ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(IHotelLogic));
|
||||||
|
if (service is IHotelLogic hoteLogic)
|
||||||
|
{
|
||||||
|
DateTime startTime = DateTime.Now;
|
||||||
|
for (int i = 0; i < 1000; i++)
|
||||||
|
{
|
||||||
|
hoteLogic.Delete(i + 1000);
|
||||||
|
}
|
||||||
|
DateTime endTime = DateTime.Now;
|
||||||
|
|
||||||
|
labelTest.Text = $"Óäàëåíèå 1000 ñòðîê âûïîëíåíî çà {(endTime - startTime).TotalMilliseconds} ìèëëèñåêóíä";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
123
Hotel/HotelView/FormMain.resx
Normal file
123
Hotel/HotelView/FormMain.resx
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="menuStrip3.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>407, 27</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
218
Hotel/HotelView/FormReservation.Designer.cs
generated
Normal file
218
Hotel/HotelView/FormReservation.Designer.cs
generated
Normal file
@ -0,0 +1,218 @@
|
|||||||
|
namespace HotelView
|
||||||
|
{
|
||||||
|
partial class FormReservation
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
numericUpDownPrice = new NumericUpDown();
|
||||||
|
label5 = new Label();
|
||||||
|
labelAuth = new Label();
|
||||||
|
comboBoxGuest = new ComboBox();
|
||||||
|
button3 = new Button();
|
||||||
|
button2 = new Button();
|
||||||
|
button1 = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
label1 = new Label();
|
||||||
|
comboBoxRoom = new ComboBox();
|
||||||
|
dateTimePickerDeparture = new DateTimePicker();
|
||||||
|
label3 = new Label();
|
||||||
|
dateTimePickerArrival = new DateTimePicker();
|
||||||
|
label2 = new Label();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// numericUpDownPrice
|
||||||
|
//
|
||||||
|
numericUpDownPrice.Location = new Point(737, 332);
|
||||||
|
numericUpDownPrice.Name = "numericUpDownPrice";
|
||||||
|
numericUpDownPrice.Size = new Size(274, 27);
|
||||||
|
numericUpDownPrice.TabIndex = 56;
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
label5.AutoSize = true;
|
||||||
|
label5.Location = new Point(752, 309);
|
||||||
|
label5.Name = "label5";
|
||||||
|
label5.Size = new Size(45, 20);
|
||||||
|
label5.TabIndex = 55;
|
||||||
|
label5.Text = "Цена";
|
||||||
|
//
|
||||||
|
// labelAuth
|
||||||
|
//
|
||||||
|
labelAuth.AutoSize = true;
|
||||||
|
labelAuth.Location = new Point(752, 14);
|
||||||
|
labelAuth.Name = "labelAuth";
|
||||||
|
labelAuth.Size = new Size(46, 20);
|
||||||
|
labelAuth.TabIndex = 54;
|
||||||
|
labelAuth.Text = "Гость";
|
||||||
|
//
|
||||||
|
// comboBoxGuest
|
||||||
|
//
|
||||||
|
comboBoxGuest.FormattingEnabled = true;
|
||||||
|
comboBoxGuest.Location = new Point(737, 39);
|
||||||
|
comboBoxGuest.Margin = new Padding(3, 5, 3, 5);
|
||||||
|
comboBoxGuest.Name = "comboBoxGuest";
|
||||||
|
comboBoxGuest.Size = new Size(274, 28);
|
||||||
|
comboBoxGuest.TabIndex = 53;
|
||||||
|
//
|
||||||
|
// button3
|
||||||
|
//
|
||||||
|
button3.Location = new Point(923, 408);
|
||||||
|
button3.Name = "button3";
|
||||||
|
button3.Size = new Size(94, 29);
|
||||||
|
button3.TabIndex = 52;
|
||||||
|
button3.Text = "Удалить";
|
||||||
|
button3.UseVisualStyleBackColor = true;
|
||||||
|
button3.Click += ButtonDelete_Click;
|
||||||
|
//
|
||||||
|
// button2
|
||||||
|
//
|
||||||
|
button2.Location = new Point(823, 408);
|
||||||
|
button2.Name = "button2";
|
||||||
|
button2.Size = new Size(94, 29);
|
||||||
|
button2.TabIndex = 51;
|
||||||
|
button2.Text = "Изменить";
|
||||||
|
button2.UseVisualStyleBackColor = true;
|
||||||
|
button2.Click += ButtonUpdate_Click;
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
button1.Location = new Point(723, 408);
|
||||||
|
button1.Name = "button1";
|
||||||
|
button1.Size = new Size(94, 29);
|
||||||
|
button1.TabIndex = 50;
|
||||||
|
button1.Text = "Добавить";
|
||||||
|
button1.UseVisualStyleBackColor = true;
|
||||||
|
button1.Click += ButtonCreate_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Location = new Point(1, -1);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.RowTemplate.Height = 29;
|
||||||
|
dataGridView.Size = new Size(696, 451);
|
||||||
|
dataGridView.TabIndex = 49;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(752, 89);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(69, 20);
|
||||||
|
label1.TabIndex = 58;
|
||||||
|
label1.Text = "Комната";
|
||||||
|
//
|
||||||
|
// comboBoxRoom
|
||||||
|
//
|
||||||
|
comboBoxRoom.FormattingEnabled = true;
|
||||||
|
comboBoxRoom.Location = new Point(737, 114);
|
||||||
|
comboBoxRoom.Margin = new Padding(3, 5, 3, 5);
|
||||||
|
comboBoxRoom.Name = "comboBoxRoom";
|
||||||
|
comboBoxRoom.Size = new Size(274, 28);
|
||||||
|
comboBoxRoom.TabIndex = 57;
|
||||||
|
//
|
||||||
|
// dateTimePickerDeparture
|
||||||
|
//
|
||||||
|
dateTimePickerDeparture.Location = new Point(737, 267);
|
||||||
|
dateTimePickerDeparture.Name = "dateTimePickerDeparture";
|
||||||
|
dateTimePickerDeparture.Size = new Size(280, 27);
|
||||||
|
dateTimePickerDeparture.TabIndex = 60;
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(752, 244);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(95, 20);
|
||||||
|
label3.TabIndex = 59;
|
||||||
|
label3.Text = "Дата выезда";
|
||||||
|
//
|
||||||
|
// dateTimePickerArrival
|
||||||
|
//
|
||||||
|
dateTimePickerArrival.Location = new Point(737, 188);
|
||||||
|
dateTimePickerArrival.Name = "dateTimePickerArrival";
|
||||||
|
dateTimePickerArrival.Size = new Size(274, 27);
|
||||||
|
dateTimePickerArrival.TabIndex = 62;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(752, 165);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(91, 20);
|
||||||
|
label2.TabIndex = 61;
|
||||||
|
label2.Text = "Дата заезда";
|
||||||
|
//
|
||||||
|
// FormReservation
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(1030, 450);
|
||||||
|
Controls.Add(dateTimePickerArrival);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(dateTimePickerDeparture);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(comboBoxRoom);
|
||||||
|
Controls.Add(numericUpDownPrice);
|
||||||
|
Controls.Add(label5);
|
||||||
|
Controls.Add(labelAuth);
|
||||||
|
Controls.Add(comboBoxGuest);
|
||||||
|
Controls.Add(button3);
|
||||||
|
Controls.Add(button2);
|
||||||
|
Controls.Add(button1);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormReservation";
|
||||||
|
Text = "FormReservation";
|
||||||
|
Load += FormReservation_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private NumericUpDown numericUpDownPrice;
|
||||||
|
private Label label5;
|
||||||
|
private Label labelAuth;
|
||||||
|
private ComboBox comboBoxGuest;
|
||||||
|
private Button button3;
|
||||||
|
private Button button2;
|
||||||
|
private Button button1;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Label label1;
|
||||||
|
private ComboBox comboBoxRoom;
|
||||||
|
private DateTimePicker dateTimePickerDeparture;
|
||||||
|
private Label label3;
|
||||||
|
private DateTimePicker dateTimePickerArrival;
|
||||||
|
private Label label2;
|
||||||
|
}
|
||||||
|
}
|
156
Hotel/HotelView/FormReservation.cs
Normal file
156
Hotel/HotelView/FormReservation.cs
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
using HotelAbstractions.Logic;
|
||||||
|
using HotelAbstractions.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace HotelView
|
||||||
|
{
|
||||||
|
public partial class FormReservation : Form
|
||||||
|
{
|
||||||
|
private readonly IReservationLogic _reservationLogic;
|
||||||
|
private readonly IGuestLogic _guestLogic;
|
||||||
|
private readonly IRoomLogic _roomLogic;
|
||||||
|
public FormReservation(IReservationLogic reservationLogic, IGuestLogic guestLogic, IRoomLogic roomLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_reservationLogic = reservationLogic;
|
||||||
|
_guestLogic = guestLogic;
|
||||||
|
_roomLogic = roomLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormReservation_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Reservation newReservation = new()
|
||||||
|
{
|
||||||
|
GuestId = ((Guest?)comboBoxGuest.SelectedItem)?.Id ?? 0,
|
||||||
|
RoomId = ((Room?)comboBoxRoom.SelectedItem)?.Id ?? 0,
|
||||||
|
ArrivalDate = ToDateOnly(dateTimePickerArrival.Value),
|
||||||
|
DepartureDate = ToDateOnly(dateTimePickerDeparture.Value),
|
||||||
|
Price = (int)numericUpDownPrice.Value,
|
||||||
|
};
|
||||||
|
|
||||||
|
_reservationLogic.Create(newReservation);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
var reservations = _reservationLogic.GetAll();
|
||||||
|
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
|
||||||
|
if (dataGridView.ColumnCount == 0)
|
||||||
|
{
|
||||||
|
dataGridView.Columns.Add("Id", "ID");
|
||||||
|
dataGridView.Columns.Add("GuestId", "GuestId");
|
||||||
|
dataGridView.Columns["GuestId"].Visible = false;
|
||||||
|
dataGridView.Columns.Add("Guest", "Гость");
|
||||||
|
dataGridView.Columns.Add("RoomId", "RoomId");
|
||||||
|
dataGridView.Columns["RoomId"].Visible = false;
|
||||||
|
dataGridView.Columns.Add("Room", "Комната");
|
||||||
|
dataGridView.Columns.Add("ArrivalDate", "Дата заезда");
|
||||||
|
dataGridView.Columns.Add("DepartureDate", "Дата выезда");
|
||||||
|
dataGridView.Columns.Add("Price", "Цена");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dataGridView.Columns["Id"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
||||||
|
dataGridView.Columns["Guest"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Room"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
||||||
|
dataGridView.Columns["ArrivalDate"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
||||||
|
dataGridView.Columns["DepartureDate"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
||||||
|
dataGridView.Columns["Price"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
||||||
|
|
||||||
|
comboBoxGuest.DataSource = _guestLogic.GetAll();
|
||||||
|
comboBoxGuest.DisplayMember = "Guest";
|
||||||
|
comboBoxGuest.ValueMember = "FIO";
|
||||||
|
|
||||||
|
comboBoxRoom.DataSource = _roomLogic.GetAll();
|
||||||
|
comboBoxRoom.DisplayMember = "Room";
|
||||||
|
comboBoxRoom.ValueMember = "Id";
|
||||||
|
|
||||||
|
foreach (var reservation in reservations)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(reservation.Id, reservation.GuestId, _guestLogic.Get(reservation.GuestId)?.FIO, reservation.RoomId, reservation.ArrivalDate,
|
||||||
|
reservation.DepartureDate, reservation.Price);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||||
|
int reservationId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||||
|
|
||||||
|
Reservation updatedReservation = new()
|
||||||
|
{
|
||||||
|
Id = reservationId,
|
||||||
|
GuestId = ((Guest?)comboBoxGuest.SelectedItem)?.Id ?? 0,
|
||||||
|
RoomId = ((Room?)comboBoxRoom.SelectedItem)?.Id ?? 0,
|
||||||
|
ArrivalDate = ToDateOnly(dateTimePickerArrival.Value),
|
||||||
|
DepartureDate = ToDateOnly(dateTimePickerDeparture.Value),
|
||||||
|
Price = (int)numericUpDownPrice.Value,
|
||||||
|
};
|
||||||
|
|
||||||
|
_reservationLogic.Update(updatedReservation);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Пожалуйста, выберите статью, информацию о которой необходимо обновить");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||||
|
int reservationId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||||
|
|
||||||
|
_reservationLogic.Delete(reservationId);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Пожалуйста, выберите статью, информацию о которой необходимо удалить");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.RowIndex >= 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||||
|
comboBoxGuest.SelectedValue = row.Cells["Guest"].Value ?? new Guest { FIO = "Неизвестнo" };
|
||||||
|
comboBoxRoom.SelectedValue = row.Cells["Room"].Value ?? new Room { Id = 0 };
|
||||||
|
dateTimePickerArrival.Text = row.Cells["ArrivalDate"].Value.ToString();
|
||||||
|
dateTimePickerDeparture.Text = row.Cells["DepartureDate"].Value.ToString();
|
||||||
|
numericUpDownPrice.Text = row.Cells["Price"].Value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateOnly ToDateOnly(DateTime dateTime)
|
||||||
|
{
|
||||||
|
var DateTime = dateTime;
|
||||||
|
var Date = new DateOnly(DateTime.Year, DateTime.Month, DateTime.Day);
|
||||||
|
return Date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Hotel/HotelView/FormReservation.resx
Normal file
120
Hotel/HotelView/FormReservation.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
243
Hotel/HotelView/FormRoom.Designer.cs
generated
Normal file
243
Hotel/HotelView/FormRoom.Designer.cs
generated
Normal file
@ -0,0 +1,243 @@
|
|||||||
|
namespace HotelView
|
||||||
|
{
|
||||||
|
partial class FormRoom
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
numericUpFlor = new NumericUpDown();
|
||||||
|
numericUpDownCountPlace = new NumericUpDown();
|
||||||
|
label4 = new Label();
|
||||||
|
label3 = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
label1 = new Label();
|
||||||
|
textBoxNumber = new TextBox();
|
||||||
|
textBoxCategory = new TextBox();
|
||||||
|
button3 = new Button();
|
||||||
|
button2 = new Button();
|
||||||
|
button1 = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
labelAuthor = new Label();
|
||||||
|
comboBoxHotel = new ComboBox();
|
||||||
|
numericUpDownPrice = new NumericUpDown();
|
||||||
|
label5 = new Label();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpFlor).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownCountPlace).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// numericUpFlor
|
||||||
|
//
|
||||||
|
numericUpFlor.Location = new Point(954, 229);
|
||||||
|
numericUpFlor.Minimum = new decimal(new int[] { 5, 0, 0, int.MinValue });
|
||||||
|
numericUpFlor.Name = "numericUpFlor";
|
||||||
|
numericUpFlor.Size = new Size(274, 27);
|
||||||
|
numericUpFlor.TabIndex = 25;
|
||||||
|
//
|
||||||
|
// numericUpDownCountPlace
|
||||||
|
//
|
||||||
|
numericUpDownCountPlace.Location = new Point(954, 160);
|
||||||
|
numericUpDownCountPlace.Name = "numericUpDownCountPlace";
|
||||||
|
numericUpDownCountPlace.Size = new Size(274, 27);
|
||||||
|
numericUpDownCountPlace.TabIndex = 24;
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(969, 206);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(43, 20);
|
||||||
|
label4.TabIndex = 23;
|
||||||
|
label4.Text = "Этаж";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(967, 137);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(126, 20);
|
||||||
|
label3.TabIndex = 22;
|
||||||
|
label3.Text = "Количество мест";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(967, 273);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(122, 20);
|
||||||
|
label2.TabIndex = 21;
|
||||||
|
label2.Text = "Номер комнаты";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(969, 72);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(81, 20);
|
||||||
|
label1.TabIndex = 20;
|
||||||
|
label1.Text = "Категория";
|
||||||
|
//
|
||||||
|
// textBoxNumber
|
||||||
|
//
|
||||||
|
textBoxNumber.Location = new Point(954, 296);
|
||||||
|
textBoxNumber.Name = "textBoxNumber";
|
||||||
|
textBoxNumber.Size = new Size(274, 27);
|
||||||
|
textBoxNumber.TabIndex = 19;
|
||||||
|
//
|
||||||
|
// textBoxCategory
|
||||||
|
//
|
||||||
|
textBoxCategory.Location = new Point(954, 95);
|
||||||
|
textBoxCategory.Name = "textBoxCategory";
|
||||||
|
textBoxCategory.Size = new Size(274, 27);
|
||||||
|
textBoxCategory.TabIndex = 18;
|
||||||
|
//
|
||||||
|
// button3
|
||||||
|
//
|
||||||
|
button3.Location = new Point(1140, 408);
|
||||||
|
button3.Name = "button3";
|
||||||
|
button3.Size = new Size(94, 29);
|
||||||
|
button3.TabIndex = 17;
|
||||||
|
button3.Text = "Удалить";
|
||||||
|
button3.UseVisualStyleBackColor = true;
|
||||||
|
button3.Click += ButtonDelete_Click;
|
||||||
|
//
|
||||||
|
// button2
|
||||||
|
//
|
||||||
|
button2.Location = new Point(1040, 408);
|
||||||
|
button2.Name = "button2";
|
||||||
|
button2.Size = new Size(94, 29);
|
||||||
|
button2.TabIndex = 16;
|
||||||
|
button2.Text = "Изменить";
|
||||||
|
button2.UseVisualStyleBackColor = true;
|
||||||
|
button2.Click += ButtonUpdate_Click;
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
button1.Location = new Point(940, 408);
|
||||||
|
button1.Name = "button1";
|
||||||
|
button1.Size = new Size(94, 29);
|
||||||
|
button1.TabIndex = 15;
|
||||||
|
button1.Text = "Добавить";
|
||||||
|
button1.UseVisualStyleBackColor = true;
|
||||||
|
button1.Click += ButtonCreate_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Location = new Point(1, 0);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.RowTemplate.Height = 29;
|
||||||
|
dataGridView.Size = new Size(910, 451);
|
||||||
|
dataGridView.TabIndex = 14;
|
||||||
|
//
|
||||||
|
// labelAuthor
|
||||||
|
//
|
||||||
|
labelAuthor.AutoSize = true;
|
||||||
|
labelAuthor.Location = new Point(969, 14);
|
||||||
|
labelAuthor.Name = "labelAuthor";
|
||||||
|
labelAuthor.Size = new Size(82, 20);
|
||||||
|
labelAuthor.TabIndex = 46;
|
||||||
|
labelAuthor.Text = "Гостиница";
|
||||||
|
//
|
||||||
|
// comboBoxHotel
|
||||||
|
//
|
||||||
|
comboBoxHotel.FormattingEnabled = true;
|
||||||
|
comboBoxHotel.Location = new Point(954, 39);
|
||||||
|
comboBoxHotel.Margin = new Padding(3, 5, 3, 5);
|
||||||
|
comboBoxHotel.Name = "comboBoxHotel";
|
||||||
|
comboBoxHotel.Size = new Size(274, 28);
|
||||||
|
comboBoxHotel.TabIndex = 45;
|
||||||
|
//
|
||||||
|
// numericUpDownPrice
|
||||||
|
//
|
||||||
|
numericUpDownPrice.Location = new Point(954, 359);
|
||||||
|
numericUpDownPrice.Name = "numericUpDownPrice";
|
||||||
|
numericUpDownPrice.Size = new Size(274, 27);
|
||||||
|
numericUpDownPrice.TabIndex = 48;
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
label5.AutoSize = true;
|
||||||
|
label5.Location = new Point(969, 336);
|
||||||
|
label5.Name = "label5";
|
||||||
|
label5.Size = new Size(45, 20);
|
||||||
|
label5.TabIndex = 47;
|
||||||
|
label5.Text = "Цена";
|
||||||
|
//
|
||||||
|
// FormRoom
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(1249, 450);
|
||||||
|
Controls.Add(numericUpDownPrice);
|
||||||
|
Controls.Add(label5);
|
||||||
|
Controls.Add(labelAuthor);
|
||||||
|
Controls.Add(comboBoxHotel);
|
||||||
|
Controls.Add(numericUpFlor);
|
||||||
|
Controls.Add(numericUpDownCountPlace);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(textBoxNumber);
|
||||||
|
Controls.Add(textBoxCategory);
|
||||||
|
Controls.Add(button3);
|
||||||
|
Controls.Add(button2);
|
||||||
|
Controls.Add(button1);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormRoom";
|
||||||
|
Text = "FormRoom";
|
||||||
|
Load += FormRoom_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpFlor).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownCountPlace).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private NumericUpDown numericUpFlor;
|
||||||
|
private NumericUpDown numericUpDownCountPlace;
|
||||||
|
private Label label4;
|
||||||
|
private Label label3;
|
||||||
|
private Label label2;
|
||||||
|
private Label label1;
|
||||||
|
private TextBox textBoxNumber;
|
||||||
|
private TextBox textBoxCategory;
|
||||||
|
private Button button3;
|
||||||
|
private Button button2;
|
||||||
|
private Button button1;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Label labelAuthor;
|
||||||
|
private ComboBox comboBoxHotel;
|
||||||
|
private NumericUpDown numericUpDownPrice;
|
||||||
|
private Label label5;
|
||||||
|
}
|
||||||
|
}
|
146
Hotel/HotelView/FormRoom.cs
Normal file
146
Hotel/HotelView/FormRoom.cs
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
using HotelAbstractions.Logic;
|
||||||
|
using HotelAbstractions.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace HotelView
|
||||||
|
{
|
||||||
|
public partial class FormRoom : Form
|
||||||
|
{
|
||||||
|
private readonly IRoomLogic _roomLogic;
|
||||||
|
private readonly IHotelLogic _hotelLogic;
|
||||||
|
public FormRoom(IRoomLogic roomLogic, IHotelLogic hotelLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_roomLogic = roomLogic;
|
||||||
|
_hotelLogic = hotelLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormRoom_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Room newRoom = new()
|
||||||
|
{
|
||||||
|
HotelId = ((Hotel?)comboBoxHotel.SelectedItem)?.Id ?? 0,
|
||||||
|
Category = textBoxCategory.Text,
|
||||||
|
CountPlace = (int)numericUpDownCountPlace.Value,
|
||||||
|
Flor = (int)numericUpFlor.Value,
|
||||||
|
Number = textBoxNumber.Text,
|
||||||
|
Price = (int)numericUpDownPrice.Value,
|
||||||
|
};
|
||||||
|
|
||||||
|
_roomLogic.Create(newRoom);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
var rooms = _roomLogic.GetAll();
|
||||||
|
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
|
||||||
|
if (dataGridView.ColumnCount == 0)
|
||||||
|
{
|
||||||
|
dataGridView.Columns.Add("Id", "ID");
|
||||||
|
dataGridView.Columns.Add("HotelId", "HotelId");
|
||||||
|
dataGridView.Columns["HotelId"].Visible = false;
|
||||||
|
dataGridView.Columns.Add("Hotel", "Гостиница");
|
||||||
|
dataGridView.Columns.Add("Category", "Категория");
|
||||||
|
dataGridView.Columns.Add("CountPlace", "Количество мест");
|
||||||
|
dataGridView.Columns.Add("Flor", "Этаж");
|
||||||
|
dataGridView.Columns.Add("Number", "Номер");
|
||||||
|
dataGridView.Columns.Add("Price", "Цена");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dataGridView.Columns["Id"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
||||||
|
dataGridView.Columns["Hotel"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Category"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
||||||
|
dataGridView.Columns["CountPlace"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
||||||
|
dataGridView.Columns["Flor"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
||||||
|
dataGridView.Columns["Number"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
||||||
|
dataGridView.Columns["Price"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
||||||
|
|
||||||
|
comboBoxHotel.DataSource = _hotelLogic.GetAll();
|
||||||
|
comboBoxHotel.DisplayMember = "Hotel";
|
||||||
|
comboBoxHotel.ValueMember = "HotelName";
|
||||||
|
|
||||||
|
foreach (var room in rooms)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(room.Id, room.HotelId, _hotelLogic.Get(room.HotelId)?.HotelName, room.Category, room.CountPlace,
|
||||||
|
room.Flor, room.Number, room.Price);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||||
|
int roomId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||||
|
|
||||||
|
Room updatedRoom = new()
|
||||||
|
{
|
||||||
|
Id = roomId,
|
||||||
|
HotelId = ((Hotel?)comboBoxHotel.SelectedItem)?.Id ?? 0,
|
||||||
|
Category = textBoxCategory.Text,
|
||||||
|
CountPlace = (int)numericUpDownCountPlace.Value,
|
||||||
|
Flor = (int)numericUpFlor.Value,
|
||||||
|
Number = textBoxNumber.Text,
|
||||||
|
Price = (int)numericUpDownPrice.Value,
|
||||||
|
};
|
||||||
|
|
||||||
|
_roomLogic.Update(updatedRoom);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Пожалуйста, выберите статью, информацию о которой необходимо обновить");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||||
|
int roomId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||||
|
|
||||||
|
_roomLogic.Delete(roomId);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Пожалуйста, выберите статью, информацию о которой необходимо удалить");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.RowIndex >= 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||||
|
comboBoxHotel.SelectedValue = row.Cells["Hotel"].Value ?? new Hotel { HotelName = "Неизвестнo" };
|
||||||
|
textBoxCategory.Text = row.Cells["Category"].Value.ToString();
|
||||||
|
numericUpDownCountPlace.Text = row.Cells["CountPlace"].Value.ToString();
|
||||||
|
numericUpFlor.Text = row.Cells["Flor"].Value.ToString();
|
||||||
|
textBoxNumber.Text = row.Cells["Number"].Value.ToString();
|
||||||
|
numericUpDownPrice.Text = row.Cells["Price"].Value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Hotel/HotelView/FormRoom.resx
Normal file
120
Hotel/HotelView/FormRoom.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
149
Hotel/HotelView/FormService.Designer.cs
generated
Normal file
149
Hotel/HotelView/FormService.Designer.cs
generated
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
namespace HotelView
|
||||||
|
{
|
||||||
|
partial class FormService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
numericUpDownPrice = new NumericUpDown();
|
||||||
|
label4 = new Label();
|
||||||
|
label1 = new Label();
|
||||||
|
textBoxName = new TextBox();
|
||||||
|
button3 = new Button();
|
||||||
|
button2 = new Button();
|
||||||
|
button1 = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// numericUpDownPrice
|
||||||
|
//
|
||||||
|
numericUpDownPrice.Location = new Point(508, 242);
|
||||||
|
numericUpDownPrice.Maximum = new decimal(new int[] { 100000, 0, 0, 0 });
|
||||||
|
numericUpDownPrice.Name = "numericUpDownPrice";
|
||||||
|
numericUpDownPrice.Size = new Size(280, 27);
|
||||||
|
numericUpDownPrice.TabIndex = 25;
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(529, 219);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(45, 20);
|
||||||
|
label4.TabIndex = 23;
|
||||||
|
label4.Text = "Цена";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(529, 104);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(125, 20);
|
||||||
|
label1.TabIndex = 20;
|
||||||
|
label1.Text = "Название услуги";
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
textBoxName.Location = new Point(508, 127);
|
||||||
|
textBoxName.Name = "textBoxName";
|
||||||
|
textBoxName.Size = new Size(280, 27);
|
||||||
|
textBoxName.TabIndex = 18;
|
||||||
|
//
|
||||||
|
// button3
|
||||||
|
//
|
||||||
|
button3.Location = new Point(700, 410);
|
||||||
|
button3.Name = "button3";
|
||||||
|
button3.Size = new Size(94, 29);
|
||||||
|
button3.TabIndex = 17;
|
||||||
|
button3.Text = "Удалить";
|
||||||
|
button3.UseVisualStyleBackColor = true;
|
||||||
|
button3.Click += ButtonDelete_Click;
|
||||||
|
//
|
||||||
|
// button2
|
||||||
|
//
|
||||||
|
button2.Location = new Point(600, 410);
|
||||||
|
button2.Name = "button2";
|
||||||
|
button2.Size = new Size(94, 29);
|
||||||
|
button2.TabIndex = 16;
|
||||||
|
button2.Text = "Изменить";
|
||||||
|
button2.UseVisualStyleBackColor = true;
|
||||||
|
button2.Click += ButtonUpdate_Click;
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
button1.Location = new Point(500, 410);
|
||||||
|
button1.Name = "button1";
|
||||||
|
button1.Size = new Size(94, 29);
|
||||||
|
button1.TabIndex = 15;
|
||||||
|
button1.Text = "Добавить";
|
||||||
|
button1.UseVisualStyleBackColor = true;
|
||||||
|
button1.Click += ButtonCreate_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Location = new Point(6, 1);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.RowTemplate.Height = 29;
|
||||||
|
dataGridView.Size = new Size(478, 448);
|
||||||
|
dataGridView.TabIndex = 14;
|
||||||
|
//
|
||||||
|
// FormService
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(numericUpDownPrice);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(button3);
|
||||||
|
Controls.Add(button2);
|
||||||
|
Controls.Add(button1);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormService";
|
||||||
|
Text = "FormService";
|
||||||
|
Load += FormService_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private NumericUpDown numericUpDownPrice;
|
||||||
|
private Label label4;
|
||||||
|
private Label label1;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private Button button3;
|
||||||
|
private Button button2;
|
||||||
|
private Button button1;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
116
Hotel/HotelView/FormService.cs
Normal file
116
Hotel/HotelView/FormService.cs
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
using HotelAbstractions.Logic;
|
||||||
|
using HotelAbstractions.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace HotelView
|
||||||
|
{
|
||||||
|
public partial class FormService : Form
|
||||||
|
{
|
||||||
|
private readonly IServiceLogic _serviceLogic;
|
||||||
|
public FormService(IServiceLogic serviceLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_serviceLogic = serviceLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormService_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Service newService = new()
|
||||||
|
{
|
||||||
|
Name = textBoxName.Text,
|
||||||
|
Price = (double)numericUpDownPrice.Value,
|
||||||
|
};
|
||||||
|
|
||||||
|
_serviceLogic.Create(newService);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
var services = _serviceLogic.GetAll();
|
||||||
|
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
|
||||||
|
if (dataGridView.ColumnCount == 0)
|
||||||
|
{
|
||||||
|
dataGridView.Columns.Add("Id", "ID");
|
||||||
|
dataGridView.Columns.Add("Name", "Название");
|
||||||
|
dataGridView.Columns.Add("Price", "Цена");
|
||||||
|
}
|
||||||
|
|
||||||
|
dataGridView.Columns["Id"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Price"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
|
||||||
|
foreach (var service in services)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(service.Id, service.Name, service.Price);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||||
|
int serviceId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||||
|
|
||||||
|
Service updatedService = new()
|
||||||
|
{
|
||||||
|
Id = serviceId,
|
||||||
|
Name = textBoxName.Text,
|
||||||
|
Price = (double)numericUpDownPrice.Value
|
||||||
|
};
|
||||||
|
|
||||||
|
_serviceLogic.Update(updatedService);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Пожалуйста, выберите гостинницу, информацию о которой необходимо обновить");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||||
|
int serviceId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||||
|
|
||||||
|
_serviceLogic.Delete(serviceId);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Пожалуйста, выберите гостинницу, информацию о которой необходимо удалить");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.RowIndex >= 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||||
|
textBoxName.Text = row.Cells["Name"].Value.ToString();
|
||||||
|
numericUpDownPrice.Text = row.Cells["Price"].Value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Hotel/HotelView/FormService.resx
Normal file
120
Hotel/HotelView/FormService.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
196
Hotel/HotelView/FormServiceCheck.Designer.cs
generated
Normal file
196
Hotel/HotelView/FormServiceCheck.Designer.cs
generated
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
namespace HotelView
|
||||||
|
{
|
||||||
|
partial class FormServiceCheck
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
dateTimePicker = new DateTimePicker();
|
||||||
|
label2 = new Label();
|
||||||
|
label1 = new Label();
|
||||||
|
comboBoxService = new ComboBox();
|
||||||
|
numericUpDownCount = new NumericUpDown();
|
||||||
|
label5 = new Label();
|
||||||
|
labelAuth = new Label();
|
||||||
|
comboBoxReservation = new ComboBox();
|
||||||
|
button3 = new Button();
|
||||||
|
button2 = new Button();
|
||||||
|
button1 = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dateTimePicker
|
||||||
|
//
|
||||||
|
dateTimePicker.Location = new Point(628, 305);
|
||||||
|
dateTimePicker.Name = "dateTimePicker";
|
||||||
|
dateTimePicker.Size = new Size(274, 27);
|
||||||
|
dateTimePicker.TabIndex = 74;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(643, 282);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(89, 20);
|
||||||
|
label2.TabIndex = 73;
|
||||||
|
label2.Text = "Дата услуги";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(643, 90);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(54, 20);
|
||||||
|
label1.TabIndex = 72;
|
||||||
|
label1.Text = "Услуга";
|
||||||
|
//
|
||||||
|
// comboBoxService
|
||||||
|
//
|
||||||
|
comboBoxService.FormattingEnabled = true;
|
||||||
|
comboBoxService.Location = new Point(628, 115);
|
||||||
|
comboBoxService.Margin = new Padding(3, 5, 3, 5);
|
||||||
|
comboBoxService.Name = "comboBoxService";
|
||||||
|
comboBoxService.Size = new Size(274, 28);
|
||||||
|
comboBoxService.TabIndex = 71;
|
||||||
|
//
|
||||||
|
// numericUpDownCount
|
||||||
|
//
|
||||||
|
numericUpDownCount.Location = new Point(628, 207);
|
||||||
|
numericUpDownCount.Name = "numericUpDownCount";
|
||||||
|
numericUpDownCount.Size = new Size(274, 27);
|
||||||
|
numericUpDownCount.TabIndex = 70;
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
label5.AutoSize = true;
|
||||||
|
label5.Location = new Point(643, 184);
|
||||||
|
label5.Name = "label5";
|
||||||
|
label5.Size = new Size(90, 20);
|
||||||
|
label5.TabIndex = 69;
|
||||||
|
label5.Text = "Количество";
|
||||||
|
//
|
||||||
|
// labelAuth
|
||||||
|
//
|
||||||
|
labelAuth.AutoSize = true;
|
||||||
|
labelAuth.Location = new Point(643, 15);
|
||||||
|
labelAuth.Name = "labelAuth";
|
||||||
|
labelAuth.Size = new Size(114, 20);
|
||||||
|
labelAuth.TabIndex = 68;
|
||||||
|
labelAuth.Text = "Бронирование";
|
||||||
|
//
|
||||||
|
// comboBoxReservation
|
||||||
|
//
|
||||||
|
comboBoxReservation.FormattingEnabled = true;
|
||||||
|
comboBoxReservation.Location = new Point(628, 40);
|
||||||
|
comboBoxReservation.Margin = new Padding(3, 5, 3, 5);
|
||||||
|
comboBoxReservation.Name = "comboBoxReservation";
|
||||||
|
comboBoxReservation.Size = new Size(274, 28);
|
||||||
|
comboBoxReservation.TabIndex = 67;
|
||||||
|
//
|
||||||
|
// button3
|
||||||
|
//
|
||||||
|
button3.Location = new Point(814, 409);
|
||||||
|
button3.Name = "button3";
|
||||||
|
button3.Size = new Size(94, 29);
|
||||||
|
button3.TabIndex = 66;
|
||||||
|
button3.Text = "Удалить";
|
||||||
|
button3.UseVisualStyleBackColor = true;
|
||||||
|
button3.Click += ButtonDelete_Click;
|
||||||
|
//
|
||||||
|
// button2
|
||||||
|
//
|
||||||
|
button2.Location = new Point(714, 409);
|
||||||
|
button2.Name = "button2";
|
||||||
|
button2.Size = new Size(94, 29);
|
||||||
|
button2.TabIndex = 65;
|
||||||
|
button2.Text = "Изменить";
|
||||||
|
button2.UseVisualStyleBackColor = true;
|
||||||
|
button2.Click += ButtonUpdate_Click;
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
button1.Location = new Point(614, 409);
|
||||||
|
button1.Name = "button1";
|
||||||
|
button1.Size = new Size(94, 29);
|
||||||
|
button1.TabIndex = 64;
|
||||||
|
button1.Text = "Добавить";
|
||||||
|
button1.UseVisualStyleBackColor = true;
|
||||||
|
button1.Click += ButtonCreate_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Location = new Point(-1, 2);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.RowTemplate.Height = 29;
|
||||||
|
dataGridView.Size = new Size(609, 446);
|
||||||
|
dataGridView.TabIndex = 63;
|
||||||
|
//
|
||||||
|
// FormServiceCheck
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(916, 450);
|
||||||
|
Controls.Add(dateTimePicker);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(comboBoxService);
|
||||||
|
Controls.Add(numericUpDownCount);
|
||||||
|
Controls.Add(label5);
|
||||||
|
Controls.Add(labelAuth);
|
||||||
|
Controls.Add(comboBoxReservation);
|
||||||
|
Controls.Add(button3);
|
||||||
|
Controls.Add(button2);
|
||||||
|
Controls.Add(button1);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormServiceCheck";
|
||||||
|
Text = "FormServiceCheck";
|
||||||
|
Load += FormServiceCheck_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DateTimePicker dateTimePicker;
|
||||||
|
private Label label2;
|
||||||
|
private Label label1;
|
||||||
|
private ComboBox comboBoxService;
|
||||||
|
private NumericUpDown numericUpDownCount;
|
||||||
|
private Label label5;
|
||||||
|
private Label labelAuth;
|
||||||
|
private ComboBox comboBoxReservation;
|
||||||
|
private Button button3;
|
||||||
|
private Button button2;
|
||||||
|
private Button button1;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
151
Hotel/HotelView/FormServiceCheck.cs
Normal file
151
Hotel/HotelView/FormServiceCheck.cs
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
using HotelAbstractions.Logic;
|
||||||
|
using HotelAbstractions.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace HotelView
|
||||||
|
{
|
||||||
|
public partial class FormServiceCheck : Form
|
||||||
|
{
|
||||||
|
private readonly IServiceCheckLogic _serviceCheckLogic;
|
||||||
|
private readonly IReservationLogic _reservationLogic;
|
||||||
|
private readonly IServiceLogic _serviceLogic;
|
||||||
|
public FormServiceCheck(IServiceCheckLogic serviceCheckLogic, IReservationLogic reservationLogic, IServiceLogic serviceLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_serviceCheckLogic = serviceCheckLogic;
|
||||||
|
_reservationLogic = reservationLogic;
|
||||||
|
_serviceLogic = serviceLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormServiceCheck_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ServiceCheck newServiceCheck = new()
|
||||||
|
{
|
||||||
|
ReservationId = ((Reservation?)comboBoxReservation.SelectedItem)?.Id ?? 0,
|
||||||
|
ServiceId = ((Service?)comboBoxService.SelectedItem)?.Id ?? 0,
|
||||||
|
Count = (int)numericUpDownCount.Value,
|
||||||
|
DateTime = dateTimePicker.Value,
|
||||||
|
};
|
||||||
|
|
||||||
|
_serviceCheckLogic.Create(newServiceCheck);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
var serviceChecks = _serviceCheckLogic.GetAll();
|
||||||
|
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
|
||||||
|
if (dataGridView.ColumnCount == 0)
|
||||||
|
{
|
||||||
|
dataGridView.Columns.Add("Id", "ID");
|
||||||
|
dataGridView.Columns.Add("ReservationId", "ReservationId");
|
||||||
|
dataGridView.Columns["ReservationId"].Visible = false;
|
||||||
|
dataGridView.Columns.Add("Reservation", "Бронирование");
|
||||||
|
dataGridView.Columns.Add("ServiceId", "ServiceId");
|
||||||
|
dataGridView.Columns["ServiceId"].Visible = false;
|
||||||
|
dataGridView.Columns.Add("Service", "Услуга");
|
||||||
|
dataGridView.Columns.Add("Count", "Количество");
|
||||||
|
dataGridView.Columns.Add("DateTime", "Дата время");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dataGridView.Columns["Id"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Reservation"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Service"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Count"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["DateTime"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
|
||||||
|
comboBoxReservation.DataSource = _reservationLogic.GetAll();
|
||||||
|
comboBoxReservation.DisplayMember = "Reservation";
|
||||||
|
comboBoxReservation.ValueMember = "Id";
|
||||||
|
|
||||||
|
comboBoxService.DataSource = _serviceLogic.GetAll();
|
||||||
|
comboBoxService.DisplayMember = "Service";
|
||||||
|
comboBoxService.ValueMember = "Name";
|
||||||
|
|
||||||
|
foreach (var serviceCheck in serviceChecks)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(serviceCheck.Id,
|
||||||
|
serviceCheck.ReservationId, _reservationLogic.Get(serviceCheck.ReservationId)?.Id,
|
||||||
|
serviceCheck.ServiceId, _serviceLogic.Get(serviceCheck.ServiceId)?.Name,
|
||||||
|
serviceCheck.Count,
|
||||||
|
serviceCheck.DateTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||||
|
int serviceCheckId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||||
|
|
||||||
|
ServiceCheck updatedServiceCheck = new()
|
||||||
|
{
|
||||||
|
Id = serviceCheckId,
|
||||||
|
ReservationId = ((Reservation?)comboBoxReservation.SelectedItem)?.Id ?? 0,
|
||||||
|
ServiceId = ((Service?)comboBoxService.SelectedItem)?.Id ?? 0,
|
||||||
|
Count = (int)numericUpDownCount.Value,
|
||||||
|
DateTime = dateTimePicker.Value,
|
||||||
|
};
|
||||||
|
|
||||||
|
_serviceCheckLogic.Update(updatedServiceCheck);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Пожалуйста, выберите статью, информацию о которой необходимо обновить");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||||
|
int serviceCheckId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||||
|
|
||||||
|
_serviceCheckLogic.Delete(serviceCheckId);
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Пожалуйста, выберите статью, информацию о которой необходимо удалить");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.RowIndex >= 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||||
|
comboBoxReservation.SelectedValue = row.Cells["Reservation"].Value ?? new Reservation { Id = 0 };
|
||||||
|
comboBoxService.SelectedValue = row.Cells["Service"].Value ?? new Service { Name = "Неизвестно" };
|
||||||
|
numericUpDownCount.Text = row.Cells["Count"].Value.ToString();
|
||||||
|
dateTimePicker.Text = row.Cells["DateTime"].Value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public FormServiceCheck()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Hotel/HotelView/FormServiceCheck.resx
Normal file
120
Hotel/HotelView/FormServiceCheck.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
21
Hotel/HotelView/HotelView.csproj
Normal file
21
Hotel/HotelView/HotelView.csproj
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\HotelAbstractions\HotelAbstractions.csproj" />
|
||||||
|
<ProjectReference Include="..\HotelDatabase\HotelDatabase.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
47
Hotel/HotelView/Program.cs
Normal file
47
Hotel/HotelView/Program.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
using static System.Windows.Forms.DataFormats;
|
||||||
|
using System;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using HotelAbstractions.Logic;
|
||||||
|
using HotelDatabase.Implement;
|
||||||
|
|
||||||
|
namespace HotelView
|
||||||
|
{
|
||||||
|
internal static class Program
|
||||||
|
{
|
||||||
|
private static ServiceProvider? _serviceProvider;
|
||||||
|
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
|
// see https://aka.ms/applicationconfiguration.
|
||||||
|
ApplicationConfiguration.Initialize();
|
||||||
|
var services = new ServiceCollection();
|
||||||
|
ConfigureServices(services);
|
||||||
|
_serviceProvider = services.BuildServiceProvider();
|
||||||
|
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddTransient<IHotelLogic, HotelImplement>();
|
||||||
|
services.AddTransient<IRoomLogic, RoomImplement>();
|
||||||
|
services.AddTransient<IReservationLogic, ReservationImplement>();
|
||||||
|
services.AddTransient<IGuestLogic, GuestImplement>();
|
||||||
|
services.AddTransient<IServiceCheckLogic, ServiceCheckImplement>();
|
||||||
|
services.AddTransient<IServiceLogic, ServiceImplement>();
|
||||||
|
|
||||||
|
services.AddTransient<FormMain>();
|
||||||
|
services.AddTransient<FormHotel>();
|
||||||
|
services.AddTransient<FormGuest>();
|
||||||
|
services.AddTransient<FormService>();
|
||||||
|
services.AddTransient<FormReservation>();
|
||||||
|
services.AddTransient<FormServiceCheck>();
|
||||||
|
services.AddTransient<FormRoom>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
63
Hotel/HotelView/Properties/Resources.Designer.cs
generated
Normal file
63
Hotel/HotelView/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан программой.
|
||||||
|
// Исполняемая версия:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||||
|
// повторной генерации кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace HotelView.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||||
|
/// </summary>
|
||||||
|
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||||
|
// с помощью такого средства, как ResGen или Visual Studio.
|
||||||
|
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||||
|
// с параметром /str или перестройте свой проект VS.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HotelView.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||||
|
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Hotel/HotelView/Properties/Resources.resx
Normal file
120
Hotel/HotelView/Properties/Resources.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
Loading…
Reference in New Issue
Block a user