电子商务b2c实验报告

信息科学与工程学院

实验报告

电子商务b2c实验报告

电子商务b2c实验报告

电子商务b2c实验报告

电子商务b2c实验报告

电子商务b2c实验报告

电子商务b2c实验报告

电子商务b2c实验报告

电子商务b2c实验报告

电子商务b2c实验报告

电子商务b2c实验报告

电子商务b2c实验报告

电子商务b2c实验报告

附件:

实验报告说明

1.实验项目名称:要用最简练的语言反映实验的内容。要求与实验指导书中相一致。

2.实验类型:一般需说明是验证型实验还是设计型实验,是创新型实验还是综合型实验。

3.实验目的与要求:目的要明确,要抓住重点,符合实验指导书中的要求。

4.实验原理:简要说明本实验项目所涉及的理论知识。

5.实验环境:实验用的软硬件环境(配置)。

6.实验方案设计(思路、步骤和方法等):这是实验报告极其重要的内容。概括整个实验

过程。

对于操作型实验,要写明依据何种原理、操作方法进行实验,要写明需要经过哪几个步骤来实现其操作。

对于设计型和综合型实验,在上述内容基础上还应该画出流程图、设计思路和设计方法,再配以相应的文字说明。

对于创新型实验,还应注明其创新点、特色。

7.实验过程(实验中涉及的记录、数据、分析):写明具体上述实验方案的具体实施,包

括实验过程中的记录、数据和相应的分析。

8.结论(结果):即根据实验过程中所见到的现象和测得的数据,做出结论。

9.小结:对本次实验的心得体会、思考和建议。

10.指导教师评语及成绩:指导教师依据学生的实际报告内容,用简练语言给出本次实验报

告的评价和价值。

实验代码

using System;

using System.Data;

using System.Configuration;

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;

using System.Collections;

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

{

    CommonClass ccObj = new CommonClass();

    GoodsClass gcObj = new GoodsClass();

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!IsPostBack)

        {

            RefineBind();

            HotBind();

            DiscountBind();

        }

    }

    //绑定市场价格

    public string GetVarMKP(string strMarketPrice)

    {

        return ccObj.VarStr(strMarketPrice, 2);

    }

    //绑定热卖价格

    public string GetVarHot(string strHotPrice)

    {

        return ccObj.VarStr(strHotPrice, 2);

    }

    protected void RefineBind()

    {

        gcObj.DLDeplayGI(1, this.dLRefine, "Refine");

    }

    protected void HotBind()

    {

        gcObj.DLDeplayGI(3, this.dlHot, "Hot");

    }

    protected void DiscountBind()

    {

        gcObj.DLDeplayGI(2, this.dlDiscount, "Discount");

    }

    public void AddressBack(DataListCommandEventArgs e)

    {

        Session["address"] = "";

        Session["address"] = "Default.aspx";

        Response.Redirect("~/showInfo.aspx?id=" + Convert.ToInt32(e.CommandArgument.ToString()));

    }

    protected void dLRefine_ItemCommand(object source, DataListCommandEventArgs e)

    {

        if (e.CommandName == "detailSee")

        {

            AddressBack(e);

        }

        else if (e.CommandName == "buy")

        {

            AddShopCart(e);

        }

    }

    protected void dlDiscount_ItemCommand(object source, DataListCommandEventArgs e)

    {

        if (e.CommandName == "detailSee")

        {

            AddressBack(e);

        }

        else if (e.CommandName == "buy")

        {

            AddShopCart(e);

        }

    }

    protected void dlHot_ItemCommand(object source, DataListCommandEventArgs e)

    {

        if (e.CommandName == "detailSee")

        {

            AddressBack(e);

        }

        else if (e.CommandName == "buy")

        {

            AddShopCart(e);

        }

    }

    ///

    /// 向购物车中添加新商品

    ///

    ///

    /// 获取或设置可选参数,

    /// 该参数与关联的 CommandName

    /// 一起被传递到 Command 事件。

    ///

    public void AddShopCart(DataListCommandEventArgs e)

    {

        Hashtable hashCar;

        if (Session["ShopCart"] == null)

        {

            //如果用户没有分配购物车

            hashCar = new Hashtable();         //新生成一个

            hashCar.Add(e.CommandArgument, 1); //添加一个商品

            Session["ShopCart"] = hashCar;     //分配给用户

        }

        else

        {

            //用户已经有购物车

            hashCar = (Hashtable)Session["ShopCart"];//得到购物车的hash表

            if (hashCar.Contains(e.CommandArgument))//购物车中已有此商品,商品数量加1

            {

                int count = Convert.ToInt32(hashCar[e.CommandArgument].ToString());//得到该商品的数量

                hashCar[e.CommandArgument] = (count + 1);//商品数量加1

            }

            else

                hashCar.Add(e.CommandArgument, 1);//如果没有此商品,则新添加一个项

        }

    }

    protected void Button1_Click(object sender, EventArgs e)

    {       

    }

}

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 Manage_Login : System.Web.UI.Page

{

    CommonClass ccObj = new CommonClass();

    DBClass dbObj = new DBClass();

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!IsPostBack)

        {

            this.labCode.Text =ccObj.RandomNum(4);//产生验证码

        }

    }

    protected void btnLogin_Click(object sender, EventArgs e)

    {

        //判断用户是否已输入了必要的信息

        if (this.txtAdminName.Text.Trim() == "" || this.txtAdminPwd.Text.Trim() == "")

        {

            Response.Write(ccObj.MessageBox("登录名和密码不能为空!"));

        }

        else

        {

            //判断用户输入的验证码是否正确

            if (txtAdminCode.Text.Trim() == labCode.Text.Trim())

            { 

                //定义一个字符串,获取用户信息

                string strSql = "select * from tb_Admin where AdminName='"+this.txtAdminName.Text.Trim()+"' and Password='"+this.txtAdminPwd.Text.Trim()+"'";

                DataTable dsTable=dbObj.GetDataSetStr(strSql, "tbAdmin");

                if (dsTable.Rows.Count > 0)

                {

                    Session["AID"] = Convert.ToInt32(dsTable.Rows[0][0].ToString());//保存用户ID

                    Session["AName"] = dsTable.Rows[0][1].ToString();//保存用户名

                    Response.Write("");

                }

                else

                {

                    Response.Write(ccObj.MessageBox("您输入的用户名或密码错误,请重新输入!"));

                }

            }

            else

            {

                Response.Write(ccObj.MessageBox("验证码输入有误,请重新输入!"));

            }

        }

    }

      

    protected void btnCancel_Click(object sender, EventArgs e)

    {

        Response.Write("");

    }

}

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 feedback : System.Web.UI.Page

{

    CommonClass ccObj = new CommonClass();

    DBClass dbObj = new DBClass();

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!IsPostBack)

        {

            if (Session["UserName"] == null)

            {

                Response.Redirect("Default.aspx");

            } 

        }

    }

    protected void btnOK_Click(object sender, EventArgs e)

    {

        if (Session["UserName"] == null)

        {

            Response.Redirect("Default.aspx");

        }

        else

        {

            string strSql = "INSERT INTO tb_LeaveWord(Uid,Subject,Content,DateTime,IP)";

            strSql += " VALUES('" + Session["UserName"].ToString() + "','" + this.txtTitle.Text + "'";

            strSql += ",'" + this.FreeTextBox1.Text + "','" + DateTime.Now + "'";

            strSql += ",'" + Request.UserHostAddress + "')";

            dbObj.ExecNonQuery(dbObj.GetCommandStr(strSql));

            Response.Write(ccObj.MessageBox("添加成功!", "Default.aspx"));

        }       

    }

    protected void Button1_Click(object sender, EventArgs e)

    {

        this.txtTitle.Text = "";

        this.FreeTextBox1.Text = "";

    }

    protected void btnBack_Click(object sender, EventArgs e)

    {

        Response.Redirect("Default.aspx");

    }

}

相关推荐