日期:2014-05-17 浏览次数:20508 次
public partial class _Default : System.Web.UI.Page
{
SqlDataReader sdr;
string[,] ary = new string[50, 2];
protected void Page_Load(object sender, EventArgs e)
{
Session.Timeout = 6000;
sltpdinfo();
}
protected void sltpdinfo()
{
SqlConnection scn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename='d:\\My Documents\\Visual Studio 2005\\WebSites\\b2cweb\\App_Data\\b2cdatabase.mdf';Integrated Security=True;User Instance=True");
SqlCommand sltpd = new SqlCommand("select pcode,pname,pscprice from product where pcode=@pcode",scn);
scn.Open();
SqlParameter pcode = new SqlParameter("pcode",Request.QueryString["pcode"]);
sltpd.Parameters.Add(pcode);
sdr = sltpd.ExecuteReader();
sdr.Read();
}
protected void btnpay_Click(object sender, EventArgs e)
{
}
protected void btnadd_Click(object sender, EventArgs e)
{
string[,] ary = new string[50, 2];
Session["pcode"] = sdr[0];
Session["pname"] = sdr[1];
Session["pscprice"] = sdr[2];
Session["mycar"] = ary;
if (ary[0,0]==null)
{
ary[0,0] = Session["pname"].ToString();
ary[0,1] = Session["pscprice"].ToString();
}
else
{
for (int i = 0; i < 50; i++)
{
if (ary[i, 0] == Session["pname"].ToString())
{
ary[i + 1, 0] = Session["pname"].ToString();
ary[i + 1, 1] = Session["pscprice"].ToString();
}
}
}
Response.Redirect("~/shopcar.aspx");
}
}