Пример #1
0
        private void TryLogin(object sender, System.EventArgs e)
        {
            FlatPanel panelName = (FlatPanel)form.Controls[1].Controls[0].Controls[2];
            FlatPanel panelPass = (FlatPanel)form.Controls[1].Controls[0].Controls[3];

            int index     = panelName.Controls.IndexOfKey("Name");
            int indexPass = panelPass.Controls.IndexOfKey("Password");

            Usuario user = new Usuario(
                panelName.Controls[index].Text,
                panelPass.Controls[indexPass].Text,
                0);

            UserDAO userDAO = new UserDAO(Server.MariaDB);

            if (userDAO.GetPassword(user.Name) == user.Password)
            {
                userDAO.SetLogin(userDAO.GetID(user.Name));

                Views views = new Views();
                form.Hide();
                views.dictionary[userDAO.GetRole(user.Name)].Show();
            }

            else
            {
                panelName.Parent.Controls[panelName.Parent.Controls.Count - 1].Visible = true;
            }
        }
Пример #2
0
        private void GoToCreate(object sender, System.EventArgs e)
        {
            try
            {
                FlatPanel parentPanel = (FlatPanel)panel.Parent;
                Control   toolbar     = parentPanel.Controls[0];

                MenuSection menuController = new MenuSection(0);
                menuController.ShowPanel(ref parentPanel, Enums.ItemMenuType.CreateAirline);

                PanelAdjustment();

                void PanelAdjustment()
                {
                    parentPanel.Controls[1].Dock   = DockStyle.None;
                    toolbar.Controls[0].Width      = parentPanel.Width;
                    parentPanel.Controls[1].Top    = toolbar.Top + toolbar.Height;
                    parentPanel.Controls[1].Width  = parentPanel.Width;
                    parentPanel.Controls[1].Height = parentPanel.Height - toolbar.Height;
                }
            }
            catch (Exception)
            {
                throw new OperationCanceledException("Wrong view.");
            }
        }
Пример #3
0
        private void Save(object sender, System.EventArgs e)
        {
            try
            {
                // Use trim for filelds names
                RadioButton myRadio = (RadioButton)panelChild.Controls[12];

                Airport airport = new Airport
                {
                    Name      = panelChild.Controls[1].Controls[0].Text,
                    Operator  = panelChild.Controls[2].Controls[0].Text,
                    Owner     = panelChild.Controls[3].Controls[0].Text,
                    ICAO      = panelChild.Controls[4].Controls[0].Text,
                    IATA      = panelChild.Controls[5].Controls[0].Text,
                    Type      = panelChild.Controls[6].Controls[0].Text,
                    Address   = panelChild.Controls[7].Controls[0].Text,
                    Serves    = panelChild.Controls[8].Controls[0].Text,
                    Large     = int.Parse(panelChild.Controls[9].Controls[0].Text),
                    Elevation = int.Parse(panelChild.Controls[10].Controls[0].Text),
                    Status    = (myRadio.Checked) ? 1 : 0,
                };


                AirportDAO dao = new AirportDAO(Server.MariaDB);
                dao.Save(airport);

                // Button is the last child
                panelChild.Controls[panelChild.Controls.Count - 1].Enabled = false;

                FlatPanel parentPanel = (FlatPanel)panel.Parent;
                Control   toolbar     = parentPanel.Controls[0];

                MenuSection menuController = new MenuSection(0);
                menuController.ShowPanel(ref parentPanel, Enums.ItemMenuType.Airports);

                PanelAdjustment();

                void PanelAdjustment()
                {
                    parentPanel.Controls[1].Dock   = DockStyle.None;
                    toolbar.Controls[0].Width      = parentPanel.Width;
                    parentPanel.Controls[1].Top    = toolbar.Top + toolbar.Height;
                    parentPanel.Controls[1].Width  = parentPanel.Width;
                    parentPanel.Controls[1].Height = parentPanel.Height - toolbar.Height;
                }
            }
            catch (Exception)
            {
                throw new OperationCanceledException("Wrong filed.");
            }
        }
