main.aspx.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
public partial class main : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            charuser();
        }
        //↓初始化载入检查用户这个方法,由于每次刷新都要载入Page_Load 所以使用 if (!Page.IsPostBack) 即只使用一次的意思 用私有方法调用
        //if (Session["UserName"] == null || Session["userid"] == null)  
        //{
        //    Response.Write("<script>alert('请先登录!')</script>");
        //    Response.Redirect("login.aspx", true); 
        //}
        //else
        //{
        //    Label1.Visible = true;
        //    Label1.Text = Convert.ToString(Session["UserName"]);
        //    Response.Write("<script>alert('欢迎回来!')</script>");
        //}
    }
    //私有方法  你也可以些成类以后方便调用
    private void charuser()
    {
        if (Session["UserName"] == null || Session["userid"] == null)
        {
            Response.Write("<script>alert('请先登录!')</script>");
            Response.Redirect("login.aspx", true);
        }
        else
        {
            Label1.Visible = true;
            Label1.Text = Convert.ToString(Session["UserName"]);
            Response.Write("<script>alert('欢迎回来!')</script>");
            SqlConnection conn = new SqlConnection(access.sqlconn);
            try
            {
                conn.Open();
                string str = "select infoid,month,category,mode,power,price,time from info";  //查信息表
                //SqlCommand cmd = new SqlCommand(str, conn);  //执行数据查询命令
                SqlDataAdapter da = new SqlDataAdapter(str, conn);
                DataSet ds = new DataSet();
                da.Fill(ds, "info");
                GridView1.DataSource = ds.Tables[0].DefaultView;
                GridView1.DataBind();
            }
            catch (SqlException ex)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<Script>alere('" + ex.Message + "')</Script>");
            }
            finally
后面还有 10 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。