Exemplo n.º 1
0
        //删除合同索赔附件
        public static void Del_SPAttachment(string htbh)
        {
            //删除对应的文件,用唯一编号关联
            //一个合同可能对应多个索赔单号,一个索赔单号可能对应多个附件
            string sql_atfilepath = "select AT_FILEPATH from TBPM_ATTACHMENTS where AT_HTBH in (" +
                                    "select GUID from TBPM_SUBCLAIM where SPS_HTBH='" + htbh + "')";

            System.Data.DataTable dt_atfilepath = DBCallCommon.GetDTUsingSqlText(sql_atfilepath);
            for (int i = 0; i < dt_atfilepath.Rows.Count; i++)
            {
                string fileName = dt_atfilepath.Rows[i]["AT_FILEPATH"].ToString();
                //string fileName = DBCallCommon.GetFieldValue(dt_atfilepath.Rows[i]["AT_FILEPATH"].ToString());
                string attachPath = @"E:/合同管理附件";//附件上传位置
                string proj_type  = "索赔文档";
                string filepath   = CommonFun.CreateDirName(attachPath, proj_type) + fileName;

                //判断文件是否存在,如果不存在提示重新上传
                if (System.IO.File.Exists(filepath))
                {
                    DBCallCommon.DeleteFile(filepath);
                    //重新读出附件信息
                }
            }
            DBCallCommon.ExeSqlText("delete from TBPM_ATTACHMENTS where AT_HTBH in(" +
                                    "select GUID from TBPM_SUBCLAIM where SPS_HTBH='" + htbh + "')");
        }
Exemplo n.º 2
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());//防止二次刷新
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "attachdel")
            {
                //获取当前操作的行索引
                GridViewRow gvrow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
                int         index = gvrow.RowIndex;

                //根据获取到得行索引,读出该条记录的ID
                string id = ((Label)(GridView1.Rows[index].FindControl("lblID"))).Text.Trim();

                //删除对应的文件
                string fileName = DBCallCommon.GetFieldValue("select AT_FILEPATH from TBPM_ATTACHMENTS where AT_ID=" + id);
                string filepath = CommonFun.CreateDirName(attachPath, proj_type) + fileName;

                //判断文件是否存在,如果不存在提示重新上传
                if (System.IO.File.Exists(filepath))
                {
                    DBCallCommon.DeleteFile(filepath);
                    //重新读出附件信息
                }
                else
                {
                    Lbl_remind.Visible = true;
                }
                //根据记录的ID从数据库中删除该记录
                DBCallCommon.ExeSqlText("delete from TBPM_ATTACHMENTS where AT_ID=" + id);
                bindGrid();
            }
            if (e.CommandName == "attachview")
            {
                //获取当前操作的行索引
                GridViewRow gvrow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
                int         index = gvrow.RowIndex;

                //根据获取到得行索引,读出该条记录的ID
                string id = ((Label)(GridView1.Rows[index].FindControl("lblID"))).Text.Trim();

                //读出对应的文件名和路径
                string fileName = DBCallCommon.GetFieldValue("select AT_FILEPATH from TBPM_ATTACHMENTS where AT_ID=" + id);
                string filepath = CommonFun.CreateDirName(attachPath, proj_type) + fileName;

                //判断文件是否存在,如果不存在提示重新上传
                if (System.IO.File.Exists(filepath))
                {
                    DBCallCommon.FileDown_byte(fileName, filepath);
                }
                else
                {
                    Lbl_remind.Visible = true;
                }
            }
            //Response.Redirect(Request.Url.ToString());
        }