public void validateLogin(string username, string password)
        {
            if (username.Length > 0)
            {
                if (password.Length == 0)
                {
                    panelLogin.lblVerification.Text      = "Vul een wachtwoord in.";
                    panelLogin.lblVerification.ForeColor = Color.Red;
                    panelLogin.lblVerification.Visible   = true;
                }
                if (password.Length > 0)
                {
                    if (SerialPort.GetPortNames().Length > 0)
                    {
                        string error   = "";
                        bool   connect = false;
                        foreach (string comport in SerialPort.GetPortNames())
                        {
                            connect = MainClient.Connect(comport, username, password, out error);
                            if (connect)
                            {
                                break;
                            }
                        }

                        if (connect)
                        {
                            panelGatherInfo.BringToFront();
                            panelTopBar.Visible     = true;
                            this.labelUsername.Text = panelLogin.textBoxUsername.Text;
                        }
                        else
                        {
                            panelLogin.lblVerification.Text      = error;
                            panelLogin.lblVerification.ForeColor = Color.Red;
                            panelLogin.lblVerification.Visible   = true;
                        }
                    }
                    else
                    {
                        panelLogin.lblVerification.Text      = "De Ergometer is niet verbonden.";
                        panelLogin.lblVerification.ForeColor = Color.Red;
                        panelLogin.lblVerification.Visible   = true;
                    }
                }
            }
            else
            {
                panelLogin.lblVerification.Text      = "Vul een gebruikersnaam in.";
                panelLogin.lblVerification.ForeColor = Color.Red;
                panelLogin.lblVerification.Visible   = true;
            }
        }
Esempio n. 2
0
        public void validateLogin(string username, string password)
        {
            if (username.Length > 0)
            {
                if (password.Length == 0)
                {
                    panelLogin.lblVerification.Text      = "Vul een wachtwoord in.";
                    panelLogin.lblVerification.ForeColor = Color.Red;
                    panelLogin.lblVerification.Visible   = true;
                }
                if (password.Length > 0)
                {
                    string error   = "";
                    bool   connect = MainClient.Connect("COM5", username, password, out error);

                    if (connect)
                    {
                        panelClientContainer.BringToFront();
                        chat = panelClientChat;
                        this.labelUsername.Text = panelLogin.textBoxUsername.Text;
                        panelTopBar.Visible     = true;
                        updateTimer.Start();
                    }
                    else
                    {
                        panelLogin.lblVerification.Text      = error;
                        panelLogin.lblVerification.ForeColor = Color.Red;
                        panelLogin.lblVerification.Visible   = true;
                    }
                }
            }
            else
            {
                panelLogin.lblVerification.Text      = "Vul een gebruikersnaam in.";
                panelLogin.lblVerification.ForeColor = Color.Red;
                panelLogin.lblVerification.Visible   = true;
            }
        }