/// <summary> /// 删除派工单,同时删除其中包含的附件 /// 上传派工单的日志和日志包含的附件 /// </summary> /// <param name="guidid"></param> /// <returns></returns> public bool DeleteData(String guidid) { bool succ = false; JConnect.GetConnect().BeginTrans(); try { //1--删除派工单 List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("Guidid", guidid)); Tb_TaskDA da1 = new Tb_TaskDA(); DataRow dr1 = da1.GetFirstDataRow(condition, "*"); if (dr1 != null) { //删除相关附件 String filename1 = dr1["RelaFile"].ToString(); if (String.IsNullOrEmpty(filename1) == false) { filename1 = System.Web.HttpContext.Current.Server.MapPath(filename1); if (File.Exists(filename1)) { File.Delete(filename1); } } //删除数据 da1.DeleteData(condition); } //2--删除派工单的日志 condition.Clear(); condition.Add(new SearchField("parentGuid", guidid)); Tb_Task_LogDA da2 = new Tb_Task_LogDA(); DataTable dt1 = da2.GetListData(condition, -1, -1, "", "*"); foreach (DataRow dr0 in dt1.Rows) { String filename1 = dr0["RelateFile"].ToString(); if (String.IsNullOrEmpty(filename1) == false) { filename1 = System.Web.HttpContext.Current.Server.MapPath(filename1); if (File.Exists(filename1)) { File.Delete(filename1); } } } da2.DeleteData(condition); JConnect.GetConnect().CommitTrans(); succ = true; } catch (Exception err) { JConnect.GetConnect().RollBackTrans(); WebFrame.Util.JTool.WriteErrorLog(err.ToString()); } return(succ); }
/// <summary> /// 根据条件删除数据 /// </summary> /// <param name="condition">删除数据条件</param> public void DeleteData(List <SearchField> condition) { try { Tb_Task_LogDA da1 = new Tb_Task_LogDA(); da1.DeleteData(condition); this.executeResultCount = da1.ExecuteResultCount; } catch (Exception err) { this.ErrorInfo = err.Message.Replace("\r", "").Replace("\t", "").Replace("\n", ""); } }