Example #1
0
        private void ButtonHome1_Click(object sender, EventArgs e)
        {
            string name = "";

            try
            {
                Panel p = (Panel)sender;
                name = f.GetNameOfButton(p);
            }
            catch { }
            try
            {
                Label l = (Label)sender;
                name = l.Text;
            }
            catch { }
            try
            {
                PictureBox pb = (PictureBox)sender;
                name = f.GetNameOfButton(panel1, pb);
            }
            catch { }
            if (name != "")
            {
                if (name != "Выход")
                {
                    for (int i = 0; i < panel1.Controls.Count; i++)
                    {
                        if (panel1.Controls[i].GetType() == typeof(Panel))
                        {
                            for (int j = 0; j < panel1.Controls[i].Controls.Count; j++)
                            {
                                if (panel1.Controls[i].Controls[j].GetType() == typeof(Panel))
                                {
                                    panel1.Controls[i].Controls[j].Visible = false;
                                }
                            }
                        }
                    }
                }
                if (name == "Турагентства")
                {
                    Controls.Remove(State);
                    Agencies ag = new Agencies(this);
                    State = ag;
                    this.Controls.Add(ag);
                    ag.Location = new Point(panel3.Location.X + panel3.Size.Width, panel3.Location.Y + panel3.Size.Height + PanelForm.Size.Height);
                    ag.Visible  = true;
                    ag.Show();
                    panel4.Visible = true;
                }
                if (name == "Турагентство")
                {
                    Controls.Remove(State);

                    OneAgency ag = new OneAgency(this, new Touragency(User.Login));
                    State = ag;
                    this.Controls.Add(ag);
                    ag.Location = new Point(panel3.Location.X + panel3.Size.Width, panel3.Location.Y + panel3.Size.Height + PanelForm.Size.Height);
                    ag.Visible  = true;
                    ag.Show();
                    panel4.Visible = true;
                }
                if (name == "SQL запросы")
                {
                    Controls.Remove(State);
                    SQLQuery sq = new SQLQuery(this);
                    State = sq;
                    this.Controls.Add(sq);
                    sq.Location = new Point(panel3.Location.X + panel3.Size.Width, panel3.Location.Y + panel3.Size.Height + PanelForm.Size.Height);
                    sq.Visible  = true;
                    sq.Show();
                    panel17.Visible = true;
                }
                if (name == "Отели")
                {
                    Controls.Remove(State);
                    Hotels a = new Hotels(this);
                    State = a;
                    this.Controls.Add(a);
                    a.Location = new Point(panel3.Location.X + panel3.Size.Width, panel3.Location.Y + panel3.Size.Height + PanelForm.Size.Height);
                    a.Visible  = true;
                    a.Show();
                    panel14.Visible = true;
                }
                if (name == "Авиарейсы")
                {
                    Controls.Remove(State);
                    Routes a = new Routes(this);
                    State = a;
                    this.Controls.Add(a);
                    a.Location = new Point(panel3.Location.X + panel3.Size.Width, panel3.Location.Y + panel3.Size.Height + PanelForm.Size.Height);
                    a.Visible  = true;
                    a.Show();
                    panel15.Visible = true;
                }
                if (name == "Аккаунты")
                {
                    Controls.Remove(State);
                    Accounts a = new Accounts(this);
                    State = a;
                    this.Controls.Add(a);
                    a.Location = new Point(panel3.Location.X + panel3.Size.Width, panel3.Location.Y + panel3.Size.Height + PanelForm.Size.Height);
                    a.Visible  = true;
                    a.Show();
                    panel16.Visible = true;
                }
                if (name == "Путевки")
                {
                    Controls.Remove(State);
                    Vouchers a = new Vouchers(this);
                    State = a;
                    this.Controls.Add(a);
                    a.Location = new Point(panel3.Location.X + panel3.Size.Width, panel3.Location.Y + panel3.Size.Height + PanelForm.Size.Height);
                    a.Visible  = true;
                    a.Show();
                    panel12.Visible = true;
                }
                if (name == "Поиск")
                {
                    Controls.Remove(State);
                    SearchVouchers a = new SearchVouchers(this);
                    State = a;

                    this.Controls.Add(a);
                    a.BringToFront();
                    a.Location = new Point(panel3.Location.X + panel3.Size.Width, panel3.Location.Y + panel3.Size.Height + PanelForm.Size.Height - 84);
                    a.Visible  = true;
                    a.Show();
                    panel13.Visible = true;
                }
                if (name == "Выход")
                {
                    MyMessageBox message = new MyMessageBox(this, "Предупреждение", "Выйти из аккаунта?", "Да", "Нет", "Выход_Да", "Выход_Нет");
                    message.Show();
                }
            }
        }