Exemplo n.º 1
0
        /// <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>
        /// <param name="PageSize">页大小</param>
        /// <param name="CurPage">当前页</param>
        /// <param name="Fields">数据字段</param>
        /// <param name="orderBy">排序表达式</param>
        /// <param name="TotalRow">数据总行数</param>
        /// <param name="Fields">要显示的字段</param>
        /// <returns>列表数据</returns>
        public DataTable GetListData(List <SearchField> condition,
                                     int PageSize, int CurPage, String orderBy,
                                     out int TotalRow, params String[] Fields)
        {
            TotalRow = 0;
            DataTable dt1 = null;

            try
            {
                Tb_Task_LogDA da1 = new Tb_Task_LogDA();
                dt1 = da1.GetListData(condition, PageSize, CurPage, orderBy, out TotalRow, Fields);
                this.executeResultCount = da1.ExecuteResultCount;
                return(dt1);
            }
            catch (Exception err)
            {
                this.ErrorInfo = err.Message.Replace("\r", "").Replace("\t", "").Replace("\n", "");
            }
            return(dt1);
        }