From c29812b2ff37971cb63100690d1bf44c2e7bf848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D1=91=D0=BD=D0=B0=20=D0=A4=D1=80=D0=BE=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0?= Date: Wed, 18 Dec 2024 20:42:44 +0400 Subject: [PATCH] =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectHorseRacing/Forms/FormBuyHorse.cs | 6 +- .../Forms/FormOwnerHorsesReport.Designer.cs | 168 ------------------ .../Forms/FormOwnerHorsesReport.cs | 80 --------- .../ProjectHorseRacing.csproj | 11 ++ 4 files changed, 14 insertions(+), 251 deletions(-) delete mode 100644 ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwnerHorsesReport.Designer.cs delete mode 100644 ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwnerHorsesReport.cs diff --git a/ProjectHorseRacing/ProjectHorseRacing/Forms/FormBuyHorse.cs b/ProjectHorseRacing/ProjectHorseRacing/Forms/FormBuyHorse.cs index c524223..4204e00 100644 --- a/ProjectHorseRacing/ProjectHorseRacing/Forms/FormBuyHorse.cs +++ b/ProjectHorseRacing/ProjectHorseRacing/Forms/FormBuyHorse.cs @@ -13,7 +13,7 @@ public partial class FormBuyHorse : Form IHorseRepository horseRepository) { InitializeComponent(); - _buyHorseRepository = buyHorseRepository ?? + _buyHorseRepository = buyHorseRepository ?? throw new ArgumentNullException(nameof(buyHorseRepository)); comboBoxOwner.DataSource = ownerRepository.ReadOwners(); comboBoxOwner.DisplayMember = "LastName"; @@ -58,8 +58,8 @@ public partial class FormBuyHorse : Form } list.Add(BuyHorseHorse.CreateElement( 0, - Convert.ToInt32(row.Cells["ColumnHorse"].Value),1)); + Convert.ToInt32(row.Cells["ColumnHorse"].Value))); } return list; } -} +} \ No newline at end of file diff --git a/ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwnerHorsesReport.Designer.cs b/ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwnerHorsesReport.Designer.cs deleted file mode 100644 index 596af49..0000000 --- a/ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwnerHorsesReport.Designer.cs +++ /dev/null @@ -1,168 +0,0 @@ -namespace ProjectHorseRacing.Forms -{ - partial class FormOwnerHorsesReport - { - /// - /// 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() - { - label4 = new Label(); - label3 = new Label(); - label2 = new Label(); - label1 = new Label(); - buttonBuild = new Button(); - buttonFile = new Button(); - textBoxFilePath = new TextBox(); - comboBoxOwner = new ComboBox(); - dateTimePickerStart = new DateTimePicker(); - dateTimePickerEnd = new DateTimePicker(); - SuspendLayout(); - // - // label4 - // - label4.AutoSize = true; - label4.Location = new Point(33, 193); - label4.Name = "label4"; - label4.Size = new Size(90, 20); - label4.TabIndex = 29; - label4.Text = "Дата конца:"; - // - // label3 - // - label3.AutoSize = true; - label3.Location = new Point(33, 144); - label3.Name = "label3"; - label3.Size = new Size(97, 20); - label3.TabIndex = 28; - label3.Text = "Дата начала:"; - // - // label2 - // - label2.AutoSize = true; - label2.Location = new Point(33, 88); - label2.Name = "label2"; - label2.Size = new Size(78, 20); - label2.TabIndex = 27; - label2.Text = "Владелец:"; - // - // label1 - // - label1.AutoSize = true; - label1.Location = new Point(33, 36); - label1.Name = "label1"; - label1.Size = new Size(112, 20); - label1.TabIndex = 26; - label1.Text = "Путь до файла:"; - // - // buttonBuild - // - buttonBuild.Location = new Point(33, 246); - buttonBuild.Margin = new Padding(3, 4, 3, 4); - buttonBuild.Name = "buttonBuild"; - buttonBuild.Size = new Size(338, 31); - buttonBuild.TabIndex = 25; - buttonBuild.Text = "Сформировать"; - buttonBuild.UseVisualStyleBackColor = true; - buttonBuild.Click += buttonBuild_Click; - // - // buttonFile - // - buttonFile.Location = new Point(339, 32); - buttonFile.Margin = new Padding(3, 4, 3, 4); - buttonFile.Name = "buttonFile"; - buttonFile.Size = new Size(30, 31); - buttonFile.TabIndex = 24; - buttonFile.Text = "..."; - buttonFile.UseVisualStyleBackColor = true; - buttonFile.Click += buttonFile_Click; - // - // textBoxFilePath - // - textBoxFilePath.Location = new Point(143, 32); - textBoxFilePath.Margin = new Padding(3, 4, 3, 4); - textBoxFilePath.Name = "textBoxFilePath"; - textBoxFilePath.Size = new Size(189, 27); - textBoxFilePath.TabIndex = 23; - // - // comboBoxOwner - // - comboBoxOwner.FormattingEnabled = true; - comboBoxOwner.Location = new Point(143, 84); - comboBoxOwner.Margin = new Padding(3, 4, 3, 4); - comboBoxOwner.Name = "comboBoxOwner"; - comboBoxOwner.Size = new Size(226, 28); - comboBoxOwner.TabIndex = 22; - // - // dateTimePickerStart - // - dateTimePickerStart.Location = new Point(143, 137); - dateTimePickerStart.Margin = new Padding(3, 4, 3, 4); - dateTimePickerStart.Name = "dateTimePickerStart"; - dateTimePickerStart.Size = new Size(228, 27); - dateTimePickerStart.TabIndex = 21; - // - // dateTimePickerEnd - // - dateTimePickerEnd.Location = new Point(143, 188); - dateTimePickerEnd.Margin = new Padding(3, 4, 3, 4); - dateTimePickerEnd.Name = "dateTimePickerEnd"; - dateTimePickerEnd.Size = new Size(228, 27); - dateTimePickerEnd.TabIndex = 20; - // - // FormOwnerHorsesReport - // - AutoScaleDimensions = new SizeF(8F, 20F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(413, 298); - Controls.Add(label4); - Controls.Add(label3); - Controls.Add(label2); - Controls.Add(label1); - Controls.Add(buttonBuild); - Controls.Add(buttonFile); - Controls.Add(textBoxFilePath); - Controls.Add(comboBoxOwner); - Controls.Add(dateTimePickerStart); - Controls.Add(dateTimePickerEnd); - Name = "FormOwnerHorsesReport"; - Text = "Отчет по покупке лошадей"; - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private Label label4; - private Label label3; - private Label label2; - private Label label1; - private Button buttonBuild; - private Button buttonFile; - private TextBox textBoxFilePath; - private ComboBox comboBoxOwner; - private DateTimePicker dateTimePickerStart; - private DateTimePicker dateTimePickerEnd; - } -} \ No newline at end of file diff --git a/ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwnerHorsesReport.cs b/ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwnerHorsesReport.cs deleted file mode 100644 index 31b5390..0000000 --- a/ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwnerHorsesReport.cs +++ /dev/null @@ -1,80 +0,0 @@ -using ProjectHorseRacing.Reports; -using ProjectHorseRacing.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 ProjectHorseRacing.Forms -{ - public partial class FormOwnerHorsesReport : Form - { - private readonly IUnityContainer _container; - - public FormOwnerHorsesReport(IUnityContainer container, IOwnerRepository ownerRepository) - { - InitializeComponent(); - _container = container ?? throw new ArgumentNullException(nameof(container)); - - comboBoxOwner.DataSource = ownerRepository.ReadOwners(); - comboBoxOwner.DisplayMember = "LastName"; - comboBoxOwner.ValueMember = "Id"; - } - - private void buttonBuild_Click(object sender, EventArgs e) - { - try - { - if (string.IsNullOrWhiteSpace(textBoxFilePath.Text)) - { - throw new Exception("Отсутствует имя файла для отчета"); - } - if (comboBoxOwner.SelectedIndex < 0) - { - throw new Exception("Не выбран корм"); - } - if (dateTimePickerEnd.Value <= dateTimePickerStart.Value) - { - throw new Exception("Дата начала должна быть раньше даты окончания"); - } - if (_container.Resolve().CreateTable(textBoxFilePath.Text, 4, (int)comboBoxOwner.SelectedValue!, dateTimePickerStart.Value, dateTimePickerEnd.Value)) - { - MessageBox.Show("Документ сформирован", - "Формирование документа", - MessageBoxButtons.OK, - MessageBoxIcon.Information); - } - else - { - MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", - "Формирование документа", - MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при создании отчета", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void buttonFile_Click(object sender, EventArgs e) - { - var sfd = new SaveFileDialog() - { - Filter = "Excel Files | *.xlsx" - }; - if (sfd.ShowDialog() != DialogResult.OK) - { - return; - } - textBoxFilePath.Text = sfd.FileName; - } - } -} diff --git a/ProjectHorseRacing/ProjectHorseRacing/ProjectHorseRacing.csproj b/ProjectHorseRacing/ProjectHorseRacing/ProjectHorseRacing.csproj index accbdf0..2f5c04a 100644 --- a/ProjectHorseRacing/ProjectHorseRacing/ProjectHorseRacing.csproj +++ b/ProjectHorseRacing/ProjectHorseRacing/ProjectHorseRacing.csproj @@ -9,7 +9,18 @@ + + + + + + + + + + +