Exemplo n.º 1
0
        protected void rpAttachment_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int attachid = int.Parse(e.CommandArgument.ToString());

            if (e.CommandName == "Delete")
            {
                SysNoticeAttach attach = new SysNoticeAttach(attachid);
                attach.Delete();
                AttachList.RemoveAt(e.Item.ItemIndex);

                LoadAttachment();

                RegisterJsAjax("0", "loadCKEDITOR();");
            }
        }
Exemplo n.º 2
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            if (!fuAttach.HasFile)
            {
                Warning("请先选择需要上传的文件");
                return;
            }

            //存储的文件名
            string fileName = Path.GetFileNameWithoutExtension(fuAttach.FileName) +
                              DateTime.Now.ToString("MMddHHmmss")
                              + Path.GetExtension(fuAttach.FileName);
            var relativePath = "Notice/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + fileName;

            //服务端存储路径
            string path = SysConsts.FileUploadDirectory + relativePath;

            if (!FileHelper.UploadFile(fuAttach.PostedFile, Server.MapPath(path)))
            {
                Warning("上传失败,请联系管理员!");
                return;
            }

            SysNoticeAttach attach = new SysNoticeAttach();

            attach.NoticeID      = NoticeID;
            attach.DownloadCount = 0;
            attach.FileName      = Path.GetFileName(fuAttach.FileName);
            attach.FileSize      = fuAttach.PostedFile.ContentLength;
            attach.FilePath      = relativePath;
            attach.UploadTime    = DateTime.Now;
            AttachList.Add(attach);

            LoadAttachment();

            if (NoticeID > 0)
            {
                attach.Add();
            }
        }