This commit is contained in:
pnevmoslon1 2024-11-11 10:59:50 +04:00
parent 8f986c6beb
commit bcd36cebc6
33 changed files with 1278 additions and 150 deletions

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34525.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectHotel", "ProjectHotel\ProjectHotel.csproj", "{A2780283-9040-4F10-8929-96574BD22EAD}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectHotel", "ProjectHotel\ProjectHotel.csproj", "{C81DFC0D-3F51-4F84-AF78-1ADA30A157B1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -11,15 +11,15 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A2780283-9040-4F10-8929-96574BD22EAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2780283-9040-4F10-8929-96574BD22EAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2780283-9040-4F10-8929-96574BD22EAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2780283-9040-4F10-8929-96574BD22EAD}.Release|Any CPU.Build.0 = Release|Any CPU
{C81DFC0D-3F51-4F84-AF78-1ADA30A157B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C81DFC0D-3F51-4F84-AF78-1ADA30A157B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C81DFC0D-3F51-4F84-AF78-1ADA30A157B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C81DFC0D-3F51-4F84-AF78-1ADA30A157B1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {63AC2E5C-4881-4878-851B-89C4AC958820}
SolutionGuid = {20DC1BC0-A8A5-4BA7-B0A2-533382967ACC}
EndGlobalSection
EndGlobal

View File

@ -12,15 +12,18 @@ public class Athlete
public int Id { get; set; }
public string FirstName { get; private set; } = string.Empty;
public string LastName { get; private set; } = string.Empty;
public KindOfSport KindOfSport { get; private set; }
public static Athlete CreateEntity(int id, string first, string last, KindOfSport kindOfSport)
public string FatherName { get; private set; } = string.Empty;
public AthleteClass Class { get; set; }
public static Athlete CreateEntity(int id, string first, string last, string father, AthleteClass athleteclass)
{
return new Athlete
{
Id = id,
FirstName = first ?? string.Empty,
LastName = last ?? string.Empty,
KindOfSport = kindOfSport
FatherName = father ?? string.Empty,
Class = athleteclass
};
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHotel.Entities;
public class AthleteSport
{
public int Id { get; private set; }
public int SportId { get; private set; }
public static AthleteSport CreateEntity(int id, int sportId)
{
return new AthleteSport
{
Id = id,
SportId = sportId
};
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHotel.Entities.Enums;
public enum AthleteClass
{
None = 0,
MSMK = 1,
MS = 2,
KMS = 3
}

View File

@ -1,24 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHotel.Entities.Enums
{
public enum KindOfSport
{
None = 0,
Archery = 1,
Athletics = 2,
Badminton = 3,
Basketball = 4,
Boxing = 5,
Cycling = 6,
Fencing = 7,
Gymnastics = 8,
Rowing = 9,
Swimming = 10
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHotel.Entities.Enums;
public enum Sport
{
None = 0,
Archery = 2,
Athletics = 4,
Badminton = 8,
Basketball = 16,
Boxing = 32,
Cycling = 64,
Fencing = 128,
Gymnastics = 256,
Rowing = 512,
Swimming = 1024
}

View File

@ -11,32 +11,16 @@ public class Hotel
public int Id { get; private set; }
public string HotelName { get; private set; } = string.Empty;
public string Adress { get; private set; } = string.Empty;
public int TotalRooms { get; private set; }
public int SingleRooms { get; private set; }
public int DoubleRooms { get; private set; }
public int TripleRooms { get; private set; }
public int AvailableSingleRooms { get; private set; }
public int AvailableDoubleRooms { get; private set; }
public int AvailableTripleRooms { get; private set; }
public static Hotel CreateEntity(int id, string hotelName, string adress, int totalRooms, int singleRooms, int doubleRooms, int tripleRooms,
int availableSingleRooms, int availableDoubleRooms, int availableTripleRooms)
public static Hotel CreateEntity(int id, string hotelName, string adress)
{
return new Hotel
{
Id = id,
HotelName = hotelName,
TotalRooms = totalRooms,
Adress = adress,
SingleRooms = singleRooms,
DoubleRooms = doubleRooms,
TripleRooms = tripleRooms,
AvailableSingleRooms = availableSingleRooms,
AvailableDoubleRooms = availableDoubleRooms,
AvailableTripleRooms = tripleRooms
Adress = adress
};
}

View File

@ -11,16 +11,16 @@ public class Rooms
{
public int Id { get; private set; }
public int HotelId { get; private set; }
public char RoomType { get; private set; }
public bool IsAvaiable { get; private set; }
public static Rooms CreateEntity(int id, int hotel, char type, bool avalible)
public string Name { get; private set; } = string.Empty;
public int Capacity { get; private set; }
public static Rooms CreateEntity(int id, int hotel, string name, int capacity)
{
return new Rooms
{
Id = id,
HotelId = hotel,
RoomType = type,
IsAvaiable = avalible
Name = name,
Capacity = capacity
};
}

View File

@ -1,39 +0,0 @@
namespace ProjectHotel
{
partial class Form1
{
/// <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()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -0,0 +1,92 @@
namespace ProjectHotel.Forms
{
partial class FormHotel
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
label1 = new Label();
label2 = new Label();
textBoxHotelName = new TextBox();
textBoxHotelAdress = new TextBox();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(15, 41);
label1.Name = "label1";
label1.Size = new Size(122, 15);
label1.TabIndex = 0;
label1.Text = "Название гостиницы";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(15, 93);
label2.Name = "label2";
label2.Size = new Size(46, 15);
label2.TabIndex = 1;
label2.Text = "Адресс";
//
// textBoxHotelName
//
textBoxHotelName.Location = new Point(168, 38);
textBoxHotelName.Name = "textBoxHotelName";
textBoxHotelName.Size = new Size(390, 23);
textBoxHotelName.TabIndex = 2;
//
// textBoxHotelAdress
//
textBoxHotelAdress.Location = new Point(168, 90);
textBoxHotelAdress.Name = "textBoxHotelAdress";
textBoxHotelAdress.Size = new Size(387, 23);
textBoxHotelAdress.TabIndex = 3;
//
// FormHotel
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(570, 167);
Controls.Add(textBoxHotelAdress);
Controls.Add(textBoxHotelName);
Controls.Add(label2);
Controls.Add(label1);
Name = "FormHotel";
StartPosition = FormStartPosition.CenterParent;
Text = "Гостиница";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private Label label2;
private TextBox textBoxHotelName;
private TextBox textBoxHotelAdress;
}
}

View File

@ -0,0 +1,82 @@
using ProjectHotel.Entities;
using ProjectHotel.Repositories;
using ProjectHotel.Repositories.Implementations;
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 ProjectHotel.Forms;
public partial class FormHotel : Form
{
private readonly IHotelRepository _hotelRepository;
private int? _hotelId;
public int Id
{
set
{
try
{
var hotel =
_hotelRepository.ReadHotelById(value);
if (hotel == null)
{
throw new
InvalidDataException(nameof(hotel));
}
textBoxHotelName.Text = hotel.HotelName;
textBoxHotelAdress.Text =
hotel.Adress;
_hotelId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormHotel(IHotelRepository hotelRepository)
{
InitializeComponent();
_hotelRepository = hotelRepository ??
throw new
ArgumentNullException(nameof(hotelRepository));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxHotelName.Text)
||
string.IsNullOrWhiteSpace(textBoxHotelName.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_hotelId.HasValue)
{
_hotelRepository.UpdateHotel(CreateHotel(_hotelId.Value));
}
else
{
_hotelRepository.CreateHotel(CreateHotel(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Hotel CreateHotel(int id) => Hotel.CreateEntity(id, textBoxHotelName.Text, textBoxHotelAdress.Text);
}

View File

@ -0,0 +1,124 @@
namespace ProjectHotel
{
partial class FormHotelForAthletes
{
/// <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();
комнатыToolStripMenuItem = new ToolStripMenuItem();
отелелиToolStripMenuItem = new ToolStripMenuItem();
спортсменыToolStripMenuItem = new ToolStripMenuItem();
операцииToolStripMenuItem = new ToolStripMenuItem();
заселениеСпортсменаToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
menuStrip1.SuspendLayout();
SuspendLayout();
//
// menuStrip1
//
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(800, 24);
menuStrip1.TabIndex = 0;
menuStrip1.Text = "menuStrip1";
//
// справочникиToolStripMenuItem
//
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { комнатыToolStripMenuItem, отелелиToolStripMenuItem, спортсменыToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(94, 20);
справочникиToolStripMenuItem.Text = "Справочники";
//
// комнатыToolStripMenuItem
//
комнатыToolStripMenuItem.Name = омнатыToolStripMenuItem";
комнатыToolStripMenuItem.Size = new Size(145, 22);
комнатыToolStripMenuItem.Text = "Комнаты";
//
// отелелиToolStripMenuItem
//
отелелиToolStripMenuItem.Name = "отелелиToolStripMenuItem";
отелелиToolStripMenuItem.Size = new Size(145, 22);
отелелиToolStripMenuItem.Text = "Отелели";
//
// спортсменыToolStripMenuItem
//
спортсменыToolStripMenuItem.Name = "спортсменыToolStripMenuItem";
спортсменыToolStripMenuItem.Size = new Size(145, 22);
спортсменыToolStripMenuItem.Text = "Спортсмены";
//
// операцииToolStripMenuItem
//
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заселениеСпортсменаToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(75, 20);
операцииToolStripMenuItem.Text = "Операции";
//
// заселениеСпортсменаToolStripMenuItem
//
заселениеСпортсменаToolStripMenuItem.Name = аселениеСпортсменаToolStripMenuItem";
заселениеСпортсменаToolStripMenuItem.Size = new Size(201, 22);
заселениеСпортсменаToolStripMenuItem.Text = "Заселение спортсмена";
//
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(60, 20);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// FormHotelForAthletes
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.hotel;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(800, 450);
Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1;
Name = "FormHotelForAthletes";
StartPosition = FormStartPosition.CenterScreen;
Text = "Гостиница";
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip1;
private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem комнатыToolStripMenuItem;
private ToolStripMenuItem отелелиToolStripMenuItem;
private ToolStripMenuItem спортсменыToolStripMenuItem;
private ToolStripMenuItem операцииToolStripMenuItem;
private ToolStripMenuItem заселениеСпортсменаToolStripMenuItem;
private ToolStripMenuItem отчетыToolStripMenuItem;
}
}

View File

@ -1,8 +1,8 @@
namespace ProjectHotel
{
public partial class Form1 : Form
public partial class FormHotelForAthletes : Form
{
public Form1()
public FormHotelForAthletes()
{
InitializeComponent();
}

View 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>

View File

@ -0,0 +1,94 @@
namespace ProjectHotel.Forms
{
partial class FormHotels
{
/// <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()
{
panel1 = new Panel();
buttonAdd = new Button();
buttonChange = new Button();
buttonDelete = new Button();
panel1.SuspendLayout();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonDelete);
panel1.Controls.Add(buttonChange);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(632, 0);
panel1.Name = "panel1";
panel1.Size = new Size(168, 450);
panel1.TabIndex = 0;
//
// buttonAdd
//
buttonAdd.BackgroundImageLayout = ImageLayout.Zoom;
buttonAdd.Location = new Point(24, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(130, 130);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
//
// buttonChange
//
buttonChange.BackgroundImageLayout = ImageLayout.Zoom;
buttonChange.Location = new Point(24, 158);
buttonChange.Name = "buttonChange";
buttonChange.Size = new Size(130, 130);
buttonChange.TabIndex = 1;
buttonChange.UseVisualStyleBackColor = true;
//
// buttonDelete
//
buttonDelete.Location = new Point(24, 308);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(130, 130);
buttonDelete.TabIndex = 2;
buttonDelete.UseVisualStyleBackColor = true;
//
// FormHotels
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(panel1);
Name = "FormHotels";
Text = "FormHotels";
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonAdd;
private Button buttonDelete;
private Button buttonChange;
}
}

View File

@ -0,0 +1,108 @@
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 ProjectHotel.Forms;
public partial class FormHotels : Form
{
private readonly IUnityContainer _container;
private readonly IAnimalRepository _animalRepository;
public FormAnimals(IUnityContainer container, IAnimalRepository
aimalRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_animalRepository = aimalRepository ??
throw new
ArgumentNullException(nameof(aimalRepository));
}
private void FormAnimals_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormAnimal>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
20
var form = _container.Resolve<FormAnimal>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_animalRepository.DeleteAnimal(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _animalRepository.ReadAnimals();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
return true;
}
}

View 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>

View File

@ -11,7 +11,7 @@ namespace ProjectHotel
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run(new FormHotelForAthletes());
}
}
}

View File

@ -2,10 +2,25 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -0,0 +1,83 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectHotel.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectHotel.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap AddImage {
get {
object obj = ResourceManager.GetObject("AddImage", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap hotel {
get {
object obj = ResourceManager.GetObject("hotel", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,133 @@
<?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>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="ImageChange" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ImageChange.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="AddImage" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\AddImage.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="hotel" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\hotel.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ImageChange" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ImageChange1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,16 @@
using ProjectHotel.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHotel.Repositories;
public interface IAthleteSportReposetory
{
IEnumerable<AthleteSport> ReadAthleteSport();
AthleteSport ReadAthleteSportById(int id);
void CreateAthleteSport(AthleteSport athleteSport);
void DeleteAthleteSport(int id);
}

View File

@ -9,8 +9,8 @@ namespace ProjectHotel.Repositories;
public interface IHotelRepository
{
IEnumerable<Hotel> ReadAthletes();
Athlete ReadHotelById(int id);
IEnumerable<Hotel> ReadHotels();
Hotel ReadHotelById(int id);
void CreateHotel(Hotel hotel);
void UpdateHotel(Hotel hotel);
void DeleteHotel(int id);

View File

@ -0,0 +1,16 @@
using ProjectHotel.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHotel.Repositories;
public interface IPlacingAthleteRepository
{
IEnumerable<PlacingAthlete> ReadPlacingAthlete(DateTime? dateForm =
null, DateTime? dateTo = null,
int? athleteId = null, int? roomId = null);
void CreatePlacingAthlete(PlacingAthlete placingAthlete);
}

View File

@ -1,18 +0,0 @@
using ProjectHotel.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHotel.Repositories;
public interface IPlacingRepository
{
IEnumerable<PlacingAthlete> ReadPlacing();
PlacingAthlete ReadPlacingById(int id);
void CreateHotel(PlacingAthlete placing);
void UpdateHotel(PlacingAthlete placing);
void DeletePlacing(int id);
}
}

View File

@ -1,12 +1,18 @@
using System;
using ProjectHotel.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHotel.Repositories
namespace ProjectHotel.Repositories;
public interface IRoomRepository
{
internal interface IRoomRepository
{
}
IEnumerable<Rooms> ReadRooms();
Rooms ReadRoomById(int id);
void CreateRoom(Rooms rooms);
void UpdateRoom(Rooms rooms);
void DeleteRoom(int id);
}

View File

@ -0,0 +1,29 @@
using ProjectHotel.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHotel.Repositories.Implementations;
internal class AthleteRepository : IAthleteRepository
{
public void CreateAthlete(Athlete athlete)
{
}
public void DeleteAthlete(int id)
{
}
public Athlete ReadAthleteById(int id)
{
return Athlete.CreateEntity(0, string.Empty, string.Empty, string.Empty, 0);
}
public IEnumerable<Athlete> ReadAthletes()
{
return [];
}
public void UpdateAthlete(Athlete athlete)
{
}
}

View File

@ -0,0 +1,28 @@
using ProjectHotel.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHotel.Repositories.Implementations;
internal class AthleteSportRepository : IAthleteSportReposetory
{
public IEnumerable<AthleteSport> ReadAthleteSport()
{
return [];
}
public AthleteSport ReadAthleteSportById(int id)
{
return AthleteSport.CreateEntity(0, 0);
}
public void CreateAthleteSport(AthleteSport athleteSport)
{
}
public void DeleteAthleteSport(int id)
{
}
}

View File

@ -0,0 +1,32 @@
using ProjectHotel.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHotel.Repositories.Implementations;
internal class HotelRepository : IHotelRepository
{
public IEnumerable<Hotel> ReadHotels()
{
return [];
}
public Hotel ReadHotelById(int id)
{
return Hotel.CreateEntity(0, string.Empty, string.Empty);
}
public void CreateHotel(Hotel hotel)
{
}
public void UpdateHotel(Hotel hotel)
{
}
public void DeleteHotel(int id)
{
}
}

View File

@ -0,0 +1,22 @@
using ProjectHotel.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHotel.Repositories.Implementations;
internal class PlacingAthleteRepository : IPlacingAthleteRepository
{
public IEnumerable<PlacingAthlete> ReadPlacingAthlete(DateTime? dateForm =
null, DateTime? dateTo = null,
int? athleteId = null, int? roomId = null)
{
return [];
}
public void CreatePlacingAthlete(PlacingAthlete placingAthlete)
{
}
}

View File

@ -0,0 +1,34 @@
using ProjectHotel.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHotel.Repositories.Implementations
{
internal class RoomRepository : IRoomRepository
{
public IEnumerable<Rooms> ReadRooms()
{
return [];
}
public Rooms ReadRoomById(int id)
{
return Rooms.CreateEntity(0, 0, string.Empty, 0);
}
public void CreateRoom(Rooms rooms)
{
}
public void UpdateRoom(Rooms rooms)
{
}
public void DeleteRoom(int id)
{
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB