基于.NET的网上商城系统的分析与设计 第8页

基于.NET的网上商城系统的分析与设计 第8页

 GetDataListData("select * from Products inner join Pictures on Products.PictureID=Pictures.PictureID");

            bbsshow();

        }

    }

    ConnectionStringSettings sets = ConfigurationManager.ConnectionStrings["DBConnection"];

    SqlConnection conn;

    protected void bbsshow()

    {

        conn = new SqlConnection(sets.ConnectionString);

        SqlCommand cmd = new SqlCommand("select bbscontent from BBS ", conn);

        conn.Open();

        SqlDataReader reader = cmd.ExecuteReader();

        while (reader.Read())

        {

            Label2.Text += reader.GetString(0) + "<br>";

        }

        reader.Close();

        conn.Close();

    }

    private void GetSourceListData()

    {

        SourceList.Items.Clear();

        conn = new SqlConnection(sets.ConnectionString);

        SqlCommand cmd = new SqlCommand("select CategoryID,Description from Categorys order by CategoryID", conn);

        conn.Open();

        SqlDataReader reader = cmd.ExecuteReader();

        while (reader.Read())

        {

            SourceList.Items.Add(new ListItem(reader["Description"].ToString(), reader["CategoryID"].ToString()));

        }

        reader.Close();

        conn.Close();

    }

    private void GetDataListData(string sqlStr)

    {

        conn = new SqlConnection(sets.ConnectionString);

        SqlDataAdapter da = new SqlDataAdapter(sqlStr, conn);

        DataSet ds = new DataSet();

        da.Fill(ds);

        DataList1.DataSource = ds;

        DataList1.DataBind();

     }

    protected void Button1_Click(object sender, EventArgs e)

    {

        GetDataListData("select * from Products inner join Categorys on Products.CategoryID=Categorys.CategoryID "

            + "inner join Pictures on Products.PictureID=Pictures.PictureID where Categorys.CategoryID=" + Convert.ToInt32(SourceList.SelectedValue));

    }

    protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)

    {

        if (e.CommandName == "image")

        {

            int product_id = Convert.ToInt32(DataList1.DataKeys[e.Item.ItemIndex]);

            Session["product_id"] = product_id;

            Response.Redirect("B2Cmain1.aspx");

        }

    }

    protected void LinkButton1_Click(object sender, EventArgs e)

    {

        Response.Redirect("Default.aspx");

    }

    protected void LinkButton2_Click(object sender, EventArgs e)

    {

        Response.Redirect("zxhIndex.aspx");

    }

}

用户注册实现代码(Regist.aspx.cs)

public partial class Regist : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

    }

    protected void handon_Click(object sender, EventArgs e)

    {

        zhuce();

    }

    protected void zhuce()

    {

        ConnectionStringSettings sets = ConfigurationManager.ConnectionStrings["DBConnection"];

        SqlConnection conn = new SqlConnection(sets.ConnectionString);

        SqlCommand cmd = new SqlCommand("insert into Users(username,password,Address,Telephone,Email) values ('" + UserName.Text + "','"+Password.Text+"','"+Address.Text+"','"+Telephone.Text+"','"+Email.Text+"')", conn);

        conn.Open();

        cmd.ExecuteNonQuery();

        conn.Close();

        Response.Write("<script>window.alert('添加用户"+UserName.Text+"成功!');</script>");

            }

    protected void Button1_Click(object sender, EventArgs e)

{

Response.Redirect("zxhIndex.aspx");

    }

}

购物主界面的实现代码(shopping.aspx.cs)

public partial class shopping : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

              BindData();

            string username = Session["username"].ToString();

            Label1.Text = username;

            bbsshow();

            }

    ConnectionStringSettings sets = ConfigurationManager.ConnectionStrings["DBConnection"];

    SqlConnection conn;

    protected void bbsshow()

    {

               conn = new SqlConnection(sets.ConnectionString);

        SqlCommand cmd = new SqlCommand("select bbscontent from BBS ", conn);

        conn.Open();

        SqlDataReader reader = cmd.ExecuteReader();

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ... 下一页  >> 

  • 上一篇文章:
  • 下一篇文章:
  • Copyright © 2007-2012 www.chuibin.com 六维论文网 版权所有