string sql2 = "select adddate,LimitYear from users where code='" + Number + "'";
DataSet ds2 = bc.getDataSet(sql2);
DateTime addTime = Convert.ToDateTime(ds2.Tables[0].Rows[0][0]);
int liyear = Convert.ToInt32(ds2.Tables[0].Rows[0][1]);
if (DateTime.Now > addTime.AddYears(+liyear))
{
bc.MessageBox("对不起,您的账户已过期,将不能登录,感谢你的使用!", "/index.aspx");
}明明断点DateTime.Now的值(2013-9-10 15:02:02) 大于 断点addTime.AddYears(+liyear)的值(2013-8-09 11:02:02)
可是这句---- bc.MessageBox("对不起,您的账户已过期,将不能登录,感谢你的使用!", "/index.aspx");--一直未见执行!请各位大师指教!万分感谢!
DataSet ds2 = bc.getDataSet(sql2);
DateTime addTime = Convert.ToDateTime(ds2.Tables[0].Rows[0][0]);
int liyear = Convert.ToInt32(ds2.Tables[0].Rows[0][1]);
if (DateTime.Now > addTime.AddYears(+liyear))
{
bc.MessageBox("对不起,您的账户已过期,将不能登录,感谢你的使用!", "/index.aspx");
}明明断点DateTime.Now的值(2013-9-10 15:02:02) 大于 断点addTime.AddYears(+liyear)的值(2013-8-09 11:02:02)
可是这句---- bc.MessageBox("对不起,您的账户已过期,将不能登录,感谢你的使用!", "/index.aspx");--一直未见执行!请各位大师指教!万分感谢!
bc.MessageBox("对不起,您的账户已过期,将不能登录,感谢你的使用!", "/index.aspx");
}
而且就算把大于号改成小于号,也会跳过去。请帮我看看。
messagebox.show()?
bc.MessageBox("对不起,您的账户已过期,将不能登录,感谢你的使用!", "/index.aspx");放在第一行(所有代码的最上一行),不设任何条件,居然也不执行!
bc.MessageBox("对不起,您的账户已过期,将不能登录,感谢你的使用!", "/index.aspx");放在第一行(所有代码的最上一行),不设任何条件,居然也不执行!
你这个加号没必要吧 如果你这个liyear值是负的那你前面的加号可能会导致错误
{
BaseClass bc = new BaseClass();
usersManager bll = new usersManager();
users model = new users();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//if (Session["userid"] != null)
//{
// Response.Redirect("usercenter.aspx");
//}
}
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{ string Number = bc.NoHTML(this.txtNumber.Text.ToString().Trim());
string password = bc.NoHTML(this.txtPassword.Text.ToString().Trim()); if (this.txtCode.Text.ToString() == Request.Cookies["CheckCode"].Value.ToString())
{
if (bll.CheckLogin(Number, password))
{
if (bc.userLimit(Number))
{
//将用户ID保存到session
string sql = "select userid,LimitYear,LimitDate,loginnum from users where code='" + Number + "'";
DataSet ds = bc.getDataSet(sql);
Session["userid"] = ds.Tables[0].Rows[0][0].ToString();
string yhm = this.txtNumber.Text.ToString();
Session.Add("yonghuming",yhm);
Session.Timeout = 600;
bc.MessageBox("我要测试!", "login.aspx");
//如果用户是第一次登录则产生用户的到期时间
if (ds.Tables[0].Rows[0][1].ToString() != "0" && ds.Tables[0].Rows[0][3].ToString() == "0")
{
string sqln = "update users set loginDate='" + DateTime.Now.ToString() + "', LimitDate='" + DateTime.Now.AddYears(+Convert.ToInt32(ds.Tables[0].Rows[0][1])) + "' where userid=" + Convert.ToInt32(ds.Tables[0].Rows[0][0]);
bc.executesql(sqln);
} //将登录次数+1
string sqlc = "update users set loginnum=loginnum+1 where userid=" + Convert.ToInt32(ds.Tables[0].Rows[0][0]);
bc.executesql(sqlc);
Response.Redirect("usercenter.aspx");
}
else
{
bc.MessageBox("对不起,您的账户已过期,将不能登录,感谢你的使用!", "/index.aspx");
} }
else
{
bc.MessageBox("用户名、密码出错,请确认正确后重试!", "login.aspx");
}
}
else
{
bc.MessageBox("验证码输入错误!", "login.aspx");
} }
}
Response.Redirect("index.aspx");这个可以。
天哪,怎么回事?
贴的给我们看下啊!
public class BaseClass
{
.......
public void MessageBox(string Message, string page)
{
HttpContext.Current.Response.Write("<script>alert('" + Message + "');location.href='" + page + "'</script>");
}
}
{
const string js = "<Script language='JavaScript'>alert('{0}');window.location.replace('{1}')</script>";
HttpContext.Current.Response.Write(string.Format(js, Message, page));
}
{
const string js = "<Script language='JavaScript'>alert('{0}');window.location.replace('{1}')</script>";
HttpContext.Current.Response.Write(string.Format(js, Message, page));
}