изменения
This commit is contained in:
parent
d590a26fb9
commit
19cebdffb2
@ -24,4 +24,15 @@ public class BuyHorse
|
||||
BuyHorseHorses = buyHorseHorses
|
||||
};
|
||||
}
|
||||
|
||||
public static BuyHorse CreateEntity(TempBuyHorseHorse tempBuyHorseHorse, IEnumerable<BuyHorseHorse> buyHorseHorses)
|
||||
{
|
||||
return new BuyHorse
|
||||
{
|
||||
Id = tempBuyHorseHorse.Id,
|
||||
OwnersId = tempBuyHorseHorse.OwnersId,
|
||||
DatePurchase = tempBuyHorseHorse.DatePurchase,
|
||||
BuyHorseHorses = buyHorseHorses
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -13,12 +13,15 @@ public class BuyHorseHorse
|
||||
|
||||
public int HorseId { get; private set; }
|
||||
|
||||
public static BuyHorseHorse CreateElement(int id, int horseId)
|
||||
public int Cost { get; private set; }
|
||||
|
||||
public static BuyHorseHorse CreateElement(int id, int horseId, int cost)
|
||||
{
|
||||
return new BuyHorseHorse
|
||||
{
|
||||
Id = id,
|
||||
HorseId = horseId
|
||||
HorseId = horseId,
|
||||
Cost = cost
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectHorseRacing.Entities;
|
||||
|
||||
public class TempBuyHorseHorse
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int OwnersId { get; private set; }
|
||||
public DateTime DatePurchase { get; private set; }
|
||||
public int HorseId { get; private set; }
|
||||
public int Cost { get; private set; }
|
||||
}
|
@ -58,7 +58,7 @@ public partial class FormBuyHorse : Form
|
||||
}
|
||||
list.Add(BuyHorseHorse.CreateElement(
|
||||
0,
|
||||
Convert.ToInt32(row.Cells["ColumnHorse"].Value)));
|
||||
Convert.ToInt32(row.Cells["ColumnHorse"].Value),1));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
168
ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwnerHorsesReport.Designer.cs
generated
Normal file
168
ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwnerHorsesReport.Designer.cs
generated
Normal file
@ -0,0 +1,168 @@
|
||||
namespace ProjectHorseRacing.Forms
|
||||
{
|
||||
partial class FormOwnerHorsesReport
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
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<TableReport>().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;
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ namespace ProjectHorseRacing.Repositories;
|
||||
|
||||
public interface IBuyHorseRepository
|
||||
{
|
||||
IEnumerable<BuyHorse> ReadBuyHorse();
|
||||
IEnumerable<BuyHorse> ReadBuyHorse(DateTime? dateForm = null, DateTime? dateTo = null, int? ownersId = null);
|
||||
|
||||
void CreateBuyHorse(BuyHorse buyHorse);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user