From 4b6a46d586829c8033487e390a263dcc74e95837 Mon Sep 17 00:00:00 2001 From: Tonb73 Date: Sun, 10 Nov 2024 16:15:39 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A5=D0=BE=D1=87=D0=B5=D1=82=D1=81=D1=8F=20?= =?UTF-8?q?=D0=BF=D0=BB=D0=B0=D0=BA=D0=B0=D1=82=D1=8C...=20=D0=92=D0=B8?= =?UTF-8?q?=D0=B4=D0=B5=D0=BE=20=D0=BA=D0=BE=D0=BD=D1=87=D0=B8=D0=BB=D0=B8?= =?UTF-8?q?=D1=81=D1=8C,=20=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B1=D0=BB=D0=B5?= =?UTF-8?q?=D0=BC=D1=8B=20=D0=BD=D0=B5=D1=82...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectTourAgency/Enities/ClientTour.cs | 7 +- .../FormTourAgency.Designer.cs | 95 +++++------ project/ProjectTourAgency/FormTourAgency.cs | 73 ++++++++- .../Forms/FormClientTour.Designer.cs | 149 ++++++++++++++++++ .../ProjectTourAgency/Forms/FormClientTour.cs | 70 ++++++++ .../Forms/FormClientTour.resx | 126 +++++++++++++++ .../Forms/FormReceipts.Designer.cs | 97 ++++++++++++ .../ProjectTourAgency/Forms/FormReceipts.cs | 68 ++++++++ .../ProjectTourAgency/Forms/FormReceipts.resx | 120 ++++++++++++++ project/ProjectTourAgency/Program.cs | 2 +- .../Repositories/IClientTourRepisitory.cs | 18 +++ 11 files changed, 772 insertions(+), 53 deletions(-) create mode 100644 project/ProjectTourAgency/Forms/FormClientTour.Designer.cs create mode 100644 project/ProjectTourAgency/Forms/FormClientTour.cs create mode 100644 project/ProjectTourAgency/Forms/FormClientTour.resx create mode 100644 project/ProjectTourAgency/Forms/FormReceipts.Designer.cs create mode 100644 project/ProjectTourAgency/Forms/FormReceipts.cs create mode 100644 project/ProjectTourAgency/Forms/FormReceipts.resx create mode 100644 project/ProjectTourAgency/Repositories/IClientTourRepisitory.cs diff --git a/project/ProjectTourAgency/Enities/ClientTour.cs b/project/ProjectTourAgency/Enities/ClientTour.cs index 5a5e4ef..a851770 100644 --- a/project/ProjectTourAgency/Enities/ClientTour.cs +++ b/project/ProjectTourAgency/Enities/ClientTour.cs @@ -11,15 +11,16 @@ public class ClientTour { public int ClientId { get; private set; } public int TourId { get; private set; } - public ClientSocialStatus ClientSocialStatus { get; private set; } - public static ClientTour CreateEntity(int clientId, int tourId, ClientSocialStatus clientSocialStatus) + public int Count { get; private set; } + + public static ClientTour CreateEntity(int clientId, int tourId, int count) { return new ClientTour { ClientId = clientId, TourId = tourId, - ClientSocialStatus = clientSocialStatus + Count = count }; } diff --git a/project/ProjectTourAgency/FormTourAgency.Designer.cs b/project/ProjectTourAgency/FormTourAgency.Designer.cs index 49a19be..f4b395f 100644 --- a/project/ProjectTourAgency/FormTourAgency.Designer.cs +++ b/project/ProjectTourAgency/FormTourAgency.Designer.cs @@ -29,69 +29,74 @@ private void InitializeComponent() { menuStrip1 = new MenuStrip(); - справочникиToolStripMenuItem = new ToolStripMenuItem(); - клиентыToolStripMenuItem = new ToolStripMenuItem(); - турыToolStripMenuItem = new ToolStripMenuItem(); - чекиToolStripMenuItem = new ToolStripMenuItem(); - предостовляемыеСкидкиToolStripMenuItem = new ToolStripMenuItem(); - операцииToolStripMenuItem = new ToolStripMenuItem(); - оформитПоездкуToolStripMenuItem = new ToolStripMenuItem(); + MenuToolStripMenuItem = new ToolStripMenuItem(); + ClientsToolStripMenuItem = new ToolStripMenuItem(); + ToursToolStripMenuItem = new ToolStripMenuItem(); + ReceiptsToolStripMenuItem = new ToolStripMenuItem(); + DiscountsToolStripMenuItem = new ToolStripMenuItem(); + OperationsToolStripMenuItem = new ToolStripMenuItem(); + CLientTourToolStripMenuItem = new ToolStripMenuItem(); отчетыToolStripMenuItem = new ToolStripMenuItem(); menuStrip1.SuspendLayout(); SuspendLayout(); // // menuStrip1 // - menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem }); + 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"; // - // справочникиToolStripMenuItem + // MenuToolStripMenuItem // - справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { клиентыToolStripMenuItem, турыToolStripMenuItem, чекиToolStripMenuItem, предостовляемыеСкидкиToolStripMenuItem }); - справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; - справочникиToolStripMenuItem.Size = new Size(94, 20); - справочникиToolStripMenuItem.Text = "Справочники"; + MenuToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ClientsToolStripMenuItem, ToursToolStripMenuItem, ReceiptsToolStripMenuItem, DiscountsToolStripMenuItem }); + MenuToolStripMenuItem.Name = "MenuToolStripMenuItem"; + MenuToolStripMenuItem.Size = new Size(94, 20); + MenuToolStripMenuItem.Text = "Справочники"; // - // клиентыToolStripMenuItem + // ClientsToolStripMenuItem // - клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; - клиентыToolStripMenuItem.Size = new Size(217, 22); - клиентыToolStripMenuItem.Text = "Клиенты"; + ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem"; + ClientsToolStripMenuItem.Size = new Size(217, 22); + ClientsToolStripMenuItem.Text = "Клиенты"; + ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click; // - // турыToolStripMenuItem + // ToursToolStripMenuItem // - турыToolStripMenuItem.Name = "турыToolStripMenuItem"; - турыToolStripMenuItem.Size = new Size(217, 22); - турыToolStripMenuItem.Text = "Туры"; + ToursToolStripMenuItem.Name = "ToursToolStripMenuItem"; + ToursToolStripMenuItem.Size = new Size(217, 22); + ToursToolStripMenuItem.Text = "Туры"; + ToursToolStripMenuItem.Click += ToursToolStripMenuItem_Click; // - // чекиToolStripMenuItem + // ReceiptsToolStripMenuItem // - чекиToolStripMenuItem.Name = "чекиToolStripMenuItem"; - чекиToolStripMenuItem.Size = new Size(217, 22); - чекиToolStripMenuItem.Text = "Чеки"; + ReceiptsToolStripMenuItem.Name = "ReceiptsToolStripMenuItem"; + ReceiptsToolStripMenuItem.Size = new Size(217, 22); + ReceiptsToolStripMenuItem.Text = "Чеки"; + ReceiptsToolStripMenuItem.Click += ReceiptsToolStripMenuItem_Click; // - // предостовляемыеСкидкиToolStripMenuItem + // DiscountsToolStripMenuItem // - предостовляемыеСкидкиToolStripMenuItem.Name = "предостовляемыеСкидкиToolStripMenuItem"; - предостовляемыеСкидкиToolStripMenuItem.Size = new Size(217, 22); - предостовляемыеСкидкиToolStripMenuItem.Text = "Предостовляемые скидки"; + DiscountsToolStripMenuItem.Name = "DiscountsToolStripMenuItem"; + DiscountsToolStripMenuItem.Size = new Size(217, 22); + DiscountsToolStripMenuItem.Text = "Предостовляемые скидки"; + DiscountsToolStripMenuItem.Click += DiscountsToolStripMenuItem_Click; // - // операцииToolStripMenuItem + // OperationsToolStripMenuItem // - операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { оформитПоездкуToolStripMenuItem }); - операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; - операцииToolStripMenuItem.Size = new Size(75, 20); - операцииToolStripMenuItem.Text = "Операции"; + OperationsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { CLientTourToolStripMenuItem }); + OperationsToolStripMenuItem.Name = "OperationsToolStripMenuItem"; + OperationsToolStripMenuItem.Size = new Size(75, 20); + OperationsToolStripMenuItem.Text = "Операции"; // - // оформитПоездкуToolStripMenuItem + // CLientTourToolStripMenuItem // - оформитПоездкуToolStripMenuItem.Name = "оформитПоездкуToolStripMenuItem"; - оформитПоездкуToolStripMenuItem.Size = new Size(173, 22); - оформитПоездкуToolStripMenuItem.Text = "Оформит поездку"; + CLientTourToolStripMenuItem.Name = "CLientTourToolStripMenuItem"; + CLientTourToolStripMenuItem.Size = new Size(180, 22); + CLientTourToolStripMenuItem.Text = "Оформит поездку"; + CLientTourToolStripMenuItem.Click += CLientTourToolStripMenuItem_Click; // // отчетыToolStripMenuItem // @@ -121,13 +126,13 @@ #endregion private MenuStrip menuStrip1; - private ToolStripMenuItem справочникиToolStripMenuItem; - private ToolStripMenuItem операцииToolStripMenuItem; + private ToolStripMenuItem MenuToolStripMenuItem; + private ToolStripMenuItem OperationsToolStripMenuItem; private ToolStripMenuItem отчетыToolStripMenuItem; - private ToolStripMenuItem клиентыToolStripMenuItem; - private ToolStripMenuItem турыToolStripMenuItem; - private ToolStripMenuItem чекиToolStripMenuItem; - private ToolStripMenuItem предостовляемыеСкидкиToolStripMenuItem; - private ToolStripMenuItem оформитПоездкуToolStripMenuItem; + private ToolStripMenuItem ClientsToolStripMenuItem; + private ToolStripMenuItem ToursToolStripMenuItem; + private ToolStripMenuItem ReceiptsToolStripMenuItem; + private ToolStripMenuItem DiscountsToolStripMenuItem; + private ToolStripMenuItem CLientTourToolStripMenuItem; } } diff --git a/project/ProjectTourAgency/FormTourAgency.cs b/project/ProjectTourAgency/FormTourAgency.cs index 70b18a8..d4f3488 100644 --- a/project/ProjectTourAgency/FormTourAgency.cs +++ b/project/ProjectTourAgency/FormTourAgency.cs @@ -1,10 +1,75 @@ -namespace ProjectTourAgency +using ProjectTourAgency.Forms; +using Unity; + +namespace ProjectTourAgency; + +public partial class FormTourAgency : Form { - public partial class FormTourAgency : Form + private readonly IUnityContainer _container; + public FormTourAgency(IUnityContainer container) { - public FormTourAgency() + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + } + + private void ClientsToolStripMenuItem_Click(object sender, EventArgs e) + { + try { - InitializeComponent(); + _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); + } + } + + private void ReceiptsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void DiscountsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void CLientTourToolStripMenuItem_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/Forms/FormClientTour.Designer.cs b/project/ProjectTourAgency/Forms/FormClientTour.Designer.cs new file mode 100644 index 0000000..756c404 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormClientTour.Designer.cs @@ -0,0 +1,149 @@ +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() + { + comboBoxClientId = new ComboBox(); + labelCLientId = new Label(); + groupBox1 = new GroupBox(); + dataGridViewReceipts = new DataGridView(); + ColumnTour = new DataGridViewComboBoxColumn(); + ColumnReceipt = new DataGridViewTextBoxColumn(); + buttonCancel = new Button(); + buttonSave = new Button(); + groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewReceipts).BeginInit(); + SuspendLayout(); + // + // comboBoxClientId + // + comboBoxClientId.FormattingEnabled = true; + comboBoxClientId.Location = new Point(208, 9); + comboBoxClientId.Name = "comboBoxClientId"; + comboBoxClientId.Size = new Size(164, 23); + comboBoxClientId.TabIndex = 7; + // + // labelCLientId + // + labelCLientId.AutoSize = true; + labelCLientId.Location = new Point(37, 12); + labelCLientId.Name = "labelCLientId"; + labelCLientId.Size = new Size(142, 15); + labelCLientId.TabIndex = 6; + labelCLientId.Text = "Идентификатор Клиента"; + // + // groupBox1 + // + groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBox1.Controls.Add(dataGridViewReceipts); + groupBox1.Location = new Point(37, 38); + groupBox1.Name = "groupBox1"; + groupBox1.Size = new Size(326, 337); + groupBox1.TabIndex = 8; + groupBox1.TabStop = false; + groupBox1.Text = "groupBox1"; + // + // dataGridViewReceipts + // + dataGridViewReceipts.AllowUserToResizeColumns = false; + dataGridViewReceipts.AllowUserToResizeRows = false; + dataGridViewReceipts.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridViewReceipts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewReceipts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewReceipts.Columns.AddRange(new DataGridViewColumn[] { ColumnTour, ColumnReceipt }); + dataGridViewReceipts.Location = new Point(6, 22); + dataGridViewReceipts.MultiSelect = false; + dataGridViewReceipts.Name = "dataGridViewReceipts"; + dataGridViewReceipts.RowHeadersVisible = false; + dataGridViewReceipts.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewReceipts.Size = new Size(314, 309); + dataGridViewReceipts.TabIndex = 9; + // + // ColumnTour + // + ColumnTour.HeaderText = "Туры"; + ColumnTour.Name = "ColumnTour"; + // + // ColumnReceipt + // + ColumnReceipt.HeaderText = "Ид Чека"; + ColumnReceipt.Name = "ColumnReceipt"; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(285, 397); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 10; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonSave.Location = new Point(43, 397); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 11; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // FormClientTour + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(398, 432); + Controls.Add(buttonSave); + Controls.Add(buttonCancel); + Controls.Add(groupBox1); + Controls.Add(comboBoxClientId); + Controls.Add(labelCLientId); + Name = "FormClientTour"; + Text = "FormClientTour"; + groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewReceipts).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ComboBox comboBoxClientId; + private Label labelCLientId; + private GroupBox groupBox1; + private DataGridView dataGridViewReceipts; + private DataGridViewCheckBoxColumn Column1; + private Button button1; + private Button buttonCancel; + private Button buttonSave; + private DataGridViewComboBoxColumn ColumnTour; + private DataGridViewTextBoxColumn ColumnReceipt; + } +} \ 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..20f78f1 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormClientTour.cs @@ -0,0 +1,70 @@ +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.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectTourAgency.Forms +{ + public partial class FormClientTour : Form + { + private readonly IReceiptRepository _receiptRepository; + public FormClientTour(IReceiptRepository receiptRepository, + IClientRepository clientRepository, ITourRepository tourRepository) + { + InitializeComponent(); + _receiptRepository = receiptRepository ?? + throw new ArgumentNullException(nameof(receiptRepository)); + + comboBoxClientId.DataSource = clientRepository.ReadClients(); + comboBoxClientId.DisplayMember = "FullName"; + comboBoxClientId.ValueMember = "Id"; + + ColumnTour.DataSource = tourRepository.ReadTours(); + ColumnTour.DisplayMember = "Departure"; + ColumnTour.ValueMember = "Id"; + + + } + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (dataGridViewReceipts.RowCount < 1 || + comboBoxClientId.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + _receiptRepository.CreateReceipt(Receipt.CreateEntity((int)comboBoxClientId.SelectedValue!, Convert.ToInt32(ColumnTour.ValueMember), 0, 0)); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private List CreateListClientTourFromDataGrid() + { + var list = new List(); + foreach(DataGridViewRow row in dataGridViewReceipts.Rows) + { + if (row.Cells["ColumnTour"].Value == null || row.Cells["ColumnReceipt"].Value == null) + { + continue; + } + + list.Add(Receipt.CreateEntity((int)comboBoxClientId.SelectedValue!,Convert.ToInt32(ColumnTour.ValueMember),0,0)); + } + return list; + } + } +} diff --git a/project/ProjectTourAgency/Forms/FormClientTour.resx b/project/ProjectTourAgency/Forms/FormClientTour.resx new file mode 100644 index 0000000..46573ae --- /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/FormReceipts.Designer.cs b/project/ProjectTourAgency/Forms/FormReceipts.Designer.cs new file mode 100644 index 0000000..021e39d --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormReceipts.Designer.cs @@ -0,0 +1,97 @@ +namespace ProjectTourAgency.Forms +{ + partial class FormReceipts + { + /// + /// 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(775, 371); + dataGridViewData.TabIndex = 5; + // + // panel1 + // + 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 = 4; + // + // 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; + // + // FormReceipts + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(924, 371); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormReceipts"; + Text = "FormReceipts"; + Load += FormReceipts_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/FormReceipts.cs b/project/ProjectTourAgency/Forms/FormReceipts.cs new file mode 100644 index 0000000..5e05e1f --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormReceipts.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 FormReceipts : Form + { + private readonly IUnityContainer _container; + + private readonly IReceiptRepository _receiptRepository; + + public FormReceipts(IReceiptRepository ReceiptRepository, IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _receiptRepository = ReceiptRepository ?? throw new ArgumentNullException(nameof(_receiptRepository)); + } + + private void FormReceipts_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 = _receiptRepository.ReadReceipts(); + + 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/FormReceipts.resx b/project/ProjectTourAgency/Forms/FormReceipts.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormReceipts.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/Program.cs b/project/ProjectTourAgency/Program.cs index 59c6dd9..3e91d8d 100644 --- a/project/ProjectTourAgency/Program.cs +++ b/project/ProjectTourAgency/Program.cs @@ -25,7 +25,7 @@ namespace ProjectTourAgency container.RegisterType(); container.RegisterType(); container.RegisterType(); - container.RegisterType(); + container.RegisterType(); return container; } diff --git a/project/ProjectTourAgency/Repositories/IClientTourRepisitory.cs b/project/ProjectTourAgency/Repositories/IClientTourRepisitory.cs new file mode 100644 index 0000000..28aa9a7 --- /dev/null +++ b/project/ProjectTourAgency/Repositories/IClientTourRepisitory.cs @@ -0,0 +1,18 @@ +using ProjectTourAgency.Enities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTourAgency.Repositories +{ + public interface IClientTourRepisitory + { + IEnumerable ReadClientTours(DateTime? dateFrom = null, + DateTime? dateTo = null, int? clientId = null, int? tourId = null); + + + void CreateReceipt(Receipt receipt); + } +}