Ejemplo n.º 1
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            //这个attachName表示原文件名。
            HttpPostedFile hpf = FileUpload1.PostedFile;
            //string attachName = FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf("\\")).Substring(1);
            string attachName = System.IO.Path.GetFileName(hpf.FileName);
            //把文件上传到Attachments目录下
            string path     = CommonFun.CreateDirName(attachPath, proj_type); //带'\'
            string fileName = DBCallCommon.Savefile(FileUpload1, path);       //fileName表示新文件名

            //把附件信息插入到attachment表
            if (attachName != "" || fileName != "")
            {
                string sqlText = "insert into TBPM_ATTACHMENTS";
                sqlText += "(AT_HTBH,AT_NAME,AT_DESCRIBE,AT_CREATDATE,AT_FILEPATH,AT_TYPE,AT_SPLB) " +
                           "Values('" + _at_htbh + "','" + attachName + "','" + txtDesc.Text.Trim() + "',getdate(),'" + fileName + "'," + _at_type + "," + _at_sp + ")";
                DBCallCommon.ExeSqlText(sqlText);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请添加附件!!!');", true);
            }
            //把所有附件信息显示出来
            bindGrid();
            txtDesc.Text = "";
            //txtBeizhu.Text = "";
            //Response.Redirect(Request.Url.ToString());//防止二次刷新
        }
Ejemplo n.º 2
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            //这个attachName表示原文件名。
            HttpPostedFile hpf        = FileUpload1.PostedFile;
            string         attachName = System.IO.Path.GetFileName(hpf.FileName);
            //把文件上传到Attachments目录下
            string path     = CommonFun.CreateDirName(attachPath, proj_type); //带'\'
            string fileName = DBCallCommon.Savefile(FileUpload1, path);       //fileName表示新文件名

            //把附件信息插入到TBQC_FILEUPLOAD表
            if (attachName != "" || fileName != "")
            {
                string sqlText = "insert into TBQC_FILEUPLOAD";
                sqlText += "(UF_CODE,UF_NAME,UF_UPLOADTIME,UF_FILEPATH,UF_TYPE) " +
                           "Values('" + _uf_code + "','" + attachName + "',getdate(),'" + fileName + "'," + _uf_type + ")";
                DBCallCommon.ExeSqlText(sqlText);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请添加附件!!!');", true);
            }
            //把所有附件信息显示出来
            bindGrid();
            upl_load_del();
        }