Пример #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     string us = textBox1.Text.Trim();
     string ps = textBox2.Text;
     System.Text.RegularExpressions.Regex rg = new System.Text.RegularExpressions.Regex(@"[\w]{1,25}");
     if (!rg.IsMatch(us))
     {
         MessageBox.Show("请输入规范的名称!");
         return;
     }
     if (ps.Length<5)
     {
         MessageBox.Show("密码长度太小!");
         return;
     }
     User ur = new User(us, ps);
     if (ur.GetStatus())
     {
         mParent.user = ur;
         Hide();
         return;
     }
     //MessageBox.Show();
 }
Пример #2
0
        private void InUserDB(string un,string ps,string iv,string sm,string sQQ,string sPhone)
        {
            try
            {
                string sWhere = "select count(*) from userinfo where username='******'";
                string sCmd = "insert into userinfo values ('"+un+"','"+DB.getMd5Hash(ps)+"',0,getdate(),'"+sm+"','"+sQQ+"','"+sPhone+"')";
                SqlConnection sc = DB.MsSQLCreate();
                sc.Open();
                System.Data.SqlClient.SqlCommand scc = new System.Data.SqlClient.SqlCommand(sWhere, sc);
                int i = int.Parse(scc.ExecuteScalar().ToString());
                if (i!=0)
                {
                    MessageBox.Show("用户名已存在!");
                    sc.Close();
                    return;
                }
                scc.CommandText=sCmd;
                i = scc.ExecuteNonQuery();
                if (i>0)
                {
                    MessageBox.Show("注册成功!");
                    scc.CommandText="select SCOPE_IDENTITY()";
                    User ur = new User(scc.ExecuteScalar().ToString());
                    mParent.user = ur;
                    Hide();
                    if (iv.Length > 0)
                    {
                        AddScore(iv);
                    }
                }else
                {
                    MessageBox.Show("注册失败!");
                }
                sc.Close();

            }
            catch
            {
                MessageBox.Show(mParent.strErrorData);
            }
        }