Пример #4
0
        private void Save(object sender, System.EventArgs e)
        {
            try
            {
                // Use trim for filelds names
                RadioButton myRadio = (RadioButton)panelChild.Controls[9];
                ComboBox    myCombo = (ComboBox)panelChild.Controls[7];

                int airlaineID = new AirlineDAO(Enums.Server.MariaDB).GetID(myCombo.SelectedItem.ToString());

                Airplane avion = new Airplane
                {
                    Model     = panelChild.Controls[1].Controls[0].Text,
                    ICAO      = panelChild.Controls[2].Controls[0].Text,
                    IATA      = panelChild.Controls[3].Controls[0].Text,
                    MaxPASS   = int.Parse(panelChild.Controls[4].Controls[0].Text),
                    MaxCargo  = int.Parse(panelChild.Controls[5].Controls[0].Text),
                    Aircraft  = panelChild.Controls[6].Controls[0].Text,
                    AirlineID = airlaineID,
                    Enabled   = (myRadio.Checked) ? 1 : 0,
                };

                AirplaneDAO dao = new AirplaneDAO(Enums.Server.MariaDB);
                dao.Save(avion);

                // Button is the last child
                panelChild.Controls[panelChild.Controls.Count - 1].Enabled = false;

                FlatPanel parentPanel = (FlatPanel)panel.Parent;
                Control   toolbar     = parentPanel.Controls[0];

                MenuSection menuController = new MenuSection(0);
                menuController.ShowPanel(ref parentPanel, Enums.ItemMenuType.Airplanes);

                PanelAdjustment();

                void PanelAdjustment()
                {
                    parentPanel.Controls[1].Dock   = DockStyle.None;
                    toolbar.Controls[0].Width      = parentPanel.Width;
                    parentPanel.Controls[1].Top    = toolbar.Top + toolbar.Height;
                    parentPanel.Controls[1].Width  = parentPanel.Width;
                    parentPanel.Controls[1].Height = parentPanel.Height - toolbar.Height;
                }
            }
            catch (Exception)
            {
                throw new OperationCanceledException("Wrong filed.");
            }
        }
Пример #5
0
        private void Save(object sender, System.EventArgs e)
        {
            try
            {
                // Use trim for filelds names
                RadioButton myRadio    = (RadioButton)panelChild.Controls[5];
                ComboBox    myCombo    = (ComboBox)panelChild.Controls[3];
                int         airlaineID = new AirlineDAO(Enums.Server.MariaDB).GetID(myCombo.SelectedItem.ToString());

                Pilot piloto = new Pilot
                {
                    Name        = panelChild.Controls[1].Controls[0].Text,
                    Sex         = panelChild.Controls[2].Controls[0].Text,
                    PilotStatus = (myRadio.Checked) ? 1 : 0,
                    AirlineID   = airlaineID
                };

                PilotDAO dao = new PilotDAO(Enums.Server.MariaDB);
                dao.Save(piloto);

                // Button is the last child
                panelChild.Controls[panelChild.Controls.Count - 1].Enabled = false;

                FlatPanel parentPanel = (FlatPanel)panel.Parent;
                Control   toolbar     = parentPanel.Controls[0];

                MenuSection menuController = new MenuSection(0);
                menuController.ShowPanel(ref parentPanel, Enums.ItemMenuType.Pilots);

                PanelAdjustment();

                void PanelAdjustment()
                {
                    parentPanel.Controls[1].Dock   = DockStyle.None;
                    toolbar.Controls[0].Width      = parentPanel.Width;
                    parentPanel.Controls[1].Top    = toolbar.Top + toolbar.Height;
                    parentPanel.Controls[1].Width  = parentPanel.Width;
                    parentPanel.Controls[1].Height = parentPanel.Height - toolbar.Height;
                }
            }
            catch (Exception)
            {
                throw new OperationCanceledException("Wrong filed.");
            }
        }
