为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

闲置物品交易平台的后台管理系统

2017-09-01 50页 doc 454KB 173阅读

用户头像

is_731942

暂无简介

举报
闲置物品交易平台的后台管理系统闲置物品交易平台的后台管理系统 基于 ASP.NET 的闲置物品交易平台的后台管理系统 第一章 绪论 1.1 选题意义 基于 ASP.NET 的闲置物品交易平台的后台管理系统,提供较为完备的功能,能方便管理员有效地管理网站,使网站的日常维护变得简洁方便,为提高用户体验提供依据,能大大提高网站的维护效率。 1.2 选题背景 快速原型法是管理信息系统的一种开发方法。在系统开发之初,为用户构造一个系统的模型,即原型,反复演示原型并征求用户的意见和建议,开发人员再根据用户意见和建议不断修改并完善原型,直到用户满意,这种开发...
闲置物品交易平台的后台管理系统
闲置物品交易平台的后台管理系统 基于 ASP.NET 的闲置物品交易平台的后台管理系统 第一章 绪论 1.1 选题意义 基于 ASP.NET 的闲置物品交易平台的后台管理系统,提供较为完备的功能,能方便管理员有效地管理网站,使网站的日常维护变得简洁方便,为提高用户体验提供依据,能大大提高网站的维护效率。 1.2 选题背景 快速原型法是管理信息系统的一种开发方法。在系统开发之初,为用户构造一个系统的模型,即原型,反复演示原型并征求用户的意见和建议,开发人员再根据用户意见和建议不断修改并完善原型,直到用户满意,这种开发方法就是快速原型法。本系统采用的正是这种开发方法。 快速原型法实质上是一种迭代的循环型的开发方式,其开发过程如如下图所示: 图 1-1 第 0 页 第二章 闲置物品交易平台后台管理系统开发相关技术 2.1 ASP.NET 简介 ASP.NET,是从 ASP 发展而来的,但是它并非只是ASP的升级版。ASP.NET 是一个已编译的、基于.NET 的环境,任何 ASP.NET 应用程序都可以使用整个.NET框架,而且可以用任何与.NET 兼容的语言(包括 Visual Basic.NET、C#和 JavaScript.NET)创作应用程序[1]。相比 ASP,ASP.NET 提供更加稳定的性能、优秀的升级性、更快速更简便的开发管理、全新的语言以及网络服务。 2.2 C#简介 C#语言是微软公司为.NET FrameWork 精心设计的一种全新的面向对象的高级程序设计语言。C#继承了C和C++强大功能的同时去掉了它们的复杂特性(比如),使其成为一种安全的、稳定的、简单的、优雅的程序设计语言。它的一个重要特点是能够与 Web 紧密结合,只需使用简单的C#语言结构、C#组件就可以方便地为 Web 服务,并允许它们通过 [1]Internet 被运行在任何操作系统上的任何语言调用 。 而且根据TIOBE 近几年的编程语言排行榜显示C#一直是主流的编程语言。 2.3 SQL Server 2008 简介 SQL Server 2008 是由微软开发和维护的关系型数据库管理系统。它是基于客户端/服务器模式的数据库系统,图形化界面使用户能够更加快捷方便地对数据库进行管理,同时提供了丰富的编程接口,为程序的开发提供了更多的便利。 SQL Server 2008数据库引擎为关系型数据和结构化数据提供了更安全可靠的存储功能,使用户可以构建和管理用于业务的高可用和高性能的数据应用程序。 第三章 闲置物品交易平台后台管理系统简介 3.1 系统概述 网站的维护和优化工作是十分繁琐的。如果没有一个可视化的管理后台,那么网站的管理会非常复杂,若没有基本的网站建设知识就很难对网站进行维护和优化。针对这一情况,本系统在满足闲置物品交易平台的后台功能的基础上,注重发挥信息系统的智能化,以减轻网站管理员的工作负担。 本系统主要实现的功能模块有注册用户信息查询、举报处理、供求信息审核、论坛管理、意见建议反馈处理、用户申诉处理、商品类别管理、公告管理、首页幻灯片、管 第 1 页 理员管理以及管理员自有密码的管理等功能。用户通过本系统,可以快捷的处理闲置物品交易平台的后台业务,还能查询平台的基本信息,对供求信息进行统计,并可以以此分析研究在校大学生的闲置物品消费行为。 3.2 系统总体功能结构图 本课题系统总体结构如下图: 图 3-1 3.3开发环境 本系统所采用的开发环境如下: 操作系统:Windows 7 数据库:SQL Server 2008 开发工具:Microsoft Visual Studio 2010 开发环境:Microsoft.NET Framework SDK v3.5 开发语言:C# 3.4 设计思路 本系统采用 ASP.NET(C#)开发技术和 SQL Server 2008数据库系统,使用Visul Studio 2010 工具作为开发工具,可跨平台运行。总体设计思路如下: 第一步:理清思路,分析系统需求,得出基本需求; 第二步:实现系统界面的原型设计以及数据库的原型设计; 第三步:在以上步骤的基础上,进行相应的功能实现,得出系统原型; 第 2 页 第四步:修正和改正系统原型; 第五步:得出最终系统。 第四章 闲置物品交易平台后台管理系统的系统分析 4.1 可行性分析 如今计算机技术、网络技术发展都特别迅速,电子商务网站开发技术也已经成熟,为闲置物品交易平台后台管理系统的开发建设提供了良好的开发平台。 微软公司为ASP.NET程序开发提供了一个非常强大的开发工具,即Visual Studio,它是目前最流行的Windows平台应用程序的集成开发环境。它提供了整个软件生命周期中所需要的大部分工具,如统一建模语言工具(UML)、集成开发环境(IDE)、代码管控工具等等。 闲置物品交易平台后台管理系统是基于 ASP.NET 并采用面向对象的C#语言在 Vistual Studio环境中进行开发建设的,功能齐全,编程简单快速,能很好的响应闲置物品交易平台的管理需求,性价比高,操作简单,是提高闲置物品交易平台管理效率和运营效率的一个有效途径。 4.2需求分析 需求分析是设计数据库的起点,需求分析的结果能够准确地反应用户的实际要求,为以后的具体设计做准备。在对用户情况的分析及本系统的业务流程分析的基础上,确定系统应实现的功能。 通过问卷调查、图书馆以及网站查找资料后,得出闲置物品交易平台后台管理系统所需的功能如下: (1)注册用户信息查询 管理员有权查看注册用户的基本信息, 其中包括用户名、注册时间、最后登陆时间、发布的供求信息以及用户账号状态等。 (2)举报处理 管理员可根据举报信息将被举报用户的账号状态设置为“冻结”,被设置为“冻结”状态的账号是不允许登录操作的。另外,管理员亦可将被举报用户发布的违规消息的状态改为“非法”。经过一定时间后,被举报用户未提交申诉材料则管理员可删除其发布的违规信息。举报信息包含被举报用户,举报理由,举报用户,举报时间。 (3)供求信息管理 第 3 页 管理员可以查询本系统中的所有供求信息,并且可以对这些信息进行相应处理。管理员如若发现违规信息,可将该信息状态设置为“非法”状态。另外,对于旧信息,管理员可对其进行删除处理。供求信息包含用户、供求类别、发布时间以及供求信息状态。 (4)意见建议反馈处理 管理员可查询注册用户对本网站的意见建议并加以回复。可以删除过期或者无用的意见建议。 (5)用户申诉处理 审核注册用户的申诉材料,包含账号密码找回申诉材料、被举报处理申诉材料。 管理员依据用户提供的账户密码找回申诉材料的真实性判断是否重置用户的账号密码。账户密码找回申诉材料,包含用户名、注册时间、最后登陆时间、发布的供求信息,邮箱、QQ账号以及手机号码。 管理员依据用户提供的被举报处理申诉材料的真实性判断是否将该用户账号及其发布的信息恢复成“正常”状态。 (6)管理员管理 管理员管理分为两部分,即超级管理员和普通管理员。超级管理员可新增或者删除管理员,可对普通管理员的登录密码进行初始化或者重置处理。普通管理员仅可以修改自己的登录密码。 (7)公告管理 发布公告,删除公告以及修改公告。 (8)首页幻灯片 管理增加、删除幻灯片图片,以及修改图片连接。 (9)商品类别管理 增加、修改或删除商品类别名称。 (10)网站栏目导航管理 增加、修改或删除网站栏目导航名称、链接以及排序。 第五章 闲置物品交易平台后台管理系统数据库设计 5.1数据库需求分析 数据库需求分析,主要是收集基本数据和数据处理的流程,是以调查和分析为主要手段的。主要解决两个问题: 第一个问题是用户的信息需求,即调查理清用户需要保存 第 4 页 哪些信息,从这些信息中要得到什么样的信息,这些信息以及信息之间应当满足的完整性要求。 第二个问题是处理要求,即调查用户要在系统中实现什么样的功能,理清数据库中各种数据之间的关系。 课题针对这两个问题,对系统的业务流程和数据流程进行详细的分析,确定需要设计如下所示的数据字段和: (1) 注册用户信息表,数据字段包括:用户编号、用户名、密码、注册邮箱、注册时间、状态 (2) 举报信息表,数据字段包括:举报编号,被举报用户,举报理由,举报用户,举报时间 (3)举报处理信息表,数据字段包括:举报处理编号,举报编号,处理意见,处理人,处理时间 (4) 供求信息表,数据字段包括:供求信息编号,用户编号,供求类别,发布时间 (5) 供求信息审核表,数据字段包括:供求审核编号,供求信息编号,审核意见,审核人,审核时间 (6) 意见建议反馈处理信息表,数据字段包括:意见建议编号,用户名,意见建议,时间,状态 (7) 商品类别表,数据字段包括:商品类别编号,类别名称,状态 (8) 公告信息表,数据字段包括:公共编号,公共内容,状态 (9) 首页幻灯片表,数据字段包括:幻灯片编号,幻灯片地址,幻灯片链接 (10) 管理员信息表,数据字段包括:管理员编号,管理员名称,登录密码,权限 (11) 导航栏表,数据字段包括:栏目编号,栏目名称,栏目排序 5.2数据库概念结构设计 数据库概念结构设计是在需求分析的基础上,依照需求分析中的信息要求,对用户信息加以分类聚集和概括,建立信息模型,并依照选定的数据库管理系统软件,把它们 [2]转换为数据的逻辑结构,再依照软硬件环境最终实现数据的合理存 储。 依据本系统需求分析阶段收集的信息设计如下实体联系图: 第 5 页 图 5-1 5.3数据库逻辑结构设计 数据库逻辑结构设计是在概念结构设计的基础上进行的数据模型设计可以是层次、 [2]网状模型和关系模型。由于本系统采用的DBMS是SQL SERVER 2008,是基于关系模型的数据库管理系统,因此本系统的数据模型也为关系模型。 第 6 页 以下是根据概念结构设计阶段完成的实体联系图而得出的关系模型: (1)注册用户信息表(用户编号、用户名、密码、注册邮箱、注册时间、手机号码、状态) (2)举报信息表(举报编号,被举报用户,举报理由,举报用户,举报时间) (3)举报处理表(举报处理编号,举报编号,举报处理结果,处理人,处理时间) (4)账号申诉材料信息表(申诉编号,用户编号,用户名,注册时间,性别,注册邮箱,电话号码,申诉时间,处理状态) (5)举报申诉材料信息表(申诉编号,举报编号,申诉理由,申诉时间,用户编号,处理状态) (6)申诉处理表(申诉处理编号,申诉编号,申诉处理结果,处理人,处理时间) (7)供求信息表(供求信息编号,用户编号,供求类别,发布时间) (8) 供求信息审核表(供求审核编号,供求信息编号,审核意见,审核人,审核时间 ) (9) 意见建议反馈处理信息表(意见建议编号,用户编号,意见建议,时间,阅读状态) (10) 商品类别表(商品类别编号,类别名称,状态,管理员编号) (11) 公告信息表(公共编号,公告标题,公共内容,状态,管理员编号) (12) 首页幻灯片表(幻灯片编号,幻灯片地址,幻灯片链接,管理员编号) (13) 管理员信息表(管理员编号,管理员名称,登录密码,权限) (14) 导航栏表(栏目编号,栏目名称,栏目排序) 其中,各表的详细设计信息如下所示: 表 5-1 Register_info(注册用户信息表) 字段 数据类型 长度 约束 备注 id int 主键,自增长 用户编号 name varchar 24 唯一,不为空 用户名 pwd varchar 24 不为空 密码 email varchar 24 唯一,不为空 注册邮箱 tel varchar 12 唯一,不为空 手机号码 state char 2 不为空 状态 regtime vachar 50 不为空 注册时间 第 7 页 表 5-2 Report_info(举报信息表) 字段 数据类型 长度 约束 备注 id int 主键,自增长 举报编号 uid int 外键 被举报用户编号 reason text 不为空 举报理由 uuid int 外键 举报用户 time varchar 12 不为空 举报时间 表 5-3 Reportresult(举报处理表) 字段 数据类型 长度 约束 备注 id int 主键,自增长 举报处理编号 rid int 外键 举报编号 result text 不为空 举报处理结果 aid int 外键 处理人 time varchar 12 不为空 处理时间 表 5-4 AppealAccount(账号申诉材料信息表) 字段 数据类型 长度 约束 备注 Id int 主键 申诉编号 UserId int 不为空 用户编号 UserName varchar 24 不为空 用户名 RegTime varchar 50 注册时间 Sex varchar 2 性别 Email varchar 50 注册邮箱 Phone varchar 12 电话号码 Time varchar 50 申诉时间 State char 2 处理状态 第 8 页 表 5-5 AppealReport(举报申诉材料信息表) 字段 数据类型 长度 约束 备注 Id int 主键 申诉编号 rid int 不为空,外举报编号 键 reason text 不为空 申诉理由 time varchar 50 不为空 申诉时间 UserId varchar 2 外键 用户编号 State varchar 50 不为空 处理状态 表 5-6 Appeal(申诉材料信息表) 字段 数据类长度 约束 备注 型 id int 主键,自增长 申诉编号 appealtype int 外键 申诉类型编号 appeal int 外键 申诉内容 content text 不为空 申诉理由 time varchar 12 不为空 申诉时间 uid int 外键 申诉人编号 表 5-7 Appealresult(申诉处理表) 字段 数据类型 长度 约束 备注 id int 主键,自增长 申诉处理编号 rid int 外键 申诉编号 result text 不为空 申诉处理结果 aid int 外键 处理人 time varchar 12 不为空 处理时间 第 9 页 表 5-8 Goods_info(供求信息表) 字段 数据类型 长度 约束 备注 id int 主键,自增长 供求信息编号 typeid int 外键 供求类别编号 uid int 外键 用户编号 time varchar 12 不为空 处理时间 表 5-9 供求信息审核表 字段 数据类型 长度 约束 备注 id int 主键,自增长 供求审核编号 typeid int 外键 供求信息编号 uid int 外键 用户编号 time varchar 12 不为空 处理时间 表 5-10 Suggestion (意见建议反馈处理信息表) 字段 数据类型 长度 约束 备注 id int 主键,自增长 意见建议编号 uid int 外键 用户编号 content int 不为空 意见建议 time varchar 12 不为空 时间 state char 2 不为空 阅读状态 表 5-11 Gtype(商品类别表) 字段 数据类型 长度 约束 备注 id int 主键,自增长 商品编号 name varchar 24 不为空 商品类别 aid int 外键 管理员 time varchar 12 不为空 时间 state char 2 不为空 状态 第 10 页 表 5-12 Notice(公告信息表) 字段 数据类型 长度 约束 备注 id int 主键,自增长 公告编号 title varchar 50 不为空 公告标题 content text 不为空 管理员 time varchar 12 不为空 时间 state char 2 不为空 状态 表 5-13 Indexbanner (首页幻灯片表) 字段 数据类型 长度 约束 备注 id int 主键,自增长 幻灯片编号 imgaddr varchar 50 不为空 幻灯片地址 url varchar 50 不为空 幻灯片链接 aid varchar 12 不为空 管理员编号 表 5-14 Navinfo(导航栏表) 字段 数据类型 长度 约束 备注 id int 主键,自增长 栏目编号 name varchar 50 不为空 栏目名称 pwd varchar 50 不为空 栏目排序 表 5-15 Admininfo(管理员信息表) 字段 数据类型 长度 约束 备注 id int 主键,自增长 管理员编号 name varchar 50 不为空 管理员名称 pwd varchar 50 不为空 登录密码 power varchar 12 不为空 权限 第 11 页 第六章 闲置物品交易平台后台管理系统主要的界面和代码的实现 6.1系统公共模块设计 6.1.1 IIS服务器配置 在建立或使用网站之前,必须通过 IIS 创建站点及设置好站点主,使用 SQL Server 2005 附加或创建相应的数据库,才能够使该站点运行起来。IIS(Internet Information Services)包含许多管理网站的 Web 服务器的功能,提供网页在线浏览、网上信息发布等功能。IIS 安装与配置成功后,生成一个默认网站,使用该默认网站作为网站的 Web 服务器, 也可以创建一个虚拟目录指向物理文件夹来加载站点。在本地 IIS 创建企业站点,将源文件存放位置 D:\E-commerce 设置为主目录。 6.1.2数据库连接配置 在整个站点中,需要和数据库建立连接时,将使用同一个连接字符串。将其存放在Web.config 文件中,这样可以有效的避免错误的发生,同时也方便程序员的调用。Web.config 文件对于访问站点的用户来说是不可见的,而且也是不可访问的。为了方便对数据的操作和限制,本系统在 Web.Config 文件中配置了一些参数。主要配置参数是数据库连接字符串,具体配置如下: name="ehConnectionString" connectionString="Data Source=LZJ-PC;Initial 6.1.3自定义公共类 本系统中包含了两个自定义公共类,分别为dataOperate类和Jscript类。 其中dataOperate类主要用于数据库管理,它的成员函数包括createCon、execSQL、seleSQL,分别用于创建数据库连接、执行sql语句、判断是否存在指定数据。 Jscript类主要用于输出Jscript脚本代码,其成员主要是重载了两个MessageBox函数, 第 12 页 一个用于弹出窗口并跳转至指定页面,另一个只弹出警告窗口。 下面是两个类的具体代码: public class dataOperate { public static SqlConnection createCon() { string connstr = "Data Source=127.0.0.1;Initial Catalog=eh;Integrated Securi ty=True"; SqlConnection conn = new SqlConnection(connstr); return conn; } public static bool execSQL(string sql) { SqlConnection conn = createCon(); conn.Open(); SqlCommand com = new SqlCommand(sql, conn); try { com.ExecuteNonQuery(); conn.Close(); } catch { conn.Close(); return false; } return true; } public static bool seleSQL(string sql) { int i; SqlConnection conn = createCon(); conn.Open(); SqlCommand com = new SqlCommand(sql, conn); try { i = Convert.ToInt32(com.ExecuteScalar()); conn.Close(); } catch { conn.Close(); return false; } 第 13 页 if (i > 0) { return true; } else { return false; } } public static DataSet getDataset(string sql, string table) { SqlConnection conn = createCon(); conn.Open(); SqlDataAdapter sda = new SqlDataAdapter(sql, conn); DataSet ds = new DataSet(); sda.Fill(ds, table); return ds; } public static SqlDataReader getRow(string sql) { SqlConnection conn = createCon(); conn.Open(); SqlCommand com = new SqlCommand(sql, conn); //conn.Close(); return com.ExecuteReader(); } public static string power(string sql) { string i=""; SqlConnection conn = createCon(); conn.Open(); SqlCommand com = new SqlCommand(sql, conn); SqlDataReader rdr = com.ExecuteReader(); while (rdr.Read()) { i = rdr["power"].ToString(); } return i; } } public class jscript { public static string MessageBox(string text, string url) { 第 14 页 string str1, str2; str2 = ";window.location="; str1 = ""; return str1; } public static string MessageBox(string text) { string str1; str1 = ""; return str1; } public static string MessageBox(string text, string url,string a) { return ""; } } 6.1.4公共母版页及自定义控件的设计 母版页和自定义控件是vs 2005 以来最重要的新功能之一,它有两种重要作用:一是 代码的复用度提高,二是为整个网站保持创建一致的布局。以下是本系统中的母版页,所 有页面都是在此母版页的基础上开发设计的。母版页的头部以及左部导航均引用了自定 义控件。 图 6-1 第 15 页 6.1.5首页设计 管理员登录成功后自动跳转至后台管理系统首页,后台管理首页界面设计如下: 图 6-2 6.2登录模块的设计与实现 当用户名、密码以及验证码都输入正确时,方可登录后台管理主界面,否则提示用户名或密码或者验证码错误。验证码的设置可以防止非法用户利用工具软件暴力破解登录密码。 6.2.1 界面设计 图 6-3 6.2.2代码实现 以下为登录按钮的主要代码: protected void btSubmit_Click(object sender, EventArgs e) { 第 16 页 string sql = "select * from admin_info where name='"+tbname.Text+ "' and pw = '"+tbpwd.Text+"'" ; if (tbcode.Text.Equals(Session["check"].ToString()))//判断验证码是否正确 { if (dataOperate.seleSQL(sql))//判断用户名以及密码是否正确 { //查询数据库 SqlDataReader rdr = dataOperate.getRow(sql); while (rdr.Read()) {//加密用户信息 Session["id"] = Convert.ToInt32(rdr["id"]); Session["info"]= EncryptHelper.SHA1Encrypt(rdr["name"].ToString() + rdr["pw"].ToString()); } Response.Redirect("Default.aspx"); } else { Response.Write(jscript.MessageBox("用户名或者密码错误")); } } else { Response.Write(jscript.MessageBox("验证码错误")); } } 以下为实现验证码的主要代码: public partial class images_Default : System.Web.UI.Page { Random ran = new Random(); protected void Page_Load(object sender, EventArgs e) { string str = getRandomValidate(4); Session["check"] = str; //使用Session记录验证码信息 getImageValidate(str); } //得到随机字符串 private string getRandomValidate(int len) { int num; int tem; string rtuStr = ""; for (int i = 0; i < len; i++) { num = ran.Next(); 第 17 页 /* * 这里可以选择生成字符和数字组合的验证码 */ tem = num % 10 + '0';//生成数字 //tem = num % 26 + 'A';//生成字符 rtuStr += Convert.ToChar(tem).ToString(); } return rtuStr; } //生成图像 private void getImageValidate(string strValue) { //string str = "OO00"; ////前两个为字母O,后两个为数字0 int width = Convert.ToInt32(strValue.Length * 12); //计算图像宽度 Bitmap img = new Bitmap(width, 23); Graphics gfc = Graphics.FromImage(img); //产生Graphics对象,进行画 图 gfc.Clear(Color.White); drawLine(gfc, img); //写验证码,需要定义Font Font font = new Font("arial", 12, FontStyle.Bold); System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), Color.DarkOrchid, Color.Blue, 1.5f, true); gfc.DrawString(strValue, font, brush, 3, 2); drawPoint(img); gfc.DrawRectangle(new Pen(Color.DarkBlue), 0, 0, img.Width - 1, img.Height - 1); //将图像添加到页面 MemoryStream ms = new MemoryStream(); img.Save(ms, System.Drawing.Imaging.ImageFormat.Gif); //更改Http头 Response.ClearContent(); Response.ContentType = "image/gif"; Response.BinaryWrite(ms.ToArray()); //Dispose gfc.Dispose(); img.Dispose(); Response.End(); } private void drawLine(Graphics gfc, Bitmap img) { //选择画10条线,也可以增加,也可以不要线,只要随机杂点即可 for (int i = 0; i < 10; i++) { int x1 = ran.Next(img.Width); 第 18 页 int y1 = ran.Next(img.Height); int x2 = ran.Next(img.Width); int y2 = ran.Next(img.Height); gfc.DrawLine(new Pen(Color.Silver), x1, y1, x2, y2); //注意画笔一定要浅颜色, 否则验证码看不清楚 } } private void drawPoint(Bitmap img) { int col = ran.Next();//在一次的图片中杂店颜色相同 for (int i = 0; i < 100; i++) { int x = ran.Next(img.Width); int y = ran.Next(img.Height); img.SetPixel(x, y, Color.FromArgb(col)); } } } 6.3注册用户信息查询模块设计与实现 管理员有权查看注册用户的基本信息, 其中包括用户名、注册时间、最后登陆时间 、发布的供求信息以及用户账号状态等。 6.3.1 界面设计 下图为用户信息查看界面: 图 6-4 下图为主要条件查询界面: 图 6-5 第 19 页 6.3.2 代码实现 以下为条件查询代码: public void bind_data(string where) { string sql = "select [UserId], [UserPassWord], [UserName], [RegTime], [Sex], [Email], [MPhone] from UserInfo where " + where; SqlDataReader result = dataOperate.getRow(sql); GridView1.DataSource = dataOperate.getRow(sql); GridView1.DataBind(); Label1.Text = GridView1.Rows.Count.ToString(); } protected void Page_Load(object sender, EventArgs e) { } protected void TextBox1_TextChanged(object sender, EventArgs e) { if (!String.IsNullOrEmpty(TextBox1.Text)) { string queryUserName = "[UserName] like '%" + TextBox1.Text+"%'"; bind_data(queryUserName); } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { if (!String.IsNullOrEmpty(DropDownList1.SelectedValue)) { string queryState = "[State] = '" + DropDownList1.SelectedValue + "'"; bind_data(queryState); } } 6.4举报处理模块设计与实现 6.4.1 界面设计 以下为查看举报信息界面: 第 20 页 图 6-6 以下为举报信息详细信息页面: 图 6-7 6.4.2 代码实现 以下为举报信息的代码实现: public partial class report : System.Web.UI.Page { public void P(string sql) { if (dataOperate.execSQL(sql)) { Response.Write(jscript.MessageBox("操作成功", "report.aspx?id=" + Reques t.QueryString["id"], "")); } 第 21 页 else { Response.Write(jscript.MessageBox("操作失败", "report.asaspx?id=" + Request.QueryString["id"], "")); } } public void Pp(int i) { string sql = "select id from [Report_result] where [rid] = " + Request.QueryString["id"]; if (dataOperate.seleSQL(sql)) { sql = "update [Report_result] set [rresult] = '"+i+"',[rtime] = CONVERT(varchar(100), GETDATE(), 20),[aid]=" + Session["id"] + " where [rid] = '" + Request.QueryString["id"] + "'"; } else { sql = "insert into [Report_result]([rid],[rresult],[rtime],[aid]) values('" + Request.QueryString["id"] + "','" + i + "', CONVERT(varchar(100), GETDATE(), 20),'" + Session["id"] + "')"; } P(sql); } protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["id"])) { SqlDataSource1.SelectCommand = "SELECT [GoodsId], [GoodsTitle], [Email], [ContractMan], [Phone], [Address], [Content], [Flag], [BuySell], [Price], [PicPat h], [ProTimeEnd], [TypeName], [Goods].[UserId], [name] FROM [Goods],[admin_info],[GoodsType],[Report_info] where [aid] = [admin_info].[id] and [Goods].[GoodTypeID]=[GoodsType].[GoodTypeID] and [Report_info].[gid]=[GoodsId] and [Report_info].[id]= " + Request.QueryString["id"]; SqlDataSource2.SelectCommand = "SELECT Report_info.id , Report_info.gid, Report_info.reason, Report_info.rtime, Report_info.UserId, Report_info.State, UserInfo.UserName FROM Report_info INNER JOIN UserInfo ON Report_info.UserId = UserInfo.UserId and Report_info.id = " + Request.QueryString["id"]; } else Response.Write(jscript.MessageBox("非法操作", "Default.aspx", "")); } protected void Button1_Click(object sender, EventArgs e) { 第 22 页 Pp(0); } protected void Button3_Click(object sender, EventArgs e) { Pp(1); } protected void Button2_Click(object sender, EventArgs e) { Pp(1); } } 6.5供求信息管理 6.5.1界面设计 下图为供求信息管理查询页面: 图 6-8 下图为供求信息管理详细页面: 第 23 页 图 6-9 6.5.2 代码实现 以下供求信息查询的代码实现: public partial class goods : System.Web.UI.Page { public string sql = "SELECT [GoodsTitle], [GoodsId], [Content], [Flag], [IsGood sPic], [DownCount], [GoodTypeID], [UserId], [BuySell], [name], [State] FROM [Goods],[admin_info] where [aid] = id "; protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["action"])) { switch (Request.QueryString["action"]) { case "1": sql += "and [BuySell]='供?'"; break; case "2": sql += "and [BuySell]='求ó'"; break; case "3": sql += "and [BuySell]='送í'"; break; case "4": sql +=" and dbo.Goods.ProTimeEnd < DATEADD(YEAR, -1, GETDATE())"; break; default: Response.Write(jscript.MessageBox("非法操作", "Default.aspx", "")); 第 24 页 return; } SqlDataSource1.SelectCommand = sql; } } protected void TextBox1_TextChanged(object sender, EventArgs e) { if (!String.IsNullOrEmpty(TextBox1.Text)) { sql += " and [GoodsId] = " + TextBox1.Text; SqlDataSource1.SelectCommand = sql; } } protected void TextBox4_TextChanged(object sender, EventArgs e) { if (!String.IsNullOrEmpty(TextBox4.Text)) { sql += " and [GoodsTitle] like '%" + TextBox4.Text +"%'"; SqlDataSource1.SelectCommand = sql; } } protected void TextBox2_TextChanged(object sender, EventArgs e) { if (!String.IsNullOrEmpty(TextBox4.Text)) { sql += " and [UserId] = '" + TextBox2.Text + "'"; SqlDataSource1.SelectCommand = sql; } } protected void TextBox3_TextChanged(object sender, EventArgs e) { if (!String.IsNullOrEmpty(TextBox4.Text)) { sql += " and [ContractMan] like '%" + TextBox3.Text + "%'"; SqlDataSource1.SelectCommand = sql; } } } 以下为供求信息管理功能的代码实现: public partial class goodsInfo : System.Web.UI.Page { public void P(string sql) { if (dataOperate.execSQL(sql)) { 第 25 页 Response.Write(jscript.MessageBox("操作成功", "goodsInfo.aspx?id=" + Request.QueryString["id"], "")); } else { Response.Write(jscript.MessageBox("操作失败", "goodsInfo.aspx?id=" + Request.QueryString["id"], "")); } } protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["id"])) SqlDataSource1.SelectCommand = "SELECT [GoodsId], [GoodsTitle], [Email], [ContractMan], [Phone], [Address], [Content], [Flag], [BuySell], [Price], [PicPath], [ProTimeEnd], [TypeName], [UserId], [name] FROM [Goods],[admin_info],[GoodsType] where [aid] = [id] and [Goods].[GoodTypeID]=[GoodsType].[GoodTypeID] and [GoodsId] = '" + Request.QueryString["id"] +"'"; else Response.Write(jscript.MessageBox("非法操作","Default.aspx","")); } protected void Button1_Click(object sender, EventArgs e) { string sql=""; SqlDataReader rdr = dataOperate.getRow("select [Flag] from [Goods] where [GoodsId] = '" + Request.QueryString["id"] + "'"); while (rdr.Read()) { if (rdr["Flag"].Equals("0") || rdr["Flag"].Equals("-1")) { sql = "update [Goods] set [Flag] = 1 where [GoodsId] = '" + Request.QueryString["id"] + "'"; } else { sql = "update [Goods] set [Flag] = 0 where [GoodsId] = '" + Request.QueryString["id"] + "'"; } } P(sql); } protected void Button3_Click(object sender, EventArgs e) { 第 26 页 string sql = "update [Goods] set [Flag] = -1 where [GoodsId] = '" + Request.QueryString["id"] + "'"; P(sql); } protected void Button2_Click(object sender, EventArgs e) { string sql = "delete [Goods] where [GoodsId] = '" + Request.QueryString["id"] + "'"; if (dataOperate.execSQL(sql)) { Response.Write(jscript.MessageBox("操作成功", "goodsInfo.aspx", "")); } else { Response.Write(jscript.MessageBox("操作失败", "goodsInfo.aspx", "")); } } } 6.6意见建议反馈处理 6.6.1界面设计 下图为意见建议查询页: 图 6-10 下图为意见建议反馈详细页: 第 27 页 图 6-11 6.6.2 代码实现 以下为意见建议查询页的代码: public partial class suggestion : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["action"])) { string sql; switch (Request.QueryString["action"]) { case "1": sql = "SELECT [id], [title], [suggestiontime], [readstate],[UserNa me] FROM [suggestion],[UserInfo] where uid = UserId and readstate='0' "; break; case "2": sql = "SELECT [id], [title], [suggestiontime], [readstate],[UserNa me] FROM [suggestion],[UserInfo] where uid = UserId"; break; default: Response.Write(jscript.MessageBox("非法操作", "Default.aspx", "")); return; } SqlDataSource1.SelectCommand = sql; } } } 以下为意见建议详细页面的代码: 第 28 页 public partial class suggestionInfo : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["id"])) { string sql = "SELECT [id],[content] , [title], [suggestiontime], [readst ate],[UserName] FROM [suggestion],[UserInfo] where uid = UserId and [id] = " + Reques t.QueryString["id"]; SqlDataSource1.SelectCommand = sql; Response.Write(sql); sql = "update [suggestion] set [readstate]='1' where id = " + Request.QueryS tring["id"]; if (!dataOperate.execSQL(sql)) { Response.Write(jscript.MessageBox("系统出错", "Default.aspx", "")); } } else { Response.Write(jscript.MessageBox("非法操作", "Default.aspx", "")); } } } 6.7用户申诉处理 6.7.1界面设计 下图为用户申诉处理查询界面: 图 6-12 第 29 页 下图为用户账号密码申诉处理详细页面: 图 6-13 下图为用户被举报申诉处理页面: 第 30 页 图 6-14 6.7.2 代码实现 以下为用户账号密码找回申诉处理页面的代码实现: public partial class AppealAccountAction : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["id"])) { idLabel.Text = Request.QueryString["id"]; string sql = "SELECT [Id], [UserId], [UserName], [RegTime], [Sex], [Email], [MPhone], [TIME], [state] FROM [AppealAccount] where id = "+Request.QueryString["id"]; SqlDataSource1.SelectCommand = sql; SqlDataReader rdr = dataOperate.getRow(sql); while (rdr.Read()) { sql = "SELECT [MPhone], [Email], [State], [Sex], [RegTime], [UserName], [UserPassWord], [UserId] FROM [UserInfo] where id" + rdr["UserId"]; SqlDataSource2.SelectCommand = sql; } } else { Response.Write(jscript.MessageBox("非法操作", "Default.aspx", "")); return; } } protected void Button2_Click(object sender, EventArgs e) { if (!dataOperate.seleSQL("select id from [AppealAccountResult] where type = '1' and id = " + Request.QueryString["id"])) { string sql = "insert into [AppealAccountResult]([id] ,[result],[time] ,[aid],[type]) values(" + Request.QueryString["id"] + ",'" + Button2.Text + "',CONVERT(varchar(100), GETDATE(), 20)," + Session["id"] + ",'1') "; if (dataOperate.execSQL(sql)) { string Uupdatesql = "update [UserInfo] set [UserPassWord] = (select MPhone from [UserInfo] where [UserId] = " + Request.QueryString["id"] + ") where [UserId] = " + Request.QueryString["id"]; dataOperate.execSQL(Uupdatesql); 第 31 页 Response.Write(jscript.MessageBox("操作成功", "AppealAccountAction.aspx?id=" + Request.QueryString["id"], "")); } else { Response.Write(jscript.MessageBox("操作失败", "AppealAccountAction.aspx?id=" + Request.QueryString["id"], "")); } } else { Response.Write(jscript.MessageBox("信息已处理,不可更改", "AppealAccountAction.aspx?id=" + Request.QueryString["id"], "")); } } protected void Button1_Click(object sender, EventArgs e) { if (!dataOperate.seleSQL("select id from [AppealAccountResult] where type = '1' and id = " + Request.QueryString["id"])) { string sql = "insert into [AppealAccountResult]([id] ,[result],[time] ,[aid],[type]) values(" + Request.QueryString["id"] + ",'" + Button2.Text + "',CONVERT(varchar(100), GETDATE(), 20)," + Session["id"] + ",'1') "; dataOperate.execSQL("update [AppealAccount] set [state] = '1' where id = " + Request.QueryString["id"]); Response.Write(sql); if (dataOperate.execSQL(sql)) { string Uupdatesql = "update [UserInfo] set [UserPassWord] = (select MPhone from [UserInfo] where [UserId] = " + Request.QueryString["id"] + ") where [UserId] = " + Request.QueryString["id"]; dataOperate.execSQL(Uupdatesql); Response.Write(jscript.MessageBox("操作成功", "AppealAccountAction.aspx?id=" + Request.QueryString["id"], "")); } else { Response.Write(jscript.MessageBox("操作失败", "AppealAccountAction.aspx?id=" + Request.QueryString["id"], "")); } } else { Response.Write(jscript.MessageBox("信息已处理,不可更改", "AppealAccountAction.aspx?id=" + Request.QueryString["id"], "")); 第 32 页 } } } 以下为用户被举报申诉处理页面的代码实现: public partial class AppealReportAction : System.Web.UI.Page { public int id,rid,gid; protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["id"])) { id = Convert.ToInt32(Request.QueryString["id"]); string sql = "SELECT [Id],[rid],[UserName],[reason],[AppealReport].[state], [TIME] FROM [AppealReport],[UserInfo] where [UserInfo].[UserId] = [AppealReport].[UserId] and Id = " + id; SqlDataReader rdr = dataOperate.getRow(sql); while (rdr.Read()) { rid = Convert.ToInt32(rdr["rid"]); } AppealSqlDataSource.SelectCommand = sql; SqlDataSource1.SelectCommand = "SELECT [GoodsId], [GoodsTitle], [Email], [ContractMan], [Phone], [Address], [Content], [Flag], [BuySell], [Price], [PicPat h], [ProTimeEnd], [TypeName], [Goods].[UserId], [name] FROM [Goods],[admin_info],[GoodsType],[Report_info] where [aid] = [admin_info].[id] and [Goods].[GoodTypeID]=[GoodsType].[GoodTypeID] and [Report_info].[gid]=[GoodsId] and [Report_info].[id]= " + rid; SqlDataSource2.SelectCommand = "SELECT Report_info.id , Report_info.gid, Report_info.reason, Report_info.rtime, Report_info.UserId, Report_info.State, UserInfo.UserName FROM Report_info INNER JOIN UserInfo ON Report_info.UserId = UserInfo.UserId and Report_info.id = " + rid; } else { Response.Write(jscript.MessageBox("非法操作", "Default.aspx", "")); return; } } protected void Button1_Click(object sender, EventArgs e) { if (!dataOperate.seleSQL("select id from [AppealAccountResult] where type = '0' and id = " + Request.QueryString["id"])) { string sql = "insert into [AppealAccountResult]([id] ,[result 第 33 页 ],[time] ,[aid],[type]) values(" + Request.QueryString["id"] + ",'" + Button1.Text + "',CONVERT(varchar(100), GETDATE(), 20)," + Session["id"] + ",'0') "; dataOperate.execSQL("update [AppealAccount] set [state] = '1' where id = " + Request.QueryString["id"]); if (dataOperate.execSQL(sql)) { SqlDataReader rdr = dataOperate.getRow("select [gid] from [Report_info] where [id] = " + rid); while (rdr.Read()) { gid = Convert.ToInt32(rdr["gid"]); } dataOperate.execSQL("update [Goods] set [State] = '1' where [GoodsId] = " + gid); dataOperate.execSQL("update [AppealReport] set [State] = '1' where [Id] = " + Request.QueryString["id"]); Response.Write(jscript.MessageBox("操作成功", "AppealReportAction.aspx?id=" + Request.QueryString["id"], "")); } else { Response.Write(jscript.MessageBox("操作失败", "AppealReportAction.aspx?id=" + Request.QueryString["id"], "")); } } else { Response.Write(jscript.MessageBox("信息已处理,不可更改", "AppealReportAction.aspx?id=" + Request.QueryString["id"], "")); } } protected void Button2_Click(object sender, EventArgs e) { if (!dataOperate.seleSQL("select id from [AppealAccountResult] where type = '0' and id = " + Request.QueryString["id"])) { string sql = "insert into [AppealAccountResult]([id] ,[result],[time] ,[aid],[type]) values(" + Request.QueryString["id"] + ",'" + Button2.Text + "',CONVERT(varchar(100), GETDATE(), 20)," + Session["id"] + ",'0') "; dataOperate.execSQL("update [AppealReport] set [state] = '1' where id = " + Request.QueryString["id"]); if (dataOperate.execSQL(sql)) { dataOperate.execSQL("update [AppealReport] set [State] = '1' where 第 34 页 [Id] = " + Request.QueryString["id"]); Response.Write(jscript.MessageBox("操作成功", "AppealReportAction .aspx?id=" + Request.QueryString["id"], "")); } else { Response.Write(jscript.MessageBox("操作失败", "AppealReportAction .aspx?id=" + Request.QueryString["id"], "")); } } else { Response.Write(jscript.MessageBox("信息已处理,不可更改", "AppealReportAction.aspx?id=" + Request.QueryString["id"], "")); } } } 6.8管理员管理 管理员管理主要包含管理员查询,用户名密码修改以及添加和删除管理员用户。在进 行管理员管理操作时必须验证权限。 6.8.1 界面设计 下图为查询界面: 图 6-15 下图为添加新管理员界面: 第 35 页 图 6-16 下图为修改管理员用户名及密码的界面: 图 6-17 6.8.2代码实现 查询界面的代码实现,主要是:GridView控件的使用以及SqlDataSource数据源的配置绑定。 以下为删除管理员的具体实现代码: protected void Page_Load(object sender, EventArgs e) { String sql = "select power from admin_info where id = " + Session["id"]; 第 36 页 if (dataOperate.power(sql).Equals("0")) { if (!String.IsNullOrEmpty(Request.QueryString["id"])) { Response.Write(jscript.MessageBox("您确定要删除")); sql = "delete from admin_info where id=" + Request.QueryString["id"]; if (dataOperate.execSQL(sql)) { Response.Write(jscript.MessageBox("删除成功", "queryManage.aspx")); } else { Response.Write(jscript.MessageBox("删除失败", "queryManage.aspx")); } } } else { Response.Write(jscript.MessageBox("您的权限不够", "Default.aspx", "")); } } 以下为添加新管理员的具体代码实现: protected void Page_Load(object sender, EventArgs e) { String sql = "select power from admin_info where id = " + Session["id"]; if (!dataOperate.power(sql).Equals("0")) Response.Write(jscript.MessageBox("您的权限不够", "Default.aspx", "")); } protected void addButton_Click(object sender, EventArgs e) { string sql = "select name from admin_info where name='" + tName.Text+ "'"; if (dataOperate.seleSQL(sql)) {//判断用户是否已经存在 Response.Write(jscript.MessageBox("用户已存在")); } else { sql = "insert into admin_info(name,pw) values( '" + tName.Text + "' , '" + tPwd.Text + "' )"; string sql1 = "insert into admin_info(name,pw) values( '" + tName.Text + "' , '" + tPwd.Text + "' )"; if (dataOperate.execSQL(sql)) { 第 37 页 Response.Write(jscript.MessageBox("添加成功")); } else { Response.Write(jscript.MessageBox("添加失败); } } } 以下为修改管理员用户名及密码的具体代码实现,包含超级管理员修改其他管理员的 用户名密码和管理员修自己的用户名及密码: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { String sql; if (!String.IsNullOrEmpty(Request.QueryString["edi"])) { //管理员修改其他管理员的用户名和密码时执行 sql = "select power from admin_info where id = " + Session["id"]; if (dataOperate.power(sql).Equals("0"))//验证管理员权限 id = Convert.ToInt32(Request.QueryString["edi"]); else Response.Write(jscript.MessageBox("您的权限不够", "Default.aspx", "")); } else { // 管理员修改自己的用户名和密码时执行 id = Convert.ToInt32(Session["id"]); } sql = "select name,pw,power from admin_info where id=" + id; SqlDataReader rdr = dataOperate.getRow(sql); while (rdr.Read()) { TextBox1.Text = rdr["name"].ToString(); TextBox2.Text = rdr["pw"].ToString(); powerRB.Items[Convert.ToInt32(rdr["power"])].Selected = true; } } } protected void Update_Click(object sender, EventArgs e) { //执行修改操作 String sql = "update admin_info set name='" + TextBox1.Text + "',pw='" + TextBo x2.Text + "',power='" + powerRB.SelectedValue + "' where id=" + id; if (dataOperate.execSQL(sql)) 第 38 页 { state = 0; Response.Write(jscript.MessageBox("修改成功")); } else { state = 0; Response.Write(jscript.MessageBox("修改失败")); } } 6.9公告管理 对网站首页的公告进行管理,主要是增删改查操作。本模块引入了kindeditor可视化 编辑插件,方便管理员编辑公告内容。 6.9.1界面设计 下图为公告查询界面: 图 6-18 下图为发布新公告和修改公告的界面设计 图 6-19 第 39 页 6.9.2代码实现 以下为发布新公告和修改公告的代码实现: public string truestr = "添加成功"; public string falsestr = "添加失败"; protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["id"])) { if (!IsPostBack) { Label1.Text = "查看编辑公告"; string sql = "select * from notice where id = " + Request.QueryString["id"]; System.Data.SqlClient.SqlDataReader rdr = dataOperate.getRow(sql); while (rdr.Read()) { titileTB.Text = rdr["title"].ToString(); content1.Text = rdr["content"].ToString(); RadioButtonList1.Items[Convert.ToInt32(rdr["state"])].Selected = true; } } truestr = "修改成功"; falsestr = "修改失败"; } } protected void Button1_Click(object sender, EventArgs e) { string sql; if (String.IsNullOrEmpty(Request.QueryString["id"])) sql = "insert into notice([title],[content],[time],[state]) values('" + titile TB.Text + "','" + content1.Text + "','" + DateTime.Now.ToString() + "','" + RadioButtonList1.SelectedValue + "')"; else sql = "update notice set title = '" + titileTB.Text + "',content = '" + conten t1.Text + "',[time] = '" + DateTime.Now.ToString() + "',[state] = '" + RadioButtonList1.SelectedValue + "' where id = " + Request.QueryString["id"]; if (dataOperate.execSQL(sql)) { Response.Write(jscript.MessageBox(truestr)); 第 40 页 } else { Response.Write(jscript.MessageBox(falsestr)); } } 6.10首页幻灯片 6.10.1界面设计 下图为首页幻灯片查看界面: 图 6-20 下图为查看编辑以及新增首页幻灯片的界面: 图 6-21 6.10.2代码实现 以下为首页幻灯片删除的代码实现: public partial class banner : System.Web.UI.Page { public void DeleteFile(string path) { System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath(path)); if (file.Exists) { file.Delete(); 第 41 页 } } protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["del"])) { string sql = "delete from [indexbanner] where [id] = "+ Request.QueryS tring["del"]; SqlDataReader rdr = dataOperate.getRow("select [img] from [indexbanner] where [id] = "+ Request.QueryString["del"]); while (rdr.Read()) { DeleteFile(rdr["img"].ToString()); } if (dataOperate.execSQL(sql)) { Response.Write(jscript.MessageBox("删除成功", "banner.aspx", "")); } else { Response.Write(jscript.MessageBox("删除失败", "banner.aspx", "")); } } } } 以下为编辑以及新增首页幻灯片的代码实现: public partial class banneradd : System.Web.UI.Page { string imgsrc = ""; string fstr = "添加失败", tstr = "添加成功",sql; public bool Upimg() { Boolean fileOk = false; if (FileUpload1.HasFile) { string type = this.FileUpload1.PostedFile.ContentType.ToLower(); if (type.Contains("image")) { fileOk = true; } else { Response.Write(""); } 第 42 页 } else { Response.Write(""); } //如果扩展符合条件,则上传 if (fileOk) { string strFileName1 = FileUpload1.FileName; //取到上传文件的名称? string[] myfile = strFileName1.Split('.'); //把文件名与文件类型分开 string dotname = myfile[myfile.Length - 1].ToString().ToLower(); //得到文件类型 string filepath = Path.GetFullPath(FileUpload1.PostedFile.FileName); Random myrdn = new Random(); //产生随机数 strFileName1 = DateTime.Now.ToString("yyMMddHHmm") + myrdn.Next(10000).ToString() + "." + dotname; string imgpath = Server.MapPath("images/"); string folder = "banner"; if (!System.IO.Directory.Exists(imgpath + folder)) { System.IO.Directory.CreateDirectory(imgpath + folder); } FileUpload1.SaveAs(imgpath + folder + "//" + strFileName1); imgsrc = strFileName1; return true; } else { return false; } } public bool DeleteFile(string path) { FileInfo file = new FileInfo(Server.MapPath(path)); if (file.Exists) { try { file.Delete(); return true; } 第 43 页 catch { Response.Write(jscript.MessageBox("系统出错")); return false; } } return false; } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!String.IsNullOrEmpty(Request.QueryString["id"])) { SqlDataReader rdr = dataOperate.getRow("select [img],[url] from [indexbanner] where [id] = " + Request.QueryString["id"]); while (rdr.Read()) { Image1.Visible = true; Image1.ImageUrl = rdr["img"].ToString(); addressTextBox.Text = rdr["url"].ToString(); Button1.Text = "修改"; fstr = "修改失败"; tstr = "修改成功"; } } } } protected void Button1_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(Request.QueryString["id"])) { if (Upimg()) { string sql = "insert into [indexbanner]([img],[url],[aid]) values ('images/banner/" + imgsrc + "','" + addressTextBox.Text + "'," + Session["id"] + ") "; if (dataOperate.execSQL(sql)) { Response.Write(""); } else { Response.Write(sql); Response.Write(""); 第 44 页 } } } else { if (DeleteFile(Image1.ImageUrl)) { if (Upimg()) { string sql = "update [indexbanner] set [img] = 'images/banner/" + imgsrc + "', [url]='" + addressTextBox.Text + "',[aid] = " + Session["id"] + " where id = " + Request.QueryString["id"]; if (dataOperate.execSQL(sql)) { Response.Write(""); } else { Response.Write(sql); Response.Write(""); } } } } } } 6.11商品类别管理 6.11.1界面设计 以下为商品类别查看界面: 图 6-22 第 45 页 以下为商品类别修改和添加界面: 图 6-23 6.11.2 代码实现 以下为商品类别删除的代码实现: protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["id"])) { Response.Write(jscript.MessageBox("您确定要删除该商品类别")); string sql = "delete from [Gtype] where id=" + Request.QueryString["id"]; if (dataOperate.execSQL(sql)) { Response.Write(jscript.MessageBox("删除成功", "goodsType.aspx")); } else { Response.Write(jscript.MessageBox("删除失败", "goodsType.aspx")); } } } 以下为商品类别修改和添加的代码实现 public partial class addGoodsType : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!String.IsNullOrEmpty(Request.QueryString["id"])) { addButton.Text = "确认修改"; 第 46 页 String sql = "select [typename], [order] from [Gtype] where [id] =" + Reques t.QueryString["id"]; SqlDataReader rdr = dataOperate.getRow(sql); while (rdr.Read()) { gtName.Text = rdr["typename"].ToString(); order.Text = rdr["order"].ToString(); } } } } protected void addButton_Click(object sender, EventArgs e) { string sql,fstr,tstr,url; if (String.IsNullOrEmpty(Request.QueryString["id"])) { sql = "insert into Gtype([typename],[order]) values( '" + gtName.Text + "' , '" + order.Text + "' )"; tstr = "添加成功"; fstr = "添加失败"; url = "addGoodsType.aspx"; } else { sql = "update [Gtype] set [typename]='" + gtName.Text + "',[order]='" + order.Text + "' where id=" + Request.QueryString["id"]; tstr = "修改成功"; fstr = "修改失败"; url = "addGoodsType.aspx?id=" + Request.QueryString["id"]; } if (dataOperate.execSQL(sql)) { Response.Write(jscript.MessageBox(tstr,url,"")); } else { Response.Write(jscript.MessageBox(fstr,url,"")); } } } 第 47 页 6.12网站栏目导航管理 6.12.1界面设计 下图为网站栏目导航查看界面: 图 6-24 下图为网站栏目导航修改以及添加界面: 图 6-25 6.12.2代码实现 以下为网站导航栏删除的实现代码: public partial class nav : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(Request.QueryString["del"])) { Response.Write(jscript.MessageBox("确定要删除,")); if (dataOperate.execSQL("delete from [navinfo] where [id]=" + Reques t.QueryString["del"])) 第 48 页 { Response.Write(jscript.MessageBox("删除成功","nav.aspx","")); } } } } 以下为网站导航栏新增以及修改的实现代码: public partial class navadd : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!String.IsNullOrEmpty(Request.QueryString["id"])) { Button1.Text = "修改"; String sql = "select [name] ,[url] ,[navorder] ,[parentid] from [navinf o] where [id]=" + Request.QueryString["id"]; SqlDataReader rdr = dataOperate.getRow(sql); while (rdr.Read()) { nameTextBox.Text = rdr["name"].ToString(); orderTextBox.Text = rdr["navorder"].ToString(); urlTextBox.Text = rdr["url"].ToString(); parentDropDownList.SelectedValue = rdr["parentid"].ToString(); } } } } protected void Button1_Click(object sender, EventArgs e) { string tstr = "添加成功", fstr = "添加失败",url = "navadd.aspx"; string sql = " INSERT INTO [eh].[dbo].[navinfo] ([name] ,[url] ,[navorder] ,[parentid]) VALUES ('" + nameTextBox.Text + "' ,'" + urlTextBox.Text + "','" + orderTextBox.Text + "'," + parentDropDownList.SelectedValue + ")"; if (!String.IsNullOrEmpty(Request.QueryString["id"])) { sql = " update [eh].[dbo].[navinfo] set [name]= '" + nameTextBox.Text + "',[url]= '" + urlTextBox.Text + "',[navorder]=" + orderTextBox.Text + " ,[parentid]=" + parentDropDownList.SelectedValue + " where id = " + Request.QueryString["id"]; tstr = "修改成功"; fstr = "修改失败"; url = url + "?id=" + Request.QueryString["id"]; 第 49 页 } if (dataOperate.execSQL(sql)) { Response.Write(jscript.MessageBox(tstr,url,"")); } else { Response.Write(jscript.MessageBox(fstr,url,"")); } } } 第七章 结论 本后台管理系统能基本满足闲置物品交易平台的后台管理需求,操作简单易于上手,将为网站管理带来极大的便利。但是也可以看到,现阶段本系统在许多方面考虑的 还不够细致灵活,一些功能还不完善,技术方面仍较粗浅,与数据库连接较频繁,系统的整体性能仍有待日后进一步的优化~ 第 50 页
/
本文档为【闲置物品交易平台的后台管理系统】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索