毕业论文论文范文课程设计实践报告法律论文英语论文教学论文医学论文农学论文艺术论文行政论文管理论文计算机安全
您现在的位置: 毕业论文 >> 论文 >> 正文

网上书店系统论文-网上书店设计与实现 第11页

更新时间:2009-5-5:  来源:毕业论文
网上书店系统论文-网上书店设计与实现 第11页
然后在使用TextBox控件作为用户名和密码输入框,并添加一个ImageButton控件,当管理员输入要添加的其它管理员信息后,只要点击该图标,就会调用ImageButton1_Click()方法,将输入的信息写入管理员表中。ImageButton1_Click()代码如下:
  protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        string leibie = this.DropDownList1.SelectedValue.Trim();
        string username = this.username.Text.Trim();
        string pwd = this.pwd.Text.Trim();
        ConnectionStringSettings settings;
        settings = ConfigurationManager.ConnectionStrings["DatabaseConnectionString1"];
        string Sqlstring = @"INSERT INTO manager(leibie, username, pwd, date)
                           VALUES('" + leibie + "','" + username + "','" + pwd + "','" + System.DateTime.Now + "')";
        if (CreateCommand(Sqlstring, settings.ConnectionString) == 1)
        {
            this.Label1.Text = "添加成功!";
            this.DropDownList1.SelectedValue = "管理员";
            this.username.Text = "";
            this.pwd.Text = "";
        }
        else
        {
            this.Label1.Text = "添加失败!请重新添加。注:你添加的用户名可能已存在!";
            this.DropDownList1.SelectedValue = "管理员";
            this.username.Text = "";
            this.pwd.Text = "";
        }
}
(3)删除管理员:在管理员管理页面,使用GridView控件将所有管理员信息列出,注意:在绑定使要在“配置Selest语句”中选“高级”,在弹出的“高级SQL生成选项”选中“生成INSERT、UPDAT 、DELETE语句”;并且由删除命令按扭执行删除帐号操作,在执行删除操作时,为了避免误删,用OnClientClick="return confirm('确认要删除此行信息吗?')"来提示确认删除。管理员管理页面如图7-11。
 
图7-11 管理员管理
7.2  图书分类管理
图书分类管理的主要功能是供网站管理员对网上书店中的图书分类进行管理,可增加、删除图书的分类信息。
(1)添加图书分类:添加图书分类页面主要使用TextBox和ImageButton控件来实现图书分类的添加,添加图书分类页面设计如图7-12。
 
图7-12 添加图书分类
在该页面有一个重要的方法,即是当用户填写好分类信息后,单击“添加”时调用的ImageButton2_Click()方法,该方法用变量来保存用户输入的信息,如果图书分类表中已有该类,则提示出错,如果不存在,就写入图书分类表booktype中。ImageButton2_Click()方法代码如下:
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        string bigtype;
        string smalltype;
        bigtype = this.bigtype.Text.Trim();
        smalltype = this.smalltype.Text.Trim();
        ConnectionStringSettings settings;
        settings = ConfigurationManager.ConnectionStrings["DatabaseConnectionString1"];
        string Sqlstring = @"INSERT INTO booktype(bigtype, smalltype)
                           VALUES('" + bigtype + "','" + smalltype + "')";
        if (CreateCommand(Sqlstring, settings.ConnectionString) == 1)
        {
            this.Label1.Text = "添加成功!请到图书分类管理页面预览你添加的类别。";
         }
        else
        {
            this.Label1.Text = "添加失败!请重新添加。注:你添加的类型可能已存在!";
        }
    }
(2)删除图书分类:在管理图书分类页面,使用GridView控件将所有图书分类信息列出,由于图书分类信息较多,所以对控件开启分页功能,即设置以下属性:AllowPaging为True表示允许分页,PageSize为15 表示每页显示15行数据,并定义PagerSettings的FirstPageText属性为第一页,LastPageText属性为最后一页,Mode属性为NextPreviousFirstLast,NextPageText属性为下一页,PreviousPageText为上一页,同删除管理员类似,在执行删除操作时,为了避免误删,使用OnClientClick="return confirm('确认要删除此行信息吗?')"来提示删除。图书分类管理页面如图7-13。
 
