触摸屏租赁
Touch screen rental
广告机租赁
Advertising rental
机器人租赁
Robot leasing
 当前位置:首页 > > C#删除数据库记录及同时删除相关附件

C#删除数据库记录及同时删除相关附件
例:知识库管理
前台:
<script type="text/javascript">
        var click = function(command, record, rowIndex, colIndex) {
            if (command == "filedown") {
                Ext.Msg.confirm("提示!", "您确认要下载该文档吗?", function(btn) {
                    if (btn == "yes") {
                        var IDSTR = record.data.IDSTR;
                        Ext.net.DirectMethods.DownFile(IDSTR);
                    }
                });
            }
            if (command == "filedel") {
                Ext.Msg.confirm("提示!", "您确定要删除吗?删除后不能恢复!", function(btn) {
                    if (btn == "yes") {
                        var noid = record.data.IDSTR;
                        Ext.net.DirectMethods.DeleteEvent(noid);
                    }
                });
            }
        }

    </script>
后台:
        /// <summary>
        /// 删除记录
        /// </summary>
        /// <param name="id"></param>
        [DirectMethod]
        public void DeleteEvent(string IDSTR)
        {
            try
            {
                modelfj = dalfj.GetModel(IDSTR);
                string path = modelfj.FJFILEIMAGE;
                string filename = Server.MapPath("~" + path);  //BLL.Config.PART_EM_UPLOAD_DOC 为路径 ("D:/EMUploadDoc/")
                System.IO.FileInfo file = new System.IO.FileInfo(filename);
                if (file.Exists)
                {
                    file.Delete();
                }
                else
                {
                    //该文件不存在 怎么提示你自己写。
                    ScriptManager1.AddScript("alertE('提示','文件不存在!');");
                }
                dalfj.Delete(IDSTR);
                log.WriteLogParam("知识库文件管理", "删除", "删除KNOWINFO:" + IDSTR);
                this.plist.AddScript(" #{plist}.reload();");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


工作室地址:重庆石桥铺电脑城B座 | 微信:z35544216 | 网址:www.35544216.com