diff --git a/ProjectTourismCompany/ProjectTourismCompany/Entities/Check.cs b/ProjectTourismCompany/ProjectTourismCompany/Entities/Check.cs new file mode 100644 index 0000000..942eab8 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Entities/Check.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Entities; + +public class Check +{ + public int Id { get; private set; } + public string Title { get; private set; } = string.Empty; + public DateTime PurchaseDate { get; private set; } + public int Price { get; private set; } + public int TripId { get; private set; } + public int ClientId { get; private set; } + public static Check CreateCheck(int id, string title, DateTime purchaseDate, int price, int tripId, int clientId) + { + return new Check() { Id = id, Title = title, PurchaseDate = purchaseDate, Price = price, TripId = tripId, ClientId = clientId }; + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Entities/Client.cs b/ProjectTourismCompany/ProjectTourismCompany/Entities/Client.cs new file mode 100644 index 0000000..83a87e6 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Entities/Client.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Entities.Enums; + +public class Client +{ + public int Id { get; private set; } + public string Name { get; private set; } = string.Empty; + public DateTime BirthDate { get; private set; } + public ClientStatus Status { get; private set; } + public string Phone { get; private set; }= string.Empty; + public static Client CreateClient(int id, string name, DateTime birth, ClientStatus status, string phone) + { + return new Client() + { + Id = id, + Name = name, + BirthDate = birth, + Status = status, + Phone = phone + }; + + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Entities/Company.cs b/ProjectTourismCompany/ProjectTourismCompany/Entities/Company.cs new file mode 100644 index 0000000..1b5e39d --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Entities/Company.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Entities; + +public class Company +{ + public int Id { get; private set; } + public string Name { get; private set; } = string.Empty; + public int CountryId { get; private set; } + + + public static Company CreateCompany(int id, string name, int countryId) + { + return new Company() { Id = id, Name = name, CountryId = countryId}; + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Entities/CompanyTrip.cs b/ProjectTourismCompany/ProjectTourismCompany/Entities/CompanyTrip.cs new file mode 100644 index 0000000..ac8d1dc --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Entities/CompanyTrip.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Entities; + +public class CompanyTrip +{ + public int Id { get; private set; } + public int CompanyId { get; private set; } + public int TripId { get; private set; } + public int AdditionalPrice { get; private set; } + public static CompanyTrip CreateCompanyTrip(int id, int companyId, int tripId, int additionalPrice) + { + return new CompanyTrip() + { + Id = id, + CompanyId = companyId, + TripId = tripId, + AdditionalPrice = additionalPrice + }; + } + +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Entities/Country.cs b/ProjectTourismCompany/ProjectTourismCompany/Entities/Country.cs new file mode 100644 index 0000000..a15c011 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Entities/Country.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Entities; + +public class Country +{ + public int Id { get; private set; } + public string CountryName { get; private set; }=string.Empty; + public static Country CreateCountry(int id, string countryName) + { + return new Country + { + Id = id, + CountryName = countryName, + }; + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Entities/Enums/CleintStatus.cs b/ProjectTourismCompany/ProjectTourismCompany/Entities/Enums/CleintStatus.cs new file mode 100644 index 0000000..397a129 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Entities/Enums/CleintStatus.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Entities.Enums; + +public enum ClientStatus +{ + None = 0, + Student = 1, + Veteran = 3, + Invalid = 4, + Parent = 5, +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Entities/Enums/TravelType.cs b/ProjectTourismCompany/ProjectTourismCompany/Entities/Enums/TravelType.cs new file mode 100644 index 0000000..117b222 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Entities/Enums/TravelType.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Entities.Enums; + +[Flags] +public enum TravelType +{ + None = 0, + Hiking = 1, + Bus = 2, + Sights = 4, + Water = 8, + Event = 16 +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Entities/Trip.cs b/ProjectTourismCompany/ProjectTourismCompany/Entities/Trip.cs new file mode 100644 index 0000000..e0d65ad --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Entities/Trip.cs @@ -0,0 +1,45 @@ +using ProjectTourismCompany.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Entities; + +public class Trip +{ + public int Id { get; private set; } + public string Title { get; private set; } = string.Empty; + public int Price { get; private set; } + public int HumanCapacity { get; private set; } + public DateTime StartDate { get; private set; } + public DateTime EndDate { get; private set;} + public string StartCity { get; private set; }=string.Empty; + public string EndCity { get; private set;} =string.Empty; + public int CompanyId { get; private set; } + public TravelType TravelType { get; private set; } + + public IEnumerable CompanyTrip + { + get; + private set; + } = []; + + public static Trip CreateOpeartion(int id, string title, int price, int humanCapacity, DateTime startDate, DateTime endDate, string startCity, string endCity, TravelType travelType, IEnumerable companyTrip) + { + return new Trip + { + Title = title, + Id = id, + Price = price, + HumanCapacity = humanCapacity, + StartDate = startDate, + EndDate = endDate, + StartCity = startCity, + EndCity = endCity, + TravelType = travelType, + CompanyTrip = companyTrip + }; + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Form1.Designer.cs b/ProjectTourismCompany/ProjectTourismCompany/Form1.Designer.cs deleted file mode 100644 index a6d4b62..0000000 --- a/ProjectTourismCompany/ProjectTourismCompany/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ProjectTourismCompany -{ - 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/ProjectTourismCompany/ProjectTourismCompany/Form1.cs b/ProjectTourismCompany/ProjectTourismCompany/Form1.cs deleted file mode 100644 index e354936..0000000 --- a/ProjectTourismCompany/ProjectTourismCompany/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ProjectTourismCompany -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/ProjectTourismCompany/ProjectTourismCompany/FormTourismCompany.Designer.cs b/ProjectTourismCompany/ProjectTourismCompany/FormTourismCompany.Designer.cs new file mode 100644 index 0000000..1018606 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/FormTourismCompany.Designer.cs @@ -0,0 +1,137 @@ +namespace ProjectTourismCompany +{ + partial class FormTourismCompany + { + /// + /// 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(); + ClientsToolStripMenuItem = new ToolStripMenuItem(); + CompaniesToolStripMenuItem = new ToolStripMenuItem(); + CountriesToolStripMenuItem = new ToolStripMenuItem(); + операцииToolStripMenuItem = new ToolStripMenuItem(); + ChecksToolStripMenuItem = new ToolStripMenuItem(); + ToursToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + menuStrip1.SuspendLayout(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.ImageScalingSize = new Size(20, 20); + menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(800, 28); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ClientsToolStripMenuItem, CompaniesToolStripMenuItem, CountriesToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(117, 24); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // ClientsToolStripMenuItem + // + ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem"; + ClientsToolStripMenuItem.Size = new Size(165, 26); + ClientsToolStripMenuItem.Text = "Клиенты"; + ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click; + // + // CompaniesToolStripMenuItem + // + CompaniesToolStripMenuItem.Name = "CompaniesToolStripMenuItem"; + CompaniesToolStripMenuItem.Size = new Size(165, 26); + CompaniesToolStripMenuItem.Text = "Компании"; + CompaniesToolStripMenuItem.Click += CompaniesToolStripMenuItem_Click; + // + // CountriesToolStripMenuItem + // + CountriesToolStripMenuItem.Name = "CountriesToolStripMenuItem"; + CountriesToolStripMenuItem.Size = new Size(165, 26); + CountriesToolStripMenuItem.Text = "Страны"; + CountriesToolStripMenuItem.Click += CountriesToolStripMenuItem_Click; + // + // операцииToolStripMenuItem + // + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ChecksToolStripMenuItem, ToursToolStripMenuItem }); + операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; + операцииToolStripMenuItem.Size = new Size(95, 24); + операцииToolStripMenuItem.Text = "Операции"; + // + // ChecksToolStripMenuItem + // + ChecksToolStripMenuItem.Name = "ChecksToolStripMenuItem"; + ChecksToolStripMenuItem.Size = new Size(302, 26); + ChecksToolStripMenuItem.Text = "Заключение договоров (чеки)"; + ChecksToolStripMenuItem.Click += ChecksToolStripMenuItem_Click; + // + // ToursToolStripMenuItem + // + ToursToolStripMenuItem.Name = "ToursToolStripMenuItem"; + ToursToolStripMenuItem.Size = new Size(302, 26); + ToursToolStripMenuItem.Text = "Проведенные туры"; + ToursToolStripMenuItem.Click += TripsToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(73, 24); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // FormTourismCompany + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.Карта_мира; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(800, 450); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Name = "FormTourismCompany"; + Text = "Туристическое агенство"; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem операцииToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem ClientsToolStripMenuItem; + private ToolStripMenuItem CompaniesToolStripMenuItem; + private ToolStripMenuItem CountriesToolStripMenuItem; + private ToolStripMenuItem ChecksToolStripMenuItem; + private ToolStripMenuItem ToursToolStripMenuItem; + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/FormTourismCompany.cs b/ProjectTourismCompany/ProjectTourismCompany/FormTourismCompany.cs new file mode 100644 index 0000000..f199ce5 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/FormTourismCompany.cs @@ -0,0 +1,88 @@ +using ProjectTourismCompany.Forms; +using System.ComponentModel; +using Unity; + +namespace ProjectTourismCompany; + +public partial class FormTourismCompany : Form +{ + private readonly IUnityContainer _container; + public FormTourismCompany(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + } + + + private void TripsToolStripMenuItem_Click(object sender, + EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + private void CompaniesToolStripMenuItem_Click(object sender, + EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ChecksToolStripMenuItem_Click(object sender, + EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void CountriesToolStripMenuItem_Click(object sender, + EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ClientsToolStripMenuItem_Click(object sender, + EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/FormTourismCompany.resx b/ProjectTourismCompany/ProjectTourismCompany/FormTourismCompany.resx new file mode 100644 index 0000000..a0623c8 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/FormTourismCompany.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/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCheck.Designer.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCheck.Designer.cs new file mode 100644 index 0000000..345125b --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCheck.Designer.cs @@ -0,0 +1,195 @@ +namespace ProjectTourismCompany.Forms +{ + partial class FormCheck + { + /// + /// 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() + { + buttonCancel = new Button(); + buttonSave = new Button(); + dateTimePickerPurchaseDate = new DateTimePicker(); + labelStartDate = new Label(); + label1 = new Label(); + numericUpDownPrice = new NumericUpDown(); + label2 = new Label(); + textBoxTitle = new TextBox(); + label3 = new Label(); + label4 = new Label(); + comboBoxClient = new ComboBox(); + comboBoxTrip = new ComboBox(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit(); + SuspendLayout(); + // + // buttonCancel + // + buttonCancel.BackColor = Color.IndianRed; + buttonCancel.Location = new Point(221, 260); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(135, 51); + buttonCancel.TabIndex = 31; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = false; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.BackColor = Color.LimeGreen; + buttonSave.Location = new Point(367, 260); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(135, 51); + buttonSave.TabIndex = 30; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = false; + buttonSave.Click += buttonSave_Click; + // + // dateTimePickerPurchaseDate + // + dateTimePickerPurchaseDate.Location = new Point(282, 66); + dateTimePickerPurchaseDate.Name = "dateTimePickerPurchaseDate"; + dateTimePickerPurchaseDate.Size = new Size(220, 27); + dateTimePickerPurchaseDate.TabIndex = 25; + // + // labelStartDate + // + labelStartDate.AutoSize = true; + labelStartDate.Location = new Point(45, 71); + labelStartDate.Name = "labelStartDate"; + labelStartDate.Size = new Size(92, 20); + labelStartDate.TabIndex = 18; + labelStartDate.Text = "Дата сделки"; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(64, 117); + label1.Name = "label1"; + label1.Size = new Size(45, 20); + label1.TabIndex = 34; + label1.Text = "Цена"; + // + // numericUpDownPrice + // + numericUpDownPrice.Location = new Point(284, 110); + numericUpDownPrice.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); + numericUpDownPrice.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownPrice.Name = "numericUpDownPrice"; + numericUpDownPrice.Size = new Size(217, 27); + numericUpDownPrice.TabIndex = 35; + numericUpDownPrice.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(45, 163); + label2.Name = "label2"; + label2.Size = new Size(101, 20); + label2.TabIndex = 36; + label2.Text = "ФИО клиента"; + // + // textBoxTitle + // + textBoxTitle.Location = new Point(282, 22); + textBoxTitle.Name = "textBoxTitle"; + textBoxTitle.Size = new Size(220, 27); + textBoxTitle.TabIndex = 38; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(45, 22); + label3.Name = "label3"; + label3.Size = new Size(135, 20); + label3.TabIndex = 37; + label3.Text = "Название путевки"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(45, 208); + label4.Name = "label4"; + label4.Size = new Size(64, 20); + label4.TabIndex = 39; + label4.Text = "Путевка"; + // + // comboBoxClient + // + comboBoxClient.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxClient.FormattingEnabled = true; + comboBoxClient.Location = new Point(282, 163); + comboBoxClient.Name = "comboBoxClient"; + comboBoxClient.Size = new Size(217, 28); + comboBoxClient.TabIndex = 41; + // + // comboBoxTrip + // + comboBoxTrip.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxTrip.FormattingEnabled = true; + comboBoxTrip.Location = new Point(282, 208); + comboBoxTrip.Name = "comboBoxTrip"; + comboBoxTrip.Size = new Size(217, 28); + comboBoxTrip.TabIndex = 42; + // + // FormCheck + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(513, 322); + Controls.Add(comboBoxTrip); + Controls.Add(comboBoxClient); + Controls.Add(label4); + Controls.Add(textBoxTitle); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(numericUpDownPrice); + Controls.Add(label1); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(dateTimePickerPurchaseDate); + Controls.Add(labelStartDate); + Name = "FormCheck"; + StartPosition = FormStartPosition.CenterParent; + Text = "Чек"; + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button buttonCancel; + private Button buttonSave; + private DateTimePicker dateTimePickerPurchaseDate; + private Label labelStartDate; + private Label label1; + private NumericUpDown numericUpDownPrice; + private Label label2; + private TextBox textBoxTitle; + private Label label3; + private Label label4; + private ComboBox comboBoxClient; + private ComboBox comboBoxTrip; + } +} \ No newline at end of file diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCheck.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCheck.cs new file mode 100644 index 0000000..29ca619 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCheck.cs @@ -0,0 +1,88 @@ +using Microsoft.VisualBasic.FileIO; +using ProjectTourismCompany.Entities; +using ProjectTourismCompany.Repositories; +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 ProjectTourismCompany.Forms; + +public partial class FormCheck : Form +{ + private readonly ICheckRepository _checkRepository; + private int _checkId; + public int Id + { + set + { + try + { + var check = _checkRepository.ReadCheckById(value); + if (check == null) + { + throw new + InvalidDataException(nameof(check)); + } + textBoxTitle.Text = check.Title; + dateTimePickerPurchaseDate.Value = check.PurchaseDate; + numericUpDownPrice.Value = check.Price; + + comboBoxClient.SelectedItem = check.ClientId; + + comboBoxTrip.SelectedItem = check.TripId; + _checkId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormCheck(ICheckRepository checkRepository, IClientRepository clientRepository) + { + InitializeComponent(); + _checkRepository = checkRepository ?? throw new ArgumentNullException(nameof(checkRepository)); + + comboBoxClient.DataSource = clientRepository.ReadClients(); + comboBoxClient.DisplayMember = "Name"; + comboBoxClient.ValueMember = "Id"; + + comboBoxTrip.DisplayMember = "Title"; + comboBoxTrip.ValueMember = "Id"; + } + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxTitle.Text) || + comboBoxTrip.SelectedIndex < 0 || + comboBoxClient.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + _checkRepository.CreateCheck(Check.CreateCheck(_checkId, textBoxTitle.Text, dateTimePickerPurchaseDate.Value, + (int)numericUpDownPrice.Value, (int)comboBoxTrip.SelectedItem!, + (int)comboBoxClient.SelectedItem!)); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => + Close(); + + +} + + diff --git a/ProjectTourismCompany/ProjectTourismCompany/Form1.resx b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCheck.resx similarity index 93% rename from ProjectTourismCompany/ProjectTourismCompany/Form1.resx rename to ProjectTourismCompany/ProjectTourismCompany/Forms/FormCheck.resx index 1af7de1..af32865 100644 --- a/ProjectTourismCompany/ProjectTourismCompany/Form1.resx +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCheck.resx @@ -1,17 +1,17 @@  - diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormChecks.Designer.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormChecks.Designer.cs new file mode 100644 index 0000000..711e716 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormChecks.Designer.cs @@ -0,0 +1,112 @@ +namespace ProjectTourismCompany.Forms +{ + partial class FormChecks + { + /// + /// 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() + { + dataGridViewChecks = new DataGridView(); + panel1 = new Panel(); + buttonDelCheck = new Button(); + buttonAddCheck = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewChecks).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewChecks + // + dataGridViewChecks.AllowUserToAddRows = false; + dataGridViewChecks.AllowUserToDeleteRows = false; + dataGridViewChecks.AllowUserToResizeColumns = false; + dataGridViewChecks.AllowUserToResizeRows = false; + dataGridViewChecks.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewChecks.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewChecks.Dock = DockStyle.Fill; + dataGridViewChecks.Location = new Point(0, 0); + dataGridViewChecks.MultiSelect = false; + dataGridViewChecks.Name = "dataGridViewChecks"; + dataGridViewChecks.ReadOnly = true; + dataGridViewChecks.RowHeadersVisible = false; + dataGridViewChecks.RowHeadersWidth = 51; + dataGridViewChecks.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewChecks.Size = new Size(800, 450); + dataGridViewChecks.TabIndex = 0; + // + // panel1 + // + panel1.Controls.Add(buttonDelCheck); + panel1.Controls.Add(buttonAddCheck); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(643, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(157, 450); + panel1.TabIndex = 1; + // + // buttonDelCheck + // + buttonDelCheck.BackgroundImage = Properties.Resources.minus; + buttonDelCheck.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelCheck.Location = new Point(17, 184); + buttonDelCheck.Name = "buttonDelCheck"; + buttonDelCheck.Size = new Size(94, 80); + buttonDelCheck.TabIndex = 5; + buttonDelCheck.UseVisualStyleBackColor = true; + buttonDelCheck.Click += buttonDel_Click; + // + // buttonAddCheck + // + buttonAddCheck.BackgroundImage = Properties.Resources.plus; + buttonAddCheck.BackgroundImageLayout = ImageLayout.Stretch; + buttonAddCheck.Location = new Point(17, 12); + buttonAddCheck.Name = "buttonAddCheck"; + buttonAddCheck.Size = new Size(94, 80); + buttonAddCheck.TabIndex = 3; + buttonAddCheck.UseVisualStyleBackColor = true; + buttonAddCheck.Click += ButtonAdd_Click; + // + // FormChecks + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(panel1); + Controls.Add(dataGridViewChecks); + Name = "FormChecks"; + Text = "Чеки"; + Load += FormChecks_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewChecks).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewChecks; + private Panel panel1; + private Button buttonDelCheck; + private Button buttonAddCheck; + } +} \ No newline at end of file diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormChecks.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormChecks.cs new file mode 100644 index 0000000..3464838 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormChecks.cs @@ -0,0 +1,100 @@ +using ProjectTourismCompany.Repositories; +using ProjectTourismCompany.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; +using Unity; + +namespace ProjectTourismCompany.Forms; + +public partial class FormChecks : Form +{ + private readonly IUnityContainer _container; + private readonly ICheckRepository _checkRepository; + + public FormChecks(IUnityContainer container, ICheckRepository checkRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _checkRepository = checkRepository ?? + throw new + ArgumentNullException(nameof(checkRepository)); + } + + + private void FormChecks_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 buttonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _checkRepository.DeleteCheck(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewChecks.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewChecks.SelectedRows[0].Cells["Id"].Value); + return true; + } + + + private void LoadList() => dataGridViewChecks.DataSource = + _checkRepository.ReadChecks(); +} + diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormChecks.resx b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormChecks.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormChecks.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/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClient.Designer.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClient.Designer.cs new file mode 100644 index 0000000..d929217 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClient.Designer.cs @@ -0,0 +1,166 @@ +namespace ProjectTourismCompany.Forms +{ + partial class FormClient + { + /// + /// 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() + { + textBoxName = new TextBox(); + textBoxPhoneNumber = new TextBox(); + label1 = new Label(); + dateTimePickerBirthDate = new DateTimePicker(); + label2 = new Label(); + label3 = new Label(); + label4 = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + comboBoxStatus = new ComboBox(); + SuspendLayout(); + // + // textBoxName + // + textBoxName.Location = new Point(230, 12); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(198, 27); + textBoxName.TabIndex = 0; + // + // textBoxPhoneNumber + // + textBoxPhoneNumber.Location = new Point(230, 198); + textBoxPhoneNumber.Name = "textBoxPhoneNumber"; + textBoxPhoneNumber.Size = new Size(198, 27); + textBoxPhoneNumber.TabIndex = 1; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(63, 15); + label1.Name = "label1"; + label1.Size = new Size(42, 20); + label1.TabIndex = 2; + label1.Text = "ФИО"; + // + // dateTimePickerBirthDate + // + dateTimePickerBirthDate.Location = new Point(230, 45); + dateTimePickerBirthDate.Name = "dateTimePickerBirthDate"; + dateTimePickerBirthDate.Size = new Size(198, 27); + dateTimePickerBirthDate.TabIndex = 3; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(63, 50); + label2.Name = "label2"; + label2.Size = new Size(116, 20); + label2.TabIndex = 4; + label2.Text = "Дата рождения"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(63, 121); + label3.Name = "label3"; + label3.Size = new Size(52, 20); + label3.TabIndex = 5; + label3.Text = "Статус"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(63, 201); + label4.Name = "label4"; + label4.Size = new Size(69, 20); + label4.TabIndex = 6; + label4.Text = "Телефон"; + // + // buttonSave + // + buttonSave.BackColor = Color.LimeGreen; + buttonSave.Location = new Point(293, 281); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(135, 51); + buttonSave.TabIndex = 8; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = false; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.BackColor = Color.IndianRed; + buttonCancel.Location = new Point(147, 281); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(135, 51); + buttonCancel.TabIndex = 9; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = false; + buttonCancel.Click += ButtonCancel_Click; + // + // comboBoxStatus + // + comboBoxStatus.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxStatus.FormattingEnabled = true; + comboBoxStatus.Location = new Point(230, 121); + comboBoxStatus.Name = "comboBoxStatus"; + comboBoxStatus.Size = new Size(198, 28); + comboBoxStatus.TabIndex = 10; + // + // FormClient + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(442, 344); + Controls.Add(comboBoxStatus); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(dateTimePickerBirthDate); + Controls.Add(label1); + Controls.Add(textBoxPhoneNumber); + Controls.Add(textBoxName); + Name = "FormClient"; + StartPosition = FormStartPosition.CenterParent; + Text = "Клиент"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private TextBox textBoxName; + private TextBox textBoxPhoneNumber; + private Label label1; + private DateTimePicker dateTimePickerBirthDate; + private Label label2; + private Label label3; + private Label label4; + private Button buttonSave; + private Button buttonCancel; + private ComboBox comboBoxStatus; + } +} \ No newline at end of file diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClient.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClient.cs new file mode 100644 index 0000000..a6663d1 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClient.cs @@ -0,0 +1,91 @@ +using Microsoft.VisualBasic.FileIO; +using ProjectTourismCompany.Entities.Enums; +using ProjectTourismCompany.Repositories; +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 ProjectTourismCompany.Forms; + +public partial class FormClient : Form +{ + + private readonly IClientRepository _clientRepository; + private int? _clientId; + public int Id + { + set + { + try + { + var client = _clientRepository.ReadClientById(value); + if (client == null) + { + throw new InvalidDataException(nameof(client)); + } + + textBoxName.Text = client.Name; + textBoxPhoneNumber.Text = client.Phone; + comboBoxStatus.SelectedItem = client.Status; + dateTimePickerBirthDate.Value = client.BirthDate; + _clientId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + + public FormClient(IClientRepository clientRepository) + { + InitializeComponent(); + _clientRepository = clientRepository ?? + throw new + ArgumentNullException(nameof(clientRepository)); + comboBoxStatus.DataSource = +Enum.GetValues(typeof(ClientStatus)); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text) + || + string.IsNullOrWhiteSpace(textBoxPhoneNumber.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_clientId.HasValue) + { + _clientRepository.UpdateClient(CreateClient(_clientId.Value)); + } + else + { + _clientRepository.UpdateClient(CreateClient(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Client CreateClient(int id) + { + return Client.CreateClient(id, textBoxName.Text, dateTimePickerBirthDate.Value, (ClientStatus)comboBoxStatus.SelectedItem!, textBoxPhoneNumber.Text); + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClient.resx b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClient.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClient.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/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClients.Designer.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClients.Designer.cs new file mode 100644 index 0000000..94cc393 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClients.Designer.cs @@ -0,0 +1,123 @@ +namespace ProjectTourismCompany.Forms +{ + partial class FormClients + { + /// + /// 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(); + buttonDelClient = new Button(); + buttonUpdClient = new Button(); + buttonAddClient = new Button(); + dataGridViewClient = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewClient).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDelClient); + panel1.Controls.Add(buttonUpdClient); + panel1.Controls.Add(buttonAddClient); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(669, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(131, 450); + panel1.TabIndex = 0; + // + // buttonDelClient + // + buttonDelClient.BackgroundImage = Properties.Resources.minus; + buttonDelClient.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelClient.Location = new Point(6, 184); + buttonDelClient.Name = "buttonDelClient"; + buttonDelClient.Size = new Size(94, 80); + buttonDelClient.TabIndex = 2; + buttonDelClient.UseVisualStyleBackColor = true; + buttonDelClient.Click += buttonDel_Click; + // + // buttonUpdClient + // + buttonUpdClient.BackgroundImage = Properties.Resources.pencil; + buttonUpdClient.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdClient.Location = new Point(6, 98); + buttonUpdClient.Name = "buttonUpdClient"; + buttonUpdClient.Size = new Size(94, 80); + buttonUpdClient.TabIndex = 1; + buttonUpdClient.UseVisualStyleBackColor = true; + buttonUpdClient.Click += buttonUpd_Click; + // + // buttonAddClient + // + buttonAddClient.BackgroundImage = Properties.Resources.plus; + buttonAddClient.BackgroundImageLayout = ImageLayout.Stretch; + buttonAddClient.Location = new Point(6, 12); + buttonAddClient.Name = "buttonAddClient"; + buttonAddClient.Size = new Size(94, 80); + buttonAddClient.TabIndex = 0; + buttonAddClient.UseVisualStyleBackColor = true; + buttonAddClient.Click += buttonAdd_Click; + // + // dataGridViewClient + // + dataGridViewClient.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewClient.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewClient.Dock = DockStyle.Fill; + dataGridViewClient.Location = new Point(0, 0); + dataGridViewClient.MultiSelect = false; + dataGridViewClient.Name = "dataGridViewClient"; + dataGridViewClient.ReadOnly = true; + dataGridViewClient.RowHeadersVisible = false; + dataGridViewClient.RowHeadersWidth = 51; + dataGridViewClient.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewClient.Size = new Size(669, 450); + dataGridViewClient.TabIndex = 1; + // + // FormClients + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewClient); + Controls.Add(panel1); + Name = "FormClients"; + StartPosition = FormStartPosition.CenterParent; + Text = "Клиенты"; + Load += FormClients_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewClient).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonDelClient; + private Button buttonUpdClient; + private Button buttonAddClient; + private DataGridView dataGridViewClient; + } +} \ No newline at end of file diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClients.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClients.cs new file mode 100644 index 0000000..47c4663 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClients.cs @@ -0,0 +1,107 @@ +using ProjectTourismCompany.Repositories; +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 Unity; + +namespace ProjectTourismCompany.Forms; + +public partial class FormClients : Form +{ + private readonly IUnityContainer _container; + private readonly IClientRepository _clientRepository; + public FormClients(IUnityContainer container, IClientRepository clientRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository)); + } + private void FormClients_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 + { + + 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 + { + _clientRepository.DeleteClient(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridViewClient.DataSource = + _clientRepository.ReadClients(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewClient.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewClient.SelectedRows[0].Cells["Id"].Value); + return true; + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClients.resx b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClients.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormClients.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/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompanies.Designer.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompanies.Designer.cs new file mode 100644 index 0000000..adf58b3 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompanies.Designer.cs @@ -0,0 +1,127 @@ +namespace ProjectTourismCompany.Forms +{ + partial class FormCompanies + { + /// + /// 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() + { + dataGridViewCompanies = new DataGridView(); + panel1 = new Panel(); + buttonDelCompany = new Button(); + buttonUpdCompany = new Button(); + buttonAddCompany = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewCompanies).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewCompanies + // + dataGridViewCompanies.AllowUserToAddRows = false; + dataGridViewCompanies.AllowUserToDeleteRows = false; + dataGridViewCompanies.AllowUserToResizeColumns = false; + dataGridViewCompanies.AllowUserToResizeRows = false; + dataGridViewCompanies.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewCompanies.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewCompanies.Dock = DockStyle.Fill; + dataGridViewCompanies.Location = new Point(0, 0); + dataGridViewCompanies.MultiSelect = false; + dataGridViewCompanies.Name = "dataGridViewCompanies"; + dataGridViewCompanies.ReadOnly = true; + dataGridViewCompanies.RowHeadersVisible = false; + dataGridViewCompanies.RowHeadersWidth = 51; + dataGridViewCompanies.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewCompanies.Size = new Size(800, 450); + dataGridViewCompanies.TabIndex = 0; + // + // panel1 + // + panel1.Controls.Add(buttonDelCompany); + panel1.Controls.Add(buttonUpdCompany); + panel1.Controls.Add(buttonAddCompany); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(665, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(135, 450); + panel1.TabIndex = 1; + // + // buttonDelCompany + // + buttonDelCompany.BackgroundImage = Properties.Resources.minus; + buttonDelCompany.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelCompany.Location = new Point(29, 183); + buttonDelCompany.Name = "buttonDelCompany"; + buttonDelCompany.Size = new Size(94, 80); + buttonDelCompany.TabIndex = 5; + buttonDelCompany.UseVisualStyleBackColor = true; + buttonDelCompany.Click += buttonDel_Click; + // + // buttonUpdCompany + // + buttonUpdCompany.BackgroundImage = Properties.Resources.pencil; + buttonUpdCompany.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdCompany.Location = new Point(29, 97); + buttonUpdCompany.Name = "buttonUpdCompany"; + buttonUpdCompany.Size = new Size(94, 80); + buttonUpdCompany.TabIndex = 4; + buttonUpdCompany.UseVisualStyleBackColor = true; + buttonUpdCompany.Click += buttonUpd_Click; + // + // buttonAddCompany + // + buttonAddCompany.BackgroundImage = Properties.Resources.plus; + buttonAddCompany.BackgroundImageLayout = ImageLayout.Stretch; + buttonAddCompany.Location = new Point(29, 11); + buttonAddCompany.Name = "buttonAddCompany"; + buttonAddCompany.Size = new Size(94, 80); + buttonAddCompany.TabIndex = 3; + buttonAddCompany.UseVisualStyleBackColor = true; + buttonAddCompany.Click += buttonAdd_Click; + // + // FormCompanies + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(panel1); + Controls.Add(dataGridViewCompanies); + Name = "FormCompanies"; + StartPosition = FormStartPosition.CenterParent; + Text = "Компании"; + Load += FormCompanies_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewCompanies).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewCompanies; + private Panel panel1; + private Button buttonDelCompany; + private Button buttonUpdCompany; + private Button buttonAddCompany; + } +} \ No newline at end of file diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompanies.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompanies.cs new file mode 100644 index 0000000..2e75024 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompanies.cs @@ -0,0 +1,111 @@ +using ProjectTourismCompany.Repositories; +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 Unity; + +namespace ProjectTourismCompany.Forms; + +public partial class FormCompanies : Form +{ + private readonly IUnityContainer _container; + private readonly ICompanyRepository _companyRepository; + + + public FormCompanies(IUnityContainer container, ICompanyRepository + companyRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _companyRepository = companyRepository ?? throw new ArgumentNullException(nameof(companyRepository)); + } + + private void FormCompanies_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 + { + 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 + { + _companyRepository.DeleteCompany(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridViewCompanies.DataSource = + _companyRepository.ReadCompanies(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewCompanies.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewCompanies.SelectedRows[0].Cells["Id"].Value); + return true; + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompanies.resx b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompanies.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompanies.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/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompany.Designer.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompany.Designer.cs new file mode 100644 index 0000000..9e7d532 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompany.Designer.cs @@ -0,0 +1,123 @@ +namespace ProjectTourismCompany.Forms +{ + partial class FormCompany + { + /// + /// 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(); + textBoxName = new TextBox(); + buttonCancel = new Button(); + buttonSave = new Button(); + comboBoxCountry = new ComboBox(); + label2 = new Label(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 9); + label1.Name = "label1"; + label1.Size = new Size(77, 20); + label1.TabIndex = 0; + label1.Text = "Название"; + // + // textBoxName + // + textBoxName.Location = new Point(107, 6); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(150, 27); + textBoxName.TabIndex = 3; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.BackColor = Color.IndianRed; + buttonCancel.Location = new Point(17, 117); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(135, 51); + buttonCancel.TabIndex = 17; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = false; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonSave.BackColor = Color.LimeGreen; + buttonSave.Location = new Point(158, 117); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(135, 51); + buttonSave.TabIndex = 16; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = false; + buttonSave.Click += ButtonSave_Click; + // + // comboBoxCountry + // + comboBoxCountry.FormattingEnabled = true; + comboBoxCountry.Location = new Point(107, 67); + comboBoxCountry.Name = "comboBoxCountry"; + comboBoxCountry.Size = new Size(150, 28); + comboBoxCountry.TabIndex = 20; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(12, 67); + label2.Name = "label2"; + label2.Size = new Size(58, 20); + label2.TabIndex = 21; + label2.Text = "Страна"; + // + // FormCompany + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(305, 180); + Controls.Add(label2); + Controls.Add(comboBoxCountry); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxName); + Controls.Add(label1); + Name = "FormCompany"; + StartPosition = FormStartPosition.CenterParent; + Text = "Компания"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private TextBox textBoxName; + private Button buttonCancel; + private Button buttonSave; + private ComboBox comboBoxCountry; + private Label label2; + } +} \ No newline at end of file diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompany.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompany.cs new file mode 100644 index 0000000..43ff829 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompany.cs @@ -0,0 +1,83 @@ +using Microsoft.VisualBasic.FileIO; +using ProjectTourismCompany.Entities; +using ProjectTourismCompany.Entities.Enums; +using ProjectTourismCompany.Repositories; +using ProjectTourismCompany.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 ProjectTourismCompany.Forms; + +public partial class FormCompany : Form +{ + private readonly ICompanyRepository _companyRepository; + private int? _companyId; + public int Id + { + set + { + try + { + var client = _companyRepository.ReadCompanyById(value); + if (client == null) + { + throw new InvalidDataException(nameof(client)); + } + + textBoxName.Text = client.Name; + comboBoxCountry.SelectedItem = client.CountryId; + _companyId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + + + + public FormCompany( + ICompanyRepository companyRepository, + ITripRepository tripRepository, + ICountryRepository countryRepository) + { + InitializeComponent(); + _companyRepository = companyRepository ?? + throw new ArgumentNullException(nameof(companyRepository)); + comboBoxCountry.DataSource = countryRepository.ReadCountries(); + comboBoxCountry.DisplayMember = "Name"; + comboBoxCountry.ValueMember = "Id"; + } + + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + _companyRepository.CreateCompany(Company.CreateCompany(0, textBoxName.Text, (int)comboBoxCountry.SelectedItem!)); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => + Close(); + +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompany.resx b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompany.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCompany.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/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountries.Designer.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountries.Designer.cs new file mode 100644 index 0000000..2b715f3 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountries.Designer.cs @@ -0,0 +1,126 @@ +namespace ProjectTourismCompany.Forms +{ + partial class FormCountries + { + /// + /// 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() + { + dataGridView1 = new DataGridView(); + panel1 = new Panel(); + buttonDelCountry = new Button(); + buttonUpdCountry = new Button(); + buttonAddCountry = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridView1 + // + dataGridView1.AllowUserToAddRows = false; + dataGridView1.AllowUserToDeleteRows = false; + dataGridView1.AllowUserToResizeColumns = false; + dataGridView1.AllowUserToResizeRows = false; + dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Dock = DockStyle.Fill; + dataGridView1.Location = new Point(0, 0); + dataGridView1.MultiSelect = false; + dataGridView1.Name = "dataGridView1"; + dataGridView1.ReadOnly = true; + dataGridView1.RowHeadersWidth = 51; + dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView1.Size = new Size(642, 450); + dataGridView1.TabIndex = 0; + // + // panel1 + // + panel1.Controls.Add(buttonDelCountry); + panel1.Controls.Add(buttonUpdCountry); + panel1.Controls.Add(buttonAddCountry); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(642, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(158, 450); + panel1.TabIndex = 1; + // + // buttonDelCountry + // + buttonDelCountry.BackgroundImage = Properties.Resources.minus; + buttonDelCountry.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelCountry.Location = new Point(38, 198); + buttonDelCountry.Name = "buttonDelCountry"; + buttonDelCountry.Size = new Size(94, 80); + buttonDelCountry.TabIndex = 7; + buttonDelCountry.UseVisualStyleBackColor = true; + buttonDelCountry.Click += buttonDel_Click; + // + // buttonUpdCountry + // + buttonUpdCountry.BackgroundImage = Properties.Resources.pencil; + buttonUpdCountry.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdCountry.Location = new Point(38, 112); + buttonUpdCountry.Name = "buttonUpdCountry"; + buttonUpdCountry.Size = new Size(94, 80); + buttonUpdCountry.TabIndex = 6; + buttonUpdCountry.UseVisualStyleBackColor = true; + buttonUpdCountry.Click += buttonUpd_Click; + // + // buttonAddCountry + // + buttonAddCountry.BackgroundImage = Properties.Resources.plus; + buttonAddCountry.BackgroundImageLayout = ImageLayout.Stretch; + buttonAddCountry.Location = new Point(38, 26); + buttonAddCountry.Name = "buttonAddCountry"; + buttonAddCountry.Size = new Size(94, 80); + buttonAddCountry.TabIndex = 4; + buttonAddCountry.UseVisualStyleBackColor = true; + buttonAddCountry.Click += buttonAdd_Click; + // + // FormCountries + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView1); + Controls.Add(panel1); + Name = "FormCountries"; + StartPosition = FormStartPosition.CenterParent; + Text = "Страны"; + Load += FormCountries_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView1; + private Panel panel1; + private Button buttonAddCountry; + private Button buttonDelCountry; + private Button buttonUpdCountry; + } +} \ No newline at end of file diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountries.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountries.cs new file mode 100644 index 0000000..17c828a --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountries.cs @@ -0,0 +1,117 @@ +using ProjectTourismCompany.Repositories; +using ProjectTourismCompany.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; +using Unity; + +namespace ProjectTourismCompany.Forms; + +public partial class FormCountries : Form +{ + private readonly IUnityContainer _container; + private readonly ICountryRepository _countryRepository; + + + public FormCountries(IUnityContainer container, ICountryRepository countryRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _countryRepository = countryRepository ?? throw new ArgumentNullException(nameof(countryRepository)); + + } + + private void FormCountries_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 + { + + 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 + { + _countryRepository.DeleteCountry(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView1.DataSource = + _countryRepository.ReadCountries(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView1.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value); + return true; + } + +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountries.resx b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountries.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountries.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/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountry.Designer.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountry.Designer.cs new file mode 100644 index 0000000..fc82c19 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountry.Designer.cs @@ -0,0 +1,98 @@ +namespace ProjectTourismCompany.Forms +{ + partial class FormCountry + { + /// + /// 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() + { + buttonCancel = new Button(); + buttonSave = new Button(); + textBoxName = new TextBox(); + label1 = new Label(); + SuspendLayout(); + // + // buttonCancel + // + buttonCancel.BackColor = Color.IndianRed; + buttonCancel.Location = new Point(33, 76); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(135, 51); + buttonCancel.TabIndex = 17; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = false; + buttonCancel.Click += buttonCancel_Click; + // + // buttonSave + // + buttonSave.BackColor = Color.LimeGreen; + buttonSave.Location = new Point(174, 76); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(135, 51); + buttonSave.TabIndex = 16; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = false; + buttonSave.Click += buttonSave_Click; + // + // textBoxName + // + textBoxName.Location = new Point(107, 6); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(150, 27); + textBoxName.TabIndex = 21; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 9); + label1.Name = "label1"; + label1.Size = new Size(77, 20); + label1.TabIndex = 18; + label1.Text = "Название"; + // + // FormCountry + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(321, 139); + Controls.Add(textBoxName); + Controls.Add(label1); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Name = "FormCountry"; + StartPosition = FormStartPosition.CenterParent; + Text = "Страна"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button buttonCancel; + private Button buttonSave; + private TextBox textBoxName; + private Label label1; + } +} \ No newline at end of file diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountry.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountry.cs new file mode 100644 index 0000000..33731b3 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountry.cs @@ -0,0 +1,81 @@ +using ProjectTourismCompany.Entities; +using ProjectTourismCompany.Repositories; +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 ProjectTourismCompany.Forms; + +public partial class FormCountry : Form +{ + + private readonly ICountryRepository _countryRepository; + private int? _countryId; + public int Id + { + set + { + try + { + var country = _countryRepository.ReadCountryById(value); + if (country == null) + { + throw new InvalidDataException(nameof(country)); + } + + textBoxName.Text = country.CountryName; + _countryId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + + public FormCountry(ICountryRepository countryRepository) + { + InitializeComponent(); + _countryRepository = countryRepository ?? throw new ArgumentNullException(nameof(countryRepository)); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_countryId.HasValue) + { + _countryRepository.UpdateCountry(CreateCountry(_countryId.Value)); + } + else + { + _countryRepository.UpdateCountry(CreateCountry(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + private Country CreateCountry(int id) + { + return Country.CreateCountry(id, textBoxName.Text); + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountry.resx b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountry.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormCountry.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/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrip.Designer.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrip.Designer.cs new file mode 100644 index 0000000..4520584 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrip.Designer.cs @@ -0,0 +1,322 @@ +namespace ProjectTourismCompany.Forms +{ + partial class FormTrip + { + /// + /// 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() + { + labelPrice = new Label(); + labelHumanCapacity = new Label(); + labelStartDate = new Label(); + labelEndDate = new Label(); + labelStartCity = new Label(); + labelEndCity = new Label(); + labelTravelType = new Label(); + numericUpDownPrice = new NumericUpDown(); + numericUpDownHumanCapacity = new NumericUpDown(); + dateTimePickerStartDate = new DateTimePicker(); + dateTimePickerEndDate = new DateTimePicker(); + textBoxStartCity = new TextBox(); + textBoxEndCity = new TextBox(); + checkedListBoxTravelType = new CheckedListBox(); + buttonCancel = new Button(); + buttonSave = new Button(); + label1 = new Label(); + textBoxTitle = new TextBox(); + groupBox1 = new GroupBox(); + dataGridView1 = new DataGridView(); + columnCompanyName = new DataGridViewComboBoxColumn(); + ColumnAdditionalPrice = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownHumanCapacity).BeginInit(); + groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + SuspendLayout(); + // + // labelPrice + // + labelPrice.AutoSize = true; + labelPrice.Location = new Point(36, 71); + labelPrice.Name = "labelPrice"; + labelPrice.Size = new Size(45, 20); + labelPrice.TabIndex = 0; + labelPrice.Text = "Цена"; + // + // labelHumanCapacity + // + labelHumanCapacity.AutoSize = true; + labelHumanCapacity.Location = new Point(36, 116); + labelHumanCapacity.Name = "labelHumanCapacity"; + labelHumanCapacity.Size = new Size(142, 20); + labelHumanCapacity.TabIndex = 1; + labelHumanCapacity.Text = "Человек максимум"; + // + // labelStartDate + // + labelStartDate.AutoSize = true; + labelStartDate.Location = new Point(36, 172); + labelStartDate.Name = "labelStartDate"; + labelStartDate.Size = new Size(94, 20); + labelStartDate.TabIndex = 2; + labelStartDate.Text = "Дата начала"; + // + // labelEndDate + // + labelEndDate.AutoSize = true; + labelEndDate.Location = new Point(36, 227); + labelEndDate.Name = "labelEndDate"; + labelEndDate.Size = new Size(87, 20); + labelEndDate.TabIndex = 3; + labelEndDate.Text = "Дата конца"; + // + // labelStartCity + // + labelStartCity.AutoSize = true; + labelStartCity.Location = new Point(36, 285); + labelStartCity.Name = "labelStartCity"; + labelStartCity.Size = new Size(129, 20); + labelStartCity.TabIndex = 4; + labelStartCity.Text = "Стартовый город"; + // + // labelEndCity + // + labelEndCity.AutoSize = true; + labelEndCity.Location = new Point(36, 339); + labelEndCity.Name = "labelEndCity"; + labelEndCity.Size = new Size(126, 20); + labelEndCity.TabIndex = 5; + labelEndCity.Text = "Конечный город"; + // + // labelTravelType + // + labelTravelType.AutoSize = true; + labelTravelType.Location = new Point(35, 427); + labelTravelType.Name = "labelTravelType"; + labelTravelType.Size = new Size(127, 20); + labelTravelType.TabIndex = 6; + labelTravelType.Text = "Тип путешествия"; + // + // numericUpDownPrice + // + numericUpDownPrice.Location = new Point(273, 69); + numericUpDownPrice.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); + numericUpDownPrice.Minimum = new decimal(new int[] { 10000, 0, 0, 0 }); + numericUpDownPrice.Name = "numericUpDownPrice"; + numericUpDownPrice.Size = new Size(220, 27); + numericUpDownPrice.TabIndex = 7; + numericUpDownPrice.Value = new decimal(new int[] { 10000, 0, 0, 0 }); + // + // numericUpDownHumanCapacity + // + numericUpDownHumanCapacity.Location = new Point(273, 114); + numericUpDownHumanCapacity.Minimum = new decimal(new int[] { 5, 0, 0, 0 }); + numericUpDownHumanCapacity.Name = "numericUpDownHumanCapacity"; + numericUpDownHumanCapacity.Size = new Size(220, 27); + numericUpDownHumanCapacity.TabIndex = 8; + numericUpDownHumanCapacity.Value = new decimal(new int[] { 5, 0, 0, 0 }); + // + // dateTimePickerStartDate + // + dateTimePickerStartDate.Location = new Point(273, 167); + dateTimePickerStartDate.Name = "dateTimePickerStartDate"; + dateTimePickerStartDate.Size = new Size(220, 27); + dateTimePickerStartDate.TabIndex = 9; + // + // dateTimePickerEndDate + // + dateTimePickerEndDate.Location = new Point(273, 222); + dateTimePickerEndDate.Name = "dateTimePickerEndDate"; + dateTimePickerEndDate.Size = new Size(220, 27); + dateTimePickerEndDate.TabIndex = 10; + // + // textBoxStartCity + // + textBoxStartCity.Location = new Point(273, 285); + textBoxStartCity.Name = "textBoxStartCity"; + textBoxStartCity.Size = new Size(220, 27); + textBoxStartCity.TabIndex = 11; + // + // textBoxEndCity + // + textBoxEndCity.Location = new Point(273, 339); + textBoxEndCity.Name = "textBoxEndCity"; + textBoxEndCity.Size = new Size(220, 27); + textBoxEndCity.TabIndex = 12; + // + // checkedListBoxTravelType + // + checkedListBoxTravelType.FormattingEnabled = true; + checkedListBoxTravelType.Location = new Point(273, 383); + checkedListBoxTravelType.Name = "checkedListBoxTravelType"; + checkedListBoxTravelType.Size = new Size(220, 114); + checkedListBoxTravelType.TabIndex = 13; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCancel.BackColor = Color.IndianRed; + buttonCancel.Location = new Point(605, 512); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(135, 51); + buttonCancel.TabIndex = 15; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = false; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonSave.BackColor = Color.LimeGreen; + buttonSave.Location = new Point(796, 512); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(135, 51); + buttonSave.TabIndex = 14; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = false; + buttonSave.Click += ButtonSave_Click; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(36, 12); + label1.Name = "label1"; + label1.Size = new Size(111, 20); + label1.TabIndex = 16; + label1.Text = "Название тура"; + // + // textBoxTitle + // + textBoxTitle.Location = new Point(273, 12); + textBoxTitle.Name = "textBoxTitle"; + textBoxTitle.Size = new Size(220, 27); + textBoxTitle.TabIndex = 17; + // + // groupBox1 + // + groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBox1.Controls.Add(dataGridView1); + groupBox1.Location = new Point(499, 12); + groupBox1.Name = "groupBox1"; + groupBox1.Size = new Size(432, 476); + groupBox1.TabIndex = 20; + groupBox1.TabStop = false; + groupBox1.Text = "groupBox1"; + // + // dataGridView1 + // + dataGridView1.AllowUserToDeleteRows = false; + dataGridView1.AllowUserToResizeColumns = false; + dataGridView1.AllowUserToResizeRows = false; + dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Columns.AddRange(new DataGridViewColumn[] { columnCompanyName, ColumnAdditionalPrice }); + dataGridView1.Dock = DockStyle.Fill; + dataGridView1.Location = new Point(3, 23); + dataGridView1.MultiSelect = false; + dataGridView1.Name = "dataGridView1"; + dataGridView1.ReadOnly = true; + dataGridView1.RowHeadersVisible = false; + dataGridView1.RowHeadersWidth = 51; + dataGridView1.Size = new Size(426, 450); + dataGridView1.TabIndex = 0; + // + // columnCompanyName + // + columnCompanyName.HeaderText = "Название компании"; + columnCompanyName.MinimumWidth = 6; + columnCompanyName.Name = "columnCompanyName"; + columnCompanyName.ReadOnly = true; + // + // ColumnAdditionalPrice + // + ColumnAdditionalPrice.HeaderText = "Добавочная стоимость"; + ColumnAdditionalPrice.MinimumWidth = 6; + ColumnAdditionalPrice.Name = "ColumnAdditionalPrice"; + ColumnAdditionalPrice.ReadOnly = true; + ColumnAdditionalPrice.Resizable = DataGridViewTriState.True; + ColumnAdditionalPrice.SortMode = DataGridViewColumnSortMode.NotSortable; + // + // FormTrip + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(943, 573); + Controls.Add(groupBox1); + Controls.Add(textBoxTitle); + Controls.Add(label1); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(checkedListBoxTravelType); + Controls.Add(textBoxEndCity); + Controls.Add(textBoxStartCity); + Controls.Add(dateTimePickerEndDate); + Controls.Add(dateTimePickerStartDate); + Controls.Add(numericUpDownHumanCapacity); + Controls.Add(numericUpDownPrice); + Controls.Add(labelTravelType); + Controls.Add(labelEndCity); + Controls.Add(labelStartCity); + Controls.Add(labelEndDate); + Controls.Add(labelStartDate); + Controls.Add(labelHumanCapacity); + Controls.Add(labelPrice); + Name = "FormTrip"; + StartPosition = FormStartPosition.CenterParent; + Text = "Туры"; + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownHumanCapacity).EndInit(); + groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelPrice; + private Label labelHumanCapacity; + private Label labelStartDate; + private Label labelEndDate; + private Label labelStartCity; + private Label labelEndCity; + private Label labelTravelType; + private NumericUpDown numericUpDownPrice; + private NumericUpDown numericUpDownHumanCapacity; + private DateTimePicker dateTimePickerStartDate; + private DateTimePicker dateTimePickerEndDate; + private TextBox textBoxStartCity; + private TextBox textBoxEndCity; + private CheckedListBox checkedListBoxTravelType; + private Button buttonCancel; + private Button buttonSave; + private Label label1; + private TextBox textBoxTitle; + private GroupBox groupBox1; + private DataGridView dataGridView1; + private DataGridViewComboBoxColumn columnCompanyName; + private DataGridViewTextBoxColumn ColumnAdditionalPrice; + } +} \ No newline at end of file diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrip.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrip.cs new file mode 100644 index 0000000..bde80bd --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrip.cs @@ -0,0 +1,131 @@ +using Microsoft.VisualBasic.FileIO; +using ProjectTourismCompany.Entities; +using ProjectTourismCompany.Entities.Enums; +using ProjectTourismCompany.Repositories; +using ProjectTourismCompany.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 ProjectTourismCompany.Forms; + +public partial class FormTrip : Form +{ + private readonly ITripRepository _tripRepository; + private int? _tripId; + public int Id + { + set + { + try + { + var trip = _tripRepository.ReadTripById(value); + if (trip == null) + { + throw new + InvalidDataException(nameof(trip)); + } + textBoxStartCity.Text = trip.StartCity; + textBoxEndCity.Text = trip.EndCity; + numericUpDownHumanCapacity.Value = trip.HumanCapacity; + numericUpDownPrice.Value = trip.Price; + dateTimePickerEndDate.Value = trip.EndDate; + dateTimePickerStartDate.Value = trip.StartDate; + _tripId = value; + + foreach (TravelType elem in +Enum.GetValues(typeof(TravelType))) + { + if ((elem & trip.TravelType) != 0) + { + checkedListBoxTravelType.SetItemChecked(checkedListBoxTravelType.Items.IndexOf( + elem), true); + } + } + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormTrip(ITripRepository tripRepository, ICompanyRepository companyRepository) + { + InitializeComponent(); + _tripRepository = tripRepository ?? throw new ArgumentNullException(nameof(tripRepository)); + foreach (var elem in Enum.GetValues(typeof(TravelType))) + { + checkedListBoxTravelType.Items.Add(elem); + } + columnCompanyName.DataSource = companyRepository.ReadCompanies(); + columnCompanyName.DisplayMember = "Name"; + columnCompanyName.ValueMember = "Id"; + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxStartCity.Text) || + string.IsNullOrWhiteSpace(textBoxEndCity.Text) || dataGridView1.RowCount < 1) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_tripId.HasValue) + { + _tripRepository.CreateTrip(CreateTrip(_tripId.Value)); + } + else + { + _tripRepository.CreateTrip(CreateTrip(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => + Close(); + + private Trip CreateTrip(int id) + { + TravelType tr = TravelType.None; + foreach (var elem in checkedListBoxTravelType.CheckedItems) + { + tr |= (TravelType)elem; + } + return Trip.CreateOpeartion(0, textBoxTitle.Text, (int)numericUpDownPrice.Value, + (int)numericUpDownHumanCapacity.Value, dateTimePickerStartDate.Value, dateTimePickerEndDate.Value, + textBoxStartCity.Text, textBoxEndCity.Text, tr, CreateListCompanyTripFromDataGrid()); + } + + + private List CreateListCompanyTripFromDataGrid() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridView1.Rows) + { + if (row.Cells["ColumnAdditionalPrice"].Value == null || + row.Cells["ColumnCompanyName"].Value == null) + { + continue; + } + list.Add(CompanyTrip.CreateCompanyTrip(0, 0, + Convert.ToInt32(row.Cells["ColumnCompanyName"].Value), + Convert.ToInt32(row.Cells["ColumnAdditionalPrice"].Value))); + } + return list; + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrip.resx b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrip.resx new file mode 100644 index 0000000..5b6b78e --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrip.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + \ No newline at end of file diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrips.Designer.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrips.Designer.cs new file mode 100644 index 0000000..e57b191 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrips.Designer.cs @@ -0,0 +1,98 @@ +namespace ProjectTourismCompany.Forms +{ + partial class FormTrips + { + /// + /// 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() + { + dataGridView1 = new DataGridView(); + panel1 = new Panel(); + buttonAddTrip = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridView1 + // + dataGridView1.AllowUserToAddRows = false; + dataGridView1.AllowUserToDeleteRows = false; + dataGridView1.AllowUserToResizeColumns = false; + dataGridView1.AllowUserToResizeRows = false; + dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Dock = DockStyle.Fill; + dataGridView1.Location = new Point(0, 0); + dataGridView1.MultiSelect = false; + dataGridView1.Name = "dataGridView1"; + dataGridView1.ReadOnly = true; + dataGridView1.RowHeadersWidth = 51; + dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView1.Size = new Size(645, 450); + dataGridView1.TabIndex = 0; + // + // panel1 + // + panel1.Controls.Add(buttonAddTrip); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(645, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(155, 450); + panel1.TabIndex = 1; + // + // buttonAddTrip + // + buttonAddTrip.BackgroundImage = Properties.Resources.plus; + buttonAddTrip.BackgroundImageLayout = ImageLayout.Stretch; + buttonAddTrip.Location = new Point(34, 31); + buttonAddTrip.Name = "buttonAddTrip"; + buttonAddTrip.Size = new Size(94, 80); + buttonAddTrip.TabIndex = 5; + buttonAddTrip.UseVisualStyleBackColor = true; + buttonAddTrip.Click += ButtonAdd_Click; + // + // FormTrips + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView1); + Controls.Add(panel1); + Name = "FormTrips"; + StartPosition = FormStartPosition.CenterParent; + Text = "Туры"; + Load += FormTrips_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView1; + private Panel panel1; + private Button buttonAddTrip; + } +} \ No newline at end of file diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrips.cs b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrips.cs new file mode 100644 index 0000000..a50652e --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrips.cs @@ -0,0 +1,65 @@ +using ProjectTourismCompany.Repositories; +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 Unity; + +namespace ProjectTourismCompany.Forms; + +public partial class FormTrips : Form +{ + private readonly IUnityContainer _container; + private readonly ITripRepository _tripRepository; + + public FormTrips(IUnityContainer container, ITripRepository tripRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _tripRepository = tripRepository ?? + throw new + ArgumentNullException(nameof(tripRepository)); + } + + + private void FormTrips_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 LoadList() => dataGridView1.DataSource = + _tripRepository.ReadTrips(); + +} + diff --git a/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrips.resx b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrips.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Forms/FormTrips.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/ProjectTourismCompany/ProjectTourismCompany/Program.cs b/ProjectTourismCompany/ProjectTourismCompany/Program.cs index 332a19c..aeeef48 100644 --- a/ProjectTourismCompany/ProjectTourismCompany/Program.cs +++ b/ProjectTourismCompany/ProjectTourismCompany/Program.cs @@ -1,17 +1,30 @@ -namespace ProjectTourismCompany +using Unity.Lifetime; +using Unity; +using ProjectTourismCompany.Repositories; +using ProjectTourismCompany.Repositories.Implementations; +using ProjectTourismCompany; + +internal static class Program { - internal static class Program + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() { - /// - /// The main entry point for the application. - /// - [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()); - } + + ApplicationConfiguration.Initialize(); + Application.Run(CreateContainer().Resolve()); } -} \ No newline at end of file + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + + return container; + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/ProjectTourismCompany.csproj b/ProjectTourismCompany/ProjectTourismCompany/ProjectTourismCompany.csproj index 663fdb8..accbdf0 100644 --- a/ProjectTourismCompany/ProjectTourismCompany/ProjectTourismCompany.csproj +++ b/ProjectTourismCompany/ProjectTourismCompany/ProjectTourismCompany.csproj @@ -8,4 +8,23 @@ enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/ProjectTourismCompany/ProjectTourismCompany/Properties/DataSources/ProjectTourismCompany.Entities.Country.datasource b/ProjectTourismCompany/ProjectTourismCompany/Properties/DataSources/ProjectTourismCompany.Entities.Country.datasource new file mode 100644 index 0000000..b1aa628 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Properties/DataSources/ProjectTourismCompany.Entities.Country.datasource @@ -0,0 +1,10 @@ + + + + ProjectTourismCompany.Entities.Country, ProjectTourismCompany, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/ProjectTourismCompany/ProjectTourismCompany/Properties/Resources.Designer.cs b/ProjectTourismCompany/ProjectTourismCompany/Properties/Resources.Designer.cs new file mode 100644 index 0000000..5c40735 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectTourismCompany.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [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("ProjectTourismCompany.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap minus { + get { + object obj = ResourceManager.GetObject("minus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap pencil { + get { + object obj = ResourceManager.GetObject("pencil", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap plus { + get { + object obj = ResourceManager.GetObject("plus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Карта_мира { + get { + object obj = ResourceManager.GetObject("Карта мира", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Properties/Resources.resx b/ProjectTourismCompany/ProjectTourismCompany/Properties/Resources.resx new file mode 100644 index 0000000..9c7b01f --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/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\pencil.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\plus.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Карта мира.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\minus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ProjectTourismCompany/ProjectTourismCompany/Repositories/ICheckRepository.cs b/ProjectTourismCompany/ProjectTourismCompany/Repositories/ICheckRepository.cs new file mode 100644 index 0000000..957364f --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Repositories/ICheckRepository.cs @@ -0,0 +1,18 @@ +using ProjectTourismCompany.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Repositories; + +public interface ICheckRepository +{ + IEnumerable ReadChecks(DateTime? dateFrom = +null, DateTime? dateTo = null, +int? tripId = null, int? clientId = null); + Check ReadCheckById(int id); + void CreateCheck(Check check); + void DeleteCheck(int id); +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Repositories/IClientRepository.cs b/ProjectTourismCompany/ProjectTourismCompany/Repositories/IClientRepository.cs new file mode 100644 index 0000000..ce2b68c --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Repositories/IClientRepository.cs @@ -0,0 +1,17 @@ +using ProjectTourismCompany.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Repositories; + +public interface IClientRepository +{ + IEnumerable ReadClients(); + Client ReadClientById(int id); + void CreateClient(Client client); + void UpdateClient(Client client); + void DeleteClient(int id); +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Repositories/ICompanyRepository.cs b/ProjectTourismCompany/ProjectTourismCompany/Repositories/ICompanyRepository.cs new file mode 100644 index 0000000..a6b1bef --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Repositories/ICompanyRepository.cs @@ -0,0 +1,18 @@ +using ProjectTourismCompany.Entities; +using ProjectTourismCompany.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Repositories; + +public interface ICompanyRepository +{ + IEnumerable ReadCompanies(); + Company ReadCompanyById(int id); + void CreateCompany(Company company); + void UpdateCompany(Company company); + void DeleteCompany(int id); +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Repositories/ICountryRepository.cs b/ProjectTourismCompany/ProjectTourismCompany/Repositories/ICountryRepository.cs new file mode 100644 index 0000000..c269d32 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Repositories/ICountryRepository.cs @@ -0,0 +1,17 @@ +using ProjectTourismCompany.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Repositories; + +public interface ICountryRepository +{ + IEnumerable ReadCountries(); + Country ReadCountryById(int id); + void CreateCountry(Country country); + void UpdateCountry(Country country); + void DeleteCountry(int id); +} \ No newline at end of file diff --git a/ProjectTourismCompany/ProjectTourismCompany/Repositories/ITripRepository.cs b/ProjectTourismCompany/ProjectTourismCompany/Repositories/ITripRepository.cs new file mode 100644 index 0000000..74a1e73 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Repositories/ITripRepository.cs @@ -0,0 +1,21 @@ +using ProjectTourismCompany.Entities; +using ProjectTourismCompany.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Repositories; + +public interface ITripRepository +{ + IEnumerable ReadTrips(DateTime? dateForm = null, +DateTime? dateTo = null, int? tripId = null, +int? companyId = null, int? countryId = null); + + Trip ReadTripById(int id); + + void CreateTrip(Trip trip); +} + diff --git a/ProjectTourismCompany/ProjectTourismCompany/Repositories/Implementations/CheckRepository.cs b/ProjectTourismCompany/ProjectTourismCompany/Repositories/Implementations/CheckRepository.cs new file mode 100644 index 0000000..4d1dd34 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Repositories/Implementations/CheckRepository.cs @@ -0,0 +1,34 @@ +using Microsoft.VisualBasic.FileIO; +using ProjectTourismCompany.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Repositories.Implementations; + +internal class CheckRepository : ICheckRepository +{ + + + public void CreateCheck(Check check) + { + + } + + public void DeleteCheck(int id) + { + + } + + public IEnumerable ReadChecks(DateTime? dateFrom = null, DateTime? dateTo = null, int? tripId = null, int? clientId = null) + { + return []; + } + + public Check ReadCheckById(int id) + { + return Check.CreateCheck(0, "title", DateTime.Now, 500, 1, 2); + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Repositories/Implementations/ClientRepository.cs b/ProjectTourismCompany/ProjectTourismCompany/Repositories/Implementations/ClientRepository.cs new file mode 100644 index 0000000..086a418 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Repositories/Implementations/ClientRepository.cs @@ -0,0 +1,36 @@ +using ProjectTourismCompany.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Repositories.Implementations; + +internal class ClientRepository : IClientRepository +{ + public void CreateClient(Client client) + { + + } + + public void DeleteClient(int id) + { + + } + + public Client ReadClientById(int id) + { + return Client.CreateClient(0, string.Empty, DateTime.Now, ClientStatus.None, "1") ; + } + + public IEnumerable ReadClients() + { + return []; + } + + public void UpdateClient(Client client) + { + + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Repositories/Implementations/CompanyRepository.cs b/ProjectTourismCompany/ProjectTourismCompany/Repositories/Implementations/CompanyRepository.cs new file mode 100644 index 0000000..42e5d46 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Repositories/Implementations/CompanyRepository.cs @@ -0,0 +1,36 @@ +using ProjectTourismCompany.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Repositories.Implementations; + +internal class CompanyRepository : ICompanyRepository +{ + public void CreateCompany(Company company) + { + + } + + public void DeleteCompany(int id) + { + + } + + public IEnumerable ReadCompanies() + { + return []; + } + + public Company ReadCompanyById(int id) + { + return Company.CreateCompany(1, "randomName", 73); + } + + public void UpdateCompany(Company company) + { + + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Repositories/Implementations/CountryRepository.cs b/ProjectTourismCompany/ProjectTourismCompany/Repositories/Implementations/CountryRepository.cs new file mode 100644 index 0000000..bfc7d47 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Repositories/Implementations/CountryRepository.cs @@ -0,0 +1,36 @@ +using ProjectTourismCompany.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Repositories.Implementations; + +internal class CountryRepository : ICountryRepository +{ + public void CreateCountry(Country country) + { + + } + + public void DeleteCountry(int id) + { + + } + + public IEnumerable ReadCountries() + { + return []; + } + + public Country ReadCountryById(int id) + { + return Country.CreateCountry(73, "Russia"); + } + + public void UpdateCountry(Country country) + { + + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Repositories/Implementations/TripRepository.cs b/ProjectTourismCompany/ProjectTourismCompany/Repositories/Implementations/TripRepository.cs new file mode 100644 index 0000000..af0cfd4 --- /dev/null +++ b/ProjectTourismCompany/ProjectTourismCompany/Repositories/Implementations/TripRepository.cs @@ -0,0 +1,26 @@ +using ProjectTourismCompany.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourismCompany.Repositories.Implementations; + +internal class TripRepository : ITripRepository +{ + public void CreateTrip(Trip trip) + { + + } + + public Trip ReadTripById(int id) + { + return Trip.CreateOpeartion(0, "a", 0, 0, DateTime.Now, DateTime.Now, "Moscow", "Piter", Entities.Enums.TravelType.None, []); + } + + public IEnumerable ReadTrips(DateTime? dateForm = null, DateTime? dateTo = null, int? tripId = null, int? companyId = null, int? countryId = null) + { + return []; + } +} diff --git a/ProjectTourismCompany/ProjectTourismCompany/Resources/minus.png b/ProjectTourismCompany/ProjectTourismCompany/Resources/minus.png new file mode 100644 index 0000000..6d2738c Binary files /dev/null and b/ProjectTourismCompany/ProjectTourismCompany/Resources/minus.png differ diff --git a/ProjectTourismCompany/ProjectTourismCompany/Resources/pencil.jpg b/ProjectTourismCompany/ProjectTourismCompany/Resources/pencil.jpg new file mode 100644 index 0000000..72caf93 Binary files /dev/null and b/ProjectTourismCompany/ProjectTourismCompany/Resources/pencil.jpg differ diff --git a/ProjectTourismCompany/ProjectTourismCompany/Resources/plus.jpg b/ProjectTourismCompany/ProjectTourismCompany/Resources/plus.jpg new file mode 100644 index 0000000..a8c3671 Binary files /dev/null and b/ProjectTourismCompany/ProjectTourismCompany/Resources/plus.jpg differ diff --git a/ProjectTourismCompany/ProjectTourismCompany/Resources/Карта мира.jpg b/ProjectTourismCompany/ProjectTourismCompany/Resources/Карта мира.jpg new file mode 100644 index 0000000..9986cea Binary files /dev/null and b/ProjectTourismCompany/ProjectTourismCompany/Resources/Карта мира.jpg differ