Пример #6
0
        private void Save(object sender, System.EventArgs e)
        {
            try
            {
                RadioButton myRadio = (RadioButton)panelChild.Controls[7];

                Airline aerolinea = new Airline
                {
                    Name          = panelChild.Controls[1].Controls[0].Text,
                    ICAO          = panelChild.Controls[2].Controls[0].Text,
                    IATA          = panelChild.Controls[3].Controls[0].Text,
                    Country       = panelChild.Controls[4].Controls[0].Text,
                    Region        = panelChild.Controls[5].Controls[0].Text,
                    AirlineStatus = (myRadio.Checked) ? 1 : 0,
                    AircraftList  = ""
                };

                AirlineDAO dao = new AirlineDAO(Enums.Server.MariaDB);
                dao.Save(aerolinea);

                // Button is the last child
                panelChild.Controls[panelChild.Controls.Count - 1].Enabled = false;

                FlatPanel parentPanel = (FlatPanel)panel.Parent;
                Control   toolbar     = parentPanel.Controls[0];

                MenuSection menuController = new MenuSection(0);
                menuController.ShowPanel(ref parentPanel, Enums.ItemMenuType.Airlines);

                PanelAdjustment();

                void PanelAdjustment()
                {
                    parentPanel.Controls[1].Dock   = DockStyle.None;
                    toolbar.Controls[0].Width      = parentPanel.Width;
                    parentPanel.Controls[1].Top    = toolbar.Top + toolbar.Height;
                    parentPanel.Controls[1].Width  = parentPanel.Width;
                    parentPanel.Controls[1].Height = parentPanel.Height - toolbar.Height;
                }
            }
            catch (Exception)
            {
                throw new OperationCanceledException("Wrong filed.");
            }
        }
Пример #7
0
        private void Save(object sender, System.EventArgs e)
        {
            try
            {
                // Use trim for filelds names
                RadioButton myRadio = (RadioButton)panelChild.Controls[3];

                Pist pist = new Pist
                {
                    Description = panelChild.Controls[1].Controls[0].Text,
                    Status      = (myRadio.Checked) ? 1 : 0,
                };

                PistDAO dao = new PistDAO(Server.MariaDB);
                dao.Save(pist);

                // Button is the last child
                panelChild.Controls[panelChild.Controls.Count - 1].Enabled = false;

                FlatPanel parentPanel = (FlatPanel)panel.Parent;
                Control   toolbar     = parentPanel.Controls[0];

                MenuSection menuController = new MenuSection(0);
                menuController.ShowPanel(ref parentPanel, Enums.ItemMenuType.Pists);

                PanelAdjustment();

                void PanelAdjustment()
                {
                    parentPanel.Controls[1].Dock   = DockStyle.None;
                    toolbar.Controls[0].Width      = parentPanel.Width;
                    parentPanel.Controls[1].Top    = toolbar.Top + toolbar.Height;
                    parentPanel.Controls[1].Width  = parentPanel.Width;
                    parentPanel.Controls[1].Height = parentPanel.Height - toolbar.Height;
                }
            }
            catch (Exception)
            {
                throw new OperationCanceledException("Wrong filed.");
            }
        }
