see.aspx.cs

来自「这是asp.net^和Visual C++Sharp编写的串并口通讯的书籍 源代」· CS 代码 · 共 55 行

CS
55
字号
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Stockpile_see : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Convert.ToString(Session["username"]) == "")
            {
                Response.Write("<script language=javascript>alert('请登录');location='../login.aspx'</script>");
            }
            this.bind();

            this.Button2.Attributes.Add("onclick","window.close();");
        }
    }
    public void bind()
    {
        string cid = Request["cid"];
        string strsql = "select * from tb_Reckoning where CommodityId=" + cid ;
        SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
        strcon.Open();
        SqlDataAdapter sda = new SqlDataAdapter(strsql, strcon);
        DataSet ds = new DataSet();
        sda.Fill(ds, "search");
        GridView1.DataSource = ds.Tables["search"];
        GridView1.DataKeyNames = new string[] { "id" };
        GridView1.DataBind();
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        this.bind();
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if(e.Row.RowType==DataControlRowType.DataRow)
        {
            e.Row.Cells[0].Text = (e.Row.DataItemIndex+2).ToString();
            e.Row.Cells[3].Text = Convert.ToString(Convert.ToDateTime(e.Row.Cells[3].Text).ToShortDateString());
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?