예제 #1
0
        public static BLLResult DeleteDetail(TList list, TDetail detail, List <TDepthNode> nodes)
        {
            var result = new BLLResult();

            using (var connection = SQLiteHelper.Connect())
            {
                connection.Open();
                var transaction = connection.BeginTransaction();
                try
                {
                    if (!detail.DbDelete(connection))
                    {
                        throw new NotImplementedException("Detail数据未成功删除");
                    }
                    if (!nodes.DbDeleteByDetailKey(connection))
                    {
                        throw new NotImplementedException("Nodes数据未成功删除");
                    }
                    list.Datas.Remove(detail);
                    list.DataCount = (short)list.Datas.Count();
                    if (!list.DbUpdate(connection))
                    {
                        throw new NotImplementedException("List数据未成功更新");
                    }
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    result.IsSuccess = false;
                    result.Message   = ex.ToString();
                }
                connection.Close();
            }
            return(result);
        }