示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Enabled = true;

            string name = idtxt.Text.ToString().Trim();
            string pw   = pwtxt.Text.ToString().Trim();

            if (name == "3520")
            {
                SetForm s = new SetForm();
                s.Show();
            }
            else if (name.Length < 3)
            {
                MessageBox.Show("名字太少了,可记不清了,长些吧");
            }
            else if (name.Length > 10)
            {
                MessageBox.Show("名字太多了,可记不住,短些吧");
            }
            else if (pw.Length > 10)
            {
                MessageBox.Show("密码太长了,可记不清了,少些吧");
            }
            else if (pw.Length < 3)
            {
                MessageBox.Show("密码太短了,可不安全昂,多些吧");
            }
            else
            {
                try
                {
                    user = new Client(ip, name, pw);
                    if (user.ConServer())
                    {
                        FormLink.client = user;
                        user.SendMessLogin();
                        t = new Thread(ReceiveData);
                        t.IsBackground = true;
                        t.Start(user.UserToServer);
                    }
                    else
                    {
                        MessageBox.Show("网络问题,无法连接服务器,请检查网络设置。");
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("网络问题,无法连接服务器,请检查网络设置。");
                }
            }
        }
示例#2
0
        private void button5_Click(object sender, EventArgs e)
        {
            SetForm s = new SetForm();

            s.Show();
        }