Пример #8
0
 /// <summary> 
 /// Required method for Designer support - do not modify 
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.panel = new Elide.Forms.FlatPanel();
     this.switchBar = new Elide.Forms.SwitchBar();
     this.SuspendLayout();
     //
     // panel
     //
     this.panel.Dock = System.Windows.Forms.DockStyle.Fill;
     this.panel.Location = new System.Drawing.Point(0, 20);
     this.panel.Name = "panel";
     this.panel.Padding = new System.Windows.Forms.Padding(2);
     this.panel.Size = new System.Drawing.Size(257, 299);
     this.panel.TabIndex = 1;
     this.panel.WideRendering = true;
     //
     // switchBar
     //
     this.switchBar.BackColor = System.Drawing.Color.DarkGray;
     this.switchBar.Dock = System.Windows.Forms.DockStyle.Top;
     this.switchBar.Location = new System.Drawing.Point(0, 0);
     this.switchBar.Name = "switchBar";
     this.switchBar.SelectedIndex = -1;
     this.switchBar.Size = new System.Drawing.Size(257, 20);
     this.switchBar.TabIndex = 0;
     this.switchBar.SelectedIndexChanged += new System.EventHandler<Elide.Forms.SwitchBarEventArgs>(this.SwitchBarSelectedIndexChanged);
     //
     // ToolWindow
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     this.Controls.Add(this.panel);
     this.Controls.Add(this.switchBar);
     this.Name = "ToolWindow";
     this.Size = new System.Drawing.Size(257, 319);
     this.ResumeLayout(false);
 }
Пример #9
0
        private void Save(object sender, System.EventArgs e)
        {
            try
            {
                ComboBox myCombo  = (ComboBox)panelChild.Controls[2];
                ComboBox myCombo2 = (ComboBox)panelChild.Controls[12];
                ComboBox myCombo3 = (ComboBox)panelChild.Controls[13];

                ComboBox myCombo4 = (ComboBox)panelChild.Controls[16];
                ComboBox myCombo5 = (ComboBox)panelChild.Controls[18];
                ComboBox myCombo6 = (ComboBox)panelChild.Controls[20];

                DateTime departureDate  = DateTime.Parse(panelChild.Controls[6].Text);
                DateTime arrivalDate    = DateTime.Parse(panelChild.Controls[9].Text);
                TimeSpan twentyFourHour = new TimeSpan(24, 0, 0);
                TimeSpan departureHour  = TimeSpan.Parse(panelChild.Controls[7].Controls[0].Text);
                TimeSpan arrivalHour    = TimeSpan.Parse(panelChild.Controls[10].Controls[0].Text);
                TimeSpan flightHour     = (departureHour > arrivalHour) ? (twentyFourHour - departureHour) + arrivalHour : arrivalHour - departureHour;

                AirlineDAO  airlineDAO  = new AirlineDAO(Server.MariaDB);
                AirplaneDAO airplaneDAO = new AirplaneDAO(Server.MariaDB);
                PilotDAO    pilotDAO    = new PilotDAO(Server.MariaDB);

                Flight flight = new Flight
                {
                    Type          = myCombo.SelectedItem.ToString(),
                    Origin        = panelChild.Controls[3].Controls[0].Text,
                    Destiny       = panelChild.Controls[4].Controls[0].Text,
                    DepartureDate = departureDate.ToString(),
                    DepartureHour = departureHour.ToString(),
                    ArrivalDate   = arrivalDate.ToString(),
                    ArrivalHour   = arrivalHour.ToString(),
                    FlightTime    = flightHour.ToString(),
                    Pist          = int.Parse(myCombo2.SelectedItem.ToString()),
                    FlightStatus  = myCombo3.SelectedItem.ToString(),
                    AirlineID     = airlineDAO.GetID(myCombo4.SelectedItem.ToString()),
                    AirplaneID    = airplaneDAO.GetID(myCombo5.SelectedItem.ToString()),
                    PilotID       = pilotDAO.GetID(myCombo6.SelectedItem.ToString()),
                };

                FlightDAO dao = new FlightDAO(Enums.Server.MariaDB);
                dao.Save(flight);

                // Button is the last child
                panelChild.Controls[panelChild.Controls.Count - 1].Enabled = false;

                FlatPanel parentPanel = (FlatPanel)panel.Parent;
                Control   toolbar     = parentPanel.Controls[0];

                MenuSection menuController = new MenuSection(0);
                menuController.ShowPanel(ref parentPanel, Enums.ItemMenuType.Flight);

                PanelAdjustment();

                void PanelAdjustment()
                {
                    parentPanel.Controls[1].Dock   = DockStyle.None;
                    toolbar.Controls[0].Width      = parentPanel.Width;
                    parentPanel.Controls[1].Top    = toolbar.Top + toolbar.Height;
                    parentPanel.Controls[1].Width  = parentPanel.Width;
                    parentPanel.Controls[1].Height = parentPanel.Height - toolbar.Height;
                }
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }
        }
