电子商务与安全课程设计.doc

上传人:仙人指路1688 文档编号:2398174 上传时间:2023-02-17 格式:DOC 页数:26 大小:711KB
返回 下载 相关 举报
电子商务与安全课程设计.doc_第1页
第1页 / 共26页
电子商务与安全课程设计.doc_第2页
第2页 / 共26页
电子商务与安全课程设计.doc_第3页
第3页 / 共26页
电子商务与安全课程设计.doc_第4页
第4页 / 共26页
电子商务与安全课程设计.doc_第5页
第5页 / 共26页
点击查看更多>>
资源描述

《电子商务与安全课程设计.doc》由会员分享,可在线阅读,更多相关《电子商务与安全课程设计.doc(26页珍藏版)》请在三一办公上搜索。

1、电子商务与安全课程设计一 设计思想:随着INTERNET的发展和普及,电子商务在人们的生活中的角色越来越重要。以互联网为依托的电子商务,可以方便商家和消费者。本课程设计利用VS2010开发环境和ASP.NET语言,设计实现了一个简单的电子商务网站。ASP.NET的运行环境:Win7+IIS+vs2010。数据库采用MICROSFOT SQL SERVER 2008。可以实现简单的在线购物以及后台管理功能。通过配置本地服务器,可以实现上线运营。二 网站功能:一 会员注册功能。网购的第一步是注册帐号。只有在注册帐号之后才能选购商品,结帐。二 登陆功能。注册之后,网站为用户在数据库中记录信息,登陆之

2、后就可以连接到数据库,从而可以将购物信息存储到数据库,同时可以使用会员信息查询功能,查看会员的购物记录,消费金额等。三 会员管理功能。会员登录之后可以通过此功能修改个人信息。四 商品信息查询。会员可以按商品所属类别、所属仓库、商品名称查看商品的详细信息。同时可以选则购买商品,点击购买商品后该商品自动加入到购物车中。五 购物车功能。会员可以在购物车中查看已经买到的商品,删除不想购买的商品。点击结帐后可以完成购物。点击清空购物车,可以删除所有添加到购物车中的商品。六 购物信息查询功能。会员可以输入自己的ID查看自己的购物记录。七 后台管理功能。登陆管理员帐户,可以实现商品管理、会员管理、仓库管理、

3、订单管理、修改管理员帐户信息等功能。三 功能的具体实现1. defailt.aspx:网站的整体布局源码:网站的整体布局public partial class _Default : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) 2.会员注册功能:MemberManage/RegPro.aspx主要源码: 威海市 /所在城市设置/地址/邮编/会员充值public partial class MemberManage_RegPro : System.Web.UI.Page protected voi

4、d Page_Load(object sender, EventArgs e) protected void btnAgree_Click(object sender, EventArgs e) Response.Redirect(Register.aspx); protected void btnRefuse_Click(object sender, EventArgs e) Response.Redirect(GoodsInfo.aspx); 3. 购物车功能:主要源码:结账?/结帐功能清?空?购o物?车/清空购物车public partial class MemberManage_Sho

5、pping : System.Web.UI.Page SqlOperate sqloperate = new SqlOperate(); SqlConnection sqlconn = new SqlConnection(ConfigurationManager.AppSettingsConnectionString); protected void Page_Load(object sender, EventArgs e) if (SessionMName = null) Response.Write(alert(您还没有登录,请登录后再使用该功能!);location=javascript

6、:history.go(-1);); if (!IsPostBack) string sqlstr = select OrderID,GoodsName,GoodsTypeName,GoodsPrice from tb_OrderInfo where OrderMember= +Convert.ToString(SessionMName) + and IsCheckout=否; gvOrderInfo.DataKeyNames = new string OrderID ; sqloperate.gvDataBind(gvOrderInfo, sqlstr); string sqlstrtpri

7、ce = select sum(GoodsPrice) as tprice from tb_OrderInfo + where OrderMember= + Convert.ToString(SessionMName) + and IsCheckout=否; sqlconn.Open(); SqlDataAdapter myda = new SqlDataAdapter(sqlstrtprice, sqlconn); DataSet myds = new DataSet(); myda.Fill(myds, tb_OrderInfo); DataRowView mydrv = myds.Tab

8、lestb_OrderInfo.DefaultView0; labMoney.Text = Convert.ToString(mydrv.Rowtprice); protected void lbtnCheck_Click(object sender, EventArgs e) if (labMoney.Text = ) Response.Write(alert(您的购物车中没有任何物品);); else string sqlstr = select MemberName,MemberMoney from tb_Member where MemberName= + SessionMName.T

