コード例 #1
0
        public int DeleteRecordAndData(int id)
        {
            try
            {
                //
                // 删除记录
                //
                _importHistoryRep.Remove(id);

                //
                // 删除记录对应的资产
                //
                var assetsList = _assetsMainRep.LogicDeleteEx(id);

                //
                // 删除资产相应的附属属性
                //
                foreach (var item in assetsList)
                {
                    //
                    // 根据资产分类代码获取资产分类名称
                    //
                    if (string.IsNullOrEmpty(item.CatCode))
                    {
                        return(1);
                    }
                    var @type = item.CatCode.GetAssetsTypeByCatCode();

                    switch (@type)
                    {
                    case AssetsTypes.Land:
                        return(_landRepository.DeleteItemByAssetsNum("ASSETS_LAND", item.AssetsNum));

                        break;

                    case AssetsTypes.Car:
                        return(_carRepository.DeleteItemByAssetsNum("ASSETS_CAR", item.AssetsNum));

                        break;

                    case AssetsTypes.Building:
                        return(_buildingRepository.DeleteItemByAssetsNum("ASSETS_BUILDING", item.AssetsNum));

                        break;

                    case AssetsTypes.Culturalrelic:
                        return(_culturalrelicRepository.DeleteItemByAssetsNum("ASSETS_CULTURALRELIC", item.AssetsNum));

                        break;

                    case AssetsTypes.Animalandplant:
                        return(_animalRepository.DeleteItemByAssetsNum("ASSETS_ANIMAL", item.AssetsNum));

                        break;

                    case AssetsTypes.Furniture:
                        return(1);

                        break;

                    case AssetsTypes.GeneralEquipment:
                        return(_generalRepository.DeleteItemByAssetsNum("ASSETS_GENERAL", item.AssetsNum));

                        break;

                    case AssetsTypes.House:
                        return(_houseRepository.DeleteItemByAssetsNum("ASSETS_HOUSE", item.AssetsNum));

                        break;

                    case AssetsTypes.SpecialEquipment:
                        return(_specialRepository.DeleteItemByAssetsNum("ASSETS_SPECIAL", item.AssetsNum));

                        break;

                    case AssetsTypes.Book:
                        return(_booksRepository.DeleteItemByAssetsNum("ASSETS_BOOK", item.AssetsNum));

                        break;
                    }
                }

                return(1);
            }
            catch (Exception)
            {
                return(0);
            }
        }