日期:2014-05-17  浏览次数:20985 次

各位大牛请进,本人小白,帮忙看段代码,谢谢了!!!!
protected void btnLogin_Click (object sender, ImageClickEventArgs e)
{
     try
     {
          SqlParameter parameter1 = new SqlParameter("@Uid\uFFFD", SqlDbType.VarChar, 0x20);
          parameter1.Value = this.txtUid.Text.Trim();
          using(SqlDataReader reader1 = SqlHelper.ExecuteReader(ConfigurationManager.ConnectionStrings["SqlConStr\uFFFD"].ConnectionString, CommandType.Text, "select Pwd from T_User where Uid = @Uid\uFFFD", new SqlParameter[]{parameter1}))
          {
               if (reader1.Read() && (Encoding.ASCII.GetString(new MD5CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(this.txtPwd.Text.Trim()))) == reader1["Pwd\uFFFD"].ToString()))
               {
                    SqlParameter[] parameterArray1 = new SqlParameter[]{new SqlParameter("@LastLoginDate\uFFFD", SqlDbType.DateTime), new SqlParameter("@LastLoginIP\uFFFD", SqlDbType.VarChar, 15), new SqlParameter("@Uid\uFFFD", SqlDbType.VarChar, 0x20)};
                    parameterArray1[0].Value = DateTime.Now;
                    parameterArray1[1].Value = base.Request.UserHostAddress;
                    parameterArray1[2].Value = this.txtUid.Text.Trim();
                    SqlHelper.ExecuteNonQuery(ConfigurationManager.ConnectionStrings["SqlConStr\uFFFD"].ConnectionString, CommandType.Text, "update T_User set LastLoginDate = @LastLoginDate, LastLoginIP = @LastLoginIP where Uid = @Uid\uFFFD", parameterArray1);
                    base.Response.Cookies["UserName\uFFFD"].Value = this.txtUid.Text.Trim();
                    if (this.ddlLoginState.SelectedIndex != 0)
                    {
                         base.Response.Cookies["UserName\uFFFD"].Value = this.txtUid.Text.Trim();
                         base.Response.Cookies["UserName\uFFFD"].Expires = DateTime.Now.AddDays((double) int.Parse(this.ddlLoginState.SelectedValue));
                    }