Пример #10
0
        protected override void InitializeComponent()
        {
            PortraitForm portraitForm = new PortraitForm("Management");

            form           = portraitForm;
            form.Width     = 1500;
            form.Height    = 900;
            form.Padding   = new Padding(20);
            form.BackColor = colors.White1;

            // Main panel
            FlatPanel mainPanel = new FlatPanel("Main");

            form.Controls.Add(mainPanel);
            mainPanel.Dock = DockStyle.Fill;


            Toolbar   toolbarController = new FlujoAereo.Logic.UI.Layouts.Toolbar();
            FlatPanel toolbar           = toolbarController.GetPanel("Toolbar");

            mainPanel.Controls.Add(toolbar);
            toolbar.Controls[0].Dock   = DockStyle.None;
            toolbar.Controls[0].Height = 70;
            toolbarController.AlignElementsRight(toolbar.Controls[0].Controls);
            toolbar.Controls[0].Controls[1].Click += new EventHandler(SetLogout);

            FlatPanel   menuWrapper    = new FlatPanel("MenuWrapper");
            MenuSection menuController = new MenuSection(200);
            FlatPanel   menu           = menuController.GetPanel("Menu");

            menuWrapper.Controls.Add(menu);
            menuWrapper.Dock = DockStyle.Left;
            menuWrapper.Left = 0;


            menu.Controls[0].Controls[0].Click += new EventHandler(
                (object sender, EventArgs e) =>
            {
                menuController.ShowPanel(ref mainPanel, Enums.ItemMenuType.Airplanes);
                PanelAdjustment();
            }
                );

            menu.Controls[0].Controls[1].Click += new EventHandler(
                (object sender, EventArgs e) =>
            {
                menuController.ShowPanel(ref mainPanel, Enums.ItemMenuType.Airlines);
                PanelAdjustment();
            }
                );

            menu.Controls[0].Controls[2].Click += new EventHandler(
                (object sender, EventArgs e) =>
            {
                menuController.ShowPanel(ref mainPanel, Enums.ItemMenuType.Pilots);
                PanelAdjustment();
            }
                );

            menu.Controls[0].Controls[3].Click += new EventHandler(
                (object sender, EventArgs e) =>
            {
                menuController.ShowPanel(ref mainPanel, Enums.ItemMenuType.Pists);
                PanelAdjustment();
            }
                );

            menu.Controls[0].Controls[4].Click += new EventHandler(
                (object sender, EventArgs e) =>
            {
                menuController.ShowPanel(ref mainPanel, Enums.ItemMenuType.Airports);
                PanelAdjustment();
            }
                );

            menu.Controls[0].Controls[5].Click += new EventHandler(
                (object sender, EventArgs e) =>
            {
                menuController.ShowPanel(ref mainPanel, Enums.ItemMenuType.Flight);
                PanelAdjustment();
            }
                );

            form.Controls.Add(menuWrapper);
            menuController.SetMenuItemsWidth(menuWrapper.Width);

            // Default panel
            menuController.ShowPanel(ref mainPanel, Enums.ItemMenuType.Airplanes);
            PanelAdjustment();

            //TimeSpan timeSpan = new TimeSpan(0, 2, 0,0);
            //TimeSpan timeSpan2 = TimeSpan.Parse("20:00");
            //MessageBox.Show(timeSpan2.ToString());

            void PanelAdjustment()
            {
                mainPanel.Controls[1].Dock   = DockStyle.None;
                mainPanel.Width              = form.Width - menu.Width;
                toolbar.Controls[0].Width    = mainPanel.Width;
                mainPanel.Controls[1].Top    = toolbar.Top + toolbar.Height;
                mainPanel.Controls[1].Width  = mainPanel.Width;
                mainPanel.Controls[1].Height = mainPanel.Height - toolbar.Height;
            }
        }
