2024-11-05 03:59:13 +04:00
|
|
|
|
using ProjectGSM.Entities;
|
2024-11-09 03:06:08 +04:00
|
|
|
|
using ProjectGSM.Entities.Enums;
|
2024-11-05 03:59:13 +04:00
|
|
|
|
using ProjectGSM.Repositories;
|
|
|
|
|
|
|
|
|
|
namespace ProjectGSM.Forms
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public partial class FormStatusHistory : Form
|
|
|
|
|
{
|
|
|
|
|
private readonly IStatusHistoryRepository _statusHistoryRepository;
|
|
|
|
|
|
|
|
|
|
|
2024-11-09 03:06:08 +04:00
|
|
|
|
public FormStatusHistory(IStatusHistoryRepository statusHistoryRepository, ICaseRepository caseRepository)
|
2024-11-05 03:59:13 +04:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
_statusHistoryRepository = statusHistoryRepository ??
|
|
|
|
|
throw new
|
|
|
|
|
ArgumentNullException(nameof(statusHistoryRepository));
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
caseBox.DataSource = caseRepository.ReadCases();
|
2024-11-19 00:05:49 +04:00
|
|
|
|
caseBox.DisplayMember = "Description";
|
2024-11-05 03:59:13 +04:00
|
|
|
|
caseBox.SelectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex) { }
|
|
|
|
|
|
2024-11-09 03:06:08 +04:00
|
|
|
|
statusBox.DataSource = Enum.GetValues(typeof(Status));
|
2024-11-05 03:59:13 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2024-11-09 03:06:08 +04:00
|
|
|
|
if (caseBox.SelectedIndex < 0)
|
2024-11-05 03:59:13 +04:00
|
|
|
|
{
|
|
|
|
|
throw new Exception("Имеются незаполненные поля");
|
|
|
|
|
}
|
2024-11-09 03:06:08 +04:00
|
|
|
|
_statusHistoryRepository.CreateStatusHistory(StatusHistory.CreateEntity(caseBox.SelectedIndex, (Status)statusBox.SelectedIndex!, priceNumeric.Value, dateTimePicker1.Value));
|
2024-11-05 03:59:13 +04:00
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
|
|
|
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cancelButton_Click(object sender, EventArgs e) => Close();
|
|
|
|
|
}
|
|
|
|
|
}
|