orderform.aspx.cs

来自「一个较小的采购系统,一些比较实际的代码,可以用来参考」· CS 代码 · 共 56 行

CS
56
字号
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 orderform : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["name"] == null)
        {
            this.Response.Redirect("display.htm");
        }

       string strsession = this.Request.QueryString["a"];
       string strvalue = this.Request.QueryString["b"];
       string stradd = getadd(strsession);

       this.lblsession.Text = strsession;
       this.lbltime.Text = this.Request.QueryString["c"];
       SqlConnection conn = new SqlConnection();
       conn.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"];
       string myselectQuery = "select * from cook where cook_session='" + strsession + "' and cook_value='"+strvalue+"'";
       SqlDataAdapter dapt = new SqlDataAdapter(myselectQuery, conn);
       DataSet ds = new DataSet();
       dapt.Fill(ds, "cook");
       this.GridView1.DataSource = ds;
       this.GridView1.DataBind();
       conn.Close();
       ds.Clear();
       conn.Dispose();
    }
     private string getadd(string strsession)//获得帐号所在的具体地址
    {
        SqlConnection conn = new SqlConnection();
        conn.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"];
        conn.Open();
        SqlCommand cmd = new SqlCommand("getadd", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter para = new SqlParameter("@user_UID", SqlDbType.NVarChar, 50);
        para.Value = strsession;
        cmd.Parameters.Add(para);
        string stradd = cmd.ExecuteScalar().ToString();
        conn.Close();
        conn.Dispose();
        return stradd;
    }
}

⌨️ 快捷键说明

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