图7-13图书分类管理
7.3  图书管理
该模块的主要功能是供网站管理员增加、修改、删除网上书店中图书的基本资料信息。
(1)添加图书:添加图书页面主要使用DropDownList、FileUpload、TextBox和ImageButton控件来实现图书的添加,添加图书页面设计如图7-14。
 
图7-14 添加图书
在该页面中,用2个DropDownList控件来分别绑定表booktype的图书的一级分类和二级分类,同管理员登录页面类似,在绑定一级分类的时候要选中“只返回唯一行”以保证类别不重复,并且对于2个DropDownList控件,还要选择“启动AutoPostBack”表示强制控件在每次选定项时回发;用TextBox控件来作为书名、作者等信息输入框,和添加图书分类不同的在于添加图书的信息里包括图片,这时就要使用FileUpload控件,利用HttpPostedFile FileUpload. PostedFile的FileName来获取上传的文件名,我们都知道,在一个路径的最后一个“\”后就是图片名,所以首先就使用string.LastIndexOf("\\")方法来获取最后一个“\”的索引位置,接着利用string.Substring(int index)方法来获取上传的图片名称,再利用Server.MapPath("")方法将存放图片的位置的相对路径转换成绝对路径,最后利用HttpPostedFile FileUpload. PostedFile.SaveAs()方法将用户上传的图片保存到服务器上。同添加图书分类一样,当用户填写好信息后,单击“添加”时调用的ImageButton2_Click()方法,该方法用变量保存用户输入的信息,如果图书表中已有该图书,则提示出错,如果不存在,就写入图书表books中。ImageButton2_Click()方法代码如下:
    protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        string bigtype = this.DropDownList1.SelectedValue.Trim();
        string smalltype = this.DropDownList2.SelectedValue.Trim();
        string bookname = this.bookname.Text.Trim();
        string writer = this.writer.Text.Trim();
        string Publisher = this.Publisher.Text.Trim();
        string PublishDate = this.PublishDate.Text.Trim();
        string PublishTimes = this.PublishTimes.Text.Trim();
        string ISBN = this.ISBN.Text.Trim();
        string PageCount = this.PageCount.Text.Trim();
        string WordCount = this.WordCount.Text.Trim();
        string Price = this.Price.Text.Trim();
        string Level1price = this.Level1price.Text.Trim();
        string Level2price = this.Level2price.Text.Trim();
        string Level3price = this.Level3price.Text.Trim();
        string Introduction = this.Introduction.Text.Trim();
        string Count = this.Count.Text.Trim();
        string mulu = this.mulu.Text.Trim();
        string tupian;
        string filepath = this.tupian.PostedFile.FileName;
        int i = filepath.LastIndexOf("\\");
        tupian = filepath.Substring(i + 1);
        string baseLocation = Server.MapPath("uploadfile/");// 上传路径
        ConnectionStringSettings settings;www.youerw.com
        settings = ConfigurationManager.ConnectionStrings["DatabaseConnectionString1"];
        string Sqlstring = @"INSERT INTO books(bigtype, smalltype, bookname, writer, Publisher, PublishDate, PublishTimes, ISBN,PageCount,WordCount, Price, Level1price, Level2price, Level3price,Introduction, Count, mulu, tupian, date)
                           VALUES('" + bigtype + "','" + smalltype + "','" + bookname + "','" + writer + "','" + Publisher + "','" + PublishDate + "','" + PublishTimes + "','" + ISBN + "','" + PageCount + "','" + WordCount + "','" + Price + "','" + Level1price + "','" + Level2price + "','" + Level3price + "','" + Introduction + "','" + Count + "','" + mulu + "','" + tupian + "','" + System.DateTime.Now + "')";
        if (CreateCommand(Sqlstring, settings.ConnectionString) == 1)
        {
            this.Label1.Text = "添加成功!请到图书管理页面预览你添加的图书。";
             try
                {
                  this.tupian.PostedFile.SaveAs(baseLocation + tupian);
                }
                catch (Exception err)
                {
                  this.Label1.Text =this.Label1.Text+ "但上传错误" + baseLocation
                     + "<br>" + err.ToString();
                }
        }

 << 上一页  [11] [12] [13] 下一页

网上书店系统论文-网上书店设计与实现 第11页下载如图片无法显示或论文不完整,请联系qq752018766
设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优文论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。