Compare commits
2 Commits
08289607b8
...
6d466b79e0
Author | SHA1 | Date | |
---|---|---|---|
6d466b79e0 | |||
ff949eabc1 |
@ -74,7 +74,20 @@ namespace HotelBusinessLogic.BusinessLogics
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool TakeBookingInWork(BookingBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, AcceptanceStatus.Обработка);
|
||||
}
|
||||
|
||||
public bool FinishBooking(BookingBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, AcceptanceStatus.Принимается);
|
||||
}
|
||||
|
||||
public bool DeliveryBooking(BookingBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, AcceptanceStatus.Принят);
|
||||
}
|
||||
private void CheckModel(BookingBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
@ -93,7 +106,22 @@ namespace HotelBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор клиента", nameof(model.ClientId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private bool ChangeStatus(BookingBindingModel model, AcceptanceStatus newStatus)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (model.Status + 1 != newStatus)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
model.Status = newStatus;
|
||||
if (_bookingStorage.Update(model) == null)
|
||||
{
|
||||
model.Status--;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,10 +96,6 @@ namespace HotelBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("Нет номера телефона", nameof(model.PhoneNumber));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля", nameof(model.Password));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,12 @@ namespace HotelBusinessLogic.BusinessLogics
|
||||
public class RoomLogic : IRoomLogic
|
||||
{
|
||||
private readonly IRoomStorage _roomStorage;
|
||||
private readonly IWorkerStorage _workerStorage;
|
||||
|
||||
public RoomLogic(IRoomStorage roomStorage)
|
||||
public RoomLogic(IRoomStorage roomStorage, IWorkerStorage workerStorage)
|
||||
{
|
||||
_roomStorage = roomStorage;
|
||||
_workerStorage = workerStorage;
|
||||
}
|
||||
public RoomViewModel? ReadElement(RoomSearchModel model)
|
||||
{
|
||||
@ -108,7 +110,33 @@ namespace HotelBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("нет поля цены", nameof(model.Cost));
|
||||
}
|
||||
var elementNumber = _roomStorage.GetElement(new RoomSearchModel
|
||||
{
|
||||
Number = model.Number
|
||||
});
|
||||
if (elementNumber != null && elementNumber.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Такой номер уже существует");
|
||||
}
|
||||
}
|
||||
|
||||
public bool ProvercaMade(RoomBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
var room = ReadElement(new RoomSearchModel { Number = model.Number});
|
||||
var workers = _workerStorage.GetFullList();
|
||||
if(room == null) return false;
|
||||
foreach (var item in workers) {
|
||||
if (room.WorkerId == item.Id)
|
||||
{
|
||||
if(item.PostName == "Горничная" || item.PostName == "Горничный")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,10 @@ namespace HotelContracts.BindingModels
|
||||
|
||||
public DateTime DepartureDate { get; set; } = DateTime.Now;
|
||||
|
||||
public int NumberHoursSpent { get; set; }
|
||||
public double NumberHoursSpent { get; set; }
|
||||
|
||||
public AcceptanceStatus Status { get; set; } = AcceptanceStatus.Неизвестен;
|
||||
|
||||
public int TotalCost { get; set; }
|
||||
public double TotalCost { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,5 @@ namespace HotelContracts.BindingModels
|
||||
public DateTime DateOfBirth { get; set; } = DateTime.Now;
|
||||
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -17,5 +17,8 @@ namespace HotelContracts.BusinessLogicsContracts
|
||||
bool Create(BookingBindingModel model);
|
||||
bool Update(BookingBindingModel model);
|
||||
bool Delete(BookingBindingModel model);
|
||||
bool TakeBookingInWork(BookingBindingModel model);
|
||||
bool FinishBooking(BookingBindingModel model);
|
||||
bool DeliveryBooking(BookingBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace HotelContracts.BusinessLogicsContracts
|
||||
{
|
||||
List<RoomViewModel>? ReadList(RoomSearchModel? model);
|
||||
RoomViewModel? ReadElement(RoomSearchModel model);
|
||||
|
||||
bool ProvercaMade(RoomBindingModel model);
|
||||
bool Create(RoomBindingModel model);
|
||||
bool Update(RoomBindingModel model);
|
||||
bool Delete(RoomBindingModel model);
|
||||
|
@ -1,4 +1,5 @@
|
||||
using HotelDataModels.Enums;
|
||||
using HotelDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -8,21 +9,25 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace HotelContracts.ViewModels
|
||||
{
|
||||
public class BookingViewModel
|
||||
{
|
||||
public class BookingViewModel : IBookingModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int RoomId { get; set; }
|
||||
|
||||
public int ClientId { get; set; }
|
||||
[DisplayName("Номер комнаты")]
|
||||
public int Number { get; set; }
|
||||
[DisplayName("Фамилия клиента")]
|
||||
public string Surname { get; set; } = string.Empty;
|
||||
[DisplayName("Дата заезда")]
|
||||
public DateTime ArrivalDate { get; set; } = DateTime.Now;
|
||||
[DisplayName("Дата выезда")]
|
||||
public DateTime DepartureDate { get; set; } = DateTime.Now;
|
||||
[DisplayName("Количество проведенных часов")]
|
||||
public int NumberHoursSpent { get; set; }
|
||||
public double NumberHoursSpent { get; set; }
|
||||
[DisplayName("Статус проверки")]
|
||||
public AcceptanceStatus Status { get; set; } = AcceptanceStatus.Неизвестен;
|
||||
[DisplayName("Полная стоимость")]
|
||||
public int TotalCost { get; set; }
|
||||
public double TotalCost { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using HotelDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
@ -7,8 +8,8 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace HotelContracts.ViewModels
|
||||
{
|
||||
public class ClientViewModel
|
||||
{
|
||||
public class ClientViewModel : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Имя")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
@ -18,7 +19,6 @@ namespace HotelContracts.ViewModels
|
||||
public DateTime DateOfBirth { get; set; } = DateTime.Now;
|
||||
[DisplayName("Номер телефона")]
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using HotelDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
@ -7,8 +8,8 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace HotelContracts.ViewModels
|
||||
{
|
||||
public class PostViewModel
|
||||
{
|
||||
public class PostViewModel : IPostModel
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название должности")]
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using HotelDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
@ -7,8 +8,8 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace HotelContracts.ViewModels
|
||||
{
|
||||
public class RoomViewModel
|
||||
{
|
||||
public class RoomViewModel : IRoomModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int WorkerId { get; set; }
|
||||
@ -22,5 +23,7 @@ namespace HotelContracts.ViewModels
|
||||
public string Condition { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public int Cost { get; set; }
|
||||
[DisplayName("Работник")]
|
||||
public string WorkerFIO { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -23,5 +23,7 @@ namespace HotelContracts.ViewModels
|
||||
public int Salary { get; set; }
|
||||
[DisplayName("Номер телефона")]
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
[DisplayName("Должность")]
|
||||
public string PostName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -13,8 +13,8 @@ namespace HotelDataModels.Models
|
||||
int ClientId { get; }
|
||||
DateTime ArrivalDate { get; }
|
||||
DateTime DepartureDate { get; }
|
||||
int NumberHoursSpent { get; }
|
||||
double NumberHoursSpent { get; }
|
||||
Enums.AcceptanceStatus Status { get; }
|
||||
int TotalCost { get; }
|
||||
double TotalCost { get; }
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,5 @@ namespace HotelDataModels.Models
|
||||
DateTime DateOfBirth { get; }
|
||||
string PhoneNumber { get; }
|
||||
|
||||
string Password { get; }
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,11 @@ namespace HotelDatabaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS01;Initial Catalog=HotelDatabaseBD;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseNpgsql(@"Host=localhost;Port=5432;Database=Hotel_Subd_DB;Username=postgres;Password=admin");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||
}
|
||||
public virtual DbSet<Booking> Bookings { get; set; }
|
||||
public virtual DbSet<Client> Clients { get; set; }
|
||||
|
@ -14,9 +14,11 @@ namespace HotelDatabaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS01;Initial Catalog=HotelDatabaseBD;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseNpgsql(@"Host=localhost;Port=5432;Database=Hotel_Subd_DB;Username=postgres;Password=admin");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||
}
|
||||
public virtual DbSet<Booking> Bookings { get; set; }
|
||||
public virtual DbSet<Client> Clients { get; set; }
|
||||
|
@ -13,7 +13,7 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.8" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -20,13 +20,17 @@ namespace HotelDatabaseImplement.Implements
|
||||
var element = context.Bookings.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
var deletedElement = context.Bookings
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Room)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
context.Bookings.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public BookingViewModel? GetElement(BookingSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
@ -34,7 +38,7 @@ namespace HotelDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new HotelDatabase();
|
||||
return context.Bookings.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
return context.Bookings.Include(x => x.Client).Include(x => x.Room).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<BookingViewModel> GetFilteredList(BookingSearchModel model)
|
||||
@ -44,13 +48,13 @@ namespace HotelDatabaseImplement.Implements
|
||||
return new();
|
||||
}
|
||||
using var context = new HotelDatabase();
|
||||
return context.Bookings.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||
return context.Bookings.Include(x => x.Client).Include(x => x.Room).Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<BookingViewModel> GetFullList()
|
||||
{
|
||||
using var context = new HotelDatabase();
|
||||
return context.Bookings.Select(x => x.GetViewModel).ToList();
|
||||
return context.Bookings.Include(x => x.Client).Include(x => x.Room).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public BookingViewModel? Insert(BookingBindingModel model)
|
||||
@ -63,9 +67,12 @@ namespace HotelDatabaseImplement.Implements
|
||||
using var context = new HotelDatabase();
|
||||
context.Bookings.Add(newBooking);
|
||||
context.SaveChanges();
|
||||
return newBooking.GetViewModel;
|
||||
return context.Bookings
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Room)
|
||||
.FirstOrDefault(x => x.Id == newBooking.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public BookingViewModel? Update(BookingBindingModel model)
|
||||
{
|
||||
using var context = new HotelDatabase();
|
||||
@ -80,7 +87,11 @@ namespace HotelDatabaseImplement.Implements
|
||||
booking.Update(model);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return booking.GetViewModel;
|
||||
return context.Bookings
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Room)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -3,6 +3,7 @@ using HotelContracts.SearchModels;
|
||||
using HotelContracts.StoragesContracts;
|
||||
using HotelContracts.ViewModels;
|
||||
using HotelDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -16,12 +17,16 @@ namespace HotelDatabaseImplement.Implements
|
||||
public RoomViewModel? Delete(RoomBindingModel model)
|
||||
{
|
||||
using var context = new HotelDatabase();
|
||||
var element = context.Rooms.FirstOrDefault(x => x.Id == model.Id);
|
||||
var element = context.Rooms.FirstOrDefault(x => x.Number == model.Number);
|
||||
if (element != null)
|
||||
{
|
||||
var deletedElement = context.Rooms
|
||||
.Include(x => x.Worker)
|
||||
.FirstOrDefault(x => x.Number == model.Number)
|
||||
?.GetViewModel;
|
||||
context.Rooms.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
return deletedElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -33,7 +38,7 @@ namespace HotelDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new HotelDatabase();
|
||||
return context.Rooms.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Number.ToString())) && x.Number.ToString() == model.Number.ToString() || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||
return context.Rooms.Include(x => x.Worker).FirstOrDefault(x => (!string.IsNullOrEmpty(model.Number.ToString())) && x.Number.ToString() == model.Number.ToString() || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<RoomViewModel> GetFilteredList(RoomSearchModel model)
|
||||
@ -43,13 +48,13 @@ namespace HotelDatabaseImplement.Implements
|
||||
return new();
|
||||
}
|
||||
using var context = new HotelDatabase();
|
||||
return context.Rooms.Where(x => x.Number.ToString().Contains(model.Number.ToString())).Select(x => x.GetViewModel).ToList();
|
||||
return context.Rooms.Include(x => x.Worker).Where(x => x.Number.ToString().Contains(model.Number.ToString())).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<RoomViewModel> GetFullList()
|
||||
{
|
||||
using var context = new HotelDatabase();
|
||||
return context.Rooms.Select(x => x.GetViewModel).ToList();
|
||||
return context.Rooms.Include(x => x.Worker).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public RoomViewModel? Insert(RoomBindingModel model)
|
||||
@ -62,7 +67,10 @@ namespace HotelDatabaseImplement.Implements
|
||||
using var context = new HotelDatabase();
|
||||
context.Rooms.Add(newRoom);
|
||||
context.SaveChanges();
|
||||
return newRoom.GetViewModel;
|
||||
return context.Rooms
|
||||
.Include(x => x.Worker)
|
||||
.FirstOrDefault(x => x.Id == newRoom.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public RoomViewModel? Update(RoomBindingModel model)
|
||||
@ -75,7 +83,10 @@ namespace HotelDatabaseImplement.Implements
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
return context.Rooms
|
||||
.Include(x => x.Worker)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using HotelContracts.SearchModels;
|
||||
using HotelContracts.StoragesContracts;
|
||||
using HotelContracts.ViewModels;
|
||||
using HotelDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -19,9 +20,13 @@ namespace HotelDatabaseImplement.Implements
|
||||
var element = context.Workers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
var deletedElement = context.Workers
|
||||
.Include(x => x.Post)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
context.Workers.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
return deletedElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -33,7 +38,7 @@ namespace HotelDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new HotelDatabase();
|
||||
return context.Workers.FirstOrDefault(x => (!string.IsNullOrEmpty(model.FIO)) && x.FIO == model.FIO || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||
return context.Workers.Include(x => x.Post).FirstOrDefault(x => (!string.IsNullOrEmpty(model.FIO)) && x.FIO == model.FIO || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<WorkerViewModel> GetFilteredList(WorkerSearchModel model)
|
||||
@ -43,13 +48,13 @@ namespace HotelDatabaseImplement.Implements
|
||||
return new();
|
||||
}
|
||||
using var context = new HotelDatabase();
|
||||
return context.Workers.Where(x => x.FIO.Contains(model.FIO)).Select(x => x.GetViewModel).ToList();
|
||||
return context.Workers.Include(x => x.Post).Where(x => x.FIO.Contains(model.FIO)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<WorkerViewModel> GetFullList()
|
||||
{
|
||||
using var context = new HotelDatabase();
|
||||
return context.Workers.Select(x => x.GetViewModel).ToList();
|
||||
return context.Workers.Include(x => x.Post).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public WorkerViewModel? Insert(WorkerBindingModel model)
|
||||
@ -62,7 +67,10 @@ namespace HotelDatabaseImplement.Implements
|
||||
using var context = new HotelDatabase();
|
||||
context.Workers.Add(newWorker);
|
||||
context.SaveChanges();
|
||||
return newWorker.GetViewModel;
|
||||
return context.Workers
|
||||
.Include(x => x.Post)
|
||||
.FirstOrDefault(x => x.Id == newWorker.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public WorkerViewModel? Update(WorkerBindingModel model)
|
||||
@ -75,7 +83,10 @@ namespace HotelDatabaseImplement.Implements
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
return context.Workers
|
||||
.Include(x => x.Post)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
223
Hotel/HotelDatabaseImplement/Migrations/20240506153412_initialMigration.Designer.cs
generated
Normal file
223
Hotel/HotelDatabaseImplement/Migrations/20240506153412_initialMigration.Designer.cs
generated
Normal file
@ -0,0 +1,223 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using HotelDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HotelDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(HotelDatabase))]
|
||||
[Migration("20240506153412_initialMigration")]
|
||||
partial class initialMigration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.16")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("HotelDatabaseImplement.Models.Booking", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("ArrivalDate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DepartureDate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<double>("NumberHoursSpent")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("RoomId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("TotalCost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("RoomId");
|
||||
|
||||
b.ToTable("Bookings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("DateOfBirth")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDatabaseImplement.Models.Post", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("PostName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Posts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDatabaseImplement.Models.Room", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Condition")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Cost")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Floor")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Number")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("NumberOfBeds")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("WorkerId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WorkerId");
|
||||
|
||||
b.ToTable("Rooms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDatabaseImplement.Models.Worker", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("DateOfBirth")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("FIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("PostId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Salary")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("WorkExperience")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PostId");
|
||||
|
||||
b.ToTable("Workers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDatabaseImplement.Models.Booking", b =>
|
||||
{
|
||||
b.HasOne("HotelDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDatabaseImplement.Models.Room", "Room")
|
||||
.WithMany()
|
||||
.HasForeignKey("RoomId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Room");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDatabaseImplement.Models.Room", b =>
|
||||
{
|
||||
b.HasOne("HotelDatabaseImplement.Models.Worker", "Worker")
|
||||
.WithMany()
|
||||
.HasForeignKey("WorkerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Worker");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDatabaseImplement.Models.Worker", b =>
|
||||
{
|
||||
b.HasOne("HotelDatabaseImplement.Models.Post", "Post")
|
||||
.WithMany()
|
||||
.HasForeignKey("PostId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Post");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HotelDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class initialMigration : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Surname = table.Column<string>(type: "text", nullable: false),
|
||||
DateOfBirth = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
PhoneNumber = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Posts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
PostName = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Posts", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Workers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
PostId = table.Column<int>(type: "integer", nullable: false),
|
||||
FIO = table.Column<string>(type: "text", nullable: false),
|
||||
DateOfBirth = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
WorkExperience = table.Column<int>(type: "integer", nullable: false),
|
||||
Salary = table.Column<int>(type: "integer", nullable: false),
|
||||
Phone = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Workers", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Workers_Posts_PostId",
|
||||
column: x => x.PostId,
|
||||
principalTable: "Posts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Rooms",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
WorkerId = table.Column<int>(type: "integer", nullable: false),
|
||||
Number = table.Column<int>(type: "integer", nullable: false),
|
||||
Floor = table.Column<int>(type: "integer", nullable: false),
|
||||
NumberOfBeds = table.Column<int>(type: "integer", nullable: false),
|
||||
Condition = table.Column<string>(type: "text", nullable: false),
|
||||
Cost = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Rooms", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Rooms_Workers_WorkerId",
|
||||
column: x => x.WorkerId,
|
||||
principalTable: "Workers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Bookings",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
RoomId = table.Column<int>(type: "integer", nullable: false),
|
||||
ClientId = table.Column<int>(type: "integer", nullable: false),
|
||||
ArrivalDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
DepartureDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
NumberHoursSpent = table.Column<double>(type: "double precision", nullable: false),
|
||||
Status = table.Column<int>(type: "integer", nullable: false),
|
||||
TotalCost = table.Column<double>(type: "double precision", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Bookings", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Bookings_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Bookings_Rooms_RoomId",
|
||||
column: x => x.RoomId,
|
||||
principalTable: "Rooms",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Bookings_ClientId",
|
||||
table: "Bookings",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Bookings_RoomId",
|
||||
table: "Bookings",
|
||||
column: "RoomId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Rooms_WorkerId",
|
||||
table: "Rooms",
|
||||
column: "WorkerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Workers_PostId",
|
||||
table: "Workers",
|
||||
column: "PostId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Bookings");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Rooms");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Workers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Posts");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,220 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using HotelDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HotelDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(HotelDatabase))]
|
||||
partial class HotelDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.16")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("HotelDatabaseImplement.Models.Booking", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("ArrivalDate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DepartureDate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<double>("NumberHoursSpent")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("RoomId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("TotalCost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("RoomId");
|
||||
|
||||
b.ToTable("Bookings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("DateOfBirth")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDatabaseImplement.Models.Post", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("PostName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Posts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDatabaseImplement.Models.Room", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Condition")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Cost")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Floor")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Number")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("NumberOfBeds")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("WorkerId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WorkerId");
|
||||
|
||||
b.ToTable("Rooms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDatabaseImplement.Models.Worker", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("DateOfBirth")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("FIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("PostId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Salary")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("WorkExperience")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PostId");
|
||||
|
||||
b.ToTable("Workers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDatabaseImplement.Models.Booking", b =>
|
||||
{
|
||||
b.HasOne("HotelDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HotelDatabaseImplement.Models.Room", "Room")
|
||||
.WithMany()
|
||||
.HasForeignKey("RoomId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Room");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDatabaseImplement.Models.Room", b =>
|
||||
{
|
||||
b.HasOne("HotelDatabaseImplement.Models.Worker", "Worker")
|
||||
.WithMany()
|
||||
.HasForeignKey("WorkerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Worker");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HotelDatabaseImplement.Models.Worker", b =>
|
||||
{
|
||||
b.HasOne("HotelDatabaseImplement.Models.Post", "Post")
|
||||
.WithMany()
|
||||
.HasForeignKey("PostId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Post");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -22,13 +22,15 @@ namespace HotelDatabaseImplement.Models
|
||||
[Required]
|
||||
public DateTime DepartureDate { get; set; }
|
||||
[Required]
|
||||
public int NumberHoursSpent { get; set; }
|
||||
public double NumberHoursSpent { get; set; }
|
||||
[Required]
|
||||
public AcceptanceStatus Status { get; set; }
|
||||
[Required]
|
||||
public int TotalCost { get; set; }
|
||||
public double TotalCost { get; set; }
|
||||
[Required]
|
||||
public int Id { get; set; }
|
||||
public virtual Room Room { get; set; }
|
||||
public virtual Client Client { get; set; }
|
||||
public static Booking Create(BookingBindingModel model)
|
||||
{
|
||||
return new Booking()
|
||||
@ -47,13 +49,7 @@ namespace HotelDatabaseImplement.Models
|
||||
{
|
||||
if (model == null) return;
|
||||
Id = model.Id;
|
||||
RoomId = model.RoomId;
|
||||
ClientId = model.ClientId;
|
||||
ArrivalDate = model.ArrivalDate;
|
||||
DepartureDate = model.DepartureDate;
|
||||
NumberHoursSpent = model.NumberHoursSpent;
|
||||
Status = model.Status;
|
||||
TotalCost = model.TotalCost;
|
||||
}
|
||||
public BookingViewModel GetViewModel => new()
|
||||
{
|
||||
@ -64,7 +60,9 @@ namespace HotelDatabaseImplement.Models
|
||||
DepartureDate = DepartureDate,
|
||||
NumberHoursSpent = NumberHoursSpent,
|
||||
Status = Status,
|
||||
TotalCost = TotalCost
|
||||
TotalCost = TotalCost,
|
||||
Number = Room.Number,
|
||||
Surname = Client.Surname
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,6 @@ namespace HotelDatabaseImplement.Models
|
||||
public DateTime DateOfBirth { get; set; }
|
||||
[Required]
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
public static Client Create(ClientBindingModel model)
|
||||
@ -32,8 +30,7 @@ namespace HotelDatabaseImplement.Models
|
||||
Name = model.Name,
|
||||
Surname = model.Surname,
|
||||
DateOfBirth = model.DateOfBirth,
|
||||
PhoneNumber = model.PhoneNumber,
|
||||
Password = model.Password,
|
||||
PhoneNumber = model.PhoneNumber
|
||||
};
|
||||
}
|
||||
public void Update(ClientBindingModel model)
|
||||
@ -44,7 +41,6 @@ namespace HotelDatabaseImplement.Models
|
||||
Surname = model.Surname;
|
||||
DateOfBirth = model.DateOfBirth;
|
||||
PhoneNumber = model.PhoneNumber;
|
||||
Password = model.Password;
|
||||
}
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
@ -53,7 +49,6 @@ namespace HotelDatabaseImplement.Models
|
||||
Surname = Surname,
|
||||
DateOfBirth = DateOfBirth,
|
||||
PhoneNumber = PhoneNumber,
|
||||
Password = Password
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ namespace HotelDatabaseImplement.Models
|
||||
public int Cost { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
public virtual Worker Worker { get; set; }
|
||||
public static Room? Create(RoomBindingModel model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
@ -46,7 +47,6 @@ namespace HotelDatabaseImplement.Models
|
||||
{
|
||||
if (model == null) return;
|
||||
Id = model.Id;
|
||||
WorkerId = model.WorkerId;
|
||||
Number = model.Number;
|
||||
NumberOfBeds = model.NumberOfBeds;
|
||||
Condition = model.Condition;
|
||||
@ -63,7 +63,8 @@ namespace HotelDatabaseImplement.Models
|
||||
NumberOfBeds = NumberOfBeds,
|
||||
Condition = Condition,
|
||||
Cost = Cost,
|
||||
Floor = Floor
|
||||
Floor = Floor,
|
||||
WorkerFIO = Worker.FIO
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace HotelDatabaseImplement.Models
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
public virtual Post Post { get; set; }
|
||||
public static Worker? Create(WorkerBindingModel model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
@ -44,7 +45,6 @@ namespace HotelDatabaseImplement.Models
|
||||
{
|
||||
if (model == null) return;
|
||||
Id = model.Id;
|
||||
PostId = model.PostId;
|
||||
FIO = model.FIO;
|
||||
DateOfBirth = model.DateOfBirth;
|
||||
WorkExperience = model.WorkExperience;
|
||||
@ -60,7 +60,8 @@ namespace HotelDatabaseImplement.Models
|
||||
DateOfBirth = DateOfBirth,
|
||||
WorkExperience = WorkExperience,
|
||||
Salary = Salary,
|
||||
Phone = Phone
|
||||
Phone = Phone,
|
||||
PostName = Post.PostName
|
||||
};
|
||||
}
|
||||
}
|
||||
|
220
Hotel/HotelView/FormBooking.Designer.cs
generated
Normal file
220
Hotel/HotelView/FormBooking.Designer.cs
generated
Normal file
@ -0,0 +1,220 @@
|
||||
namespace HotelView
|
||||
{
|
||||
partial class FormBooking
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
label5 = new Label();
|
||||
label6 = new Label();
|
||||
textBoxTotalPrice = new TextBox();
|
||||
textBoxTotalHour = new TextBox();
|
||||
comboBoxRoom = new ComboBox();
|
||||
comboBoxClient = new ComboBox();
|
||||
dateTimePickerArriv = new DateTimePicker();
|
||||
dateTimePickerDep = new DateTimePicker();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(14, 27);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(72, 20);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Комната:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(14, 68);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(61, 20);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Клиент:";
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(283, 280);
|
||||
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(88, 40);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(93, 280);
|
||||
buttonSave.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(95, 40);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(14, 120);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(118, 20);
|
||||
label3.TabIndex = 8;
|
||||
label3.Text = "Дата прибытия:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(14, 167);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(103, 20);
|
||||
label4.TabIndex = 9;
|
||||
label4.Text = "Дата отъезда:";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.Location = new Point(14, 233);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(48, 20);
|
||||
label5.TabIndex = 10;
|
||||
label5.Text = "Цена:";
|
||||
//
|
||||
// label6
|
||||
//
|
||||
label6.AutoSize = true;
|
||||
label6.Location = new Point(218, 233);
|
||||
label6.Name = "label6";
|
||||
label6.Size = new Size(48, 20);
|
||||
label6.TabIndex = 11;
|
||||
label6.Text = "Часы:";
|
||||
//
|
||||
// textBoxTotalPrice
|
||||
//
|
||||
textBoxTotalPrice.Enabled = false;
|
||||
textBoxTotalPrice.Location = new Point(68, 230);
|
||||
textBoxTotalPrice.Name = "textBoxTotalPrice";
|
||||
textBoxTotalPrice.Size = new Size(144, 27);
|
||||
textBoxTotalPrice.TabIndex = 12;
|
||||
//
|
||||
// textBoxTotalHour
|
||||
//
|
||||
textBoxTotalHour.Enabled = false;
|
||||
textBoxTotalHour.Location = new Point(272, 230);
|
||||
textBoxTotalHour.Name = "textBoxTotalHour";
|
||||
textBoxTotalHour.Size = new Size(144, 27);
|
||||
textBoxTotalHour.TabIndex = 13;
|
||||
//
|
||||
// comboBoxRoom
|
||||
//
|
||||
comboBoxRoom.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxRoom.FormattingEnabled = true;
|
||||
comboBoxRoom.Location = new Point(93, 24);
|
||||
comboBoxRoom.Name = "comboBoxRoom";
|
||||
comboBoxRoom.Size = new Size(323, 28);
|
||||
comboBoxRoom.TabIndex = 14;
|
||||
//
|
||||
// comboBoxClient
|
||||
//
|
||||
comboBoxClient.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxClient.FormattingEnabled = true;
|
||||
comboBoxClient.Location = new Point(93, 68);
|
||||
comboBoxClient.Name = "comboBoxClient";
|
||||
comboBoxClient.Size = new Size(323, 28);
|
||||
comboBoxClient.TabIndex = 15;
|
||||
comboBoxClient.SelectedIndexChanged += comboBoxClient_SelectedIndexChanged;
|
||||
//
|
||||
// dateTimePickerArriv
|
||||
//
|
||||
dateTimePickerArriv.Format = DateTimePickerFormat.Time;
|
||||
dateTimePickerArriv.Location = new Point(138, 120);
|
||||
dateTimePickerArriv.Name = "dateTimePickerArriv";
|
||||
dateTimePickerArriv.Size = new Size(278, 27);
|
||||
dateTimePickerArriv.TabIndex = 16;
|
||||
dateTimePickerArriv.ValueChanged += textBoxdateTimePickerArriv_TextChanged;
|
||||
//
|
||||
// dateTimePickerDep
|
||||
//
|
||||
dateTimePickerDep.Format = DateTimePickerFormat.Time;
|
||||
dateTimePickerDep.Location = new Point(138, 167);
|
||||
dateTimePickerDep.Name = "dateTimePickerDep";
|
||||
dateTimePickerDep.Size = new Size(278, 27);
|
||||
dateTimePickerDep.TabIndex = 17;
|
||||
dateTimePickerDep.ValueChanged += textBoxdateTimePickerDep_TextChanged;
|
||||
//
|
||||
// FormBooking
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(454, 366);
|
||||
Controls.Add(dateTimePickerDep);
|
||||
Controls.Add(dateTimePickerArriv);
|
||||
Controls.Add(comboBoxClient);
|
||||
Controls.Add(comboBoxRoom);
|
||||
Controls.Add(textBoxTotalHour);
|
||||
Controls.Add(textBoxTotalPrice);
|
||||
Controls.Add(label6);
|
||||
Controls.Add(label5);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormBooking";
|
||||
Text = "Покупатель";
|
||||
Load += FormBooking_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private Label label5;
|
||||
private Label label6;
|
||||
private TextBox textBoxTotalPrice;
|
||||
private TextBox textBoxTotalHour;
|
||||
private ComboBox comboBoxRoom;
|
||||
private ComboBox comboBoxClient;
|
||||
private DateTimePicker dateTimePickerArriv;
|
||||
private DateTimePicker dateTimePickerDep;
|
||||
}
|
||||
}
|
170
Hotel/HotelView/FormBooking.cs
Normal file
170
Hotel/HotelView/FormBooking.cs
Normal file
@ -0,0 +1,170 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
using HotelContracts.SearchModels;
|
||||
using HotelDatabaseImplement.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 FormBooking : Form
|
||||
{
|
||||
|
||||
private readonly IBookingLogic _logic;
|
||||
private readonly IRoomLogic _logicR;
|
||||
private readonly IClientLogic _logicC;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormBooking(IBookingLogic logic, IRoomLogic logicR, IClientLogic logicC)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
_logicR = logicR;
|
||||
_logicC = logicC;
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxClient.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите клиента", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxRoom.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите комнату", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if(Convert.ToDouble(textBoxTotalHour.Text) < 1)
|
||||
{
|
||||
MessageBox.Show("Бронь не может быть меньше часа", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var model = new BookingBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
RoomId = Convert.ToInt32(comboBoxRoom.SelectedValue),
|
||||
ClientId = Convert.ToInt32(comboBoxClient.SelectedValue),
|
||||
ArrivalDate = dateTimePickerArriv.Value,
|
||||
DepartureDate = dateTimePickerDep.Value,
|
||||
NumberHoursSpent = Convert.ToDouble(textBoxTotalHour.Text),
|
||||
TotalCost = Convert.ToDouble(textBoxTotalPrice.Text),
|
||||
Status = HotelDataModels.Enums.AcceptanceStatus.Неизвестен,
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void CalcHour()
|
||||
{
|
||||
if(dateTimePickerDep.Value.Date != dateTimePickerArriv.Value)
|
||||
{
|
||||
try
|
||||
{
|
||||
var start = dateTimePickerArriv.Value;
|
||||
var end = dateTimePickerDep.Value;
|
||||
var Day = (end.Day - start.Day) * 24;
|
||||
var Hour = (end.Hour - start.Hour);
|
||||
double Minute = (end.Minute - start.Minute) / 60;
|
||||
textBoxTotalHour.Text = (Day + Hour + Minute).ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void CalcSum()
|
||||
{
|
||||
if(Convert.ToDouble(textBoxTotalHour.Text) >= 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
int id = Convert.ToInt32(comboBoxRoom.SelectedValue);
|
||||
var roomPrice = _logicR.ReadElement(new RoomSearchModel
|
||||
{
|
||||
Id
|
||||
= id
|
||||
});
|
||||
var Sum = (roomPrice?.Cost ?? 0)* Convert.ToDouble(textBoxTotalHour.Text);
|
||||
textBoxTotalPrice.Text = Sum.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void textBoxdateTimePickerArriv_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcHour();
|
||||
CalcSum();
|
||||
}
|
||||
private void textBoxdateTimePickerDep_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcHour();
|
||||
CalcSum();
|
||||
}
|
||||
private void comboBoxClient_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcHour();
|
||||
CalcSum();
|
||||
}
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
private void FormBooking_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var roomList = _logicR.ReadList(null);
|
||||
var clientList = _logicC.ReadList(null);
|
||||
if (roomList != null)
|
||||
{
|
||||
comboBoxRoom.DisplayMember = "Number";
|
||||
comboBoxRoom.ValueMember = "Id";
|
||||
comboBoxRoom.DataSource = roomList;
|
||||
comboBoxRoom.SelectedItem = null;
|
||||
}
|
||||
if (clientList != null)
|
||||
{
|
||||
comboBoxClient.DisplayMember = "Name";
|
||||
comboBoxClient.ValueMember = "Id";
|
||||
comboBoxClient.DataSource = clientList;
|
||||
comboBoxClient.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Hotel/HotelView/FormBooking.resx
Normal file
120
Hotel/HotelView/FormBooking.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>
|
167
Hotel/HotelView/FormClient.Designer.cs
generated
Normal file
167
Hotel/HotelView/FormClient.Designer.cs
generated
Normal file
@ -0,0 +1,167 @@
|
||||
namespace HotelView
|
||||
{
|
||||
partial class FormClient
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
textBoxName = new TextBox();
|
||||
dateTimePicker = new DateTimePicker();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
textBoxSurname = new TextBox();
|
||||
textBoxPhone = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(14, 27);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(42, 20);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Имя:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(14, 118);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(119, 20);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Дата рождения:";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(133, 16);
|
||||
textBoxName.Margin = new Padding(3, 4, 3, 4);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(237, 27);
|
||||
textBoxName.TabIndex = 2;
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(133, 118);
|
||||
dateTimePicker.Margin = new Padding(3, 4, 3, 4);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(237, 27);
|
||||
dateTimePicker.TabIndex = 3;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(285, 226);
|
||||
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(88, 40);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(184, 226);
|
||||
buttonSave.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(95, 40);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(14, 72);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(76, 20);
|
||||
label3.TabIndex = 8;
|
||||
label3.Text = "Фамилия:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(14, 168);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(130, 20);
|
||||
label4.TabIndex = 9;
|
||||
label4.Text = "Номер телефона:";
|
||||
//
|
||||
// textBoxSurname
|
||||
//
|
||||
textBoxSurname.Location = new Point(133, 69);
|
||||
textBoxSurname.Name = "textBoxSurname";
|
||||
textBoxSurname.Size = new Size(237, 27);
|
||||
textBoxSurname.TabIndex = 10;
|
||||
//
|
||||
// textBoxPhone
|
||||
//
|
||||
textBoxPhone.Location = new Point(150, 168);
|
||||
textBoxPhone.Name = "textBoxPhone";
|
||||
textBoxPhone.Size = new Size(220, 27);
|
||||
textBoxPhone.TabIndex = 11;
|
||||
//
|
||||
// FormClient
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(387, 282);
|
||||
Controls.Add(textBoxPhone);
|
||||
Controls.Add(textBoxSurname);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(dateTimePicker);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormClient";
|
||||
Text = "Покупатель";
|
||||
Load += FormClient_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private TextBox textBoxName;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private TextBox textBoxSurname;
|
||||
private TextBox textBoxPhone;
|
||||
}
|
||||
}
|
91
Hotel/HotelView/FormClient.cs
Normal file
91
Hotel/HotelView/FormClient.cs
Normal file
@ -0,0 +1,91 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
using HotelContracts.SearchModels;
|
||||
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 FormClient : Form
|
||||
{
|
||||
|
||||
private readonly IClientLogic _logic;
|
||||
private int? _id;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormClient(IClientLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните Имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var model = new ClientBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
Name = textBoxName.Text,
|
||||
Surname = textBoxSurname.Text,
|
||||
DateOfBirth = dateTimePicker.Value,
|
||||
PhoneNumber = textBoxPhone.Text
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void FormClient_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new ClientSearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.Name;
|
||||
textBoxSurname.Text = view.Surname;
|
||||
dateTimePicker.Value = (DateTime)view.DateOfBirth;
|
||||
textBoxPhone.Text = view.PhoneNumber;
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Hotel/HotelView/FormClient.resx
Normal file
120
Hotel/HotelView/FormClient.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>
|
152
Hotel/HotelView/FormClients.Designer.cs
generated
Normal file
152
Hotel/HotelView/FormClients.Designer.cs
generated
Normal file
@ -0,0 +1,152 @@
|
||||
namespace HotelView
|
||||
{
|
||||
partial class FormClients
|
||||
{
|
||||
/// <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();
|
||||
buttonDel = new Button();
|
||||
buttonUpd = new Button();
|
||||
buttonAdd = new Button();
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
button3 = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = Color.White;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Left;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.ShowCellToolTips = false;
|
||||
dataGridView.ShowEditingIcon = false;
|
||||
dataGridView.Size = new Size(600, 600);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.Location = new Point(645, 155);
|
||||
buttonDel.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(141, 47);
|
||||
buttonDel.TabIndex = 7;
|
||||
buttonDel.Text = "Удалить";
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.Location = new Point(645, 87);
|
||||
buttonUpd.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(141, 47);
|
||||
buttonUpd.TabIndex = 6;
|
||||
buttonUpd.Text = "Изменить";
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(645, 20);
|
||||
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(141, 47);
|
||||
buttonAdd.TabIndex = 5;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(645, 220);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(141, 47);
|
||||
button1.TabIndex = 8;
|
||||
button1.Text = "Тест добавления";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += button1_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(645, 287);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(141, 47);
|
||||
button2.TabIndex = 9;
|
||||
button2.Text = "Тест удаления";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += button2_Click;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Location = new Point(645, 352);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(141, 47);
|
||||
button3.TabIndex = 10;
|
||||
button3.Text = "Тест обновления";
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += button3_Click;
|
||||
//
|
||||
// FormClients
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(818, 600);
|
||||
Controls.Add(button3);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(buttonDel);
|
||||
Controls.Add(buttonUpd);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormClients";
|
||||
Text = "Покупатели";
|
||||
Load += FormClients_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonDel;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
private Button button3;
|
||||
}
|
||||
}
|
190
Hotel/HotelView/FormClients.cs
Normal file
190
Hotel/HotelView/FormClients.cs
Normal file
@ -0,0 +1,190 @@
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
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 HotelContracts.SearchModels;
|
||||
|
||||
namespace HotelView
|
||||
{
|
||||
public partial class FormClients : Form
|
||||
{
|
||||
private readonly IClientLogic _logic;
|
||||
public FormClients(IClientLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["PhoneNumber"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClient));
|
||||
if (service is FormClient form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClient));
|
||||
if (service is FormClient form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ClientBindingModel { Id = id }))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Доп информация в логах");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FormClients_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Create(new ClientBindingModel
|
||||
{
|
||||
Name = "Игооооорь",
|
||||
Surname = "Игоревич",
|
||||
DateOfBirth = DateTime.Now,
|
||||
PhoneNumber = "80942436674"
|
||||
});
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
var element = _logic.ReadElement(new ClientSearchModel
|
||||
{
|
||||
Id= id
|
||||
});
|
||||
for (int i = id; i < id + 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Delete(new ClientBindingModel
|
||||
{
|
||||
Id = i,
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
var element = _logic.ReadElement(new ClientSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
for (int i = id; i < id + 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Update(new ClientBindingModel
|
||||
{
|
||||
Id = i,
|
||||
Name = "Игооооорь",
|
||||
Surname = "Игоревич",
|
||||
DateOfBirth = DateTime.Now,
|
||||
PhoneNumber = "80942436674"
|
||||
});
|
||||
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Hotel/HotelView/FormClients.resx
Normal file
120
Hotel/HotelView/FormClients.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>
|
229
Hotel/HotelView/FormMain.Designer.cs
generated
Normal file
229
Hotel/HotelView/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,229 @@
|
||||
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()
|
||||
{
|
||||
menuStrip1 = new MenuStrip();
|
||||
объектыToolStripMenuItem = new ToolStripMenuItem();
|
||||
postToolStripMenuItem = new ToolStripMenuItem();
|
||||
workerToolStripMenuItem = new ToolStripMenuItem();
|
||||
roomToolStripMenuItem = new ToolStripMenuItem();
|
||||
клиентToolStripMenuItem = new ToolStripMenuItem();
|
||||
buttonIssuedBooking = new Button();
|
||||
buttonBookingReady = new Button();
|
||||
buttonTakeBookingInWork = new Button();
|
||||
buttonCreateBooking = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
button3 = new Button();
|
||||
menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { объектыToolStripMenuItem, клиентToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Padding = new Padding(7, 3, 0, 3);
|
||||
menuStrip1.Size = new Size(1387, 30);
|
||||
menuStrip1.TabIndex = 0;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// объектыToolStripMenuItem
|
||||
//
|
||||
объектыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { postToolStripMenuItem, workerToolStripMenuItem, roomToolStripMenuItem });
|
||||
объектыToolStripMenuItem.Name = "объектыToolStripMenuItem";
|
||||
объектыToolStripMenuItem.Size = new Size(84, 24);
|
||||
объектыToolStripMenuItem.Text = "Объекты";
|
||||
//
|
||||
// postToolStripMenuItem
|
||||
//
|
||||
postToolStripMenuItem.Name = "postToolStripMenuItem";
|
||||
postToolStripMenuItem.Size = new Size(169, 26);
|
||||
postToolStripMenuItem.Text = "Должность";
|
||||
postToolStripMenuItem.Click += postToolStripMenuItem_Click;
|
||||
//
|
||||
// workerToolStripMenuItem
|
||||
//
|
||||
workerToolStripMenuItem.Name = "workerToolStripMenuItem";
|
||||
workerToolStripMenuItem.Size = new Size(169, 26);
|
||||
workerToolStripMenuItem.Text = "Рабочий";
|
||||
workerToolStripMenuItem.Click += workerToolStripMenuItem_Click;
|
||||
//
|
||||
// roomToolStripMenuItem
|
||||
//
|
||||
roomToolStripMenuItem.Name = "roomToolStripMenuItem";
|
||||
roomToolStripMenuItem.Size = new Size(169, 26);
|
||||
roomToolStripMenuItem.Text = "Комната";
|
||||
roomToolStripMenuItem.Click += roomToolStripMenuItem_Click;
|
||||
//
|
||||
// клиентToolStripMenuItem
|
||||
//
|
||||
клиентToolStripMenuItem.Name = "клиентToolStripMenuItem";
|
||||
клиентToolStripMenuItem.Size = new Size(72, 24);
|
||||
клиентToolStripMenuItem.Text = "Клиент";
|
||||
клиентToolStripMenuItem.Click += clientToolStripMenuItem_Click;
|
||||
//
|
||||
// buttonIssuedBooking
|
||||
//
|
||||
buttonIssuedBooking.Location = new Point(1106, 275);
|
||||
buttonIssuedBooking.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonIssuedBooking.Name = "buttonIssuedBooking";
|
||||
buttonIssuedBooking.Size = new Size(226, 37);
|
||||
buttonIssuedBooking.TabIndex = 11;
|
||||
buttonIssuedBooking.Text = "Заказ выдан";
|
||||
buttonIssuedBooking.UseVisualStyleBackColor = true;
|
||||
buttonIssuedBooking.Click += buttonIssuedBooking_Click;
|
||||
//
|
||||
// buttonBookingReady
|
||||
//
|
||||
buttonBookingReady.Location = new Point(1106, 205);
|
||||
buttonBookingReady.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonBookingReady.Name = "buttonBookingReady";
|
||||
buttonBookingReady.Size = new Size(226, 37);
|
||||
buttonBookingReady.TabIndex = 10;
|
||||
buttonBookingReady.Text = "Заказ принимается";
|
||||
buttonBookingReady.UseVisualStyleBackColor = true;
|
||||
buttonBookingReady.Click += buttonBookingReady_Click;
|
||||
//
|
||||
// buttonTakeBookingInWork
|
||||
//
|
||||
buttonTakeBookingInWork.Location = new Point(1106, 133);
|
||||
buttonTakeBookingInWork.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonTakeBookingInWork.Name = "buttonTakeBookingInWork";
|
||||
buttonTakeBookingInWork.Size = new Size(226, 37);
|
||||
buttonTakeBookingInWork.TabIndex = 9;
|
||||
buttonTakeBookingInWork.Text = "Отдать на выполнение";
|
||||
buttonTakeBookingInWork.UseVisualStyleBackColor = true;
|
||||
buttonTakeBookingInWork.Click += buttonTakeBookingInWork_Click;
|
||||
//
|
||||
// buttonCreateBooking
|
||||
//
|
||||
buttonCreateBooking.Location = new Point(1106, 61);
|
||||
buttonCreateBooking.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonCreateBooking.Name = "buttonCreateBooking";
|
||||
buttonCreateBooking.Size = new Size(226, 37);
|
||||
buttonCreateBooking.TabIndex = 8;
|
||||
buttonCreateBooking.Text = "Создать бронь";
|
||||
buttonCreateBooking.UseVisualStyleBackColor = true;
|
||||
buttonCreateBooking.Click += buttonCreateBooking_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView.BackgroundColor = Color.White;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Left;
|
||||
dataGridView.Location = new Point(0, 30);
|
||||
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(1049, 570);
|
||||
dataGridView.TabIndex = 7;
|
||||
dataGridView.CellContentClick += dataGridView_CellContentClick;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(1106, 346);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(226, 37);
|
||||
button1.TabIndex = 12;
|
||||
button1.Text = "Тест добавления";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += button1_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(1106, 417);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(226, 37);
|
||||
button2.TabIndex = 13;
|
||||
button2.Text = "Тест удаления";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += button2_Click;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Location = new Point(1106, 484);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(226, 37);
|
||||
button3.TabIndex = 14;
|
||||
button3.Text = "Тест обновления";
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += button3_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1387, 600);
|
||||
Controls.Add(button3);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(buttonIssuedBooking);
|
||||
Controls.Add(buttonBookingReady);
|
||||
Controls.Add(buttonTakeBookingInWork);
|
||||
Controls.Add(buttonCreateBooking);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormMain";
|
||||
Text = "Главное окно";
|
||||
Load += FormMain_Load;
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem объектыToolStripMenuItem;
|
||||
private ToolStripMenuItem postToolStripMenuItem;
|
||||
private ToolStripMenuItem workerToolStripMenuItem;
|
||||
private ToolStripMenuItem roomToolStripMenuItem;
|
||||
private Button buttonIssuedBooking;
|
||||
private Button buttonBookingReady;
|
||||
private Button buttonTakeBookingInWork;
|
||||
private Button buttonCreateBooking;
|
||||
private DataGridView dataGridView;
|
||||
private ToolStripMenuItem клиентToolStripMenuItem;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
private Button button3;
|
||||
}
|
||||
}
|
285
Hotel/HotelView/FormMain.cs
Normal file
285
Hotel/HotelView/FormMain.cs
Normal file
@ -0,0 +1,285 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
using HotelContracts.SearchModels;
|
||||
using HotelDatabaseImplement.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 System.Xml.Linq;
|
||||
|
||||
namespace HotelView
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
|
||||
private readonly IBookingLogic _logic;
|
||||
private readonly IRoomLogic _logicR;
|
||||
private readonly IClientLogic _logicC;
|
||||
|
||||
public FormMain(IBookingLogic logic, IRoomLogic logicR, IClientLogic logicC)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
_logicR = logicR;
|
||||
_logicC = logicC;
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
var _list = _logic.ReadList(null);
|
||||
if (_list != null)
|
||||
{
|
||||
dataGridView.DataSource = _list;
|
||||
dataGridView.Columns["RoomId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["Number"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Surname"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
|
||||
private void clientToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
if (service is FormClients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void postToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPosts));
|
||||
if (service is FormPosts form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void workerToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormWorkers));
|
||||
if (service is FormWorkers form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void roomToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormRooms));
|
||||
if (service is FormRooms form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCreateBooking_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormBooking));
|
||||
if (service is FormBooking form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonTakeBookingInWork_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
var operationResult = _logic.TakeBookingInWork(new BookingBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Status = Enum.Parse<HotelDataModels.Enums.AcceptanceStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonBookingReady_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
var operationResult = _logic.FinishBooking(new BookingBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Status = Enum.Parse<HotelDataModels.Enums.AcceptanceStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonIssuedBooking_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
var operationResult = _logic.DeliveryBooking(new BookingBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Status = Enum.Parse<HotelDataModels.Enums.AcceptanceStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
var elementR = _logicR.ReadElement(new RoomSearchModel
|
||||
{
|
||||
Number = 1
|
||||
});
|
||||
var elementC = _logicC.ReadElement(new ClientSearchModel
|
||||
{
|
||||
Name = "Игооооорь"
|
||||
});
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Create(new BookingBindingModel
|
||||
{
|
||||
RoomId = elementR?.Id ?? 0,
|
||||
ClientId = elementC?.Id ?? 0,
|
||||
ArrivalDate = DateTime.Now,
|
||||
DepartureDate = DateTime.Now,
|
||||
NumberHoursSpent = 5,
|
||||
Status = HotelDataModels.Enums.AcceptanceStatus.Неизвестен,
|
||||
TotalCost =123
|
||||
});
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
var element = _logic.ReadElement(new BookingSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
for (int i = id; i < id + 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Delete(new BookingBindingModel
|
||||
{
|
||||
Id = i,
|
||||
});
|
||||
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
var element = _logic.ReadElement(new BookingSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
var elementR = _logicR.ReadElement(new RoomSearchModel
|
||||
{
|
||||
Number = 1
|
||||
});
|
||||
var elementC = _logicC.ReadElement(new ClientSearchModel
|
||||
{
|
||||
Name = "Игооооорь"
|
||||
});
|
||||
for (int i = id; i < id + 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Update(new BookingBindingModel
|
||||
{
|
||||
RoomId = elementR?.Id ?? 0,
|
||||
ClientId = elementC?.Id ?? 0,
|
||||
ArrivalDate = DateTime.Now,
|
||||
DepartureDate = DateTime.Now,
|
||||
NumberHoursSpent = 5,
|
||||
Status = HotelDataModels.Enums.AcceptanceStatus.Неизвестен,
|
||||
TotalCost = 100
|
||||
});
|
||||
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
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="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
100
Hotel/HotelView/FormPost.Designer.cs
generated
Normal file
100
Hotel/HotelView/FormPost.Designer.cs
generated
Normal file
@ -0,0 +1,100 @@
|
||||
namespace HotelView
|
||||
{
|
||||
partial class FormPost
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
label1 = new Label();
|
||||
textBoxPost = new TextBox();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(14, 27);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(89, 20);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Должность:";
|
||||
//
|
||||
// textBoxPost
|
||||
//
|
||||
textBoxPost.Location = new Point(99, 24);
|
||||
textBoxPost.Margin = new Padding(3, 4, 3, 4);
|
||||
textBoxPost.Name = "textBoxPost";
|
||||
textBoxPost.Size = new Size(237, 27);
|
||||
textBoxPost.TabIndex = 2;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(248, 73);
|
||||
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(88, 40);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(138, 73);
|
||||
buttonSave.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(95, 40);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// FormPost
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(364, 136);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxPost);
|
||||
Controls.Add(label1);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormPost";
|
||||
Text = "Покупатель";
|
||||
Load += FormPost_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private TextBox textBoxPost;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
}
|
||||
}
|
84
Hotel/HotelView/FormPost.cs
Normal file
84
Hotel/HotelView/FormPost.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
using HotelContracts.SearchModels;
|
||||
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 FormPost : Form
|
||||
{
|
||||
|
||||
private readonly IPostLogic _logic;
|
||||
private int? _id;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormPost(IPostLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxPost.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните Имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var model = new PostBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
PostName = textBoxPost.Text,
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void FormPost_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new PostSearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxPost.Text = view.PostName;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Hotel/HotelView/FormPost.resx
Normal file
120
Hotel/HotelView/FormPost.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>
|
152
Hotel/HotelView/FormPosts.Designer.cs
generated
Normal file
152
Hotel/HotelView/FormPosts.Designer.cs
generated
Normal file
@ -0,0 +1,152 @@
|
||||
namespace HotelView
|
||||
{
|
||||
partial class FormPosts
|
||||
{
|
||||
/// <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();
|
||||
buttonDel = new Button();
|
||||
buttonUpd = new Button();
|
||||
buttonAdd = new Button();
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
button3 = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = Color.White;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Left;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.ShowCellToolTips = false;
|
||||
dataGridView.ShowEditingIcon = false;
|
||||
dataGridView.Size = new Size(600, 600);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.Location = new Point(645, 155);
|
||||
buttonDel.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(142, 47);
|
||||
buttonDel.TabIndex = 7;
|
||||
buttonDel.Text = "Удалить";
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.Location = new Point(645, 87);
|
||||
buttonUpd.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(142, 47);
|
||||
buttonUpd.TabIndex = 6;
|
||||
buttonUpd.Text = "Изменить";
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(645, 20);
|
||||
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(142, 47);
|
||||
buttonAdd.TabIndex = 5;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(645, 224);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(142, 46);
|
||||
button1.TabIndex = 8;
|
||||
button1.Text = "Тест создания";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += button1_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(645, 293);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(142, 46);
|
||||
button2.TabIndex = 9;
|
||||
button2.Text = "Тест удаления";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += button2_Click;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Location = new Point(645, 358);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(142, 46);
|
||||
button3.TabIndex = 10;
|
||||
button3.Text = "Тест обновления";
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += button3_Click;
|
||||
//
|
||||
// FormPosts
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(818, 600);
|
||||
Controls.Add(button3);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(buttonDel);
|
||||
Controls.Add(buttonUpd);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormPosts";
|
||||
Text = "Покупатели";
|
||||
Load += FormPosts_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonDel;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
private Button button3;
|
||||
}
|
||||
}
|
183
Hotel/HotelView/FormPosts.cs
Normal file
183
Hotel/HotelView/FormPosts.cs
Normal file
@ -0,0 +1,183 @@
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
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 HotelContracts.SearchModels;
|
||||
|
||||
namespace HotelView
|
||||
{
|
||||
public partial class FormPosts : Form
|
||||
{
|
||||
private readonly IPostLogic _logic;
|
||||
public FormPosts(IPostLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["PostName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPost));
|
||||
if (service is FormPost form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPost));
|
||||
if (service is FormPost form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new PostBindingModel { Id = id }))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Доп информация в логах");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FormPosts_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Create(new PostBindingModel
|
||||
{
|
||||
PostName = "Горничная"
|
||||
});
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
var element = _logic.ReadElement(new PostSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
for (int i = id; i < id + 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Delete(new PostBindingModel
|
||||
{
|
||||
Id = i,
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
var element = _logic.ReadElement(new PostSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
for (int i = id; i < id + 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Update(new PostBindingModel
|
||||
{
|
||||
Id = i,
|
||||
PostName = "Горничный"
|
||||
});
|
||||
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Hotel/HotelView/FormPosts.resx
Normal file
120
Hotel/HotelView/FormPosts.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>
|
212
Hotel/HotelView/FormRoom.Designer.cs
generated
Normal file
212
Hotel/HotelView/FormRoom.Designer.cs
generated
Normal file
@ -0,0 +1,212 @@
|
||||
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()
|
||||
{
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
textBoxNumber = new TextBox();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
label5 = new Label();
|
||||
textBoxFloor = new TextBox();
|
||||
label6 = new Label();
|
||||
comboBoxWorker = new ComboBox();
|
||||
textBoxNumberOfBeds = new TextBox();
|
||||
textBoxCondition = new TextBox();
|
||||
textBoxCost = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(14, 27);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(60, 20);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Номер:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(14, 68);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(46, 20);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Этаж:";
|
||||
//
|
||||
// textBoxNumber
|
||||
//
|
||||
textBoxNumber.Location = new Point(111, 24);
|
||||
textBoxNumber.Margin = new Padding(3, 4, 3, 4);
|
||||
textBoxNumber.Name = "textBoxNumber";
|
||||
textBoxNumber.Size = new Size(237, 27);
|
||||
textBoxNumber.TabIndex = 2;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(260, 278);
|
||||
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(88, 40);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(159, 278);
|
||||
buttonSave.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(95, 40);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(14, 108);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(148, 20);
|
||||
label3.TabIndex = 8;
|
||||
label3.Text = "Кол. спальных мест:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(14, 150);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(86, 20);
|
||||
label4.TabIndex = 9;
|
||||
label4.Text = "Состояние:";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.Location = new Point(14, 190);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(81, 20);
|
||||
label5.TabIndex = 10;
|
||||
label5.Text = "Цена(час):";
|
||||
//
|
||||
// textBoxFloor
|
||||
//
|
||||
textBoxFloor.Location = new Point(111, 65);
|
||||
textBoxFloor.Name = "textBoxFloor";
|
||||
textBoxFloor.Size = new Size(237, 27);
|
||||
textBoxFloor.TabIndex = 11;
|
||||
//
|
||||
// label6
|
||||
//
|
||||
label6.AutoSize = true;
|
||||
label6.Location = new Point(14, 228);
|
||||
label6.Name = "label6";
|
||||
label6.Size = new Size(77, 20);
|
||||
label6.TabIndex = 12;
|
||||
label6.Text = "Работник:";
|
||||
//
|
||||
// comboBoxWorker
|
||||
//
|
||||
comboBoxWorker.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxWorker.FormattingEnabled = true;
|
||||
comboBoxWorker.Location = new Point(111, 225);
|
||||
comboBoxWorker.Name = "comboBoxWorker";
|
||||
comboBoxWorker.Size = new Size(237, 28);
|
||||
comboBoxWorker.TabIndex = 13;
|
||||
//
|
||||
// textBoxNumberOfBeds
|
||||
//
|
||||
textBoxNumberOfBeds.Location = new Point(168, 108);
|
||||
textBoxNumberOfBeds.Name = "textBoxNumberOfBeds";
|
||||
textBoxNumberOfBeds.Size = new Size(178, 27);
|
||||
textBoxNumberOfBeds.TabIndex = 14;
|
||||
//
|
||||
// textBoxCondition
|
||||
//
|
||||
textBoxCondition.Location = new Point(111, 147);
|
||||
textBoxCondition.Name = "textBoxCondition";
|
||||
textBoxCondition.Size = new Size(237, 27);
|
||||
textBoxCondition.TabIndex = 15;
|
||||
//
|
||||
// textBoxCost
|
||||
//
|
||||
textBoxCost.Location = new Point(111, 187);
|
||||
textBoxCost.Name = "textBoxCost";
|
||||
textBoxCost.Size = new Size(235, 27);
|
||||
textBoxCost.TabIndex = 16;
|
||||
//
|
||||
// FormRoom
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(368, 331);
|
||||
Controls.Add(textBoxCost);
|
||||
Controls.Add(textBoxCondition);
|
||||
Controls.Add(textBoxNumberOfBeds);
|
||||
Controls.Add(comboBoxWorker);
|
||||
Controls.Add(label6);
|
||||
Controls.Add(textBoxFloor);
|
||||
Controls.Add(label5);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxNumber);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormRoom";
|
||||
Text = "Комнаты";
|
||||
Load += FormRoom_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private TextBox textBoxNumber;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private Label label5;
|
||||
private TextBox textBoxFloor;
|
||||
private Label label6;
|
||||
private ComboBox comboBoxWorker;
|
||||
private TextBox textBoxNumberOfBeds;
|
||||
private TextBox textBoxCondition;
|
||||
private TextBox textBoxCost;
|
||||
}
|
||||
}
|
105
Hotel/HotelView/FormRoom.cs
Normal file
105
Hotel/HotelView/FormRoom.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
using HotelContracts.SearchModels;
|
||||
using HotelDatabaseImplement.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 _logicR;
|
||||
private readonly IWorkerLogic _logicW;
|
||||
private int? _id;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormRoom(IWorkerLogic logicW, IRoomLogic logicR)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logicW = logicW;
|
||||
_logicR = logicR;
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxNumber.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните номер", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return;
|
||||
}
|
||||
if (comboBoxWorker.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите рабочего", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var model = new RoomBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
Number = Convert.ToInt32(textBoxNumber.Text),
|
||||
Floor = Convert.ToInt32(textBoxFloor.Text),
|
||||
NumberOfBeds = Convert.ToInt32(textBoxNumberOfBeds.Text),
|
||||
Condition = textBoxCondition.Text,
|
||||
Cost = Convert.ToInt32(textBoxCost.Text),
|
||||
WorkerId = Convert.ToInt32(comboBoxWorker.SelectedValue),
|
||||
};
|
||||
|
||||
var operationResult = _id.HasValue ? _logicR.Update(model) : _logicR.Create(model);
|
||||
var provercaMade = _logicR.ProvercaMade(model);
|
||||
if (!provercaMade)
|
||||
{
|
||||
_logicR.Delete(model);
|
||||
throw new Exception("Данный работник не горнечная");
|
||||
}
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void FormRoom_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var workerList = _logicW.ReadList(null);
|
||||
if (workerList != null)
|
||||
{
|
||||
comboBoxWorker.DisplayMember = "FIO";
|
||||
comboBoxWorker.ValueMember = "Id";
|
||||
comboBoxWorker.DataSource = workerList;
|
||||
comboBoxWorker.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
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>
|
152
Hotel/HotelView/FormRooms.Designer.cs
generated
Normal file
152
Hotel/HotelView/FormRooms.Designer.cs
generated
Normal file
@ -0,0 +1,152 @@
|
||||
namespace HotelView
|
||||
{
|
||||
partial class FormRooms
|
||||
{
|
||||
/// <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();
|
||||
buttonDel = new Button();
|
||||
buttonUpd = new Button();
|
||||
buttonAdd = new Button();
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
button3 = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = Color.White;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Left;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.ShowCellToolTips = false;
|
||||
dataGridView.ShowEditingIcon = false;
|
||||
dataGridView.Size = new Size(840, 600);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.Location = new Point(881, 182);
|
||||
buttonDel.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(144, 47);
|
||||
buttonDel.TabIndex = 7;
|
||||
buttonDel.Text = "Удалить";
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.Location = new Point(881, 118);
|
||||
buttonUpd.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(144, 47);
|
||||
buttonUpd.TabIndex = 6;
|
||||
buttonUpd.Text = "Изменить";
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(881, 53);
|
||||
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(144, 47);
|
||||
buttonAdd.TabIndex = 5;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(881, 247);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(144, 47);
|
||||
button1.TabIndex = 8;
|
||||
button1.Text = "Тест добавления";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += button1_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(881, 313);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(144, 47);
|
||||
button2.TabIndex = 9;
|
||||
button2.Text = "Тест удаления";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += button2_Click;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Location = new Point(881, 380);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(144, 47);
|
||||
button3.TabIndex = 10;
|
||||
button3.Text = "Тест обновления";
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += button3_Click;
|
||||
//
|
||||
// FormRooms
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1049, 600);
|
||||
Controls.Add(button3);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(buttonDel);
|
||||
Controls.Add(buttonUpd);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormRooms";
|
||||
Text = "Покупатели";
|
||||
Load += FormBuyers_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonDel;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
private Button button3;
|
||||
}
|
||||
}
|
200
Hotel/HotelView/FormRooms.cs
Normal file
200
Hotel/HotelView/FormRooms.cs
Normal file
@ -0,0 +1,200 @@
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
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 HotelContracts.SearchModels;
|
||||
using HotelDatabaseImplement.Models;
|
||||
|
||||
namespace HotelView
|
||||
{
|
||||
public partial class FormRooms : Form
|
||||
{
|
||||
private readonly IRoomLogic _logic;
|
||||
private readonly IWorkerLogic _logicW;
|
||||
public FormRooms(IRoomLogic logic, IWorkerLogic logicW)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
_logicW = logicW;
|
||||
|
||||
}
|
||||
|
||||
private void FormBuyers_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["WorkerId"].Visible = false;
|
||||
dataGridView.Columns["WorkerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormRoom));
|
||||
if (service is FormRoom form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormRoom));
|
||||
if (service is FormRoom form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int number = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Number"].Value);
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new RoomBindingModel { Number = number }))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Доп информация в логах");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
var element = _logicW.ReadElement(new WorkerSearchModel
|
||||
{
|
||||
FIO = "Паша Пашок Паша"
|
||||
});
|
||||
for (int i = 1; i < 1001; i++)
|
||||
{
|
||||
var operationResult = _logic.Create(new RoomBindingModel
|
||||
{
|
||||
WorkerId = element?.Id ?? 0,
|
||||
Number = i,
|
||||
Floor = 1,
|
||||
NumberOfBeds = 4,
|
||||
Condition = "Норм",
|
||||
Cost = 350
|
||||
});
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
int Number = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Number"].Value);
|
||||
var element = _logic.ReadElement(new RoomSearchModel
|
||||
{
|
||||
Number = Number
|
||||
});
|
||||
for (int i = Number; i < Number + 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Delete(new RoomBindingModel
|
||||
{
|
||||
Number = i
|
||||
});
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
var element = _logic.ReadElement(new RoomSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
for (int i = id; i < id + 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Update(new RoomBindingModel
|
||||
{
|
||||
Id = i,
|
||||
WorkerId = element?.Id ?? 0,
|
||||
Number = i+1000,
|
||||
Floor = 2,
|
||||
NumberOfBeds = 5,
|
||||
Condition = "Отличненько",
|
||||
Cost = 400
|
||||
});
|
||||
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Hotel/HotelView/FormRooms.resx
Normal file
120
Hotel/HotelView/FormRooms.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>
|
213
Hotel/HotelView/FormWorker.Designer.cs
generated
Normal file
213
Hotel/HotelView/FormWorker.Designer.cs
generated
Normal file
@ -0,0 +1,213 @@
|
||||
namespace HotelView
|
||||
{
|
||||
partial class FormWorker
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
textBoxFIO = new TextBox();
|
||||
dateTimePicker = new DateTimePicker();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
label5 = new Label();
|
||||
label6 = new Label();
|
||||
textBoxWorkExperience = new TextBox();
|
||||
textBoxSalary = new TextBox();
|
||||
textBoxPhone = new TextBox();
|
||||
comboBoxPost = new ComboBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(14, 23);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(45, 20);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "ФИО:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(14, 63);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(119, 20);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Дата рождения:";
|
||||
//
|
||||
// textBoxFIO
|
||||
//
|
||||
textBoxFIO.Location = new Point(133, 20);
|
||||
textBoxFIO.Margin = new Padding(3, 4, 3, 4);
|
||||
textBoxFIO.Name = "textBoxFIO";
|
||||
textBoxFIO.Size = new Size(237, 27);
|
||||
textBoxFIO.TabIndex = 2;
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(133, 58);
|
||||
dateTimePicker.Margin = new Padding(3, 4, 3, 4);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(237, 27);
|
||||
dateTimePicker.TabIndex = 3;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(282, 266);
|
||||
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(88, 40);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(171, 266);
|
||||
buttonSave.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(95, 40);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(14, 105);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(105, 20);
|
||||
label3.TabIndex = 8;
|
||||
label3.Text = "Опыт работы:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(14, 144);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(76, 20);
|
||||
label4.TabIndex = 9;
|
||||
label4.Text = "Зарплата:";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.Location = new Point(14, 184);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(72, 20);
|
||||
label5.TabIndex = 10;
|
||||
label5.Text = "Телефон:";
|
||||
//
|
||||
// label6
|
||||
//
|
||||
label6.AutoSize = true;
|
||||
label6.Location = new Point(14, 224);
|
||||
label6.Name = "label6";
|
||||
label6.Size = new Size(89, 20);
|
||||
label6.TabIndex = 11;
|
||||
label6.Text = "Должность:";
|
||||
//
|
||||
// textBoxWorkExperience
|
||||
//
|
||||
textBoxWorkExperience.Location = new Point(133, 102);
|
||||
textBoxWorkExperience.Name = "textBoxWorkExperience";
|
||||
textBoxWorkExperience.Size = new Size(236, 27);
|
||||
textBoxWorkExperience.TabIndex = 12;
|
||||
//
|
||||
// textBoxSalary
|
||||
//
|
||||
textBoxSalary.Location = new Point(134, 141);
|
||||
textBoxSalary.Name = "textBoxSalary";
|
||||
textBoxSalary.Size = new Size(236, 27);
|
||||
textBoxSalary.TabIndex = 13;
|
||||
//
|
||||
// textBoxPhone
|
||||
//
|
||||
textBoxPhone.Location = new Point(133, 177);
|
||||
textBoxPhone.Name = "textBoxPhone";
|
||||
textBoxPhone.Size = new Size(237, 27);
|
||||
textBoxPhone.TabIndex = 14;
|
||||
//
|
||||
// comboBoxPost
|
||||
//
|
||||
comboBoxPost.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxPost.FormattingEnabled = true;
|
||||
comboBoxPost.Location = new Point(135, 221);
|
||||
comboBoxPost.Name = "comboBoxPost";
|
||||
comboBoxPost.Size = new Size(234, 28);
|
||||
comboBoxPost.TabIndex = 15;
|
||||
//
|
||||
// FormWorker
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(429, 345);
|
||||
Controls.Add(comboBoxPost);
|
||||
Controls.Add(textBoxPhone);
|
||||
Controls.Add(textBoxSalary);
|
||||
Controls.Add(textBoxWorkExperience);
|
||||
Controls.Add(label6);
|
||||
Controls.Add(label5);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(dateTimePicker);
|
||||
Controls.Add(textBoxFIO);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormWorker";
|
||||
Text = "Покупатель";
|
||||
Load += FormWorker_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private TextBox textBoxFIO;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private Label label5;
|
||||
private Label label6;
|
||||
private TextBox textBoxWorkExperience;
|
||||
private TextBox textBoxSalary;
|
||||
private TextBox textBoxPhone;
|
||||
private ComboBox comboBoxPost;
|
||||
}
|
||||
}
|
98
Hotel/HotelView/FormWorker.cs
Normal file
98
Hotel/HotelView/FormWorker.cs
Normal file
@ -0,0 +1,98 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
using HotelContracts.SearchModels;
|
||||
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 FormWorker : Form
|
||||
{
|
||||
|
||||
private readonly IWorkerLogic _logicW;
|
||||
private readonly IPostLogic _logicP;
|
||||
private int? _id;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormWorker(IWorkerLogic logicW, IPostLogic logicP)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logicW = logicW;
|
||||
_logicP = logicP;
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxFIO.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните Имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return;
|
||||
}
|
||||
if (comboBoxPost.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var model = new WorkerBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
FIO = textBoxFIO.Text,
|
||||
DateOfBirth = dateTimePicker.Value,
|
||||
WorkExperience = Convert.ToInt32(textBoxWorkExperience.Text),
|
||||
Salary = Convert.ToInt32(textBoxSalary.Text),
|
||||
Phone = textBoxPhone.Text,
|
||||
PostId = Convert.ToInt32(comboBoxPost.SelectedValue),
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logicW.Update(model) : _logicW.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void FormWorker_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var postList = _logicP.ReadList(null);
|
||||
if (postList != null)
|
||||
{
|
||||
comboBoxPost.DisplayMember = "PostName";
|
||||
comboBoxPost.ValueMember = "Id";
|
||||
comboBoxPost.DataSource = postList;
|
||||
comboBoxPost.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
120
Hotel/HotelView/FormWorker.resx
Normal file
120
Hotel/HotelView/FormWorker.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>
|
152
Hotel/HotelView/FormWorkers.Designer.cs
generated
Normal file
152
Hotel/HotelView/FormWorkers.Designer.cs
generated
Normal file
@ -0,0 +1,152 @@
|
||||
namespace HotelView
|
||||
{
|
||||
partial class FormWorkers
|
||||
{
|
||||
/// <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();
|
||||
buttonDel = new Button();
|
||||
buttonUpd = new Button();
|
||||
buttonAdd = new Button();
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
button3 = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = Color.White;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Left;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.ShowCellToolTips = false;
|
||||
dataGridView.ShowEditingIcon = false;
|
||||
dataGridView.Size = new Size(829, 600);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.Location = new Point(888, 185);
|
||||
buttonDel.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(146, 47);
|
||||
buttonDel.TabIndex = 7;
|
||||
buttonDel.Text = "Удалить";
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.Location = new Point(888, 117);
|
||||
buttonUpd.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(146, 47);
|
||||
buttonUpd.TabIndex = 6;
|
||||
buttonUpd.Text = "Изменить";
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(888, 50);
|
||||
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(146, 47);
|
||||
buttonAdd.TabIndex = 5;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(888, 251);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(146, 47);
|
||||
button1.TabIndex = 8;
|
||||
button1.Text = "Тест добавления";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += button1_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(888, 316);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(146, 47);
|
||||
button2.TabIndex = 9;
|
||||
button2.Text = "Тест удаления";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += button2_Click;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Location = new Point(888, 382);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(146, 47);
|
||||
button3.TabIndex = 10;
|
||||
button3.Text = "Тест обновления";
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += button3_Click;
|
||||
//
|
||||
// FormWorkers
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1070, 600);
|
||||
Controls.Add(button3);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(buttonDel);
|
||||
Controls.Add(buttonUpd);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormWorkers";
|
||||
Text = "Покупатели";
|
||||
Load += FormWorkers_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonDel;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
private Button button3;
|
||||
}
|
||||
}
|
199
Hotel/HotelView/FormWorkers.cs
Normal file
199
Hotel/HotelView/FormWorkers.cs
Normal file
@ -0,0 +1,199 @@
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
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 HotelContracts.SearchModels;
|
||||
|
||||
namespace HotelView
|
||||
{
|
||||
public partial class FormWorkers : Form
|
||||
{
|
||||
private readonly IWorkerLogic _logic;
|
||||
private readonly IPostLogic _logicP;
|
||||
public FormWorkers(IWorkerLogic logic, IPostLogic logicP)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
_logicP = logicP;
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["PostId"].Visible = false;
|
||||
dataGridView.Columns["PostName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormWorker));
|
||||
if (service is FormWorker form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormWorker));
|
||||
if (service is FormWorker form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new WorkerBindingModel { Id = id }))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Доп информация в логах");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FormWorkers_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
var element = _logicP.ReadElement(new PostSearchModel
|
||||
{
|
||||
PostName = "Горничная"
|
||||
});
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Create(new WorkerBindingModel
|
||||
{
|
||||
PostId = element?.Id ?? 0,
|
||||
FIO = "Паша Пашок Паша",
|
||||
DateOfBirth =DateTime.Now,
|
||||
WorkExperience = 10,
|
||||
Salary = 1024,
|
||||
Phone = "52354347356"
|
||||
});
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
var element = _logic.ReadElement(new WorkerSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
for (int i = id; i < id + 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Delete(new WorkerBindingModel
|
||||
{
|
||||
Id = i,
|
||||
});
|
||||
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
var element = _logic.ReadElement(new WorkerSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
for (int i = id; i < id + 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Update(new WorkerBindingModel
|
||||
{
|
||||
Id = i,
|
||||
PostId = element?.Id ?? 0,
|
||||
FIO = "Паша)",
|
||||
DateOfBirth = DateTime.Now,
|
||||
WorkExperience = 5,
|
||||
Salary = 666,
|
||||
Phone = "Норм номер"
|
||||
});
|
||||
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Hotel/HotelView/FormWorkers.resx
Normal file
120
Hotel/HotelView/FormWorkers.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>
|
@ -8,4 +8,20 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.16">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HotelBusinessLogic\HotelBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\HotelContracts\HotelContracts.csproj" />
|
||||
<ProjectReference Include="..\HotelDatabaseImplement\HotelDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\HotelDataModels\HotelDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,17 +1,53 @@
|
||||
using HotelBusinessLogic.BusinessLogics;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
using HotelContracts.StoragesContracts;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using HotelDatabaseImplement.Implements;
|
||||
using System;
|
||||
namespace HotelView
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
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();
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
// 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<IBookingStorage, BookingStorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IPostStorage, PostStorage>();
|
||||
services.AddTransient<IRoomStorage, RoomStorage>();
|
||||
services.AddTransient<IWorkerStorage, WorkerStorage>();
|
||||
|
||||
services.AddTransient<IBookingLogic, BookingLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IPostLogic, PostLogic>();
|
||||
services.AddTransient<IRoomLogic, RoomLogic>();
|
||||
services.AddTransient<IWorkerLogic, WorkerLogic>();
|
||||
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormClients>();
|
||||
services.AddTransient<FormClient>();
|
||||
services.AddTransient<FormPosts>();
|
||||
services.AddTransient<FormPost>();
|
||||
services.AddTransient<FormWorker>();
|
||||
services.AddTransient<FormWorkers>();
|
||||
services.AddTransient<FormRooms>();
|
||||
services.AddTransient<FormRoom>();
|
||||
services.AddTransient<FormBooking>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user