157 lines
5.7 KiB
C#
157 lines
5.7 KiB
C#
|
using Microsoft.Extensions.Logging;
|
|||
|
using PrecastConcretePlantContracts.BindingModels;
|
|||
|
using PrecastConcretePlantContracts.BusinessLogicsContracts;
|
|||
|
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;
|
|||
|
|
|||
|
namespace PrecastConcretePlantView
|
|||
|
{
|
|||
|
public partial class FormMain : Form
|
|||
|
{
|
|||
|
private readonly ILogger _logger;
|
|||
|
private readonly IOrderLogic _orderLogic;
|
|||
|
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
_logger = logger;
|
|||
|
_orderLogic = orderLogic;
|
|||
|
}
|
|||
|
private void FormMain_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
LoadData();
|
|||
|
}
|
|||
|
private void LoadData()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var list = _orderLogic.ReadList(null);
|
|||
|
if (list != null)
|
|||
|
{
|
|||
|
dataGridView.DataSource = list;
|
|||
|
dataGridView.Columns["ReinforcedId"].Visible = false;
|
|||
|
dataGridView.Columns["ReinforcedName"].AutoSizeMode =
|
|||
|
DataGridViewAutoSizeColumnMode.Fill;
|
|||
|
}
|
|||
|
_logger.LogInformation("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
_logger.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|||
|
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
}
|
|||
|
}
|
|||
|
private void <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
var service = Program.ServiceProvider?.GetService(typeof(FormComponentS));
|
|||
|
if (service is FormComponentS form)
|
|||
|
{
|
|||
|
form.ShowDialog();
|
|||
|
}
|
|||
|
}
|
|||
|
private void <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
var service = Program.ServiceProvider?.GetService(typeof(FormReinforcedS));
|
|||
|
if (service is FormReinforcedS form)
|
|||
|
{
|
|||
|
form.ShowDialog();
|
|||
|
}
|
|||
|
}
|
|||
|
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
|||
|
if (service is FormCreateOrder form)
|
|||
|
{
|
|||
|
form.ShowDialog();
|
|||
|
LoadData();
|
|||
|
}
|
|||
|
}
|
|||
|
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (dataGridView.SelectedRows.Count == 1)
|
|||
|
{
|
|||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|||
|
_logger.LogInformation("<22><><EFBFBD><EFBFBD><EFBFBD> No{id}. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> '<27> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'", id);
|
|||
|
try
|
|||
|
{
|
|||
|
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
|||
|
{
|
|||
|
Id = id
|
|||
|
});
|
|||
|
if (!operationResult)
|
|||
|
{
|
|||
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>.");
|
|||
|
}
|
|||
|
LoadData();
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
_logger.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|||
|
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
private void ButtonOrderReady_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (dataGridView.SelectedRows.Count == 1)
|
|||
|
{
|
|||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|||
|
_logger.LogInformation("<22><><EFBFBD><EFBFBD><EFBFBD> No{id}. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> '<27><><EFBFBD><EFBFBD><EFBFBD>'", id);
|
|||
|
try
|
|||
|
{
|
|||
|
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
|||
|
{
|
|||
|
Id = id
|
|||
|
});
|
|||
|
if (!operationResult)
|
|||
|
{
|
|||
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>.");
|
|||
|
}
|
|||
|
LoadData();
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
_logger.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|||
|
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (dataGridView.SelectedRows.Count == 1)
|
|||
|
{
|
|||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|||
|
_logger.LogInformation("<22><><EFBFBD><EFBFBD><EFBFBD> No{id}. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> '<27><><EFBFBD><EFBFBD><EFBFBD>'", id);
|
|||
|
try
|
|||
|
{
|
|||
|
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
|
|||
|
{
|
|||
|
Id = id
|
|||
|
});
|
|||
|
if (!operationResult)
|
|||
|
{
|
|||
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>.");
|
|||
|
}
|
|||
|
_logger.LogInformation("<22><><EFBFBD><EFBFBD><EFBFBD> No{id} <20><><EFBFBD><EFBFBD><EFBFBD>", id);
|
|||
|
LoadData();
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
_logger.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|||
|
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
private void ButtonRef_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
LoadData();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|