diff --git a/ProjectHotel/ProjectHotel.sln b/ProjectHotel/ProjectHotel.sln index 79aafa7..a7410ac 100644 --- a/ProjectHotel/ProjectHotel.sln +++ b/ProjectHotel/ProjectHotel.sln @@ -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 diff --git a/ProjectHotel/ProjectHotel/Entities/Athlete.cs b/ProjectHotel/ProjectHotel/Entities/Athlete.cs index 77ee676..c4607a4 100644 --- a/ProjectHotel/ProjectHotel/Entities/Athlete.cs +++ b/ProjectHotel/ProjectHotel/Entities/Athlete.cs @@ -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 + }; } diff --git a/ProjectHotel/ProjectHotel/Entities/AthleteSport.cs b/ProjectHotel/ProjectHotel/Entities/AthleteSport.cs new file mode 100644 index 0000000..ab500bd --- /dev/null +++ b/ProjectHotel/ProjectHotel/Entities/AthleteSport.cs @@ -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 + + + }; + } +} diff --git a/ProjectHotel/ProjectHotel/Entities/Enums/AthleteClass.cs b/ProjectHotel/ProjectHotel/Entities/Enums/AthleteClass.cs new file mode 100644 index 0000000..556a03e --- /dev/null +++ b/ProjectHotel/ProjectHotel/Entities/Enums/AthleteClass.cs @@ -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 + +} diff --git a/ProjectHotel/ProjectHotel/Entities/Enums/KindOfSport.cs b/ProjectHotel/ProjectHotel/Entities/Enums/KindOfSport.cs deleted file mode 100644 index c179c78..0000000 --- a/ProjectHotel/ProjectHotel/Entities/Enums/KindOfSport.cs +++ /dev/null @@ -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 - } -} - diff --git a/ProjectHotel/ProjectHotel/Entities/Enums/Sport.cs b/ProjectHotel/ProjectHotel/Entities/Enums/Sport.cs new file mode 100644 index 0000000..c75799b --- /dev/null +++ b/ProjectHotel/ProjectHotel/Entities/Enums/Sport.cs @@ -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 +} + diff --git a/ProjectHotel/ProjectHotel/Entities/Hotel.cs b/ProjectHotel/ProjectHotel/Entities/Hotel.cs index de369fd..38ac0ff 100644 --- a/ProjectHotel/ProjectHotel/Entities/Hotel.cs +++ b/ProjectHotel/ProjectHotel/Entities/Hotel.cs @@ -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 + }; } diff --git a/ProjectHotel/ProjectHotel/Entities/Rooms.cs b/ProjectHotel/ProjectHotel/Entities/Rooms.cs index 9569030..0792a28 100644 --- a/ProjectHotel/ProjectHotel/Entities/Rooms.cs +++ b/ProjectHotel/ProjectHotel/Entities/Rooms.cs @@ -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 }; } diff --git a/ProjectHotel/ProjectHotel/Form1.Designer.cs b/ProjectHotel/ProjectHotel/Form1.Designer.cs deleted file mode 100644 index fe81357..0000000 --- a/ProjectHotel/ProjectHotel/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ProjectHotel -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - 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 - } -} diff --git a/ProjectHotel/ProjectHotel/Forms/FormHotel.Designer.cs b/ProjectHotel/ProjectHotel/Forms/FormHotel.Designer.cs new file mode 100644 index 0000000..e6d5bee --- /dev/null +++ b/ProjectHotel/ProjectHotel/Forms/FormHotel.Designer.cs @@ -0,0 +1,92 @@ +namespace ProjectHotel.Forms +{ + partial class FormHotel + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/ProjectHotel/ProjectHotel/Forms/FormHotel.cs b/ProjectHotel/ProjectHotel/Forms/FormHotel.cs new file mode 100644 index 0000000..7f09583 --- /dev/null +++ b/ProjectHotel/ProjectHotel/Forms/FormHotel.cs @@ -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); +} + diff --git a/ProjectHotel/ProjectHotel/Form1.resx b/ProjectHotel/ProjectHotel/Forms/FormHotel.resx similarity index 93% rename from ProjectHotel/ProjectHotel/Form1.resx rename to ProjectHotel/ProjectHotel/Forms/FormHotel.resx index 1af7de1..af32865 100644 --- a/ProjectHotel/ProjectHotel/Form1.resx +++ b/ProjectHotel/ProjectHotel/Forms/FormHotel.resx @@ -1,17 +1,17 @@  - diff --git a/ProjectHotel/ProjectHotel/Forms/FormHotelForAthletes.Designer.cs b/ProjectHotel/ProjectHotel/Forms/FormHotelForAthletes.Designer.cs new file mode 100644 index 0000000..17894e5 --- /dev/null +++ b/ProjectHotel/ProjectHotel/Forms/FormHotelForAthletes.Designer.cs @@ -0,0 +1,124 @@ +namespace ProjectHotel +{ + partial class FormHotelForAthletes + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} diff --git a/ProjectHotel/ProjectHotel/Form1.cs b/ProjectHotel/ProjectHotel/Forms/FormHotelForAthletes.cs similarity index 50% rename from ProjectHotel/ProjectHotel/Form1.cs rename to ProjectHotel/ProjectHotel/Forms/FormHotelForAthletes.cs index cddc13a..f56f2e7 100644 --- a/ProjectHotel/ProjectHotel/Form1.cs +++ b/ProjectHotel/ProjectHotel/Forms/FormHotelForAthletes.cs @@ -1,8 +1,8 @@ namespace ProjectHotel { - public partial class Form1 : Form + public partial class FormHotelForAthletes : Form { - public Form1() + public FormHotelForAthletes() { InitializeComponent(); } diff --git a/ProjectHotel/ProjectHotel/Forms/FormHotelForAthletes.resx b/ProjectHotel/ProjectHotel/Forms/FormHotelForAthletes.resx new file mode 100644 index 0000000..a0623c8 --- /dev/null +++ b/ProjectHotel/ProjectHotel/Forms/FormHotelForAthletes.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/ProjectHotel/ProjectHotel/Forms/FormHotels.Designer.cs b/ProjectHotel/ProjectHotel/Forms/FormHotels.Designer.cs new file mode 100644 index 0000000..dbfce9a --- /dev/null +++ b/ProjectHotel/ProjectHotel/Forms/FormHotels.Designer.cs @@ -0,0 +1,94 @@ +namespace ProjectHotel.Forms +{ + partial class FormHotels + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/ProjectHotel/ProjectHotel/Forms/FormHotels.cs b/ProjectHotel/ProjectHotel/Forms/FormHotels.cs new file mode 100644 index 0000000..c84373a --- /dev/null +++ b/ProjectHotel/ProjectHotel/Forms/FormHotels.cs @@ -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().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(); + 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; + } +} + + diff --git a/ProjectHotel/ProjectHotel/Forms/FormHotels.resx b/ProjectHotel/ProjectHotel/Forms/FormHotels.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectHotel/ProjectHotel/Forms/FormHotels.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectHotel/ProjectHotel/Program.cs b/ProjectHotel/ProjectHotel/Program.cs index 2721a33..8177a3b 100644 --- a/ProjectHotel/ProjectHotel/Program.cs +++ b/ProjectHotel/ProjectHotel/Program.cs @@ -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()); } } } \ No newline at end of file diff --git a/ProjectHotel/ProjectHotel/ProjectHotel.csproj b/ProjectHotel/ProjectHotel/ProjectHotel.csproj index e1a0735..af03d74 100644 --- a/ProjectHotel/ProjectHotel/ProjectHotel.csproj +++ b/ProjectHotel/ProjectHotel/ProjectHotel.csproj @@ -2,10 +2,25 @@ WinExe - net7.0-windows + net8.0-windows enable true enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/ProjectHotel/ProjectHotel/Properties/Resources.Designer.cs b/ProjectHotel/ProjectHotel/Properties/Resources.Designer.cs new file mode 100644 index 0000000..9476918 --- /dev/null +++ b/ProjectHotel/ProjectHotel/Properties/Resources.Designer.cs @@ -0,0 +1,83 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace ProjectHotel.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // 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() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [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; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap AddImage { + get { + object obj = ResourceManager.GetObject("AddImage", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap hotel { + get { + object obj = ResourceManager.GetObject("hotel", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ProjectHotel/ProjectHotel/Properties/Resources.resx b/ProjectHotel/ProjectHotel/Properties/Resources.resx new file mode 100644 index 0000000..efd84b8 --- /dev/null +++ b/ProjectHotel/ProjectHotel/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\ImageChange.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\AddImage.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\hotel.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ImageChange1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ProjectHotel/ProjectHotel/Repositories/IAthleteSportReposetory.cs b/ProjectHotel/ProjectHotel/Repositories/IAthleteSportReposetory.cs new file mode 100644 index 0000000..3c6ded8 --- /dev/null +++ b/ProjectHotel/ProjectHotel/Repositories/IAthleteSportReposetory.cs @@ -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 ReadAthleteSport(); + AthleteSport ReadAthleteSportById(int id); + void CreateAthleteSport(AthleteSport athleteSport); + void DeleteAthleteSport(int id); +} diff --git a/ProjectHotel/ProjectHotel/Repositories/IHotelRepository.cs b/ProjectHotel/ProjectHotel/Repositories/IHotelRepository.cs index d523633..0519c0e 100644 --- a/ProjectHotel/ProjectHotel/Repositories/IHotelRepository.cs +++ b/ProjectHotel/ProjectHotel/Repositories/IHotelRepository.cs @@ -9,8 +9,8 @@ namespace ProjectHotel.Repositories; public interface IHotelRepository { - IEnumerable ReadAthletes(); - Athlete ReadHotelById(int id); + IEnumerable ReadHotels(); + Hotel ReadHotelById(int id); void CreateHotel(Hotel hotel); void UpdateHotel(Hotel hotel); void DeleteHotel(int id); diff --git a/ProjectHotel/ProjectHotel/Repositories/IPlacingAthleteRepository.cs b/ProjectHotel/ProjectHotel/Repositories/IPlacingAthleteRepository.cs new file mode 100644 index 0000000..89bf0df --- /dev/null +++ b/ProjectHotel/ProjectHotel/Repositories/IPlacingAthleteRepository.cs @@ -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 ReadPlacingAthlete(DateTime? dateForm = + null, DateTime? dateTo = null, + int? athleteId = null, int? roomId = null); + void CreatePlacingAthlete(PlacingAthlete placingAthlete); +} diff --git a/ProjectHotel/ProjectHotel/Repositories/IPlacingRepository.cs b/ProjectHotel/ProjectHotel/Repositories/IPlacingRepository.cs deleted file mode 100644 index a0d31cd..0000000 --- a/ProjectHotel/ProjectHotel/Repositories/IPlacingRepository.cs +++ /dev/null @@ -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 ReadPlacing(); - PlacingAthlete ReadPlacingById(int id); - void CreateHotel(PlacingAthlete placing); - void UpdateHotel(PlacingAthlete placing); - void DeletePlacing(int id); -} -} diff --git a/ProjectHotel/ProjectHotel/Repositories/IRoomRepository.cs b/ProjectHotel/ProjectHotel/Repositories/IRoomRepository.cs index f72d681..d32eeb3 100644 --- a/ProjectHotel/ProjectHotel/Repositories/IRoomRepository.cs +++ b/ProjectHotel/ProjectHotel/Repositories/IRoomRepository.cs @@ -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 ReadRooms(); + Rooms ReadRoomById(int id); + void CreateRoom(Rooms rooms); + void UpdateRoom(Rooms rooms); + void DeleteRoom(int id); } diff --git a/ProjectHotel/ProjectHotel/Repositories/Implementations/AthleteRepository.cs b/ProjectHotel/ProjectHotel/Repositories/Implementations/AthleteRepository.cs new file mode 100644 index 0000000..c7de4a3 --- /dev/null +++ b/ProjectHotel/ProjectHotel/Repositories/Implementations/AthleteRepository.cs @@ -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 ReadAthletes() + { + return []; + } + public void UpdateAthlete(Athlete athlete) + { + } +} diff --git a/ProjectHotel/ProjectHotel/Repositories/Implementations/AthleteSportRepository.cs b/ProjectHotel/ProjectHotel/Repositories/Implementations/AthleteSportRepository.cs new file mode 100644 index 0000000..aa4066e --- /dev/null +++ b/ProjectHotel/ProjectHotel/Repositories/Implementations/AthleteSportRepository.cs @@ -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 ReadAthleteSport() + { + return []; + } + public AthleteSport ReadAthleteSportById(int id) + { + return AthleteSport.CreateEntity(0, 0); + } + public void CreateAthleteSport(AthleteSport athleteSport) + { + + } + public void DeleteAthleteSport(int id) + { + + } +} diff --git a/ProjectHotel/ProjectHotel/Repositories/Implementations/HotelRepository.cs b/ProjectHotel/ProjectHotel/Repositories/Implementations/HotelRepository.cs new file mode 100644 index 0000000..3b952f6 --- /dev/null +++ b/ProjectHotel/ProjectHotel/Repositories/Implementations/HotelRepository.cs @@ -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 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) + { + + } +} diff --git a/ProjectHotel/ProjectHotel/Repositories/Implementations/PlacingAthleteRepository.cs b/ProjectHotel/ProjectHotel/Repositories/Implementations/PlacingAthleteRepository.cs new file mode 100644 index 0000000..ae856ab --- /dev/null +++ b/ProjectHotel/ProjectHotel/Repositories/Implementations/PlacingAthleteRepository.cs @@ -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 ReadPlacingAthlete(DateTime? dateForm = + null, DateTime? dateTo = null, + int? athleteId = null, int? roomId = null) + { + return []; + } + public void CreatePlacingAthlete(PlacingAthlete placingAthlete) + { + + } +} diff --git a/ProjectHotel/ProjectHotel/Repositories/Implementations/RoomRepository.cs b/ProjectHotel/ProjectHotel/Repositories/Implementations/RoomRepository.cs new file mode 100644 index 0000000..2ba2260 --- /dev/null +++ b/ProjectHotel/ProjectHotel/Repositories/Implementations/RoomRepository.cs @@ -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 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) + { + + } + + } +} diff --git a/ProjectHotel/ProjectHotel/Resources/hotel.jpg b/ProjectHotel/ProjectHotel/Resources/hotel.jpg new file mode 100644 index 0000000..d0397cc Binary files /dev/null and b/ProjectHotel/ProjectHotel/Resources/hotel.jpg differ