9、oString() + ; sqlconn.Open(); SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlconn); DataSet myds = new DataSet(); myda.Fill(myds, tb_Member); DataRowView mydrv = myds.Tablestb_Member.DefaultView0; string MPrice = Convert.ToString(mydrv.RowMemberMoney); if (Convert.ToInt32(MPrice) Convert.ToInt3

10、2(labMoney.Text.Trim() Response.Write(alert(您的余额不足,请重新充值后再购买!);); else string sqlstrshop1 = update tb_Member set MemberMoney= + (Convert.ToInt32(MPrice) - Convert.ToInt32(labMoney.Text) + where MemberName= + SessionMName.ToString() + ; sqloperate.DataCom(sqlstrshop1); string sqlstrshop2 = update tb_

11、OrderInfo set IsCheckout=是 where OrderMember= + SessionMName.ToString() + ; sqloperate.DataCom(sqlstrshop2); Response.Redirect(SuccShop.aspx); protected void lbtnClear_Click(object sender, EventArgs e) string sqlstr = delete from tb_OrderInfo where OrderMember= + SessionMName.ToString() + and IsChec

12、kout=否; sqloperate.DataCom(sqlstr); Response.Redirect(Shopping.aspx); protected void gvOrderInfo_PageIndexChanging(object sender, GridViewPageEventArgs e) gvOrderInfo.PageIndex = e.NewPageIndex; gvOrderInfo.DataBind(); protected void gvOrderInfo_RowDataBound(object sender, GridViewRowEventArgs e) if

13、 (e.Row.RowType = DataControlRowType.DataRow) (LinkButton)(e.Row.Cells3.Controls0).Attributes.Add(onclick, return confirm(确定要删除吗?); protected void gvOrderInfo_RowDeleting(object sender, GridViewDeleteEventArgs e) string sqlstr = delete from tb_OrderInfo where OrderID= + gvOrderInfo.DataKeyse.RowInde

14、x.Value + ; sqloperate.DataCom(sqlstr); Response.Redirect(Shopping.aspx); 4. 购物信息查询源码:public partial class MemberManage_OrderInfo : System.Web.UI.Page SqlOperate sqloperate = new SqlOperate(); SqlConnection sqlconn = new SqlConnection(ConfigurationManager.AppSettingsConnectionString); protected void

15、 Page_Load(object sender, EventArgs e) if (!IsPostBack) protected void txtSel_Click(object sender, EventArgs e) if (SessionMName = null) Response.Write(alert(您还没有登录,请登录后再使用,谢谢!);location=javascript:history.go(-1);); else this.gvbind(); protected void gvShopInfo_PageIndexChanging(object sender, GridV

16、iewPageEventArgs e) gvShopInfo.PageIndex = e.NewPageIndex; this.gvbind(); public void gvbind() string sqlstr = select MemberID,MemberName from tb_Member where MemberID= + txtMID.Text.Trim() + ; sqlconn.Open(); SqlCommand sqlcom = new SqlCommand(sqlstr,sqlconn); int count = Convert.ToInt32(sqlcom.Exe

17、cuteScalar(); if (count 0) SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlconn); DataSet myds = new DataSet(); myda.Fill(myds, tb_Member); DataRowView mydrv = myds.Tablestb_Member.DefaultView0; string sqlstrbind = select * from tb_OrderInfo where OrderMember= + Convert.ToString(mydrv.RowMemberN

18、ame) + ; SqlCommand com = new SqlCommand(sqlstrbind,sqlconn); int countInfo = Convert.ToInt32(com.ExecuteScalar(); if (countInfo 0) sqloperate.gvDataBind(gvShopInfo, sqlstrbind); else gvShopInfo.Visible = false; Response.Write(alert(没有该会员购物信息); else Response.Write(alert(没有该用户,请您重新输入!);location=javas

19、cript:history.go(-1);); 5. 后台管理功能:登录源码:1.登录:public partial class AdminManage_Login : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) if (!IsPostBack) Random randobj = new Random(); labCode.Text = randobj.Next(1000, 10000).ToString(); protected void ImageButton1_Click(object s

20、ender, ImageClickEventArgs e) SqlConnection sqlconn = new SqlConnection(ConfigurationManager.AppSettingsConnectionString); sqlconn.Open(); SqlCommand sqlcom = new SqlCommand(proAdminInfo, sqlconn); sqlcom.CommandType = CommandType.StoredProcedure; sqlcom.Parameters.Add(AdminName, SqlDbType.VarChar,

21、20).Value = txtAdminName.Text.Trim(); sqlcom.Parameters.Add(AdminPwd, SqlDbType.VarChar, 20).Value = txtAdminPwd.Text.Trim(); SqlDataReader read = sqlcom.ExecuteReader(); if (txtAdminCode.Text.Trim() = labCode.Text.Trim() if (read.Read() /Response.Write(windows.open(AdminIndex.aspx);); Response.Redi

22、rect(AdminIndex.aspx); else Response.Write(alert(您输入的用户名或密码错误,请重新输入!);location=javascript:history.go(-1);); else Response.Write(alert(验证码输入有误,请重新输入!);location=javascript:history.go(-1);); protected void ImageButton2_Click(object sender, ImageClickEventArgs e) Response.Write(window.close();location=j

23、avascript:history.go(-1);); 2. 后台管理:1.管理员添加或者删除:public partial class AdminManage_EditAdmin : System.Web.UI.Page SqlConnection sqlconn = new SqlConnection(ConfigurationManager.AppSettingsConnectionString); SqlOperate sqloperate = new SqlOperate(); protected void Page_Load(object sender, EventArgs e)

24、if (!IsPostBack) txtAID.Text = RequestAdminID.ToString(); string sqlstr = select * from tb_Admin where AdminID=+RequestAdminID.ToString()+; sqlconn.Open(); SqlDataAdapter myda = new SqlDataAdapter(sqlstr,sqlconn); DataSet myds = new DataSet(); myda.Fill(myds,tb_Admin); DataRowView mydrv=myds.Tablest

25、b_Admin.DefaultView0; txtAName.Text = Convert.ToString(mydrv.RowAdminName); txtAPwd.Text = Convert.ToString(mydrv.RowAdminPwd); sqlconn.Close(); protected void btnAdd_Click(object sender, EventArgs e) string sqltest = select * from tb_Admin where AdminName= + txtAName.Text + ; sqlconn.Open(); SqlCom

26、mand sqlcom = new SqlCommand(sqltest, sqlconn); SqlDataReader read = sqlcom.ExecuteReader(); read.Read(); if (read.HasRows) if (this.txtAName.Text.Trim() = readAdminName.ToString().Trim() Response.Write(alert(该管理员已经存在);localtion=EditAdmin.aspx); return; else string sqlstr = insert into tb_Admin(Admi

27、nName,AdminPwd) + values( + txtAName.Text.Trim() + , + txtAPwd.Text.Trim() + ); sqloperate.DataCom(sqlstr); Response.Write(alert(添加成功);location=AdminManage.aspx;); protected void btnEdit_Click(object sender, EventArgs e) string sqlstr = update tb_Admin set AdminName=+txtAName.Text.Trim() +,AdminPwd=

28、+txtAPwd.Text.Trim()+ where AdminID=+RequestAdminID.ToString()+; sqloperate.DataCom(sqlstr); Response.Write(alert(修改成功);location=AdminManage.aspx;); protected void btnBack_Click(object sender, EventArgs e) Response.Redirect(AdminManage.aspx); 2. 商品管理:public partial class AdminManage_EditGoods : Syst

29、em.Web.UI.Page SqlOperate sqloperate = new SqlOperate(); SqlConnection sqlconn = new SqlConnection(ConfigurationManager.AppSettingsConnectionString); protected void Page_Load(object sender, EventArgs e) sqlconn.Open(); if (!IsPostBack) string sqlstr = select * from tb_GoodsType; sqloperate.ddlDataBi

30、nd(ddlGType, sqlstr, GoodsTypeName); string sqlstrshow = select * from tb_GoodsInfo where GoodsID=+RequestGoodsID.ToString()+; SqlDataAdapter myapter = new SqlDataAdapter(sqlstrshow,sqlconn); DataSet mydset = new DataSet(); myapter.Fill(mydset,tb_GoodsInfo); DataRowView mydrview=mydset.Tablestb_Good

31、sInfo.DefaultView0; txtGName.Text = Convert.ToString(mydrview.RowGoodsName); txtGPrice.Text = Convert.ToString(mydrview.RowGoodsPrice); txtGIntroduce.Text = Convert.ToString(mydrview.RowGoodsIntroduce); imgPhoto.ImageUrl = Convert.ToString(mydrview.RowGoodsPhoto); string sqlstrimg = select Image fro

32、m tb_Image; sqloperate.ddlDataBind(ddlPhoto,sqlstrimg,Image); string strGID; strGID = Convert.ToString(mydrview.RowGoodsTypeID); string sqlstrbind = select * from tb_GoodsType where GoodsTypeID= + strGID + ; SqlDataAdapter myda = new SqlDataAdapter(sqlstrbind, sqlconn); DataSet myds = new DataSet();

33、 myda.Fill(myds, tb_GoodsType); DataRowView mydrv = myds.Tablestb_GoodsType.DefaultView0; ddlGType.SelectedValue = Convert.ToString(mydrv.RowGoodsTypeName); SessionGid = strGID; if (Convert.ToString(mydrview.RowGoodsIsNew).Trim() = 是) cbIsNew.Checked = true; else cbIsNew.Checked = false; sqlconn.Clo

34、se(); protected void btnAdd_Click(object sender, EventArgs e) string sqltest = select * from tb_GoodsInfo where GoodsName= + this.txtGName.Text + ; sqlconn.Open(); SqlCommand sqlcom = new SqlCommand(sqltest, sqlconn); SqlDataReader read = sqlcom.ExecuteReader(); read.Read(); if (read.HasRows) if (this.txtGName.Text.Trim() = readGoodsName.ToString().Trim() Response.Write(alert(该商品已经存在);localtion=EditGoods.aspx); return;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 建筑/施工/环境 > 项目建议


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号