138 lines
4.1 KiB
C#
138 lines
4.1 KiB
C#
using RestaurantContracts.BindingModels;
|
|
using RestaurantContracts.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 RestaurantView
|
|
{
|
|
public partial class FormMain : Form
|
|
{
|
|
private readonly IOrderLogic _orderLogic;
|
|
|
|
private readonly IBackUpLogic _backUpLogic;
|
|
|
|
public FormMain(IOrderLogic orderLogic, IBackUpLogic backUpLogic)
|
|
{
|
|
InitializeComponent();
|
|
_orderLogic = orderLogic;
|
|
_backUpLogic = backUpLogic;
|
|
}
|
|
|
|
private void LoadData()
|
|
{
|
|
try
|
|
{
|
|
var list = _orderLogic.ReadList(null);
|
|
if (list != null)
|
|
{
|
|
dataGridView.DataSource = list;
|
|
dataGridView.Columns["ClientId"].Visible = false;
|
|
dataGridView.Columns["OrderProducts"].Visible = false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void FormMain_Load(object sender, EventArgs e)
|
|
{
|
|
LoadData();
|
|
}
|
|
|
|
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
|
if (service is FormClients form)
|
|
{
|
|
form.ShowDialog();
|
|
}
|
|
}
|
|
|
|
private void ProvidersToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormProviders));
|
|
if (service is FormProviders form)
|
|
{
|
|
form.ShowDialog();
|
|
}
|
|
}
|
|
|
|
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
|
if (service is FormComponents form)
|
|
{
|
|
form.ShowDialog();
|
|
}
|
|
}
|
|
|
|
private void ProductsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormProducts));
|
|
if (service is FormProducts form)
|
|
{
|
|
form.ShowDialog();
|
|
}
|
|
}
|
|
|
|
private void buttonAdd_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
|
if (service is FormCreateOrder form)
|
|
{
|
|
form.ShowDialog();
|
|
LoadData();
|
|
}
|
|
}
|
|
|
|
private void buttonUpd_Click(object sender, EventArgs e)
|
|
{
|
|
LoadData();
|
|
}
|
|
|
|
private void backUpToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (_backUpLogic != null)
|
|
{
|
|
var fbd = new FolderBrowserDialog();
|
|
if (fbd.ShowDialog() == DialogResult.OK)
|
|
{
|
|
_backUpLogic.CreateBackUp(new BackUpBindingModel
|
|
{
|
|
FolderName = fbd.SelectedPath
|
|
});
|
|
MessageBox.Show("Áåêàï ñîçäàí", "Ñîîáùåíèå",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK,
|
|
MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void TestsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormTests));
|
|
if (service is FormTests form)
|
|
{
|
|
form.ShowDialog();
|
|
LoadData();
|
|
}
|
|
}
|
|
}
|
|
}
|