示例#1
0
文件: Main.cs 项目: KanLei/UdpAndTcp
        /// <summary>
        /// login
        /// </summary>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string userName = txtUserName.Text.Trim();
            string password = txtPassword.Text.Trim();
            if (userName.IsNullOrWhiteSpace() || password.IsNullOrWhiteSpace())
            {
                this.ShakeForm();
                txtUserName.Text = txtPassword.Text = "";
                txtUserName.Focus();
                SystemSounds.Exclamation.Play();
                return;
            }

            lblShowConnMsg.Visible = pictureBox1.Visible = true;
            userInfo = new UserInfo { Name = userName, Password = password };
            Func<int> myFun = () =>
            {
                // validate input user info
                OperateUserInfo operate = new OperateUserInfo();
                Thread.Sleep(2000);
                return operate.ValidateUserInfo(userInfo);
            };
            myFun.BeginInvoke(CallBackMethod, myFun);
        }
示例#2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            string userName = txtUserName.Text.Trim();
            string password = txtPassword.Text.Trim();
            string repeatPassword = txtRepeatPassword.Text.Trim();
            string mail = txtMail.Text.Trim();

            // 验证用户输入的信息是否合法
            if (VerifyUserInfo.Verify(userName, password, mail) == false)
            {
                MessageBox.Show("请检查输入的信息!", "信息不合法:");
                return;
            }
            else
            {
                // TODO:判断用户是否已经存在

                if (password.Equals(repeatPassword))
                {
                    UserInfo user = new UserInfo()
                    {
                        Name = userName,
                        Password = password,
                        Email = mail
                    };
                    OperateUserInfo operate = new OperateUserInfo();
                    bool record = operate.AddUserInfo(user);
                    if (record == true)
                    {
                        MessageBox.Show("注册成功!");
                    }
                }
                else
                    MessageBox.Show("密码不一致!", "错误:", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }