Esempio n. 1
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());
        }
Esempio n. 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 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;
                }
            }
        }