当前位置: 首页>>代码示例>>C#>>正文


C# LoginModel.doLogin方法代码示例

本文整理汇总了C#中LoginModel.doLogin方法的典型用法代码示例。如果您正苦于以下问题:C# LoginModel.doLogin方法的具体用法?C# LoginModel.doLogin怎么用?C# LoginModel.doLogin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LoginModel的用法示例。


在下文中一共展示了LoginModel.doLogin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnSubmit_Click

        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if ((txtCurrentPassword.Text.Equals("")) || (txtNewPassword.Text.Equals("")))
            {
                MessageBox.Show("One or more fields has been left empty.");
            }
            else
            {

                //Get passwords
                String passwordOld = txtCurrentPassword.Text;
                String passwordNew = txtNewPassword.Text;

                LoginModel loginValidateAttempt = new LoginModel();
                User detailsToCheck = loginValidateAttempt.doLogin(currentUser.getUsername(), passwordOld);

                //If a login attempt does not return null, the attempt was successful
                if (detailsToCheck != null)
                {
                    //If the new password is the same as the old password, we say something
                    if (detailsToCheck.getPassword().Equals(Encryption.calcMD5(passwordNew)))
                    {
                        MessageBox.Show("The password you entered is the same as your old password.");
                    }
                    else
                    {
                        //Then we can change the password
                        UserModel uModel = new UserModel();
                        uModel.updatePassword(passwordNew, currentUser.getUsername());

                        MessageBox.Show("Password successfully changed.");
                        this.Close();
                    }

                }
                else
                {
                    MessageBox.Show("The password you entered does not match your current password.");
                }
            }
        }
开发者ID:andrewdavis1995,项目名称:MALTMusic,代码行数:41,代码来源:PasswordChange.cs

示例2: cmdLogin_Click

        /*
         * Button to attempt the login
         * @AUTHOR: Andrew Davis
         */
        private void cmdLogin_Click(object sender, EventArgs e)
        {
            // Create a LoginModel object to handle the login
            LoginModel loginModel = new LoginModel();

            // Get the user credentials from the form
            String username = txtUsername.Text;
            String password = txtPassword.Text;

            // Attempt the login
            User loggedIn = loginModel.doLogin(username, password);

            // If it was successful, go to the Home Page
            if (loggedIn != null)
            {

                MessageBox.Show("SUCCESS! LOGGED IN AS: " + loggedIn.getFirstName() + " " + loggedIn.getLastName());

                // Create a Home Form
                HomePage homeForm = new HomePage();

                // Set the Current User of the HomePage to be the newly logged in user
                homeForm.setCurrentUser(loggedIn);

                // Show the Home Form
                homeForm.Show();

                // Hide the current form
                this.Hide();

            }
            else
            {
                MessageBox.Show("UNSUCCESSFUL LOGIN");

                // Clear the Password field
                txtPassword.Text = "";
            }
        }
开发者ID:andrewdavis1995,项目名称:MALTMusic,代码行数:43,代码来源:Login.cs


注:本文中的LoginModel.doLogin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。