• 图片上传


     protected void btnUpload_Click(object sender, EventArgs e)
            {
                Button btnupload = sender as Button;
                if (btnupload.ID.Equals("btnUpload"))//待补中的上传
                {
                    if (!fuFileUp.HasFile)
                    {
                        //ScriptManager.RegisterClientScriptBlock(this.upAttachment, this.GetType(), "", "alert('请选择要上传的文件!')", true);
                        ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "", "alert('请选择要上传的文件!')", true);
                        return;
                    }
                }
                string strUploadFile = ConfigHelper.GetConfigString("UploadFilePath");

                string remoteFilePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + strUploadFile.TrimEnd('\\') + "\\" +
                                  "\\Approval\\";
                if (!Directory.Exists(remoteFilePath))
                {
                    Directory.CreateDirectory(remoteFilePath);
                }
                DataRow drNewRow = Attachment.NewRow();///加新行,都临时保存到viewState中
                drNewRow["AttachmentID"] = Guid.NewGuid();
                string strFileName = "";
                string strOrgFileName = "";
                strFileName = "/" + System.DateTime.Now.ToString("yyyyMMdd") + "_" + Guid.NewGuid() + Path.GetExtension(fuFileUp.FileName);
                strOrgFileName = fuFileUp.FileName; //文件名
                fuFileUp.PostedFile.SaveAs(remoteFilePath + strFileName);
                string remoteFileName = "http://www.cnblogs.com/" + strUploadFile + "/Approval" + strFileName;//相对路径
                drNewRow["ReferenceID"] = strInventoryID;
                drNewRow["FileName"] = strOrgFileName;
                drNewRow["FileType"] = strOrgFileName.Substring(strOrgFileName.LastIndexOf("."));
                drNewRow["FileFullName"] = remoteFileName;

                drNewRow["CreateBy"] = GetCurrentUser();
                drNewRow["CreateDate"] = DateTime.Now.ToString();
                drNewRow["ActiveFlag"] = (int)Common.CommonEnum.ActiveFlag.valid;

                Attachment.Rows.Add(drNewRow.ItemArray);
                LoadAttachment();
            }

      protected void rptAttachment_ItemCommand(object source, RepeaterCommandEventArgs e)
            {
                if (e.CommandName.Equals("Delete"))
                {
                    if (Attachment != null && Attachment.Rows.Count > 0)
                    {
                        DataRow[] drs = Attachment.Select("AttachmentID='" + e.CommandArgument.ToString() + "'");
                        if (drs.Length > 0)
                        {
                            drs[0]["ActiveFlag"] = (int)Common.CommonEnum.ActiveFlag.invalid;
                            drs[0]["ModifyBy"] = GetCurrentUser();
                            drs[0]["ModifyDate"] = DateTime.Now.ToString();
                            Attachment.AcceptChanges();

                            MessageBox.Show(this.Page, "删除成功!");
                        }
                    }

                    else
                    {
                        MessageBox.Show(this.Page, "删除失败!");
                    }

                    LoadAttachment();
                }
            }

  • 相关阅读:
    oracle单行函数 之 转换函数
    oracle单行函数 之 时间函数
    oracle单行函数 之 数字函数
    oracle单行函数 之 字符函数
    oracle 之 如何链接别人电脑的oracle
    轻应用介绍
    Web 目录枚举与遍历漏洞解决
    接口测试工具(Postman)
    Tomcat 编码不一致导致乱码
    持久化配置管理 diamond 使用简介
  • 原文地址:https://www.cnblogs.com/sisiblog/p/2932246.html
Copyright © 2020-2023  润新知