Пример #1
0
        //#endregion
        //bool _canClose = false;

        private void loginBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (usernameTBox.Text == "" || usernameTBox.Text == "username" || passwordTBox.Text == "" || passwordTBox.Text == "password")
                {
                    MessageBox.Show("Please enter your username and password");
                    return;
                }

                else if (usernameTBox.Text != "" || usernameTBox.Text != "username" || passwordTBox.Text != "" || passwordTBox.Text != "password")
                {
                    string    inputUserName = usernameTBox.Text;
                    DataTable validateUsers = new DataTable();
                    validateUsers.TableName = "ValidateUsers";
                    validateUsers           = WebMethods.DbValidateUsers(inputUserName, validateUsers);

                    if (validateUsers.Rows[0][0].ToString() != "1")
                    {
                        MessageBox.Show("You do not have permission to use this application.\nPlease contact the system administrator if you wish to use EQA-Master. ");
                    }

                    else if (validateUsers.Rows[0][0].ToString() == "1")
                    {
                        _guid = UserAuth.GetUserAuth(usernameTBox.Text, passwordTBox.Text, 2);
                        if (_guid == "False")
                        {
                            MessageBox.Show("The username and password entered are not correct.");
                            return;
                        }
                        else if (_guid == "invalid permission")
                        {
                            MessageBox.Show("You do not have permission to use this application.\nPlease contact the system administrator if you wish to use Probe Master.");
                            return;
                        }

                        else
                        {
                            this.Hide();
                            StartUp_Form start = new StartUp_Form();
                            start.Show();
                            start.Activate();
                        }
                    }
                }
            }
            catch (SqlException)
            {
                MessageBox.Show("Failure to connect to EQA-Master, please contact the administrator.");
            }
        }