Пример #11
0
        protected override void InitializeComponent()
        {
            form        = new SquareForm("Login shit");
            form.Height = 599;
            form.Width  = 750;

            Panel panel = new Panel
            {
                Name = "logo",
                BackgroundImageLayout = ImageLayout.Center,
                BackgroundImage       = Image.FromFile("logo.jpg"),
                Width  = 400,
                Height = 400
            };

            form.Controls.Add(panel);

            FlatPanel panelMain = new FlatPanel("main")
            {
                AutoSize     = true,
                AutoSizeMode = AutoSizeMode.GrowOnly,
                Dock         = System.Windows.Forms.DockStyle.None,
                BackColor    = colors.LightGray1,
                Padding      = new Padding(1),
                Left         = panel.Width,
            };

            form.Controls.Add(panelMain);


            FlatPanel panelLogin = new FlatPanel("main")
            {
                AutoSize  = true,
                Dock      = System.Windows.Forms.DockStyle.None,
                BackColor = colors.LighterGray1,
                Padding   = new Padding(20),
                Location  = new Point(1, 1)
            };

            panelMain.Controls.Add(panelLogin);


            // Don't touch in order to don't mess the center alignment

            FlatLabelTitle title = new FlatLabelTitle("Sign in", 0, 20);

            panelLogin.Controls.Add(title);

            FlatTextBoxAutoFocus _ = new FlatTextBoxAutoFocus("_");

            panelLogin.Controls.Add(_);

            FlatPanel panelTxtName = new FlatPanel("Name")
            {
                AutoSize     = true,
                AutoSizeMode = new AutoSizeMode(),
                Dock         = System.Windows.Forms.DockStyle.None,
                BackColor    = colors.White1,
                Padding      = new Padding(4)
            };

            panelTxtName.Location = new Point(20, 70);

            FlatTextBox txtName = new FlatTextBox("Name", 4, 4);

            panelTxtName.Controls.Add(txtName);
            panelLogin.Controls.Add(panelTxtName);


            FlatPanel panelTxtPassword = new FlatPanel("Password")
            {
                AutoSize     = true,
                AutoSizeMode = new AutoSizeMode(),
                Dock         = System.Windows.Forms.DockStyle.None,
                BackColor    = colors.White1,
                Padding      = new Padding(4),
            };

            panelTxtPassword.Location = new Point(20, 110);

            FlatTextBox txtPassword = new FlatTextBox("Password", 4, 4);

            panelTxtPassword.Controls.Add(txtPassword);


            panelLogin.Controls.Add(panelTxtPassword);

            button = new FlatButton("Log in");
            panelLogin.Controls.Add(button);


            button.Width    = panelTxtName.Width;
            button.Location = new Point(20, button.Parent.Height + 20);
            button.Click   += new System.EventHandler(TryLogin);

            panelLogin.Height += button.Height + 30;

            int positionX = centerElement.Horizontal(title.Size.Width, panelLogin.ClientSize.Width);

            title.Location = new System.Drawing.Point(positionX, title.Location.Y);

            panelMain.Top = centerElement.Vertical(panelMain.Height, form.ClientSize.Height);

            panelLogin.Controls.Add(
                new FlatLabelError("Oops! It looks like you may have forgotten your password.", 0, button.Height + 30)
            {
                Dock        = DockStyle.Bottom,
                MaximumSize = new Size(panelLogin.Width - 40, 0),
                Visible     = false
            }
                );
        }