using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace RezerveBeliteHavaPeimaCS
{
    public partial class frmMdi : Form
    {
        frmChangpassword frmChpw;
        frmCustumers frmcus;
        frmRezerveSale frmrezsal;
        frmServiceDef frmserdef;
        frmServiceTypes frmsertyp;
        frmStaffs frmstaf;
        frmUserjadid frmuser;
        frmRptReserves frmRptR;
        frmRptCustomers frmRptCust;
        frmRptStaffs frmRptSt;
        frmRptServiceDef frmRptDef;
        frmCustumersStatus frmStateCust;
        frmHelp frmH;
        public frmMdi()
        {
            InitializeComponent();
        }
        private void ShowNewForm(object sender, EventArgs e)
        {
            if (frmcus == null || frmcus.IsDisposed)
            {
                frmcus = new frmCustumers();
                frmcus.MdiParent = this;
                frmcus.Show();
            }
            else
            {
                frmcus.Activate();
            }
        }
        private void OpenFile(object sender, EventArgs e)
        {
            if (frmstaf == null || frmstaf.IsDisposed)
            {
                frmstaf = new frmStaffs();
                frmstaf.MdiParent = this;
                frmstaf.Show();
            }
            else
            {
                frmstaf.Activate();
            }
        }
        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
            this.Close();
        }
        private void ToolBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmuser == null || frmuser.IsDisposed)
            {
                frmuser = new frmUserjadid();
                frmuser.MdiParent = this;
                frmuser.Show();
            }
            else
            {
                frmuser.Activate();
            }
        }
        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmChpw == null || frmChpw.IsDisposed)
            {
                frmChpw = new frmChangpassword();
                frmChpw.MdiParent = this;
                frmChpw.Show();
            }
            else
            {
                frmChpw.Activate();
            }
        }
        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmRptR == null || frmRptR.IsDisposed)
            {
                frmRptR = new frmRptReserves();
                frmRptR.MdiParent = this;
                frmRptR.Show();
            }
            else
            {
                frmRptR.Activate();
            }
        }
        private void undoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmserdef == null || frmserdef.IsDisposed)
            {
                frmserdef = new frmServiceDef();
                frmserdef.MdiParent = this;
                frmserdef.Show();
            }
            else
            {
                frmserdef.Activate();
            }
        }
        private void redoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmrezsal == null || frmrezsal.IsDisposed)
            {
                frmrezsal = new frmRezerveSale();
               frmrezsal.MdiParent = this;
               frmrezsal.Show();
            }
            else
            {
                frmrezsal.Activate();
            }
        }
        private void paarvazHaieTarifiToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmRptDef == null || frmRptDef.IsDisposed)
            {
                frmRptDef = new frmRptServiceDef();
                frmRptDef.MdiParent = this;
                frmRptDef.Show();
            }
            else
            {
                frmRptDef.Activate();
            }
        }
        private void moshtarianListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmRptCust == null || frmRptCust.IsDisposed)
            {
                frmRptCust = new frmRptCustomers();
                frmRptCust.MdiParent = this;
                frmRptCust.Show();
            }
            else
            {
                frmRptCust.Activate();
            }
        }
        private void karmandanListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmRptSt == null || frmRptSt.IsDisposed)
            {
                frmRptSt = new frmRptStaffs();
                frmRptSt.MdiParent = this;
                frmRptSt.Show();
            }
            else
            {
                frmRptSt.Activate();
            }
        }
        private void frmMdi_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }
        private void servTypDefToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmsertyp == null || frmsertyp.IsDisposed)
            {
                frmsertyp = new frmServiceTypes();
                frmsertyp.MdiParent = this;
                frmsertyp.Show();
            }
            else
            {
                frmsertyp.Activate();
            }
        }
        private void quCustomerStatToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmStateCust == null || frmStateCust.IsDisposed)
            {
                frmStateCust = new frmCustumersStatus();
                frmStateCust.MdiParent = this;
                frmStateCust.Show();
            }
            else
            {
                frmStateCust.Activate();
            }
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmH == null || frmH.IsDisposed)
            {
                frmH = new frmHelp();
                frmH.MdiParent = this;
                frmH.Show();
            }
            else
            {
                frmH.Activate();
            }
        }

        private void WordPadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormStartPosition.CenterScreen.ToString();
            System.Diagnostics.Process.Start("wordpad.exe");
        }

        private void CalculatorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormStartPosition.CenterScreen.ToString();
            System.Diagnostics.Process.Start("calc.exe");
        }

        private void frmMdi_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MessageBox.Show("آیا قصد خروج از برنامه را دارید؟", "", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                e.Cancel = false;
            else e.Cancel = true;
        }
    }
}
