示例#1
0
    private void EditShuMuSavePage(int meid)
    {
        int      id      = Utils.ParseInt(Utils.GetRequest("id", "all", 2, @"^[0-9]\d*$", "ID错误"));
        int      nid     = Utils.ParseInt(Utils.GetRequest("nid", "all", 2, @"^[0-9]\d*$", "ID错误"));
        string   title   = Utils.GetRequest("title", "all", 2, @"^[\s\S]{1,200}$", "书本名称限1-200字");
        string   summary = Utils.GetRequest("summary", "all", 2, @"^[\s\S]{1,500}$", "书本简介限1-500字");
        string   img     = Utils.GetRequest("img", "all", 2, @"^[\s\S]{1,200}$", "书本封面地址填写出错");
        string   author  = Utils.GetRequest("author", "all", 2, @"^[\s\S]{1,50}$", "书本作者限1-50字");
        int      length  = Utils.ParseInt(Utils.GetRequest("length", "all", 2, @"^[0-9]\d*$", "字数填写错误"));
        string   tags    = Utils.GetRequest("tags", "all", 2, @"^[^\#]{1,50}(?:\#[^\#]{1,50}){0,500}$", "多个搜索关键词请用#分开");
        int      state   = Utils.ParseInt(Utils.GetRequest("state", "all", 2, @"^[0-1]$", "书本状态选择错误"));
        int      types   = Utils.ParseInt(Utils.GetRequest("types", "all", 2, @"^[0-1]$", "书本性质选择错误"));
        int      aid     = meid;// Utils.ParseInt(Utils.GetRequest("aid", "all", 2, @"^[0-9]\d*$", "上传会员ID错误"));
        DateTime addtime = Utils.ParseTime(Utils.GetRequest("addtime", "post", 2, DT.RegexTime, "添加时间填写错误"));
        int      isover  = Utils.ParseInt(Utils.GetRequest("isover", "all", 2, @"^[0-1]$", "是否完结选择错误"));

        Book.Model.ShuMu m = new Book.BLL.ShuMu().GetShuMu(nid);
        if (m == null)
        {
            Utils.Error("不存在的书本", "");
        }
        if (m.isdel == 1)
        {
            Utils.Error("不存在的记录", "");
        }
        if (m.aid != meid)
        {
            Utils.Error("不存在的记录", "");
        }
        //int state = Utils.ParseInt(ub.GetSub("BookIsShuMu2", xmlPath));

        Book.Model.ShuMu model = new Book.Model.ShuMu();
        model.id      = nid;
        model.nid     = id;
        model.title   = title;
        model.summary = summary;
        model.img     = img;
        model.author  = author;
        model.length  = length;
        model.tags    = tags;
        model.state   = state;
        model.addtime = addtime;
        model.aid     = aid;
        model.types   = types;
        model.isover  = isover;
        new Book.BLL.ShuMu().Update(model);
        Utils.Success("编辑书本", "修改书本成功,正在返回..", Utils.getPage("bookman.aspx?act=list&id=" + id + ""), "1");
    }
示例#2
0
 /// <summary>
 /// 更新一条数据(后台使用)
 /// </summary>
 public void Update2(Book.Model.ShuMu model)
 {
     dal.Update2(model);
 }
示例#3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Book.Model.ShuMu model)
 {
     return(dal.Add(model));
 }
示例#4
0
    private void AddShuMuSavePage(int meid)
    {
        int    id      = Utils.ParseInt(Utils.GetRequest("id", "all", 2, @"^[0-9]\d*$", "ID错误"));
        string title   = Utils.GetRequest("title", "all", 2, @"^[\s\S]{1,200}$", "书本名称限1-200字");
        string summary = Utils.GetRequest("summary", "all", 2, @"^[\s\S]{1,500}$", "书本简介限1-500字");
        string author  = Utils.GetRequest("author", "all", 2, @"^[\s\S]{1,50}$", "书本作者限1-50字");
        int    length  = Utils.ParseInt(Utils.GetRequest("length", "all", 2, @"^[0-9]\d*$", "字数填写错误"));
        string tags    = Utils.GetRequest("tags", "all", 2, @"^[^\#]{1,50}(?:\#[^\#]{1,50}){0,500}$", "多个搜索关键词请用#分开");
        //int state = Utils.ParseInt(Utils.GetRequest("state", "all", 2, @"^[0-2]$", "书本状态选择错误"));
        int types = Utils.ParseInt(Utils.GetRequest("types", "all", 2, @"^[0-1]$", "书本性质选择错误"));
        int aid   = meid;// Utils.ParseInt(Utils.GetRequest("aid", "all", 2, @"^[0-9]\d*$", "上传会员ID错误"));
        //------------------------------------附件接收开始------------------------------------
        int    uid = meid;
        string img = "";

        //遍历File表单元素
        System.Web.HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
        for (int iFile = 0; iFile < files.Count; iFile++)
        {
            //检查文件扩展名字
            System.Web.HttpPostedFile postedFile = files[iFile];
            string fileName, fileExtension;
            fileName = System.IO.Path.GetFileName(postedFile.FileName);
            string UpExt = ".jpg,.jpeg,.gif,.png,.bmp";
            int    UpLength = 500;
            if (fileName != "")
            {
                fileExtension = System.IO.Path.GetExtension(fileName).ToLower();
                //检查是否允许上传格式
                if (UpExt.IndexOf(fileExtension) == -1)
                {
                    Utils.Error("附件格式只允许" + UpExt + "", "");
                }
                if (postedFile.ContentLength > Convert.ToInt32(UpLength * 1024))
                {
                    Utils.Error("附件大小限500K内", "");
                }
                string DirPath     = string.Empty;
                string prevDirPath = string.Empty;
                string Path        = "/Files/book/" + uid + "/";
                if (BCW.Files.FileTool.CreateDirectory(Path, out DirPath))
                {
                    //生成随机文件名
                    fileName = DT.getDateTimeNum() + iFile + fileExtension;
                    string SavePath = System.Web.HttpContext.Current.Request.MapPath(DirPath) + fileName;
                    postedFile.SaveAs(SavePath);

                    img = DirPath + fileName;
                }
                else
                {
                    Utils.Error("上传出现错误", "");
                }
            }
        }
        //------------------------------------附件接收结束------------------------------------
        int state = Utils.ParseInt(ub.GetSub("BookIsShuMu", xmlPath));

        Book.Model.ShuMu model = new Book.Model.ShuMu();
        model.nid     = id;
        model.title   = title;
        model.summary = summary;
        model.img     = img;
        model.author  = author;
        model.length  = length;
        model.tags    = tags;
        model.state   = state;
        model.addtime = DateTime.Now;
        model.aid     = aid;
        model.types   = types;
        model.isgood  = 0;
        new Book.BLL.ShuMu().Add(model);
        Utils.Success("添加书本", "添加书本成功,正在返回..", ReplaceWap(Utils.getUrl("bookman.aspx?act=list&amp;id=" + id + "")), "1");
    }