using SushiBarBusinessLogic; using SushiBarView.Forms; namespace SushiBarView { public partial class MainForm : Form { private readonly ChequeLogic _chequeLogic; public MainForm(ChequeLogic ChequeLogic) { InitializeComponent(); _chequeLogic = ChequeLogic; } private void MainForm_Load(object sender, EventArgs e) { LoadData(); } private void LoadData() { try { var List = _chequeLogic.ReadList(null); if (List != null) { DataGridView.DataSource = List; DataGridView.Columns["CustomerId"].Visible = false; DataGridView.Columns["PromotionId"].Visible = false; DataGridView.Columns["ChequeItems"].Visible = false; DataGridView.Columns["OrderDate"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; DataGridView.Columns["TotalSum"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void IngredientsToolStripMenuItem_Click(object sender, EventArgs e) { FormIngredients Form = new FormIngredients(new SushiBarBusinessLogic.IngredientLogic(new SushiBarDatabaseImplement.Storages.IngredientStorage())); Form.ShowDialog(); } private void DishesToolStripMenuItem_Click(object sender, EventArgs e) { FormDishes Form = new FormDishes(new SushiBarBusinessLogic.DishLogic(new SushiBarDatabaseImplement.Storages.DishStorage())); Form.ShowDialog(); } private void CooksToolStripMenuItem_Click(object sender, EventArgs e) { FormCooks Form = new FormCooks(new SushiBarBusinessLogic.CookLogic(new SushiBarDatabaseImplement.Storages.CookStorage())); Form.ShowDialog(); } private void CustomersToolStripMenuItem_Click(object sender, EventArgs e) { FormCustomers Form = new FormCustomers(new SushiBarBusinessLogic.CustomerLogic(new SushiBarDatabaseImplement.Storages.CustomerStorage())); Form.ShowDialog(); } private void PromotionsToolStripMenuItem_Click(object sender, EventArgs e) { FormPromotions Form = new FormPromotions(new SushiBarBusinessLogic.PromotionLogic(new SushiBarDatabaseImplement.Storages.PromotionStorage())); Form.ShowDialog(); } private void CreateOrderButton_Click(object sender, EventArgs e) { FormCreateCheque Form = new FormCreateCheque( new ChequeLogic(new SushiBarDatabaseImplement.Storages.ChequeStorage()), new CustomerLogic(new SushiBarDatabaseImplement.Storages.CustomerStorage())); Form.ShowDialog(); LoadData(); } private void RefreshButton_Click(object sender, EventArgs e) { LoadData(); } private void ChequeInfo_Click(object sender, EventArgs e) { FormCreateCheque Form = new FormCreateCheque( new ChequeLogic(new SushiBarDatabaseImplement.Storages.ChequeStorage()), new CustomerLogic(new SushiBarDatabaseImplement.Storages.CustomerStorage())); Form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); Form.ShowDialog(); LoadData(); } } }