Beispiel #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 + "')");
        }
Beispiel #2
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());
        }
        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 UF_FILEPATH from TBQC_FILEUPLOAD where UF_ID=" + id);

                //2017.1.10修改
                string file_fat = "";
                if (!string.IsNullOrEmpty(fileName))
                {
                    file_fat = fileName.Substring(0, 4);
                }
                string filepath = attachPath + "\\" + file_fat + "\\" + proj_type + "\\" + fileName;
                //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 TBQC_FILEUPLOAD where UF_ID=" + id);
                bindGrid();
                upl_load_del();
            }
            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 UF_FILEPATH from TBQC_FILEUPLOAD where UF_ID=" + id);

                //2017.1.10修改
                string file_fat = "";
                if (!string.IsNullOrEmpty(fileName))
                {
                    file_fat = fileName.Substring(0, 4);
                }
                string filepath = attachPath + "\\" + file_fat + "\\" + proj_type + "\\" + fileName;
                //string filepath = CommonFun.CreateDirName(attachPath, proj_type) + fileName;

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