Ejemplo n.º 1
0
        private void ShowInfo(int _id)
        {
            BLL.Forum_Attachment   bll   = new BLL.Forum_Attachment();
            Model.Forum_Attachment model = bll.GetModel(_id);
            //编写赋值操作Begin

            //txtId.Text = model.Id;
            //txtUserId.Text = model.UserId;
            //txtBoardId.Text = model.BoardId;
            //txtTopicId.Text = model.TopicId;
            //txtPostId.Text = model.PostId;
            //txtUploadDatetime.Text = model.UploadDatetime;
            //txtName.Text = model.Name;
            //txtFileName.Text = model.FileName;
            //txtDescription.Text = model.Description;
            //txtFileType.Text = model.FileType;
            //txtFileSize.Text = model.FileSize;
            //txtIsImage.Text = model.IsImage;
            //txtThumb.Text = model.Thumb;
            //txtDownload.Text = model.Download;
            //txtCost.Text = model.Cost;
            //txtCostType.Text = model.CostType;

            //编写赋值操作End
        }
Ejemplo n.º 2
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.Forum_Attachment   bll   = new BLL.Forum_Attachment();
            Model.Forum_Attachment model = bll.GetModel(_id);

            //编写编辑操作Begin
            //model.Id = txtId.Text;
            //model.UserId = txtUserId.Text;
            //model.BoardId = txtBoardId.Text;
            //model.TopicId = txtTopicId.Text;
            //model.PostId = txtPostId.Text;
            //model.UploadDatetime = txtUploadDatetime.Text;
            //model.Name = txtName.Text;
            //model.FileName = txtFileName.Text;
            //model.Description = txtDescription.Text;
            //model.FileType = txtFileType.Text;
            //model.FileSize = txtFileSize.Text;
            //model.IsImage = txtIsImage.Text;
            //model.Thumb = txtThumb.Text;
            //model.Download = txtDownload.Text;
            //model.Cost = txtCost.Text;
            //model.CostType = txtCostType.Text;
            //编写编辑操作End

            if (bll.Update(model))
            {
                AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改管理员:" + model.Name); //记录日志
                result = true;
            }

            return(result);
        }
Ejemplo n.º 3
0
        private void down(HttpContext context)
        {
            Model.Forum_Attachment model = bll.GetModel(aid);

            if (!BLL.Forum_BoardPermission.CheckPermission(model.BoardId + "|" + modelUser.GroupId, "ViewAttachment"))
            {
                context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                                                                        new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,你还没有下载附件的权限呢!"))));

                return;
            }


            if (model != null)
            {
                //取得文件物理路径
                string fullFileName = Utils.GetMapPath(model.FileName);
                if (!File.Exists(fullFileName))
                {
                    context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                                                                            new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您要下载的文件不存在或已经被删除!"))));
                    return;
                }

                model.Download += 1;
                bll.Update(model);

                FileInfo file = new FileInfo(fullFileName);                                                                     //路径
                context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");                                   //解决中文乱码
                context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.Name)); //解决中文文件名乱码
                context.Response.AddHeader("Content-length", file.Length.ToString());
                context.Response.ContentType = "application/zip";
                context.Response.WriteFile(file.FullName);
                context.Response.End();
            }
        }