2024-06-23 17:04:26 +04:00
|
|
|
|
using Contracts.BindingModels;
|
|
|
|
|
using Contracts.BusinessLogicContracts;
|
|
|
|
|
using Contracts.SearchModels;
|
|
|
|
|
using Contracts.ViewModels;
|
|
|
|
|
using DataModels.Models;
|
|
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Microsoft.VisualBasic.Logging;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace WinFormsApp
|
|
|
|
|
{
|
|
|
|
|
public partial class FormSuppliers : Form
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
private readonly ISupplierLogic _supplierLogic;
|
|
|
|
|
private readonly IProductLogic _productLogic;
|
|
|
|
|
public FormSuppliers(ILogger<FormMain> logger, ISupplierLogic supplierLogic, IProductLogic productLogic)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
_supplierLogic = supplierLogic;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_productLogic = productLogic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FormSuppliers_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadData()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var list = _supplierLogic.ReadList(null);
|
|
|
|
|
if (list != null)
|
|
|
|
|
{
|
|
|
|
|
dataGridView.DataSource = list;
|
|
|
|
|
}
|
2024-06-23 23:07:41 +04:00
|
|
|
|
_logger.LogInformation("Загрузка компьютеров");
|
2024-06-23 17:04:26 +04:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2024-06-23 23:07:41 +04:00
|
|
|
|
_logger.LogError(ex, "Ошибка загрузки компьютеров");
|
2024-06-23 17:04:26 +04:00
|
|
|
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-23 23:07:41 +04:00
|
|
|
|
private void buttonAdd_Click(object sender, EventArgs e)
|
2024-06-23 17:04:26 +04:00
|
|
|
|
{
|
2024-06-23 23:07:41 +04:00
|
|
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormSupplier));
|
|
|
|
|
if (service is FormSupplier form)
|
2024-06-23 17:04:26 +04:00
|
|
|
|
{
|
2024-06-23 23:07:41 +04:00
|
|
|
|
if (form.ShowDialog() == DialogResult.OK)
|
2024-06-23 17:04:26 +04:00
|
|
|
|
{
|
2024-06-23 23:07:41 +04:00
|
|
|
|
LoadData();
|
2024-06-23 17:04:26 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-23 23:07:41 +04:00
|
|
|
|
private void buttonEdit_Click(object sender, EventArgs e)
|
2024-06-23 17:04:26 +04:00
|
|
|
|
{
|
|
|
|
|
|
2024-06-23 23:07:41 +04:00
|
|
|
|
if (dataGridView.SelectedRows.Count == 1)
|
2024-06-23 19:31:00 +04:00
|
|
|
|
{
|
2024-06-23 23:07:41 +04:00
|
|
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormSupplier));
|
|
|
|
|
if (service is FormSupplier form)
|
2024-06-23 19:31:00 +04:00
|
|
|
|
{
|
2024-06-23 23:07:41 +04:00
|
|
|
|
form.Id = (Guid)dataGridView.SelectedRows[0].Cells["Id"].Value;
|
|
|
|
|
if (form.ShowDialog() == DialogResult.OK)
|
2024-06-23 19:31:00 +04:00
|
|
|
|
{
|
2024-06-23 23:07:41 +04:00
|
|
|
|
LoadData();
|
2024-06-23 19:31:00 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-06-23 18:55:46 +04:00
|
|
|
|
}
|
2024-06-23 17:04:26 +04:00
|
|
|
|
}
|
|
|
|
|
}
|