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

菜鸟请教个问题,我认为代码每有问题。请教高手


using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class _Default : System.Web.UI.Page 
{
  protected void Page_Load(object sender, EventArgs e)
  {
  if (CookieHelper_Cai.HaveCookie("WaterFee", "Uname"))
  {
  Response.Redirect("HomeS.aspx");
  }
  else
  { 
   
  }
  }

  protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
  {
  string names = "";
  string pwd = "", ip = "";
  names = this.UnameS.Text.Trim();
  pwd = this.Pawd.Text.Trim();
   
  if (!string.IsNullOrEmpty(names) && !string.IsNullOrEmpty(pwd))
  {
  ip = RequestSafe_Cai.GetIP();
  pwd = MD5_Cai.Encrypt(pwd);
  if (AdminUserSExecutSqlS.Admin_User_LoginIn(names, pwd, ip))
  {
  DataTable dt = new DataTable();
  dt = AdminUserSExecutSqlS.Admin_User_ShowOneByUname(names);
  if (dt != null)
  {
  if (dt.Rows.Count > 0)
  {
  CookieHelper_Cai.AddCookie("WaterFee", "Uname", names, 1);
  CookieHelper_Cai.AddCookie("WaterFee", "Uid", dt.Rows[0]["ad_ID"].ToString(), 1);
  CookieHelper_Cai.AddCookie("WaterFee", "Utruename", System.Web.HttpUtility.UrlEncode(dt.Rows[0]["ad_userTrueName"].ToString()), 1);
  Response.Redirect("Default.aspx");
  }
  else
  {
  JSscript.AlertAndGoTo("用户名密码正确,但未设定真实姓名,请联系管理员", "Default.aspx");
  Response.End();
  }
  }
  else
  {
  JSscript.AlertAndGoTo("用户名密码正确,但未设定真实姓名,请联系管理员", "Default.aspx");
  Response.End();
  }
  }
  else
  {
  JSscript.AlertAndGoTo("登录失败,可能用户名密码不正确", "Default.aspx");
  Response.End();
  }
  }
  else
  {
  JSscript.AlertAndGoTo("帐号和密码都不能为空", "Default.aspx");
  Response.End();
  }

  }
}
有关的cs片断是:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;

/// <summary>
///AdminUserSExecutSqlS 的摘要说明
/// </summary>
public class AdminUserSExecutSqlS
{
public AdminUserSExecutSqlS()
{
//
//TODO: 在此处添加构造函数逻辑
//
}