diff --git a/project/ProjectTourAgency/Enities/AddMoney.cs b/project/ProjectTourAgency/Enities/AddMoney.cs new file mode 100644 index 0000000..3865dfe --- /dev/null +++ b/project/ProjectTourAgency/Enities/AddMoney.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Enities +{ + public class AddMoney + { + public int Id { get; private set; } + public int ClientId { get; private set; } + public DateTime Date { get; private set; } + public int MoneyAmount{ get; private set; } + + public static AddMoney CreateEntity(int id,int cId, + DateTime date, int money) + { + return new AddMoney + { + Id = id, + ClientId = cId, + Date = date, + MoneyAmount = money + }; + } + } +} diff --git a/project/ProjectTourAgency/Enities/Client.cs b/project/ProjectTourAgency/Enities/Client.cs new file mode 100644 index 0000000..52609a6 --- /dev/null +++ b/project/ProjectTourAgency/Enities/Client.cs @@ -0,0 +1,33 @@ +using ProjectTourAgency.Enities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Enities; + +public class Client +{ + public int Id { get;private set; } + public string FullName { get; private set; } = string.Empty; + public DateTime BirthDate { get; private set; } + public string PhoneNumber { get; private set; } = string.Empty; + public ClientStatus ClientStatus { get; private set; } + public int Money { get; private set; } + + public static Client CreateEntity(int id, string fullName, + DateTime birthDate, string phoneNumber, int money, ClientStatus cs) + { + return new Client + { + Id = id, + ClientStatus = cs, + FullName = fullName, + BirthDate = birthDate, + PhoneNumber = phoneNumber, + Money = money + }; + } + +} diff --git a/project/ProjectTourAgency/Enities/ClientTour.cs b/project/ProjectTourAgency/Enities/ClientTour.cs new file mode 100644 index 0000000..a05bd98 --- /dev/null +++ b/project/ProjectTourAgency/Enities/ClientTour.cs @@ -0,0 +1,29 @@ +using ProjectTourAgency.Enities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Enities; + +public class ClientTour +{ + public int Id { get; private set; } + public int ClientId { get; private set; } + public int TourId { get; private set; } + + public int Cost { get; private set; } + + public static ClientTour CreateEntity(int id,int clientId, int tourId, int cost) + { + return new ClientTour + { + Id = id, + ClientId = clientId, + TourId = tourId, + Cost = cost + }; + } + +} diff --git a/project/ProjectTourAgency/Enities/Employee.cs b/project/ProjectTourAgency/Enities/Employee.cs new file mode 100644 index 0000000..1ee2ff2 --- /dev/null +++ b/project/ProjectTourAgency/Enities/Employee.cs @@ -0,0 +1,28 @@ +using ProjectTourAgency.Enities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Enities; + +public class Employee +{ + public int Id { get; private set; } + public string FullName { get; private set; } = string.Empty; + + public EmpoyeeJob EmployeeJob { get; private set; } + + public static Employee CreateEntity(int id, string fullName, + EmpoyeeJob job) + { + return new Employee + { + Id = id, + FullName = fullName, + EmployeeJob = job + + }; + } +} diff --git a/project/ProjectTourAgency/Enities/Enums/ClientStatus.cs b/project/ProjectTourAgency/Enities/Enums/ClientStatus.cs new file mode 100644 index 0000000..57e0ea5 --- /dev/null +++ b/project/ProjectTourAgency/Enities/Enums/ClientStatus.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Enities.Enums; + +[Flags] +public enum ClientStatus +{ + None = 0, + RegularCustomer = 1, + AgressiveCustomer = 2, + FriendlyCustomer = 3, + VIPCustomer = 4 + +} diff --git a/project/ProjectTourAgency/Enities/Enums/EmpoyeeJob.cs b/project/ProjectTourAgency/Enities/Enums/EmpoyeeJob.cs new file mode 100644 index 0000000..c67d5eb --- /dev/null +++ b/project/ProjectTourAgency/Enities/Enums/EmpoyeeJob.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.Tracing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Enities.Enums; + +public enum EmpoyeeJob +{ + None = 0, + Driver = 1, + Archeologist = 2, + ETC = 3 +} diff --git a/project/ProjectTourAgency/Enities/Route.cs b/project/ProjectTourAgency/Enities/Route.cs new file mode 100644 index 0000000..09e80b9 --- /dev/null +++ b/project/ProjectTourAgency/Enities/Route.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Enities; + +public class Route +{ + public int Id { get; private set; } + public string Destination { get; private set; } = string.Empty; + public string Departure { get; private set; } = string.Empty; + public int Duration { get; private set; } + public static Route CreateEntity(int id, string destination, + string departure, int duration) + { + return new Route + { + Id = id, + Destination = destination, + Departure = departure, + Duration = duration + }; + } + +} diff --git a/project/ProjectTourAgency/Enities/Tour.cs b/project/ProjectTourAgency/Enities/Tour.cs new file mode 100644 index 0000000..03f1cc9 --- /dev/null +++ b/project/ProjectTourAgency/Enities/Tour.cs @@ -0,0 +1,29 @@ +using ProjectTourAgency.Enities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Enities; + +public class Tour +{ + public int Id { get; private set; } + public int EmployeeId { get; private set; } + public int RouteId { get; private set; } + public DateTime DepartureDate { get; private set; } + public IEnumerable ClientTours { get; private set; } = []; + public static Tour CreateEntity(int id, int employeeId, int routeId, + DateTime date,IEnumerable clientTours) + { + return new Tour + { + Id = id, + EmployeeId = employeeId, + RouteId = routeId, + DepartureDate = date, + ClientTours = clientTours + }; + } +} diff --git a/project/ProjectTourAgency/Form1.Designer.cs b/project/ProjectTourAgency/Form1.Designer.cs deleted file mode 100644 index b03c90e..0000000 --- a/project/ProjectTourAgency/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ProjectTourAgency -{ - 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/project/ProjectTourAgency/Form1.cs b/project/ProjectTourAgency/Form1.cs deleted file mode 100644 index 5a07bcd..0000000 --- a/project/ProjectTourAgency/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ProjectTourAgency -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/project/ProjectTourAgency/FormTourAgency.Designer.cs b/project/ProjectTourAgency/FormTourAgency.Designer.cs new file mode 100644 index 0000000..5c20f90 --- /dev/null +++ b/project/ProjectTourAgency/FormTourAgency.Designer.cs @@ -0,0 +1,138 @@ +namespace ProjectTourAgency +{ + partial class FormTourAgency + { + /// + /// 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(); + MenuToolStripMenuItem = new ToolStripMenuItem(); + ClientsToolStripMenuItem = new ToolStripMenuItem(); + RotesToolStripMenuItem = new ToolStripMenuItem(); + EmployeesToolStripMenuItem = new ToolStripMenuItem(); + OperationsToolStripMenuItem = new ToolStripMenuItem(); + пополнитьБалансПользователяToolStripMenuItem = new ToolStripMenuItem(); + турToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + menuStrip1.SuspendLayout(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.Items.AddRange(new ToolStripItem[] { MenuToolStripMenuItem, OperationsToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(784, 24); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; + // + // MenuToolStripMenuItem + // + MenuToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ClientsToolStripMenuItem, RotesToolStripMenuItem, EmployeesToolStripMenuItem }); + MenuToolStripMenuItem.Name = "MenuToolStripMenuItem"; + MenuToolStripMenuItem.Size = new Size(94, 20); + MenuToolStripMenuItem.Text = "Справочники"; + // + // ClientsToolStripMenuItem + // + ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem"; + ClientsToolStripMenuItem.Size = new Size(140, 22); + ClientsToolStripMenuItem.Text = "Клиенты"; + ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click; + // + // RotesToolStripMenuItem + // + RotesToolStripMenuItem.Name = "RotesToolStripMenuItem"; + RotesToolStripMenuItem.Size = new Size(140, 22); + RotesToolStripMenuItem.Text = "маршруты"; + RotesToolStripMenuItem.Click += RotesToolStripMenuItem_Click; + // + // EmployeesToolStripMenuItem + // + EmployeesToolStripMenuItem.Name = "EmployeesToolStripMenuItem"; + EmployeesToolStripMenuItem.Size = new Size(140, 22); + EmployeesToolStripMenuItem.Text = "Сотрудники"; + EmployeesToolStripMenuItem.Click += EmployeesToolStripMenuItem_Click; + // + // OperationsToolStripMenuItem + // + OperationsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { пополнитьБалансПользователяToolStripMenuItem, турToolStripMenuItem }); + OperationsToolStripMenuItem.Name = "OperationsToolStripMenuItem"; + OperationsToolStripMenuItem.Size = new Size(75, 20); + OperationsToolStripMenuItem.Text = "Операции"; + // + // пополнитьБалансПользователяToolStripMenuItem + // + пополнитьБалансПользователяToolStripMenuItem.Name = "пополнитьБалансПользователяToolStripMenuItem"; + пополнитьБалансПользователяToolStripMenuItem.Size = new Size(256, 22); + пополнитьБалансПользователяToolStripMenuItem.Text = "Пополнить баланс пользователя"; + пополнитьБалансПользователяToolStripMenuItem.Click += AddMoneyToolStripMenuItem_Click; + // + // турToolStripMenuItem + // + турToolStripMenuItem.Name = "турToolStripMenuItem"; + турToolStripMenuItem.Size = new Size(256, 22); + турToolStripMenuItem.Text = "Тур"; + турToolStripMenuItem.Click += ToursToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 20); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // FormTourAgency + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.Снимок_экрана_2024_11_08_2139261; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(784, 411); + Controls.Add(menuStrip1); + DoubleBuffered = true; + MainMenuStrip = menuStrip1; + Name = "FormTourAgency"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Тур Агенство"; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem MenuToolStripMenuItem; + private ToolStripMenuItem OperationsToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem ClientsToolStripMenuItem; + private ToolStripMenuItem RotesToolStripMenuItem; + private ToolStripMenuItem EmployeesToolStripMenuItem; + private ToolStripMenuItem пополнитьБалансПользователяToolStripMenuItem; + private ToolStripMenuItem турToolStripMenuItem; + } +} diff --git a/project/ProjectTourAgency/FormTourAgency.cs b/project/ProjectTourAgency/FormTourAgency.cs new file mode 100644 index 0000000..aca7679 --- /dev/null +++ b/project/ProjectTourAgency/FormTourAgency.cs @@ -0,0 +1,76 @@ +using ProjectTourAgency.Forms; +using Unity; + +namespace ProjectTourAgency; + +public partial class FormTourAgency : Form +{ + private readonly IUnityContainer _container; + public FormTourAgency(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + } + + private void ClientsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + private void RotesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void EmployeesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void AddMoneyToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ToursToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } +} diff --git a/project/ProjectTourAgency/FormTourAgency.resx b/project/ProjectTourAgency/FormTourAgency.resx new file mode 100644 index 0000000..a0623c8 --- /dev/null +++ b/project/ProjectTourAgency/FormTourAgency.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/project/ProjectTourAgency/Form1.resx b/project/ProjectTourAgency/Forms/.resx similarity index 93% rename from project/ProjectTourAgency/Form1.resx rename to project/ProjectTourAgency/Forms/.resx index 1af7de1..af32865 100644 --- a/project/ProjectTourAgency/Form1.resx +++ b/project/ProjectTourAgency/Forms/.resx @@ -1,17 +1,17 @@  - diff --git a/project/ProjectTourAgency/Forms/FormAddMoney.Designer.cs b/project/ProjectTourAgency/Forms/FormAddMoney.Designer.cs new file mode 100644 index 0000000..59af847 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormAddMoney.Designer.cs @@ -0,0 +1,118 @@ +namespace ProjectTourAgency.Forms +{ + partial class FormAddMoney + { + /// + /// 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() + { + labelClient = new Label(); + labelMoney = new Label(); + comboBoxClientId = new ComboBox(); + textBoxMoney = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelClient + // + labelClient.AutoSize = true; + labelClient.Location = new Point(32, 28); + labelClient.Name = "labelClient"; + labelClient.Size = new Size(66, 15); + labelClient.TabIndex = 0; + labelClient.Text = "ID Клиента"; + // + // labelMoney + // + labelMoney.AutoSize = true; + labelMoney.Location = new Point(32, 79); + labelMoney.Name = "labelMoney"; + labelMoney.Size = new Size(173, 15); + labelMoney.TabIndex = 1; + labelMoney.Text = "на сколько пополнить баланс"; + // + // comboBoxClientId + // + comboBoxClientId.FormattingEnabled = true; + comboBoxClientId.Location = new Point(231, 28); + comboBoxClientId.Name = "comboBoxClientId"; + comboBoxClientId.Size = new Size(121, 23); + comboBoxClientId.TabIndex = 2; + // + // textBoxMoney + // + textBoxMoney.Location = new Point(231, 71); + textBoxMoney.Name = "textBoxMoney"; + textBoxMoney.Size = new Size(126, 23); + textBoxMoney.TabIndex = 3; + // + // buttonSave + // + buttonSave.Location = new Point(32, 128); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 4; + buttonSave.Text = "Пополнить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(242, 128); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(89, 26); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмнить"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormAddMoney + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(386, 184); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxMoney); + Controls.Add(comboBoxClientId); + Controls.Add(labelMoney); + Controls.Add(labelClient); + Name = "FormAddMoney"; + Text = "FormAddMoney"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelClient; + private Label labelMoney; + private ComboBox comboBoxClientId; + private TextBox textBoxMoney; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/project/ProjectTourAgency/Forms/FormAddMoney.cs b/project/ProjectTourAgency/Forms/FormAddMoney.cs new file mode 100644 index 0000000..4bd4d43 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormAddMoney.cs @@ -0,0 +1,49 @@ +using ProjectTourAgency.Enities; +using ProjectTourAgency.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 ProjectTourAgency.Forms +{ + public partial class FormAddMoney : Form + { + private readonly IAddMoneyRepository _addMoneyRepository; + public FormAddMoney(IAddMoneyRepository addMoneyRepository, IClientRepository clientRepository) + { + InitializeComponent(); + _addMoneyRepository = addMoneyRepository ?? + throw new ArgumentNullException(nameof(addMoneyRepository)); + comboBoxClientId.DataSource = clientRepository.ReadClients(); + comboBoxClientId.DisplayMember = "Name"; + comboBoxClientId.ValueMember = "Id"; + + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxClientId.SelectedIndex < 0 || String.IsNullOrWhiteSpace(textBoxMoney.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + _addMoneyRepository.CreateAddMoney(AddMoney.CreateEntity(0, (int)comboBoxClientId.SelectedValue!, DateTime.Now, Convert.ToInt32(textBoxMoney.Text))); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + } +} diff --git a/project/ProjectTourAgency/Forms/FormAddMoney.resx b/project/ProjectTourAgency/Forms/FormAddMoney.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormAddMoney.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/project/ProjectTourAgency/Forms/FormAddMoneys.Designer.cs b/project/ProjectTourAgency/Forms/FormAddMoneys.Designer.cs new file mode 100644 index 0000000..b69a94a --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormAddMoneys.Designer.cs @@ -0,0 +1,97 @@ +namespace ProjectTourAgency.Forms +{ + partial class FormAddMoneys + { + /// + /// 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() + { + dataGridViewData = new DataGridView(); + panel1 = new Panel(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(699, 362); + dataGridViewData.TabIndex = 3; + // + // panel1 + // + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(699, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(149, 362); + panel1.TabIndex = 2; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.free_icon_add_button_5974633; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(43, 25); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(61, 59); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // FormAddMoneys + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(848, 362); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormAddMoneys"; + Text = "FormAddMoneys"; + Load += FormAddMoneys_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel1; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/project/ProjectTourAgency/Forms/FormAddMoneys.cs b/project/ProjectTourAgency/Forms/FormAddMoneys.cs new file mode 100644 index 0000000..8b9ae68 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormAddMoneys.cs @@ -0,0 +1,68 @@ +using ProjectTourAgency.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 ProjectTourAgency.Forms +{ + public partial class FormAddMoneys : Form + { + private readonly IUnityContainer _container; + + private readonly IAddMoneyRepository _addMoneyRepository; + + public FormAddMoneys(IAddMoneyRepository addMoneyRepository, IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _addMoneyRepository = addMoneyRepository ?? throw new ArgumentNullException(nameof(_addMoneyRepository)); + } + + private void FormAddMoneys_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() => dataGridViewData.DataSource = _addMoneyRepository.ReadAddMoneys(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["ID"].Value); + return true; + } + } +} diff --git a/project/ProjectTourAgency/Forms/FormAddMoneys.resx b/project/ProjectTourAgency/Forms/FormAddMoneys.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormAddMoneys.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/project/ProjectTourAgency/Forms/FormClient.Designer.cs b/project/ProjectTourAgency/Forms/FormClient.Designer.cs new file mode 100644 index 0000000..98e0391 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormClient.Designer.cs @@ -0,0 +1,196 @@ +namespace ProjectTourAgency.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() + { + labelName = new Label(); + labelDate = new Label(); + labelNumber = new Label(); + labelMoney = new Label(); + textBoxName = new TextBox(); + dateTimePickerDate = new DateTimePicker(); + textBoxNumber = new TextBox(); + textBoxMoney = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + checkedListBoxClientStatus = new CheckedListBox(); + labelClientStatus = new Label(); + SuspendLayout(); + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(17, 15); + labelName.Margin = new Padding(4, 0, 4, 0); + labelName.Name = "labelName"; + labelName.Size = new Size(112, 25); + labelName.TabIndex = 0; + labelName.Text = "Полное имя"; + // + // labelDate + // + labelDate.AutoSize = true; + labelDate.Location = new Point(17, 75); + labelDate.Margin = new Padding(4, 0, 4, 0); + labelDate.Name = "labelDate"; + labelDate.Size = new Size(137, 25); + labelDate.TabIndex = 1; + labelDate.Text = "Дата рождения"; + // + // labelNumber + // + labelNumber.AutoSize = true; + labelNumber.Location = new Point(17, 147); + labelNumber.Margin = new Padding(4, 0, 4, 0); + labelNumber.Name = "labelNumber"; + labelNumber.Size = new Size(150, 25); + labelNumber.TabIndex = 2; + labelNumber.Text = "Номер телефона"; + // + // labelMoney + // + labelMoney.AutoSize = true; + labelMoney.Location = new Point(17, 213); + labelMoney.Margin = new Padding(4, 0, 4, 0); + labelMoney.Name = "labelMoney"; + labelMoney.Size = new Size(67, 25); + labelMoney.TabIndex = 3; + labelMoney.Text = "Баланс"; + // + // textBoxName + // + textBoxName.Location = new Point(187, 15); + textBoxName.Margin = new Padding(4, 5, 4, 5); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(141, 31); + textBoxName.TabIndex = 4; + // + // dateTimePickerDate + // + dateTimePickerDate.Location = new Point(187, 75); + dateTimePickerDate.Margin = new Padding(4, 5, 4, 5); + dateTimePickerDate.Name = "dateTimePickerDate"; + dateTimePickerDate.Size = new Size(284, 31); + dateTimePickerDate.TabIndex = 5; + // + // textBoxNumber + // + textBoxNumber.Location = new Point(187, 142); + textBoxNumber.Margin = new Padding(4, 5, 4, 5); + textBoxNumber.Name = "textBoxNumber"; + textBoxNumber.Size = new Size(141, 31); + textBoxNumber.TabIndex = 6; + // + // textBoxMoney + // + textBoxMoney.Location = new Point(187, 208); + textBoxMoney.Margin = new Padding(4, 5, 4, 5); + textBoxMoney.Name = "textBoxMoney"; + textBoxMoney.Size = new Size(141, 31); + textBoxMoney.TabIndex = 7; + // + // buttonSave + // + buttonSave.Location = new Point(69, 378); + buttonSave.Margin = new Padding(4, 5, 4, 5); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(107, 38); + buttonSave.TabIndex = 8; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(364, 378); + buttonCancel.Margin = new Padding(4, 5, 4, 5); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(107, 38); + buttonCancel.TabIndex = 9; + buttonCancel.Text = "Отменить"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // checkedListBoxClientStatus + // + checkedListBoxClientStatus.FormattingEnabled = true; + checkedListBoxClientStatus.Location = new Point(187, 247); + checkedListBoxClientStatus.Name = "checkedListBoxClientStatus"; + checkedListBoxClientStatus.Size = new Size(284, 116); + checkedListBoxClientStatus.TabIndex = 10; + // + // labelClientStatus + // + labelClientStatus.AutoSize = true; + labelClientStatus.Location = new Point(17, 270); + labelClientStatus.Margin = new Padding(4, 0, 4, 0); + labelClientStatus.Name = "labelClientStatus"; + labelClientStatus.Size = new Size(67, 25); + labelClientStatus.TabIndex = 11; + labelClientStatus.Text = "Баланс"; + // + // FormClient + // + AutoScaleDimensions = new SizeF(10F, 25F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(556, 430); + Controls.Add(labelClientStatus); + Controls.Add(checkedListBoxClientStatus); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxMoney); + Controls.Add(textBoxNumber); + Controls.Add(dateTimePickerDate); + Controls.Add(textBoxName); + Controls.Add(labelMoney); + Controls.Add(labelNumber); + Controls.Add(labelDate); + Controls.Add(labelName); + Margin = new Padding(4, 5, 4, 5); + Name = "FormClient"; + Text = "FormClient"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelName; + private Label labelDate; + private Label labelNumber; + private Label labelMoney; + private TextBox textBoxName; + private DateTimePicker dateTimePickerDate; + private TextBox textBoxNumber; + private TextBox textBoxMoney; + private Button buttonSave; + private Button buttonCancel; + private CheckedListBox checkedListBoxClientStatus; + private Label labelClientStatus; + } +} \ No newline at end of file diff --git a/project/ProjectTourAgency/Forms/FormClient.cs b/project/ProjectTourAgency/Forms/FormClient.cs new file mode 100644 index 0000000..b0e3949 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormClient.cs @@ -0,0 +1,116 @@ + +using Microsoft.VisualBasic.FileIO; +using ProjectRouteAgency.Repositories; +using ProjectTourAgency.Enities; +using ProjectTourAgency.Enities.Enums; +using ProjectTourAgency.Implementations; +using ProjectTourAgency.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 ProjectTourAgency.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 InvalidOperationException(nameof(client)); + } + textBoxName.Text = client.FullName; + textBoxNumber.Text = client.PhoneNumber; + textBoxMoney.Text = client.Money.ToString(); + dateTimePickerDate.Value = client.BirthDate; + foreach (ClientStatus elem in +Enum.GetValues(typeof(ClientStatus))) + { + if ((elem & client.ClientStatus) != 0) + { + checkedListBoxClientStatus.SetItemChecked(checkedListBoxClientStatus.Items.IndexOf( + elem), true); + } + } + + _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)); + foreach (var elem in Enum.GetValues(typeof(ClientStatus))) + { + checkedListBoxClientStatus.Items.Add(elem); + } + + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text) || + string.IsNullOrWhiteSpace(textBoxNumber.Text) + || string.IsNullOrWhiteSpace(textBoxMoney.Text) || string.IsNullOrWhiteSpace(dateTimePickerDate.Text) + || checkedListBoxClientStatus.CheckedItems.Count == 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_clientId.HasValue) + { + _clientRepository.UpdateClient(CreateClient(_clientId.Value)); + } + else + { + _clientRepository.CreateClient(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) + { + ClientStatus clientStatus = ClientStatus.None; + foreach (var elem in checkedListBoxClientStatus.CheckedItems) + { + clientStatus |= (ClientStatus)elem; + } + return Client.CreateEntity(id, textBoxName.Text, dateTimePickerDate.Value, textBoxNumber.Text, + int.Parse(textBoxMoney.Text), clientStatus); + + + } + } +} diff --git a/project/ProjectTourAgency/Forms/FormClient.resx b/project/ProjectTourAgency/Forms/FormClient.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/project/ProjectTourAgency/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/project/ProjectTourAgency/Forms/FormClientTour.Designer.cs b/project/ProjectTourAgency/Forms/FormClientTour.Designer.cs new file mode 100644 index 0000000..d3194d5 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormClientTour.Designer.cs @@ -0,0 +1,191 @@ +namespace ProjectTourAgency.Forms +{ + partial class FormClientTour + { + /// + /// 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() + { + labelEmployeeName = new Label(); + labelDate = new Label(); + groupBoxTour = new GroupBox(); + dataGridView = new DataGridView(); + ColumnClient = new DataGridViewComboBoxColumn(); + ColumnCost = new DataGridViewTextBoxColumn(); + labelRoute = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + comboBoxEmployeeId = new ComboBox(); + comboBoxRouteId = new ComboBox(); + dateTimePicker = new DateTimePicker(); + groupBoxTour.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // labelEmployeeName + // + labelEmployeeName.AutoSize = true; + labelEmployeeName.Location = new Point(12, 19); + labelEmployeeName.Name = "labelEmployeeName"; + labelEmployeeName.Size = new Size(59, 15); + labelEmployeeName.TabIndex = 0; + labelEmployeeName.Text = "Работник"; + // + // labelDate + // + labelDate.AutoSize = true; + labelDate.Location = new Point(12, 95); + labelDate.Name = "labelDate"; + labelDate.Size = new Size(127, 15); + labelDate.TabIndex = 1; + labelDate.Text = "Дата проведения тура"; + // + // groupBoxTour + // + groupBoxTour.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBoxTour.Controls.Add(dataGridView); + groupBoxTour.Location = new Point(18, 123); + groupBoxTour.Name = "groupBoxTour"; + groupBoxTour.Size = new Size(360, 248); + groupBoxTour.TabIndex = 2; + groupBoxTour.TabStop = false; + groupBoxTour.Text = "Клиенты"; + // + // dataGridView + // + dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnClient, ColumnCost }); + dataGridView.Location = new Point(6, 22); + dataGridView.Name = "dataGridView"; + dataGridView.Size = new Size(348, 220); + dataGridView.TabIndex = 0; + dataGridView.CellContentClick += dataGridView_CellContentClick; + // + // ColumnClient + // + ColumnClient.HeaderText = "Клиент"; + ColumnClient.Name = "ColumnClient"; + ColumnClient.Resizable = DataGridViewTriState.True; + ColumnClient.SortMode = DataGridViewColumnSortMode.Automatic; + // + // ColumnCost + // + ColumnCost.HeaderText = "Цена"; + ColumnCost.Name = "ColumnCost"; + // + // labelRoute + // + labelRoute.AutoSize = true; + labelRoute.Location = new Point(12, 61); + labelRoute.Name = "labelRoute"; + labelRoute.Size = new Size(60, 15); + labelRoute.TabIndex = 3; + labelRoute.Text = "Маршрут"; + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonSave.Location = new Point(29, 400); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(110, 25); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(249, 400); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(110, 25); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // comboBoxEmployeeId + // + comboBoxEmployeeId.FormattingEnabled = true; + comboBoxEmployeeId.Location = new Point(145, 16); + comboBoxEmployeeId.Name = "comboBoxEmployeeId"; + comboBoxEmployeeId.Size = new Size(186, 23); + comboBoxEmployeeId.TabIndex = 6; + // + // comboBoxRouteId + // + comboBoxRouteId.FormattingEnabled = true; + comboBoxRouteId.Location = new Point(145, 58); + comboBoxRouteId.Name = "comboBoxRouteId"; + comboBoxRouteId.Size = new Size(186, 23); + comboBoxRouteId.TabIndex = 7; + // + // dateTimePicker + // + dateTimePicker.Location = new Point(145, 89); + dateTimePicker.Name = "dateTimePicker"; + dateTimePicker.Size = new Size(186, 23); + dateTimePicker.TabIndex = 8; + // + // FormClientTour + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(406, 456); + Controls.Add(dateTimePicker); + Controls.Add(comboBoxRouteId); + Controls.Add(comboBoxEmployeeId); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(labelRoute); + Controls.Add(groupBoxTour); + Controls.Add(labelDate); + Controls.Add(labelEmployeeName); + Name = "FormClientTour"; + Text = "FormClientTour"; + groupBoxTour.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelEmployeeName; + private Label labelDate; + private GroupBox groupBoxTour; + private DataGridView dataGridView; + private DataGridViewComboBoxColumn ColumnClient; + private DataGridViewTextBoxColumn ColumnCost; + private Label labelRoute; + private Button buttonSave; + private Button buttonCancel; + private ComboBox comboBoxEmployeeId; + private ComboBox comboBoxRouteId; + private DateTimePicker dateTimePicker; + } +} \ No newline at end of file diff --git a/project/ProjectTourAgency/Forms/FormClientTour.cs b/project/ProjectTourAgency/Forms/FormClientTour.cs new file mode 100644 index 0000000..76552b8 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormClientTour.cs @@ -0,0 +1,83 @@ +using ProjectEmployeeAgency.Repositories; +using ProjectRouteAgency.Repositories; +using ProjectTourAgency.Enities; +using ProjectTourAgency.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 ProjectTourAgency.Forms +{ + public partial class FormClientTour : Form + { + private readonly ITourRepository _tourRepository; + public FormClientTour(ITourRepository tourRepository, + IEmployeeRepository employeeRepository, + IRouteRepository routeRepository, IClientRepository clientRepository) + { + InitializeComponent(); + _tourRepository = tourRepository ?? + throw new ArgumentNullException(nameof(tourRepository)); + comboBoxEmployeeId.DataSource = employeeRepository.ReadEmployees(); + comboBoxEmployeeId.DisplayMember = "FullName"; + comboBoxEmployeeId.ValueMember = "Id"; + + comboBoxRouteId.DataSource = routeRepository.ReadRoutes(); + comboBoxRouteId.DisplayMember = "Destination"; + comboBoxRouteId.ValueMember = "Id"; + + ColumnClient.DataSource = clientRepository.ReadClients(); + ColumnClient.DisplayMember = "FullName"; + ColumnClient.ValueMember = "Id"; + } + + private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (dataGridView.RowCount < 1 + || comboBoxEmployeeId.SelectedIndex < 0 + || comboBoxRouteId.SelectedIndex < 0) + { + throw new Exception("Есть незаполненные поля"); + } + _tourRepository.CreateTour(Tour.CreateEntity(0, comboBoxEmployeeId.SelectedIndex, + comboBoxRouteId.SelectedIndex, dateTimePicker.Value,CreateListClientTourFromDataGrid())); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + private List CreateListClientTourFromDataGrid() + { + var list = new List(); + foreach(DataGridViewRow row in dataGridView.Rows) + { + if (row.Cells["ColumnClient"].Value == null + || row.Cells["ColumnCost"].Value == null) + { + continue; + } + list.Add(ClientTour.CreateEntity(0, Convert.ToInt32(row.Cells["ColumnClient"].Value), 0, + Convert.ToInt32(row.Cells["ColumnCost"].Value))); + } + return list; + } + + } +} diff --git a/project/ProjectTourAgency/Forms/FormClientTour.resx b/project/ProjectTourAgency/Forms/FormClientTour.resx new file mode 100644 index 0000000..bb2c7f8 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormClientTour.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/project/ProjectTourAgency/Forms/FormClients.Designer.cs b/project/ProjectTourAgency/Forms/FormClients.Designer.cs new file mode 100644 index 0000000..f9bfecd --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormClients.Designer.cs @@ -0,0 +1,126 @@ +namespace ProjectTourAgency.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(); + buttonDelete = new Button(); + buttonUpdate = new Button(); + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDelete); + panel1.Controls.Add(buttonUpdate); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(775, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(149, 371); + panel1.TabIndex = 0; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.free_icon_delete_3807871; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(43, 276); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(61, 59); + buttonDelete.TabIndex = 3; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += buttonDelete_Click; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources.free_icon_edit_8679935; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(43, 142); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(61, 59); + buttonUpdate.TabIndex = 2; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += buttonUpdate_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.free_icon_add_button_5974633; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(43, 25); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(61, 59); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(775, 371); + dataGridViewData.TabIndex = 1; + // + // FormClients + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(924, 371); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormClients"; + StartPosition = FormStartPosition.CenterParent; + Text = "Клиенты"; + Load += FormClients_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonDelete; + private Button buttonUpdate; + private Button buttonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/project/ProjectTourAgency/Forms/FormClients.cs b/project/ProjectTourAgency/Forms/FormClients.cs new file mode 100644 index 0000000..dd15c95 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormClients.cs @@ -0,0 +1,111 @@ +using ProjectTourAgency.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 ProjectTourAgency.Forms +{ + public partial class FormClients : Form + { + private readonly IUnityContainer _container; + + private readonly IClientRepository _clientRepository; + + public FormClients(IClientRepository clientRepository, IUnityContainer container) + { + 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 buttonUpdate_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 buttonDelete_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() => dataGridViewData.DataSource = _clientRepository.ReadClients(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + + if(dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["ID"].Value); + return true; + } + } +} diff --git a/project/ProjectTourAgency/Forms/FormClients.resx b/project/ProjectTourAgency/Forms/FormClients.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/project/ProjectTourAgency/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/project/ProjectTourAgency/Forms/FormEmployee.Designer.cs b/project/ProjectTourAgency/Forms/FormEmployee.Designer.cs new file mode 100644 index 0000000..3014ad7 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormEmployee.Designer.cs @@ -0,0 +1,118 @@ +namespace ProjectTourAgency.Forms +{ + partial class FormEmployee + { + /// + /// 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() + { + comboBoxJob = new ComboBox(); + label1 = new Label(); + label2 = new Label(); + textBoxName = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // comboBoxJob + // + comboBoxJob.FormattingEnabled = true; + comboBoxJob.Location = new Point(130, 75); + comboBoxJob.Name = "comboBoxJob"; + comboBoxJob.Size = new Size(121, 23); + comboBoxJob.TabIndex = 0; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 75); + label1.Name = "label1"; + label1.Size = new Size(69, 15); + label1.TabIndex = 1; + label1.Text = "Должность"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(12, 31); + label2.Name = "label2"; + label2.Size = new Size(31, 15); + label2.TabIndex = 2; + label2.Text = "Имя"; + // + // textBoxName + // + textBoxName.Location = new Point(130, 28); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(100, 23); + textBoxName.TabIndex = 3; + // + // buttonSave + // + buttonSave.Location = new Point(42, 148); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(155, 148); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отменить"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormEmployee + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(338, 224); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxName); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(comboBoxJob); + Name = "FormEmployee"; + Text = "FormEmployee"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ComboBox comboBoxJob; + private Label label1; + private Label label2; + private TextBox textBoxName; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/project/ProjectTourAgency/Forms/FormEmployee.cs b/project/ProjectTourAgency/Forms/FormEmployee.cs new file mode 100644 index 0000000..b1d07b1 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormEmployee.cs @@ -0,0 +1,89 @@ + +using ProjectEmployeeAgency.Repositories; +using ProjectRouteAgency.Repositories; +using ProjectTourAgency.Enities; +using ProjectTourAgency.Enities.Enums; +using ProjectTourAgency.Implementations; +using ProjectTourAgency.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 ProjectTourAgency.Forms +{ + public partial class FormEmployee: Form + { + private readonly IEmployeeRepository _employeeRepository; + + private int? _employeeId; + public int Id + { + set + { + try + { + var employee = _employeeRepository.ReadEmployeeById(value); + if (employee == null) + { + throw new InvalidOperationException(nameof(employee)); + } + textBoxName.Text = employee.FullName; + comboBoxJob.SelectedItem = employee.EmployeeJob; + _employeeId = value; + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении ланных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormEmployee(IEmployeeRepository employeeRepository) + { + InitializeComponent(); + _employeeRepository = employeeRepository ?? + throw new ArgumentNullException(nameof(employeeRepository)); + comboBoxJob.DataSource = Enum.GetValues(typeof(EmpoyeeJob)); + + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text) || + string.IsNullOrWhiteSpace(comboBoxJob.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_employeeId.HasValue) + { + _employeeRepository.UpdateEmployee(CreateEmployee(_employeeId.Value)); + } + else + { + _employeeRepository.CreateEmployee(CreateEmployee(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + private Employee CreateEmployee(int id) => Employee.CreateEntity(id, textBoxName.Text, (Enities.Enums.EmpoyeeJob)comboBoxJob.SelectedItem!); + } +} diff --git a/project/ProjectTourAgency/Forms/FormEmployee.resx b/project/ProjectTourAgency/Forms/FormEmployee.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormEmployee.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/project/ProjectTourAgency/Forms/FormEmployees.Designer.cs b/project/ProjectTourAgency/Forms/FormEmployees.Designer.cs new file mode 100644 index 0000000..5105b8f --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormEmployees.Designer.cs @@ -0,0 +1,125 @@ +namespace ProjectTourAgency.Forms +{ + partial class FormEmployees + { + /// + /// 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() + { + dataGridViewData = new DataGridView(); + panel1 = new Panel(); + buttonDelete = new Button(); + buttonUpdate = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(783, 450); + dataGridViewData.TabIndex = 3; + // + // panel1 + // + panel1.Controls.Add(buttonDelete); + panel1.Controls.Add(buttonUpdate); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(783, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(149, 450); + panel1.TabIndex = 2; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.free_icon_delete_3807871; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(43, 276); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(61, 59); + buttonDelete.TabIndex = 3; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += buttonDelete_Click; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources.free_icon_edit_8679935; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(43, 142); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(61, 59); + buttonUpdate.TabIndex = 2; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += buttonUpdate_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.free_icon_add_button_5974633; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(43, 25); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(61, 59); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // FormEmployees + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(932, 450); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormEmployees"; + Text = "FormEmployees"; + Load += FormEmployees_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel1; + private Button buttonDelete; + private Button buttonUpdate; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/project/ProjectTourAgency/Forms/FormEmployees.cs b/project/ProjectTourAgency/Forms/FormEmployees.cs new file mode 100644 index 0000000..2e8bdae --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormEmployees.cs @@ -0,0 +1,112 @@ +using ProjectEmployeeAgency.Repositories; +using ProjectTourAgency.Implementations; +using ProjectTourAgency.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 ProjectTourAgency.Forms +{ + public partial class FormEmployees: Form + { + private readonly IUnityContainer _container; + + private readonly IEmployeeRepository _employeeRepository; + + public FormEmployees(IEmployeeRepository employeeRepository, IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(_employeeRepository)); + } + + private void FormEmployees_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 buttonUpdate_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 buttonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _employeeRepository.DeleteEmployee(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _employeeRepository.ReadEmployees(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["ID"].Value); + return true; + } + } +} diff --git a/project/ProjectTourAgency/Forms/FormEmployees.resx b/project/ProjectTourAgency/Forms/FormEmployees.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormEmployees.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/project/ProjectTourAgency/Forms/FormRoute.Designer.cs b/project/ProjectTourAgency/Forms/FormRoute.Designer.cs new file mode 100644 index 0000000..c73ac85 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormRoute.Designer.cs @@ -0,0 +1,151 @@ +namespace ProjectTourAgency.Forms +{ + partial class FormRoute + { + /// + /// 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() + { + textBoxDestination = new TextBox(); + labelDestination = new Label(); + labelDeparture = new Label(); + textBoxDuration = new TextBox(); + textBoxDeparture = new TextBox(); + labelDuration = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // textBoxDestination + // + textBoxDestination.Location = new Point(206, 53); + textBoxDestination.Margin = new Padding(4, 5, 4, 5); + textBoxDestination.Name = "textBoxDestination"; + textBoxDestination.Size = new Size(321, 31); + textBoxDestination.TabIndex = 4; + // + // labelDestination + // + labelDestination.AutoSize = true; + labelDestination.Location = new Point(24, 53); + labelDestination.Margin = new Padding(4, 0, 4, 0); + labelDestination.Name = "labelDestination"; + labelDestination.Size = new Size(148, 25); + labelDestination.TabIndex = 3; + labelDestination.Text = "Место прибытия"; + // + // labelDeparture + // + labelDeparture.AutoSize = true; + labelDeparture.Location = new Point(15, 128); + labelDeparture.Margin = new Padding(4, 0, 4, 0); + labelDeparture.Name = "labelDeparture"; + labelDeparture.Size = new Size(135, 25); + labelDeparture.TabIndex = 5; + labelDeparture.Text = "Место отбытия"; + // + // textBoxDuration + // + textBoxDuration.Location = new Point(206, 190); + textBoxDuration.Margin = new Padding(4, 5, 4, 5); + textBoxDuration.Name = "textBoxDuration"; + textBoxDuration.Size = new Size(321, 31); + textBoxDuration.TabIndex = 7; + // + // textBoxDeparture + // + textBoxDeparture.Location = new Point(206, 125); + textBoxDeparture.Margin = new Padding(4, 5, 4, 5); + textBoxDeparture.Name = "textBoxDeparture"; + textBoxDeparture.Size = new Size(321, 31); + textBoxDeparture.TabIndex = 8; + // + // labelDuration + // + labelDuration.AutoSize = true; + labelDuration.Location = new Point(15, 190); + labelDuration.Margin = new Padding(4, 0, 4, 0); + labelDuration.Name = "labelDuration"; + labelDuration.Size = new Size(179, 25); + labelDuration.TabIndex = 10; + labelDuration.Text = "Продолжительность"; + // + // buttonSave + // + buttonSave.Location = new Point(98, 250); + buttonSave.Margin = new Padding(4, 5, 4, 5); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(107, 38); + buttonSave.TabIndex = 12; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(366, 250); + buttonCancel.Margin = new Padding(4, 5, 4, 5); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(107, 38); + buttonCancel.TabIndex = 13; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormRoute + // + AutoScaleDimensions = new SizeF(10F, 25F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(591, 310); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(labelDuration); + Controls.Add(textBoxDeparture); + Controls.Add(textBoxDuration); + Controls.Add(labelDeparture); + Controls.Add(textBoxDestination); + Controls.Add(labelDestination); + Margin = new Padding(4, 5, 4, 5); + Name = "FormRoute"; + StartPosition = FormStartPosition.CenterParent; + Text = "Тур"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + private DateTimePicker dateTimePickerDepartureDate; + private TextBox textBoxDestination; + private Label labelDestination; + private Label labelDeparture; + private TextBox textBoxDuration; + private TextBox textBoxDeparture; + private Label labelDate; + private Label labelDuration; + private TextBox textBoxPrice; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/project/ProjectTourAgency/Forms/FormRoute.cs b/project/ProjectTourAgency/Forms/FormRoute.cs new file mode 100644 index 0000000..c07594e --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormRoute.cs @@ -0,0 +1,90 @@ + +using ProjectRouteAgency.Repositories; +using ProjectTourAgency.Enities; +using ProjectTourAgency.Implementations; +using ProjectTourAgency.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 ProjectTourAgency.Forms +{ + public partial class FormRoute : Form + { + private readonly IRouteRepository _routeRepository; + + private int? _routeId; + public int Id + { + set + { + try + { + var route = _routeRepository.ReadRouteById(value); + if (route == null) + { + throw new InvalidOperationException(nameof(route)); + } + textBoxDestination.Text = route.Destination; + textBoxDeparture.Text = route.Departure; + textBoxDuration.Text = route.Duration.ToString(); + _routeId = value; + + } + catch(Exception ex) + { + MessageBox.Show(ex.Message,"Ошибка при получении ланных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormRoute(IRouteRepository routeRepository, ITourRepository tourRepository) + { + InitializeComponent(); + _routeRepository = routeRepository ?? + throw new ArgumentNullException(nameof(routeRepository)); + + + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxDestination.Text) || + string.IsNullOrWhiteSpace(textBoxDeparture.Text) || string.IsNullOrWhiteSpace(textBoxDuration.Text) + || string.IsNullOrWhiteSpace(textBoxPrice.Text) || string.IsNullOrWhiteSpace(dateTimePickerDepartureDate.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_routeId.HasValue) + { + _routeRepository.UpdateRoute(CreateRoute(_routeId.Value)); + } + else + { + _routeRepository.CreateRoute(CreateRoute(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + private Route CreateRoute(int id) => Route.CreateEntity(id, textBoxDestination.Text, + textBoxDeparture.Text, int.Parse(textBoxDuration.Text)); + } +} diff --git a/project/ProjectTourAgency/Forms/FormRoute.resx b/project/ProjectTourAgency/Forms/FormRoute.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormRoute.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/project/ProjectTourAgency/Forms/FormRoutes.Designer.cs b/project/ProjectTourAgency/Forms/FormRoutes.Designer.cs new file mode 100644 index 0000000..dffaca5 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormRoutes.Designer.cs @@ -0,0 +1,125 @@ +namespace ProjectTourAgency.Forms +{ + partial class FormRoutes + { + /// + /// 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() + { + dataGridViewData = new DataGridView(); + panel1 = new Panel(); + buttonDelete = new Button(); + buttonUpdate = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(775, 371); + dataGridViewData.TabIndex = 3; + // + // panel1 + // + panel1.Controls.Add(buttonDelete); + panel1.Controls.Add(buttonUpdate); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(775, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(149, 371); + panel1.TabIndex = 2; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.free_icon_delete_3807871; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(43, 276); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(61, 59); + buttonDelete.TabIndex = 3; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += buttonDelete_Click; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources.free_icon_edit_8679935; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(43, 142); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(61, 59); + buttonUpdate.TabIndex = 2; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += buttonUpdate_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.free_icon_add_button_5974633; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(43, 25); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(61, 59); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // FormTours + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(924, 371); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormTours"; + Text = "Туры"; + Load += FormRoutes_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel1; + private Button buttonDelete; + private Button buttonUpdate; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/project/ProjectTourAgency/Forms/FormRoutes.cs b/project/ProjectTourAgency/Forms/FormRoutes.cs new file mode 100644 index 0000000..e9ce87e --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormRoutes.cs @@ -0,0 +1,111 @@ +using ProjectRouteAgency.Repositories; +using ProjectTourAgency.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 ProjectTourAgency.Forms +{ + public partial class FormRoutes : Form + { + private readonly IUnityContainer _container; + + private readonly IRouteRepository _routeRepository; + + public FormRoutes(IRouteRepository routeRepository, IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _routeRepository = routeRepository ?? throw new ArgumentNullException(nameof(_routeRepository)); + } + + private void FormRoutes_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 buttonUpdate_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 buttonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _routeRepository.DeleteRoute(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _routeRepository.ReadRoutes(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["ID"].Value); + return true; + } + } +} diff --git a/project/ProjectTourAgency/Forms/FormRoutes.resx b/project/ProjectTourAgency/Forms/FormRoutes.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormRoutes.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/project/ProjectTourAgency/Forms/FormTours.Designer.cs b/project/ProjectTourAgency/Forms/FormTours.Designer.cs new file mode 100644 index 0000000..a5b7a3f --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormTours.Designer.cs @@ -0,0 +1,111 @@ +namespace ProjectTourAgency.Forms +{ + partial class FormTours + { + /// + /// 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() + { + dataGridViewData = new DataGridView(); + panel1 = new Panel(); + buttonDelete = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(746, 462); + dataGridViewData.TabIndex = 3; + // + // panel1 + // + panel1.Controls.Add(buttonDelete); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(746, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(149, 462); + panel1.TabIndex = 2; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.free_icon_delete_3807871; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(43, 276); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(61, 59); + buttonDelete.TabIndex = 3; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += buttonDelete_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.free_icon_add_button_5974633; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(43, 25); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(61, 59); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // FormTours + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(895, 462); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormTours"; + Text = "FormTours"; + Load += FormTours_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel1; + private Button buttonDelete; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/project/ProjectTourAgency/Forms/FormTours.cs b/project/ProjectTourAgency/Forms/FormTours.cs new file mode 100644 index 0000000..64529f2 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormTours.cs @@ -0,0 +1,91 @@ +using ProjectTourAgency.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 ProjectTourAgency.Forms +{ + public partial class FormTours : Form + { + private readonly IUnityContainer _container; + + private readonly ITourRepository _tourRepository; + + public FormTours(ITourRepository tourRepository, IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _tourRepository = tourRepository ?? throw new ArgumentNullException(nameof(_tourRepository)); + } + + private void FormTours_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 buttonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _tourRepository.DeleteTour(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _tourRepository.ReadTours(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["ID"].Value); + return true; + } + } +} diff --git a/project/ProjectTourAgency/Forms/FormTours.resx b/project/ProjectTourAgency/Forms/FormTours.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormTours.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/project/ProjectTourAgency/Implementations/AddMoneyRepository.cs b/project/ProjectTourAgency/Implementations/AddMoneyRepository.cs new file mode 100644 index 0000000..02e56e7 --- /dev/null +++ b/project/ProjectTourAgency/Implementations/AddMoneyRepository.cs @@ -0,0 +1,39 @@ +using ProjectTourAgency.Enities; +using ProjectTourAgency.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Implementations +{ + internal class AddMoneyRepository : IAddMoneyRepository + + { + public void CreateAddMoney(AddMoney client) + { + + } + + public void DeleteAddMoney(int id) + { + + } + + public AddMoney ReadAddMoneyById(int id) + { + return AddMoney.CreateEntity(0,0,DateTime.Now,0); + } + + public IEnumerable ReadAddMoneys() + { + return []; + } + + public void UpdateAddMoney(AddMoney client) + { + + } + } +} diff --git a/project/ProjectTourAgency/Implementations/ClientRepository.cs b/project/ProjectTourAgency/Implementations/ClientRepository.cs new file mode 100644 index 0000000..354eb53 --- /dev/null +++ b/project/ProjectTourAgency/Implementations/ClientRepository.cs @@ -0,0 +1,34 @@ +using ProjectTourAgency.Enities; +using ProjectTourAgency.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Implementations; + +public class ClientRepository : IClientRepository +{ + public void CreateClient(Client client) + { + } + + public void DeleteClient(int id) + { + } + + public Client ReadClientById(int id) + { + return Client.CreateEntity(0, string.Empty, DateTime.Now, string.Empty, 0, Enities.Enums.ClientStatus.None); + } + + public IEnumerable ReadClients() + { + return []; + } + + public void UpdateClient(Client client) + { + } +} diff --git a/project/ProjectTourAgency/Implementations/EmployeeRepository.cs b/project/ProjectTourAgency/Implementations/EmployeeRepository.cs new file mode 100644 index 0000000..d6c71e5 --- /dev/null +++ b/project/ProjectTourAgency/Implementations/EmployeeRepository.cs @@ -0,0 +1,35 @@ +using ProjectEmployeeAgency.Repositories; +using ProjectTourAgency.Enities; +using ProjectTourAgency.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Implementations; + +public class EmployeeRepository : IEmployeeRepository +{ + public void CreateEmployee(Employee employee) + { + } + + public void DeleteEmployee(int id) + { + } + + public Employee ReadEmployeeById(int id) + { + return Employee.CreateEntity(0, string.Empty,0); + } + + public IEnumerable ReadEmployees() + { + return []; + } + + public void UpdateEmployee(Employee employee) + { + } +} diff --git a/project/ProjectTourAgency/Implementations/RouteRepository.cs b/project/ProjectTourAgency/Implementations/RouteRepository.cs new file mode 100644 index 0000000..7ef29f3 --- /dev/null +++ b/project/ProjectTourAgency/Implementations/RouteRepository.cs @@ -0,0 +1,37 @@ +using ProjectRouteAgency.Repositories; +using ProjectTourAgency.Enities; +using ProjectTourAgency.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Implementations; + +public class RouteRepository : IRouteRepository +{ + public void CreateRoute(Route route) + { + + } + + public void DeleteRoute(int id) + { + + } + + public Route ReadRouteById(int id) + { + return Route.CreateEntity(0, string.Empty,string.Empty, 0); + } + + public IEnumerable ReadRoutes() + { + return []; + } + + public void UpdateRoute(Route route) + { + } +} diff --git a/project/ProjectTourAgency/Implementations/TourRepository.cs b/project/ProjectTourAgency/Implementations/TourRepository.cs new file mode 100644 index 0000000..0ca7486 --- /dev/null +++ b/project/ProjectTourAgency/Implementations/TourRepository.cs @@ -0,0 +1,35 @@ +using ProjectTourAgency.Enities; +using ProjectTourAgency.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Implementations; + +public class TourRepository : ITourRepository +{ + public void CreateTour(Tour tour) + { + + } + + public void DeleteTour(int id) + { + } + + public Tour ReadTourById(int id) + { + return Tour.CreateEntity(0,0, 0,DateTime.Now, []); + } + + public IEnumerable ReadTours() + { + return []; + } + + public void UpdateTour(Tour tour) + { + } +} diff --git a/project/ProjectTourAgency/Program.cs b/project/ProjectTourAgency/Program.cs index 41bd0d6..676f643 100644 --- a/project/ProjectTourAgency/Program.cs +++ b/project/ProjectTourAgency/Program.cs @@ -1,3 +1,9 @@ +using ProjectEmployeeAgency.Repositories; +using ProjectRouteAgency.Repositories; +using ProjectTourAgency.Implementations; +using ProjectTourAgency.Repositories; +using Unity; + namespace ProjectTourAgency { internal static class Program @@ -11,7 +17,21 @@ namespace ProjectTourAgency // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(CreateContainer().Resolve()); + } + + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + + return container; } } } \ No newline at end of file diff --git a/project/ProjectTourAgency/ProjectTourAgency.csproj b/project/ProjectTourAgency/ProjectTourAgency.csproj index 663fdb8..accbdf0 100644 --- a/project/ProjectTourAgency/ProjectTourAgency.csproj +++ b/project/ProjectTourAgency/ProjectTourAgency.csproj @@ -8,4 +8,23 @@ enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/project/ProjectTourAgency/Properties/Resources.Designer.cs b/project/ProjectTourAgency/Properties/Resources.Designer.cs new file mode 100644 index 0000000..80fd14f --- /dev/null +++ b/project/ProjectTourAgency/Properties/Resources.Designer.cs @@ -0,0 +1,113 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectTourAgency.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("ProjectTourAgency.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 free_icon_add_button_5974633 { + get { + object obj = ResourceManager.GetObject("free-icon-add-button-5974633", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap free_icon_delete_3807871 { + get { + object obj = ResourceManager.GetObject("free-icon-delete-3807871", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap free_icon_edit_8679935 { + get { + object obj = ResourceManager.GetObject("free-icon-edit-8679935", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Снимок_экрана_2024_11_08_213926 { + get { + object obj = ResourceManager.GetObject("Снимок экрана 2024-11-08 213926", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Снимок_экрана_2024_11_08_2139261 { + get { + object obj = ResourceManager.GetObject("Снимок экрана 2024-11-08 2139261", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/project/ProjectTourAgency/Properties/Resources.resx b/project/ProjectTourAgency/Properties/Resources.resx new file mode 100644 index 0000000..639146d --- /dev/null +++ b/project/ProjectTourAgency/Properties/Resources.resx @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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\free-icon-edit-8679935.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Снимок экрана 2024-11-08 213926.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\free-icon-add-button-5974633.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Снимок экрана 2024-11-08 2139261.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\free-icon-delete-3807871.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/project/ProjectTourAgency/Repositories/IAddMoneyRepository.cs b/project/ProjectTourAgency/Repositories/IAddMoneyRepository.cs new file mode 100644 index 0000000..9f8e7b6 --- /dev/null +++ b/project/ProjectTourAgency/Repositories/IAddMoneyRepository.cs @@ -0,0 +1,20 @@ +using ProjectTourAgency.Enities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Repositories; + +public interface IAddMoneyRepository +{ + IEnumerable ReadAddMoneys(); + + AddMoney ReadAddMoneyById(int id); + + void CreateAddMoney(AddMoney client); + void UpdateAddMoney(AddMoney client); + + void DeleteAddMoney(int id); +} diff --git a/project/ProjectTourAgency/Repositories/IClientRepository.cs b/project/ProjectTourAgency/Repositories/IClientRepository.cs new file mode 100644 index 0000000..2bcd7d9 --- /dev/null +++ b/project/ProjectTourAgency/Repositories/IClientRepository.cs @@ -0,0 +1,20 @@ +using ProjectTourAgency.Enities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.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/project/ProjectTourAgency/Repositories/IClientTourRepository.cs b/project/ProjectTourAgency/Repositories/IClientTourRepository.cs new file mode 100644 index 0000000..c854b3e --- /dev/null +++ b/project/ProjectTourAgency/Repositories/IClientTourRepository.cs @@ -0,0 +1,17 @@ +using ProjectTourAgency.Enities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Repositories +{ + public interface IClientTourRepository + { + IEnumerable ReadClientTours(int? clientId = null, int? tourId = null); + + + void CreateReceipt(ClientTour clientTour); + } +} diff --git a/project/ProjectTourAgency/Repositories/IEmployeeRepository.cs b/project/ProjectTourAgency/Repositories/IEmployeeRepository.cs new file mode 100644 index 0000000..4133a51 --- /dev/null +++ b/project/ProjectTourAgency/Repositories/IEmployeeRepository.cs @@ -0,0 +1,16 @@ +using ProjectTourAgency.Enities; + +namespace ProjectEmployeeAgency.Repositories; + +public interface IEmployeeRepository +{ + IEnumerable ReadEmployees(); + + Employee ReadEmployeeById(int id); + + void CreateEmployee(Employee tour); + + void UpdateEmployee(Employee tour); + + void DeleteEmployee(int id); +} diff --git a/project/ProjectTourAgency/Repositories/IRouteRepository.cs b/project/ProjectTourAgency/Repositories/IRouteRepository.cs new file mode 100644 index 0000000..840ca92 --- /dev/null +++ b/project/ProjectTourAgency/Repositories/IRouteRepository.cs @@ -0,0 +1,21 @@ +using ProjectTourAgency.Enities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRouteAgency.Repositories; + +public interface IRouteRepository +{ + IEnumerable ReadRoutes(); + + Route ReadRouteById(int id); + + void CreateRoute(Route tour); + + void UpdateRoute(Route tour); + + void DeleteRoute(int id); +} diff --git a/project/ProjectTourAgency/Repositories/ITourRepositiry.cs b/project/ProjectTourAgency/Repositories/ITourRepositiry.cs new file mode 100644 index 0000000..39364e5 --- /dev/null +++ b/project/ProjectTourAgency/Repositories/ITourRepositiry.cs @@ -0,0 +1,21 @@ +using ProjectTourAgency.Enities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Repositories; + +public interface ITourRepository +{ + IEnumerable ReadTours(); + + Tour ReadTourById(int id); + + void CreateTour(Tour tour); + + void UpdateTour(Tour tour); + + void DeleteTour(int id); +} diff --git a/project/ProjectTourAgency/Resources/free-icon-add-button-5974633.png b/project/ProjectTourAgency/Resources/free-icon-add-button-5974633.png new file mode 100644 index 0000000..8ea3150 Binary files /dev/null and b/project/ProjectTourAgency/Resources/free-icon-add-button-5974633.png differ diff --git a/project/ProjectTourAgency/Resources/free-icon-delete-3807871.png b/project/ProjectTourAgency/Resources/free-icon-delete-3807871.png new file mode 100644 index 0000000..f575bf5 Binary files /dev/null and b/project/ProjectTourAgency/Resources/free-icon-delete-3807871.png differ diff --git a/project/ProjectTourAgency/Resources/free-icon-edit-8679935.png b/project/ProjectTourAgency/Resources/free-icon-edit-8679935.png new file mode 100644 index 0000000..26b2fa7 Binary files /dev/null and b/project/ProjectTourAgency/Resources/free-icon-edit-8679935.png differ diff --git a/project/ProjectTourAgency/Resources/Снимок экрана 2024-11-08 213926.png b/project/ProjectTourAgency/Resources/Снимок экрана 2024-11-08 213926.png new file mode 100644 index 0000000..b8b8695 Binary files /dev/null and b/project/ProjectTourAgency/Resources/Снимок экрана 2024-11-08 213926.png differ diff --git a/project/ProjectTourAgency/Resources/Снимок экрана 2024-11-08 2139261.png b/project/ProjectTourAgency/Resources/Снимок экрана 2024-11-08 2139261.png new file mode 100644 index 0000000..b8b8695 Binary files /dev/null and b/project/ProjectTourAgency/Resources/Снимок экрана 2024-11-08 2139261.png differ diff --git a/project/newProject/ProjectTourAgency/Enities/AddMoney.cs b/project/newProject/ProjectTourAgency/Enities/AddMoney.cs new file mode 100644 index 0000000..3865dfe --- /dev/null +++ b/project/newProject/ProjectTourAgency/Enities/AddMoney.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Enities +{ + public class AddMoney + { + public int Id { get; private set; } + public int ClientId { get; private set; } + public DateTime Date { get; private set; } + public int MoneyAmount{ get; private set; } + + public static AddMoney CreateEntity(int id,int cId, + DateTime date, int money) + { + return new AddMoney + { + Id = id, + ClientId = cId, + Date = date, + MoneyAmount = money + }; + } + } +} diff --git a/project/newProject/ProjectTourAgency/Enities/Client.cs b/project/newProject/ProjectTourAgency/Enities/Client.cs new file mode 100644 index 0000000..778d55f --- /dev/null +++ b/project/newProject/ProjectTourAgency/Enities/Client.cs @@ -0,0 +1,31 @@ +using ProjectTourAgency.Enities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Enities; + +public class Client +{ + public int Id { get;private set; } + public string FullName { get; private set; } = string.Empty; + public DateTime BirthDate { get; private set; } + public string PhoneNumber { get; private set; } = string.Empty; + public int Money { get; private set; } + + public static Client CreateEntity(int id, string fullName, + DateTime birthDate, string phoneNumber, int money) + { + return new Client + { + Id = id, + FullName = fullName, + BirthDate = birthDate, + PhoneNumber = phoneNumber, + Money = money + }; + } + +} diff --git a/project/newProject/ProjectTourAgency/Enities/ClientTour.cs b/project/newProject/ProjectTourAgency/Enities/ClientTour.cs new file mode 100644 index 0000000..a851770 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Enities/ClientTour.cs @@ -0,0 +1,27 @@ +using ProjectTourAgency.Enities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Enities; + +public class ClientTour +{ + public int ClientId { get; private set; } + public int TourId { get; private set; } + + public int Count { get; private set; } + + public static ClientTour CreateEntity(int clientId, int tourId, int count) + { + return new ClientTour + { + ClientId = clientId, + TourId = tourId, + Count = count + }; + } + +} diff --git a/project/newProject/ProjectTourAgency/Enities/Employee.cs b/project/newProject/ProjectTourAgency/Enities/Employee.cs new file mode 100644 index 0000000..1ee2ff2 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Enities/Employee.cs @@ -0,0 +1,28 @@ +using ProjectTourAgency.Enities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Enities; + +public class Employee +{ + public int Id { get; private set; } + public string FullName { get; private set; } = string.Empty; + + public EmpoyeeJob EmployeeJob { get; private set; } + + public static Employee CreateEntity(int id, string fullName, + EmpoyeeJob job) + { + return new Employee + { + Id = id, + FullName = fullName, + EmployeeJob = job + + }; + } +} diff --git a/project/newProject/ProjectTourAgency/Enities/Enums/EmpoyeeJob.cs b/project/newProject/ProjectTourAgency/Enities/Enums/EmpoyeeJob.cs new file mode 100644 index 0000000..c67d5eb --- /dev/null +++ b/project/newProject/ProjectTourAgency/Enities/Enums/EmpoyeeJob.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.Tracing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Enities.Enums; + +public enum EmpoyeeJob +{ + None = 0, + Driver = 1, + Archeologist = 2, + ETC = 3 +} diff --git a/project/newProject/ProjectTourAgency/Enities/Route.cs b/project/newProject/ProjectTourAgency/Enities/Route.cs new file mode 100644 index 0000000..4d760ce --- /dev/null +++ b/project/newProject/ProjectTourAgency/Enities/Route.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Enities; + +public class Route +{ + public int Id { get; private set; } + public int TourId { get; private set; } + public string Destination { get; private set; } = string.Empty; + public string Departure { get; private set; } = string.Empty; + public int Duration { get; private set; } + public static Route CreateEntity(int id, int TourId, string destination, + string departure, int duration) + { + return new Route + { + Id = id, + TourId = TourId, + Destination = destination, + Departure = departure, + Duration = duration + }; + } + +} diff --git a/project/newProject/ProjectTourAgency/Enities/Tour.cs b/project/newProject/ProjectTourAgency/Enities/Tour.cs new file mode 100644 index 0000000..8a75846 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Enities/Tour.cs @@ -0,0 +1,25 @@ +using ProjectTourAgency.Enities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Enities; + +public class Tour +{ + public int Id { get; private set; } + public DateTime DepartureDate { get; private set; } + public int Cost { get; private set; } + public static Tour CreateEntity(int id, + DateTime date,int cost) + { + return new Tour + { + Id = id, + DepartureDate = date, + Cost = cost + }; + } +} diff --git a/project/newProject/ProjectTourAgency/FormTourAgency.Designer.cs b/project/newProject/ProjectTourAgency/FormTourAgency.Designer.cs new file mode 100644 index 0000000..f0f7913 --- /dev/null +++ b/project/newProject/ProjectTourAgency/FormTourAgency.Designer.cs @@ -0,0 +1,137 @@ +namespace ProjectTourAgency +{ + partial class FormTourAgency + { + /// + /// 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(); + MenuToolStripMenuItem = new ToolStripMenuItem(); + ClientsToolStripMenuItem = new ToolStripMenuItem(); + RotesToolStripMenuItem = new ToolStripMenuItem(); + EmployeesToolStripMenuItem = new ToolStripMenuItem(); + OperationsToolStripMenuItem = new ToolStripMenuItem(); + пополнитьБалансПользователяToolStripMenuItem = new ToolStripMenuItem(); + турToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + menuStrip1.SuspendLayout(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.Items.AddRange(new ToolStripItem[] { MenuToolStripMenuItem, OperationsToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(784, 24); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; + // + // MenuToolStripMenuItem + // + MenuToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ClientsToolStripMenuItem, RotesToolStripMenuItem, EmployeesToolStripMenuItem }); + MenuToolStripMenuItem.Name = "MenuToolStripMenuItem"; + MenuToolStripMenuItem.Size = new Size(94, 20); + MenuToolStripMenuItem.Text = "Справочники"; + // + // ClientsToolStripMenuItem + // + ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem"; + ClientsToolStripMenuItem.Size = new Size(140, 22); + ClientsToolStripMenuItem.Text = "Клиенты"; + ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click; + // + // RotesToolStripMenuItem + // + RotesToolStripMenuItem.Name = "RotesToolStripMenuItem"; + RotesToolStripMenuItem.Size = new Size(140, 22); + RotesToolStripMenuItem.Text = "маршруты"; + RotesToolStripMenuItem.Click += RotesToolStripMenuItem_Click; + // + // EmployeesToolStripMenuItem + // + EmployeesToolStripMenuItem.Name = "EmployeesToolStripMenuItem"; + EmployeesToolStripMenuItem.Size = new Size(140, 22); + EmployeesToolStripMenuItem.Text = "Сотрудники"; + EmployeesToolStripMenuItem.Click += EmployeesToolStripMenuItem_Click; + // + // OperationsToolStripMenuItem + // + OperationsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { пополнитьБалансПользователяToolStripMenuItem, турToolStripMenuItem }); + OperationsToolStripMenuItem.Name = "OperationsToolStripMenuItem"; + OperationsToolStripMenuItem.Size = new Size(75, 20); + OperationsToolStripMenuItem.Text = "Операции"; + // + // пополнитьБалансПользователяToolStripMenuItem + // + пополнитьБалансПользователяToolStripMenuItem.Name = "пополнитьБалансПользователяToolStripMenuItem"; + пополнитьБалансПользователяToolStripMenuItem.Size = new Size(256, 22); + пополнитьБалансПользователяToolStripMenuItem.Text = "Пополнить баланс пользователя"; + пополнитьБалансПользователяToolStripMenuItem.Click += пополнитьБалансПользователяToolStripMenuItem_Click; + // + // турToolStripMenuItem + // + турToolStripMenuItem.Name = "турToolStripMenuItem"; + турToolStripMenuItem.Size = new Size(256, 22); + турToolStripMenuItem.Text = "Тур"; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 20); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // FormTourAgency + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.Снимок_экрана_2024_11_08_2139261; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(784, 411); + Controls.Add(menuStrip1); + DoubleBuffered = true; + MainMenuStrip = menuStrip1; + Name = "FormTourAgency"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Тур Агенство"; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem MenuToolStripMenuItem; + private ToolStripMenuItem OperationsToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem ClientsToolStripMenuItem; + private ToolStripMenuItem RotesToolStripMenuItem; + private ToolStripMenuItem EmployeesToolStripMenuItem; + private ToolStripMenuItem пополнитьБалансПользователяToolStripMenuItem; + private ToolStripMenuItem турToolStripMenuItem; + } +} diff --git a/project/newProject/ProjectTourAgency/FormTourAgency.cs b/project/newProject/ProjectTourAgency/FormTourAgency.cs new file mode 100644 index 0000000..54fbb9d --- /dev/null +++ b/project/newProject/ProjectTourAgency/FormTourAgency.cs @@ -0,0 +1,64 @@ +using ProjectTourAgency.Forms; +using Unity; + +namespace ProjectTourAgency; + +public partial class FormTourAgency : Form +{ + private readonly IUnityContainer _container; + public FormTourAgency(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + } + + private void ClientsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + private void RotesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void EmployeesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } +} diff --git a/project/newProject/ProjectTourAgency/FormTourAgency.resx b/project/newProject/ProjectTourAgency/FormTourAgency.resx new file mode 100644 index 0000000..a0623c8 --- /dev/null +++ b/project/newProject/ProjectTourAgency/FormTourAgency.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/project/newProject/ProjectTourAgency/Forms/.resx b/project/newProject/ProjectTourAgency/Forms/.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/.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/project/newProject/ProjectTourAgency/Forms/FormAddMoney.Designer.cs b/project/newProject/ProjectTourAgency/Forms/FormAddMoney.Designer.cs new file mode 100644 index 0000000..59af847 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormAddMoney.Designer.cs @@ -0,0 +1,118 @@ +namespace ProjectTourAgency.Forms +{ + partial class FormAddMoney + { + /// + /// 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() + { + labelClient = new Label(); + labelMoney = new Label(); + comboBoxClientId = new ComboBox(); + textBoxMoney = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelClient + // + labelClient.AutoSize = true; + labelClient.Location = new Point(32, 28); + labelClient.Name = "labelClient"; + labelClient.Size = new Size(66, 15); + labelClient.TabIndex = 0; + labelClient.Text = "ID Клиента"; + // + // labelMoney + // + labelMoney.AutoSize = true; + labelMoney.Location = new Point(32, 79); + labelMoney.Name = "labelMoney"; + labelMoney.Size = new Size(173, 15); + labelMoney.TabIndex = 1; + labelMoney.Text = "на сколько пополнить баланс"; + // + // comboBoxClientId + // + comboBoxClientId.FormattingEnabled = true; + comboBoxClientId.Location = new Point(231, 28); + comboBoxClientId.Name = "comboBoxClientId"; + comboBoxClientId.Size = new Size(121, 23); + comboBoxClientId.TabIndex = 2; + // + // textBoxMoney + // + textBoxMoney.Location = new Point(231, 71); + textBoxMoney.Name = "textBoxMoney"; + textBoxMoney.Size = new Size(126, 23); + textBoxMoney.TabIndex = 3; + // + // buttonSave + // + buttonSave.Location = new Point(32, 128); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 4; + buttonSave.Text = "Пополнить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(242, 128); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(89, 26); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмнить"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormAddMoney + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(386, 184); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxMoney); + Controls.Add(comboBoxClientId); + Controls.Add(labelMoney); + Controls.Add(labelClient); + Name = "FormAddMoney"; + Text = "FormAddMoney"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelClient; + private Label labelMoney; + private ComboBox comboBoxClientId; + private TextBox textBoxMoney; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/project/newProject/ProjectTourAgency/Forms/FormAddMoney.cs b/project/newProject/ProjectTourAgency/Forms/FormAddMoney.cs new file mode 100644 index 0000000..918074d --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormAddMoney.cs @@ -0,0 +1,48 @@ +using ProjectTourAgency.Enities; +using ProjectTourAgency.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 ProjectTourAgency.Forms +{ + public partial class FormAddMoney : Form + { + private readonly IAddMoneyRepository _addMoneyRepository; + public FormAddMoney(IAddMoneyRepository addMoneyRepository, IClientRepository clientRepository) + { + InitializeComponent(); + _addMoneyRepository = addMoneyRepository ?? + throw new ArgumentNullException(nameof(addMoneyRepository)); + comboBoxClientId.DataSource = clientRepository.ReadClients(); + comboBoxClientId.DisplayMember = "Name"; + comboBoxClientId.ValueMember = "Id"; + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxClientId.SelectedIndex < 0 || String.IsNullOrWhiteSpace(textBoxMoney.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + _addMoneyRepository.CreateAddMoney(AddMoney.CreateEntity(0, (int)comboBoxClientId.SelectedValue!, DateTime.Now, Convert.ToInt32(textBoxMoney.Text))); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + } +} diff --git a/project/newProject/ProjectTourAgency/Forms/FormAddMoney.resx b/project/newProject/ProjectTourAgency/Forms/FormAddMoney.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormAddMoney.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/project/newProject/ProjectTourAgency/Forms/FormClient.Designer.cs b/project/newProject/ProjectTourAgency/Forms/FormClient.Designer.cs new file mode 100644 index 0000000..6cc1b92 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormClient.Designer.cs @@ -0,0 +1,161 @@ +namespace ProjectTourAgency.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() + { + labelName = new Label(); + labelDate = new Label(); + labelNumber = new Label(); + labelMoney = new Label(); + textBoxName = new TextBox(); + dateTimePickerDate = new DateTimePicker(); + textBoxNumber = new TextBox(); + textBoxMoney = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(12, 9); + labelName.Name = "labelName"; + labelName.Size = new Size(75, 15); + labelName.TabIndex = 0; + labelName.Text = "Полное имя"; + // + // labelDate + // + labelDate.AutoSize = true; + labelDate.Location = new Point(12, 45); + labelDate.Name = "labelDate"; + labelDate.Size = new Size(90, 15); + labelDate.TabIndex = 1; + labelDate.Text = "Дата рождения"; + // + // labelNumber + // + labelNumber.AutoSize = true; + labelNumber.Location = new Point(12, 88); + labelNumber.Name = "labelNumber"; + labelNumber.Size = new Size(101, 15); + labelNumber.TabIndex = 2; + labelNumber.Text = "Номер телефона"; + // + // labelMoney + // + labelMoney.AutoSize = true; + labelMoney.Location = new Point(12, 128); + labelMoney.Name = "labelMoney"; + labelMoney.Size = new Size(46, 15); + labelMoney.TabIndex = 3; + labelMoney.Text = "Баланс"; + // + // textBoxName + // + textBoxName.Location = new Point(131, 9); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(100, 23); + textBoxName.TabIndex = 4; + // + // dateTimePickerDate + // + dateTimePickerDate.Location = new Point(131, 45); + dateTimePickerDate.Name = "dateTimePickerDate"; + dateTimePickerDate.Size = new Size(200, 23); + dateTimePickerDate.TabIndex = 5; + // + // textBoxNumber + // + textBoxNumber.Location = new Point(131, 85); + textBoxNumber.Name = "textBoxNumber"; + textBoxNumber.Size = new Size(100, 23); + textBoxNumber.TabIndex = 6; + // + // textBoxMoney + // + textBoxMoney.Location = new Point(131, 125); + textBoxMoney.Name = "textBoxMoney"; + textBoxMoney.Size = new Size(100, 23); + textBoxMoney.TabIndex = 7; + // + // buttonSave + // + buttonSave.Location = new Point(49, 198); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 8; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(173, 198); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 9; + buttonCancel.Text = "Отменить"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormClient + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(389, 251); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxMoney); + Controls.Add(textBoxNumber); + Controls.Add(dateTimePickerDate); + Controls.Add(textBoxName); + Controls.Add(labelMoney); + Controls.Add(labelNumber); + Controls.Add(labelDate); + Controls.Add(labelName); + Name = "FormClient"; + Text = "FormClient"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelName; + private Label labelDate; + private Label labelNumber; + private Label labelMoney; + private TextBox textBoxName; + private DateTimePicker dateTimePickerDate; + private TextBox textBoxNumber; + private TextBox textBoxMoney; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/project/newProject/ProjectTourAgency/Forms/FormClient.cs b/project/newProject/ProjectTourAgency/Forms/FormClient.cs new file mode 100644 index 0000000..9ee0970 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormClient.cs @@ -0,0 +1,88 @@ + +using ProjectRouteAgency.Repositories; +using ProjectTourAgency.Enities; +using ProjectTourAgency.Implementations; +using ProjectTourAgency.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 ProjectTourAgency.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 InvalidOperationException(nameof(client)); + } + textBoxName.Text = client.FullName; + textBoxNumber.Text = client.PhoneNumber; + textBoxMoney.Text = client.Money.ToString(); + dateTimePickerDate.Value = client.BirthDate; + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении ланных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormClient(IClientRepository clientRepository) + { + InitializeComponent(); + _clientRepository = clientRepository ?? + throw new ArgumentNullException(nameof(clientRepository)); + + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text) || + string.IsNullOrWhiteSpace(textBoxNumber.Text) + || string.IsNullOrWhiteSpace(textBoxMoney.Text) || string.IsNullOrWhiteSpace(dateTimePickerDate.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_clientId.HasValue) + { + _clientRepository.UpdateClient(CreateClient(_clientId.Value)); + } + else + { + _clientRepository.CreateClient(CreateClient(_clientId.Value)); + } + 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) => Client.CreateEntity(id, textBoxName.Text, dateTimePickerDate.Value,textBoxNumber.Text, Convert.ToInt32(textBoxMoney.Text)); + } +} diff --git a/project/newProject/ProjectTourAgency/Forms/FormClient.resx b/project/newProject/ProjectTourAgency/Forms/FormClient.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/project/newProject/ProjectTourAgency/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/project/newProject/ProjectTourAgency/Forms/FormClients.Designer.cs b/project/newProject/ProjectTourAgency/Forms/FormClients.Designer.cs new file mode 100644 index 0000000..f9bfecd --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormClients.Designer.cs @@ -0,0 +1,126 @@ +namespace ProjectTourAgency.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(); + buttonDelete = new Button(); + buttonUpdate = new Button(); + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDelete); + panel1.Controls.Add(buttonUpdate); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(775, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(149, 371); + panel1.TabIndex = 0; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.free_icon_delete_3807871; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(43, 276); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(61, 59); + buttonDelete.TabIndex = 3; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += buttonDelete_Click; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources.free_icon_edit_8679935; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(43, 142); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(61, 59); + buttonUpdate.TabIndex = 2; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += buttonUpdate_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.free_icon_add_button_5974633; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(43, 25); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(61, 59); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(775, 371); + dataGridViewData.TabIndex = 1; + // + // FormClients + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(924, 371); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormClients"; + StartPosition = FormStartPosition.CenterParent; + Text = "Клиенты"; + Load += FormClients_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonDelete; + private Button buttonUpdate; + private Button buttonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/project/newProject/ProjectTourAgency/Forms/FormClients.cs b/project/newProject/ProjectTourAgency/Forms/FormClients.cs new file mode 100644 index 0000000..b557f14 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormClients.cs @@ -0,0 +1,110 @@ +using ProjectTourAgency.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 ProjectTourAgency.Forms +{ + public partial class FormClients : Form + { + private readonly IUnityContainer _container; + + private readonly IClientRepository _clientRepository; + + public FormClients(IClientRepository clientRepository, IUnityContainer container) + { + 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 buttonUpdate_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 buttonDelete_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() => dataGridViewData.DataSource = _clientRepository.ReadClients(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if(dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["ID"].Value); + return true; + } + } +} diff --git a/project/newProject/ProjectTourAgency/Forms/FormClients.resx b/project/newProject/ProjectTourAgency/Forms/FormClients.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/project/newProject/ProjectTourAgency/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/project/newProject/ProjectTourAgency/Forms/FormEmployee.Designer.cs b/project/newProject/ProjectTourAgency/Forms/FormEmployee.Designer.cs new file mode 100644 index 0000000..3014ad7 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormEmployee.Designer.cs @@ -0,0 +1,118 @@ +namespace ProjectTourAgency.Forms +{ + partial class FormEmployee + { + /// + /// 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() + { + comboBoxJob = new ComboBox(); + label1 = new Label(); + label2 = new Label(); + textBoxName = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // comboBoxJob + // + comboBoxJob.FormattingEnabled = true; + comboBoxJob.Location = new Point(130, 75); + comboBoxJob.Name = "comboBoxJob"; + comboBoxJob.Size = new Size(121, 23); + comboBoxJob.TabIndex = 0; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 75); + label1.Name = "label1"; + label1.Size = new Size(69, 15); + label1.TabIndex = 1; + label1.Text = "Должность"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(12, 31); + label2.Name = "label2"; + label2.Size = new Size(31, 15); + label2.TabIndex = 2; + label2.Text = "Имя"; + // + // textBoxName + // + textBoxName.Location = new Point(130, 28); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(100, 23); + textBoxName.TabIndex = 3; + // + // buttonSave + // + buttonSave.Location = new Point(42, 148); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(155, 148); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отменить"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormEmployee + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(338, 224); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxName); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(comboBoxJob); + Name = "FormEmployee"; + Text = "FormEmployee"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ComboBox comboBoxJob; + private Label label1; + private Label label2; + private TextBox textBoxName; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/project/newProject/ProjectTourAgency/Forms/FormEmployee.cs b/project/newProject/ProjectTourAgency/Forms/FormEmployee.cs new file mode 100644 index 0000000..0026bde --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormEmployee.cs @@ -0,0 +1,87 @@ + +using ProjectEmployeeAgency.Repositories; +using ProjectRouteAgency.Repositories; +using ProjectTourAgency.Enities; +using ProjectTourAgency.Implementations; +using ProjectTourAgency.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 ProjectTourAgency.Forms +{ + public partial class FormEmployee: Form + { + private readonly IEmployeeRepository _employeeRepository; + + private int? _employeeId; + public int Id + { + set + { + try + { + var employee = _employeeRepository.ReadEmployeeById(value); + if (employee == null) + { + throw new InvalidOperationException(nameof(employee)); + } + textBoxName.Text = employee.FullName; + comboBoxJob.SelectedItem = employee.EmployeeJob; + + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении ланных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormEmployee(IEmployeeRepository employeeRepository) + { + InitializeComponent(); + _employeeRepository = employeeRepository ?? + throw new ArgumentNullException(nameof(employeeRepository)); + + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text) || + string.IsNullOrWhiteSpace(comboBoxJob.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_employeeId.HasValue) + { + _employeeRepository.UpdateEmployee(CreateEmployee(_employeeId.Value)); + } + else + { + _employeeRepository.CreateEmployee(CreateEmployee(_employeeId.Value)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + private Employee CreateEmployee(int id) => Employee.CreateEntity(id, textBoxName.Text, (Enities.Enums.EmpoyeeJob)comboBoxJob.SelectedItem!); + } +} diff --git a/project/newProject/ProjectTourAgency/Forms/FormEmployee.resx b/project/newProject/ProjectTourAgency/Forms/FormEmployee.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormEmployee.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/project/newProject/ProjectTourAgency/Forms/FormEmployees.Designer.cs b/project/newProject/ProjectTourAgency/Forms/FormEmployees.Designer.cs new file mode 100644 index 0000000..5105b8f --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormEmployees.Designer.cs @@ -0,0 +1,125 @@ +namespace ProjectTourAgency.Forms +{ + partial class FormEmployees + { + /// + /// 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() + { + dataGridViewData = new DataGridView(); + panel1 = new Panel(); + buttonDelete = new Button(); + buttonUpdate = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(783, 450); + dataGridViewData.TabIndex = 3; + // + // panel1 + // + panel1.Controls.Add(buttonDelete); + panel1.Controls.Add(buttonUpdate); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(783, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(149, 450); + panel1.TabIndex = 2; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.free_icon_delete_3807871; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(43, 276); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(61, 59); + buttonDelete.TabIndex = 3; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += buttonDelete_Click; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources.free_icon_edit_8679935; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(43, 142); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(61, 59); + buttonUpdate.TabIndex = 2; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += buttonUpdate_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.free_icon_add_button_5974633; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(43, 25); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(61, 59); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // FormEmployees + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(932, 450); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormEmployees"; + Text = "FormEmployees"; + Load += FormEmployees_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel1; + private Button buttonDelete; + private Button buttonUpdate; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/project/newProject/ProjectTourAgency/Forms/FormEmployees.cs b/project/newProject/ProjectTourAgency/Forms/FormEmployees.cs new file mode 100644 index 0000000..458e5e0 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormEmployees.cs @@ -0,0 +1,112 @@ +using ProjectEmployeeAgency.Repositories; +using ProjectTourAgency.Implementations; +using ProjectTourAgency.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 ProjectTourAgency.Forms +{ + public partial class FormEmployees: Form + { + private readonly IUnityContainer _container; + + private readonly IEmployeeRepository _employeeRepository; + + public FormEmployees(IEmployeeRepository employeeRepository, IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(_employeeRepository)); + } + + private void FormEmployees_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 buttonUpdate_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 buttonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _employeeRepository.DeleteEmployee(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _employeeRepository.ReadEmployees(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["ID"].Value); + return true; + } + } +} diff --git a/project/newProject/ProjectTourAgency/Forms/FormEmployees.resx b/project/newProject/ProjectTourAgency/Forms/FormEmployees.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormEmployees.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/project/newProject/ProjectTourAgency/Forms/FormRoute.Designer.cs b/project/newProject/ProjectTourAgency/Forms/FormRoute.Designer.cs new file mode 100644 index 0000000..e2d0566 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormRoute.Designer.cs @@ -0,0 +1,165 @@ +namespace ProjectTourAgency.Forms +{ + partial class FormRoute + { + /// + /// 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() + { + textBoxDestination = new TextBox(); + labelDestination = new Label(); + labelDeparture = new Label(); + textBoxDuration = new TextBox(); + labelTourId = new Label(); + textBoxDeparture = new TextBox(); + labelDuration = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + comboBoxTourId = new ComboBox(); + SuspendLayout(); + // + // textBoxDestination + // + textBoxDestination.Location = new Point(144, 32); + textBoxDestination.Name = "textBoxDestination"; + textBoxDestination.Size = new Size(226, 23); + textBoxDestination.TabIndex = 4; + // + // labelDestination + // + labelDestination.AutoSize = true; + labelDestination.Location = new Point(38, 32); + labelDestination.Name = "labelDestination"; + labelDestination.Size = new Size(100, 15); + labelDestination.TabIndex = 3; + labelDestination.Text = "Место прибытия"; + // + // labelDeparture + // + labelDeparture.AutoSize = true; + labelDeparture.Location = new Point(38, 78); + labelDeparture.Name = "labelDeparture"; + labelDeparture.Size = new Size(91, 15); + labelDeparture.TabIndex = 5; + labelDeparture.Text = "Место отбытия"; + // + // textBoxDuration + // + textBoxDuration.Location = new Point(144, 114); + textBoxDuration.Name = "textBoxDuration"; + textBoxDuration.Size = new Size(226, 23); + textBoxDuration.TabIndex = 7; + // + // labelTourId + // + labelTourId.AutoSize = true; + labelTourId.Location = new Point(38, 163); + labelTourId.Name = "labelTourId"; + labelTourId.Size = new Size(94, 15); + labelTourId.TabIndex = 6; + labelTourId.Text = "Стоимость тура"; + // + // textBoxDeparture + // + textBoxDeparture.Location = new Point(144, 75); + textBoxDeparture.Name = "textBoxDeparture"; + textBoxDeparture.Size = new Size(226, 23); + textBoxDeparture.TabIndex = 8; + // + // labelDuration + // + labelDuration.AutoSize = true; + labelDuration.Location = new Point(45, 117); + labelDuration.Name = "labelDuration"; + labelDuration.Size = new Size(84, 15); + labelDuration.TabIndex = 10; + labelDuration.Text = "Дата отбытия"; + // + // buttonSave + // + buttonSave.Location = new Point(63, 251); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 12; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(256, 251); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 13; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // comboBoxTourId + // + comboBoxTourId.FormattingEnabled = true; + comboBoxTourId.Location = new Point(144, 163); + comboBoxTourId.Name = "comboBoxTourId"; + comboBoxTourId.Size = new Size(226, 23); + comboBoxTourId.TabIndex = 14; + // + // FormRoute + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(414, 284); + Controls.Add(comboBoxTourId); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(labelDuration); + Controls.Add(textBoxDeparture); + Controls.Add(textBoxDuration); + Controls.Add(labelTourId); + Controls.Add(labelDeparture); + Controls.Add(textBoxDestination); + Controls.Add(labelDestination); + Name = "FormRoute"; + StartPosition = FormStartPosition.CenterParent; + Text = "Тур"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + private DateTimePicker dateTimePickerDepartureDate; + private TextBox textBoxDestination; + private Label labelDestination; + private Label labelDeparture; + private TextBox textBoxDuration; + private Label labelTourId; + private TextBox textBoxDeparture; + private Label labelDate; + private Label labelDuration; + private TextBox textBoxPrice; + private Button buttonSave; + private Button buttonCancel; + private ComboBox comboBoxTourId; + } +} \ No newline at end of file diff --git a/project/newProject/ProjectTourAgency/Forms/FormRoute.cs b/project/newProject/ProjectTourAgency/Forms/FormRoute.cs new file mode 100644 index 0000000..4603fb4 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormRoute.cs @@ -0,0 +1,91 @@ + +using ProjectRouteAgency.Repositories; +using ProjectTourAgency.Enities; +using ProjectTourAgency.Implementations; +using ProjectTourAgency.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 ProjectTourAgency.Forms +{ + public partial class FormRoute : Form + { + private readonly IRouteRepository _routeRepository; + + private int? _routeId; + public int Id + { + set + { + try + { + var route = _routeRepository.ReadRouteById(value); + if (route == null) + { + throw new InvalidOperationException(nameof(route)); + } + textBoxDestination.Text = route.Destination; + textBoxDeparture.Text = route.Departure; + textBoxDuration.Text = route.Duration.ToString(); + + } + catch(Exception ex) + { + MessageBox.Show(ex.Message,"Ошибка при получении ланных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormRoute(IRouteRepository routeRepository, ITourRepository tourRepository) + { + InitializeComponent(); + _routeRepository = routeRepository ?? + throw new ArgumentNullException(nameof(routeRepository)); + comboBoxTourId.DataSource = tourRepository.ReadTours(); + comboBoxTourId.DisplayMember = "FullName"; + comboBoxTourId.ValueMember = "Id"; + + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxDestination.Text) || + string.IsNullOrWhiteSpace(textBoxDeparture.Text) || string.IsNullOrWhiteSpace(textBoxDuration.Text) + || string.IsNullOrWhiteSpace(textBoxPrice.Text) || string.IsNullOrWhiteSpace(dateTimePickerDepartureDate.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_routeId.HasValue) + { + _routeRepository.UpdateRoute(CreateRoute(_routeId.Value)); + } + else + { + _routeRepository.CreateRoute(CreateRoute(_routeId.Value)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + private Route CreateRoute(int id) => Route.CreateEntity(id, (int)comboBoxTourId.SelectedValue!, textBoxDestination.Text, + textBoxDeparture.Text, int.Parse(textBoxDuration.Text)); + } +} diff --git a/project/newProject/ProjectTourAgency/Forms/FormRoute.resx b/project/newProject/ProjectTourAgency/Forms/FormRoute.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormRoute.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/project/newProject/ProjectTourAgency/Forms/FormRoutes.Designer.cs b/project/newProject/ProjectTourAgency/Forms/FormRoutes.Designer.cs new file mode 100644 index 0000000..dffaca5 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormRoutes.Designer.cs @@ -0,0 +1,125 @@ +namespace ProjectTourAgency.Forms +{ + partial class FormRoutes + { + /// + /// 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() + { + dataGridViewData = new DataGridView(); + panel1 = new Panel(); + buttonDelete = new Button(); + buttonUpdate = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(775, 371); + dataGridViewData.TabIndex = 3; + // + // panel1 + // + panel1.Controls.Add(buttonDelete); + panel1.Controls.Add(buttonUpdate); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(775, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(149, 371); + panel1.TabIndex = 2; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.free_icon_delete_3807871; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(43, 276); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(61, 59); + buttonDelete.TabIndex = 3; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += buttonDelete_Click; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources.free_icon_edit_8679935; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(43, 142); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(61, 59); + buttonUpdate.TabIndex = 2; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += buttonUpdate_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.free_icon_add_button_5974633; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(43, 25); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(61, 59); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // FormTours + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(924, 371); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormTours"; + Text = "Туры"; + Load += FormRoutes_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel1; + private Button buttonDelete; + private Button buttonUpdate; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/project/newProject/ProjectTourAgency/Forms/FormRoutes.cs b/project/newProject/ProjectTourAgency/Forms/FormRoutes.cs new file mode 100644 index 0000000..e9ce87e --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormRoutes.cs @@ -0,0 +1,111 @@ +using ProjectRouteAgency.Repositories; +using ProjectTourAgency.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 ProjectTourAgency.Forms +{ + public partial class FormRoutes : Form + { + private readonly IUnityContainer _container; + + private readonly IRouteRepository _routeRepository; + + public FormRoutes(IRouteRepository routeRepository, IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _routeRepository = routeRepository ?? throw new ArgumentNullException(nameof(_routeRepository)); + } + + private void FormRoutes_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 buttonUpdate_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 buttonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _routeRepository.DeleteRoute(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _routeRepository.ReadRoutes(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["ID"].Value); + return true; + } + } +} diff --git a/project/newProject/ProjectTourAgency/Forms/FormRoutes.resx b/project/newProject/ProjectTourAgency/Forms/FormRoutes.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Forms/FormRoutes.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/project/newProject/ProjectTourAgency/Implementations/AddMoneyRepository.cs b/project/newProject/ProjectTourAgency/Implementations/AddMoneyRepository.cs new file mode 100644 index 0000000..02e56e7 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Implementations/AddMoneyRepository.cs @@ -0,0 +1,39 @@ +using ProjectTourAgency.Enities; +using ProjectTourAgency.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Implementations +{ + internal class AddMoneyRepository : IAddMoneyRepository + + { + public void CreateAddMoney(AddMoney client) + { + + } + + public void DeleteAddMoney(int id) + { + + } + + public AddMoney ReadAddMoneyById(int id) + { + return AddMoney.CreateEntity(0,0,DateTime.Now,0); + } + + public IEnumerable ReadAddMoneys() + { + return []; + } + + public void UpdateAddMoney(AddMoney client) + { + + } + } +} diff --git a/project/newProject/ProjectTourAgency/Implementations/ClientRepository.cs b/project/newProject/ProjectTourAgency/Implementations/ClientRepository.cs new file mode 100644 index 0000000..9ec7f12 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Implementations/ClientRepository.cs @@ -0,0 +1,34 @@ +using ProjectTourAgency.Enities; +using ProjectTourAgency.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Implementations; + +public class ClientRepository : IClientRepository +{ + public void CreateClient(Client client) + { + } + + public void DeleteClient(int id) + { + } + + public Client ReadClientById(int id) + { + return Client.CreateEntity(0, string.Empty, DateTime.Now, string.Empty, 0); + } + + public IEnumerable ReadClients() + { + return []; + } + + public void UpdateClient(Client client) + { + } +} diff --git a/project/newProject/ProjectTourAgency/Implementations/EmployeeRepository.cs b/project/newProject/ProjectTourAgency/Implementations/EmployeeRepository.cs new file mode 100644 index 0000000..d6c71e5 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Implementations/EmployeeRepository.cs @@ -0,0 +1,35 @@ +using ProjectEmployeeAgency.Repositories; +using ProjectTourAgency.Enities; +using ProjectTourAgency.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Implementations; + +public class EmployeeRepository : IEmployeeRepository +{ + public void CreateEmployee(Employee employee) + { + } + + public void DeleteEmployee(int id) + { + } + + public Employee ReadEmployeeById(int id) + { + return Employee.CreateEntity(0, string.Empty,0); + } + + public IEnumerable ReadEmployees() + { + return []; + } + + public void UpdateEmployee(Employee employee) + { + } +} diff --git a/project/newProject/ProjectTourAgency/Implementations/RouteRepository.cs b/project/newProject/ProjectTourAgency/Implementations/RouteRepository.cs new file mode 100644 index 0000000..e2ee252 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Implementations/RouteRepository.cs @@ -0,0 +1,37 @@ +using ProjectRouteAgency.Repositories; +using ProjectTourAgency.Enities; +using ProjectTourAgency.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Implementations; + +public class RouteRepository : IRouteRepository +{ + public void CreateRoute(Route route) + { + + } + + public void DeleteRoute(int id) + { + + } + + public Route ReadRouteById(int id) + { + return Route.CreateEntity(0,0, string.Empty,string.Empty, 0); + } + + public IEnumerable ReadRoutes() + { + return []; + } + + public void UpdateRoute(Route route) + { + } +} diff --git a/project/newProject/ProjectTourAgency/Implementations/TourRepositiry.cs b/project/newProject/ProjectTourAgency/Implementations/TourRepositiry.cs new file mode 100644 index 0000000..0d63b70 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Implementations/TourRepositiry.cs @@ -0,0 +1,35 @@ +using ProjectTourAgency.Enities; +using ProjectTourAgency.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Implementations; + +public class TourRepositiry : ITourRepository +{ + public void CreateTour(Tour tour) + { + + } + + public void DeleteTour(int id) + { + } + + public Tour ReadTourById(int id) + { + return Tour.CreateEntity(0,DateTime.Now,0); + } + + public IEnumerable ReadTours() + { + return []; + } + + public void UpdateTour(Tour tour) + { + } +} diff --git a/project/newProject/ProjectTourAgency/Program.cs b/project/newProject/ProjectTourAgency/Program.cs new file mode 100644 index 0000000..08a2e39 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Program.cs @@ -0,0 +1,36 @@ +using ProjectEmployeeAgency.Repositories; +using ProjectRouteAgency.Repositories; +using ProjectTourAgency.Implementations; +using ProjectTourAgency.Repositories; +using Unity; + +namespace ProjectTourAgency +{ + internal static class Program + { + /// + /// 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(CreateContainer().Resolve()); + } + + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + + return container; + } + } +} \ No newline at end of file diff --git a/project/newProject/ProjectTourAgency/ProjectTourAgency.csproj b/project/newProject/ProjectTourAgency/ProjectTourAgency.csproj new file mode 100644 index 0000000..accbdf0 --- /dev/null +++ b/project/newProject/ProjectTourAgency/ProjectTourAgency.csproj @@ -0,0 +1,30 @@ + + + + WinExe + net8.0-windows + enable + true + enable + + + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + \ No newline at end of file diff --git a/project/newProject/ProjectTourAgency/ProjectTourAgency.sln b/project/newProject/ProjectTourAgency/ProjectTourAgency.sln new file mode 100644 index 0000000..df45f37 --- /dev/null +++ b/project/newProject/ProjectTourAgency/ProjectTourAgency.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34525.116 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectTourAgency", "ProjectTourAgency.csproj", "{1DF30EE1-3015-4980-A3F9-153C7A11049F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1DF30EE1-3015-4980-A3F9-153C7A11049F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1DF30EE1-3015-4980-A3F9-153C7A11049F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1DF30EE1-3015-4980-A3F9-153C7A11049F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1DF30EE1-3015-4980-A3F9-153C7A11049F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E81AC68F-76E2-40C7-8F94-77E003A138B0} + EndGlobalSection +EndGlobal diff --git a/project/newProject/ProjectTourAgency/Properties/Resources.Designer.cs b/project/newProject/ProjectTourAgency/Properties/Resources.Designer.cs new file mode 100644 index 0000000..80fd14f --- /dev/null +++ b/project/newProject/ProjectTourAgency/Properties/Resources.Designer.cs @@ -0,0 +1,113 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectTourAgency.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("ProjectTourAgency.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 free_icon_add_button_5974633 { + get { + object obj = ResourceManager.GetObject("free-icon-add-button-5974633", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap free_icon_delete_3807871 { + get { + object obj = ResourceManager.GetObject("free-icon-delete-3807871", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap free_icon_edit_8679935 { + get { + object obj = ResourceManager.GetObject("free-icon-edit-8679935", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Снимок_экрана_2024_11_08_213926 { + get { + object obj = ResourceManager.GetObject("Снимок экрана 2024-11-08 213926", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Снимок_экрана_2024_11_08_2139261 { + get { + object obj = ResourceManager.GetObject("Снимок экрана 2024-11-08 2139261", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/project/newProject/ProjectTourAgency/Properties/Resources.resx b/project/newProject/ProjectTourAgency/Properties/Resources.resx new file mode 100644 index 0000000..639146d --- /dev/null +++ b/project/newProject/ProjectTourAgency/Properties/Resources.resx @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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\free-icon-edit-8679935.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Снимок экрана 2024-11-08 213926.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\free-icon-add-button-5974633.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Снимок экрана 2024-11-08 2139261.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\free-icon-delete-3807871.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/project/newProject/ProjectTourAgency/Repositories/IAddMoneyRepository.cs b/project/newProject/ProjectTourAgency/Repositories/IAddMoneyRepository.cs new file mode 100644 index 0000000..9f8e7b6 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Repositories/IAddMoneyRepository.cs @@ -0,0 +1,20 @@ +using ProjectTourAgency.Enities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Repositories; + +public interface IAddMoneyRepository +{ + IEnumerable ReadAddMoneys(); + + AddMoney ReadAddMoneyById(int id); + + void CreateAddMoney(AddMoney client); + void UpdateAddMoney(AddMoney client); + + void DeleteAddMoney(int id); +} diff --git a/project/newProject/ProjectTourAgency/Repositories/IClientRepository.cs b/project/newProject/ProjectTourAgency/Repositories/IClientRepository.cs new file mode 100644 index 0000000..2bcd7d9 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Repositories/IClientRepository.cs @@ -0,0 +1,20 @@ +using ProjectTourAgency.Enities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.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/project/newProject/ProjectTourAgency/Repositories/IClientTourRepository.cs b/project/newProject/ProjectTourAgency/Repositories/IClientTourRepository.cs new file mode 100644 index 0000000..c854b3e --- /dev/null +++ b/project/newProject/ProjectTourAgency/Repositories/IClientTourRepository.cs @@ -0,0 +1,17 @@ +using ProjectTourAgency.Enities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Repositories +{ + public interface IClientTourRepository + { + IEnumerable ReadClientTours(int? clientId = null, int? tourId = null); + + + void CreateReceipt(ClientTour clientTour); + } +} diff --git a/project/newProject/ProjectTourAgency/Repositories/IEmployeeRepository.cs b/project/newProject/ProjectTourAgency/Repositories/IEmployeeRepository.cs new file mode 100644 index 0000000..4133a51 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Repositories/IEmployeeRepository.cs @@ -0,0 +1,16 @@ +using ProjectTourAgency.Enities; + +namespace ProjectEmployeeAgency.Repositories; + +public interface IEmployeeRepository +{ + IEnumerable ReadEmployees(); + + Employee ReadEmployeeById(int id); + + void CreateEmployee(Employee tour); + + void UpdateEmployee(Employee tour); + + void DeleteEmployee(int id); +} diff --git a/project/newProject/ProjectTourAgency/Repositories/IRouteRepository.cs b/project/newProject/ProjectTourAgency/Repositories/IRouteRepository.cs new file mode 100644 index 0000000..840ca92 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Repositories/IRouteRepository.cs @@ -0,0 +1,21 @@ +using ProjectTourAgency.Enities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectRouteAgency.Repositories; + +public interface IRouteRepository +{ + IEnumerable ReadRoutes(); + + Route ReadRouteById(int id); + + void CreateRoute(Route tour); + + void UpdateRoute(Route tour); + + void DeleteRoute(int id); +} diff --git a/project/newProject/ProjectTourAgency/Repositories/ITourRepositiry.cs b/project/newProject/ProjectTourAgency/Repositories/ITourRepositiry.cs new file mode 100644 index 0000000..39364e5 --- /dev/null +++ b/project/newProject/ProjectTourAgency/Repositories/ITourRepositiry.cs @@ -0,0 +1,21 @@ +using ProjectTourAgency.Enities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Repositories; + +public interface ITourRepository +{ + IEnumerable ReadTours(); + + Tour ReadTourById(int id); + + void CreateTour(Tour tour); + + void UpdateTour(Tour tour); + + void DeleteTour(int id); +} diff --git a/project/newProject/ProjectTourAgency/Resources/free-icon-add-button-5974633.png b/project/newProject/ProjectTourAgency/Resources/free-icon-add-button-5974633.png new file mode 100644 index 0000000..8ea3150 Binary files /dev/null and b/project/newProject/ProjectTourAgency/Resources/free-icon-add-button-5974633.png differ diff --git a/project/newProject/ProjectTourAgency/Resources/free-icon-delete-3807871.png b/project/newProject/ProjectTourAgency/Resources/free-icon-delete-3807871.png new file mode 100644 index 0000000..f575bf5 Binary files /dev/null and b/project/newProject/ProjectTourAgency/Resources/free-icon-delete-3807871.png differ diff --git a/project/newProject/ProjectTourAgency/Resources/free-icon-edit-8679935.png b/project/newProject/ProjectTourAgency/Resources/free-icon-edit-8679935.png new file mode 100644 index 0000000..26b2fa7 Binary files /dev/null and b/project/newProject/ProjectTourAgency/Resources/free-icon-edit-8679935.png differ diff --git a/project/newProject/ProjectTourAgency/Resources/Снимок экрана 2024-11-08 213926.png b/project/newProject/ProjectTourAgency/Resources/Снимок экрана 2024-11-08 213926.png new file mode 100644 index 0000000..b8b8695 Binary files /dev/null and b/project/newProject/ProjectTourAgency/Resources/Снимок экрана 2024-11-08 213926.png differ diff --git a/project/newProject/ProjectTourAgency/Resources/Снимок экрана 2024-11-08 2139261.png b/project/newProject/ProjectTourAgency/Resources/Снимок экрана 2024-11-08 2139261.png new file mode 100644 index 0000000..b8b8695 Binary files /dev/null and b/project/newProject/ProjectTourAgency/Resources/Снимок экрана 2024-11-08 2139261.png differ