BookManage.aspx.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;

public partial class BookShow : System.Web.UI.Page
{
    static string bookimg = "not_exist.jpg";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Admin"] == null)
        {
            Response.Redirect("Default.aspx");
        }
    }

    protected void AddBook_Click(object sender, EventArgs e)
    {
        BookManager bm = new BookManager();
        bool re = bm.BookAdd(this.bookname.Text, this.bookclass.Text, bookimg, this.bookauthor.Text, this.bookpublisher.Text, this.bookprice.Text, this.bookdescription.Text, this.booknumber.Text);
        if (re)
        {
            Response.Redirect("BookManage.aspx");
        }
        else
            Response.Write("<script>alert('添加失败')</script>");
    }

    protected void Upload_Click(object sender, EventArgs e)
    {
        bool fileIsValid = false;

        if (this.FileUpload_I.HasFile)
        {
            //获取文件的后缀名
            String fileExtension = Path.GetExtension(this.FileUpload_I.FileName).ToLower();
            String[] restrictedExtension = { ".jpg", ".gif", ".bmp", ".png" };
            //判断文件类型是否符合要求
            for (int i = 0; i < restrictedExtension.Length; i++)
            {
                if (fileExtension == restrictedExtension[i])
                    fileIsValid = true;
            }

            if (fileIsValid == true)
            {
                try
                {
                    this.FileUpload_I.SaveAs(Server.MapPath("~/IMG/Book/") + FileUpload_I.FileName);
                    //this.Label.Text = "上传成功,文件预览:<br />";
后面还有 26 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。