/// <summary> /// DeleteDirect /// </summary> /// <param name="unitId">unitId</param> /// <param name="unitType">unitType</param> /// <param name="companyId">companyId</param> public void DeleteDirect(int unitId, string unitType, int companyId) { UnitsGateway unitsGateway = new UnitsGateway(); unitsGateway.LoadByUnitId(unitId, companyId); if (unitsGateway.Table.Rows.Count > 0) { // ... Delete unit categories UnitsCategory unitsCategory = new UnitsCategory(null); UnitsCategoryGateway unitsCategoryGateway = new UnitsCategoryGateway(); unitsCategoryGateway.LoadByUnitId(unitId, companyId); foreach (UnitsTDS.LFS_FM_UNIT_CATEGORYRow rowCategories in (UnitsTDS.LFS_FM_UNIT_CATEGORYDataTable)unitsCategoryGateway.Table) { unitsCategory.DeleteDirect(unitId, rowCategories.CategoryID, companyId); } // ... if vehicle type then delete unit if (unitType == "Vehicle") { UnitsVehicle unitsVehicle = new UnitsVehicle(null); unitsVehicle.DeleteDirect(unitId, companyId); } // ... Delete inspections UnitsInspection unitsInspection = new UnitsInspection(null); UnitsInspectionGateway unitsInspectionGateway = new UnitsInspectionGateway(); unitsInspectionGateway.LoadByUnitId(unitId, companyId); foreach (UnitsTDS.LFS_FM_UNIT_INSPECTIONRow rowInspections in (UnitsTDS.LFS_FM_UNIT_INSPECTIONDataTable)unitsInspectionGateway.Table) { unitsInspection.DeletedDirect(unitId, rowInspections.InspectionID, companyId); } // ... Delete unit unitsGateway.Delete(unitId, companyId); } }