78 lines
2.6 KiB
C#
78 lines
2.6 KiB
C#
using BeautySaloonContracts.BindingModels;
|
|
using BeautySaloonContracts.BusinessLogicsContracts;
|
|
using BeautySaloonContracts.SearchModels;
|
|
|
|
namespace BeautySaloonView
|
|
{
|
|
public partial class FormClientOrders : Form
|
|
{
|
|
private readonly IOrderLogic _logic;
|
|
private int? _idClient;
|
|
public int IdClient { set { _idClient = value; } }
|
|
public FormClientOrders(IOrderLogic logic)
|
|
{
|
|
InitializeComponent();
|
|
_logic = logic;
|
|
}
|
|
private void FormClientOrders_Load(object sender, EventArgs e)
|
|
{
|
|
LoadData();
|
|
}
|
|
private void LoadData()
|
|
{
|
|
try
|
|
{
|
|
var list = _logic.ReadList(new OrderSearchModel
|
|
{
|
|
ClientId = _idClient
|
|
});
|
|
if (list != null)
|
|
{
|
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
dataGridView.DataSource = list;
|
|
dataGridView.Columns["Id"].Visible = false;
|
|
dataGridView.Columns["ClientId"].Visible = false;
|
|
dataGridView.Columns["EmployeeId"].Visible = false;
|
|
dataGridView.Columns["OrderServices"].Visible = false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
|
if (service is FormCreateOrder form)
|
|
{
|
|
form.IdClient = _idClient.Value;
|
|
if (form.ShowDialog() == DialogResult.OK)
|
|
{
|
|
LoadData();
|
|
}
|
|
}
|
|
}
|
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
|
{
|
|
if (dataGridView.SelectedRows.Count == 1)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
|
if (service is FormCreateOrder form)
|
|
{
|
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
form.IdClient = _idClient.Value;
|
|
if (form.ShowDialog() == DialogResult.OK)
|
|
{
|
|
LoadData();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
private void ButtonRef_Click(object sender, EventArgs e)
|
|
{
|
|
LoadData();
|
|
}
|
|
}
|
|
}
|