算了,经过一天的努力,我已经知道怎么写了!不知道是不是我没说清楚,为什么你们的答案都那么奇怪呢? Checktime(); int dy = int.Parse(days); if (dy > 300) { int j = dy - 300; lblTip.Text = "软件已过期"+j+"天!"; } else { Response.Redirect("index.aspx"); } private void Checktime() { try { conn = new SqlConnection(connectionString); if (conn.State == ConnectionState.Closed) { conn.Open(); } cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "select Datediff(day,Min(login_time),Max(login_time)) days from dt_user_login_log"; da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds); days = ds.Tables[0].Rows[0][0].ToString(); } catch (Exception ex) { } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } }
if(days>300) // 提示不能登录, return;
110,536
社区成员
642,578
社区内容
加载中
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