using System;
using System.Windows.Forms;

namespace RestaurantApp
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();

            this.Text = $"Ресторан - {Program.CurrentUser}";
            lblUser.Text = $"{Program.CurrentUser} ({Program.CurrentRole})";

            // Разграничение прав доступа
            bool isAdmin = Program.CurrentRole == "admin";
            bool isManager = Program.CurrentRole == "manager";
            bool isWaiter = Program.CurrentRole == "waiter";

            // Только admin и manager могут редактировать сотрудников и смотреть отчёты
            сотрудникиToolStripMenuItem.Enabled = isAdmin || isManager;
            отчётыToolStripMenuItem.Enabled = isAdmin || isManager;

            // Подписка на события меню
            клиентыToolStripMenuItem.Click += (s, e) => OpenForm(new ClientForm());
            блюдаToolStripMenuItem.Click += (s, e) => OpenForm(new DishForm());
            сотрудникиToolStripMenuItem.Click += (s, e) => OpenForm(new EmployeeForm());
            заказыToolStripMenuItem.Click += (s, e) => OpenForm(new OrderForm());
            бронированияToolStripMenuItem.Click += (s, e) => OpenForm(new ReservationForm());
            отчётыToolStripMenuItem.Click += (s, e) => OpenForm(new ReportForm());
            выходToolStripMenuItem.Click += (s, e) => { this.Close(); Application.Exit(); };
        }

        private void OpenForm(Form form)
        {
            form.MdiParent = this;
            form.WindowState = FormWindowState.Maximized;
            form.Show();
        }
    }
}