Ejemplo n.º 1
0
        private static void DeleteOthers(DwgFileModel model, SQLiteConnection connection)
        {
            if (model != null)
            {
                using (SQLiteCommand command = connection.CreateCommand())
                {
                    //MUST DELETE CHILD FIRST.
                    List <FixtureDetailsModel>       fixtures     = DBFixtureDetails.SelectRows(connection, model.relativePath);
                    List <FixtureBeingUsedAreaModel> areas        = DBFixtureBeingUsedArea.SelectRows(connection, model.relativePath);
                    List <InsertPointModel>          insertPoints = DBInsertPoint.SelectRows(connection, model.relativePath);
                    List <TableModel>       tables = DBTable.SelectRows(connection, model.relativePath);
                    List <AreaBorderModel>  areaU  = DBAreaBorder.SelectRows(connection, model.relativePath);
                    List <FixtureUnitModel> units  = DBFixture_Unit.SelectRows(connection, model.relativePath);

                    foreach (FixtureDetailsModel fixture in fixtures)
                    {
                        DBFixtureDetails.DeleteRow(connection, fixture.ID);
                    }

                    foreach (FixtureBeingUsedAreaModel area in areas)
                    {
                        DBFixtureBeingUsedArea.DeleteRow(connection, area.ID);
                    }

                    foreach (InsertPointModel insertPoint in insertPoints)
                    {
                        DBInsertPoint.DeleteRow(connection, insertPoint.ID);
                    }

                    foreach (TableModel table in tables)
                    {
                        DBTable.DeleteRow(connection, table.ID);
                    }

                    foreach (AreaBorderModel m in areaU)
                    {
                        DBTable.DeleteRow(connection, m.ID);
                    }

                    foreach (FixtureUnitModel m in units)
                    {
                        DBTable.DeleteRow(connection, m.ID);
                    }

                    DBCommand.DeleteRow(DBDwgFileName.name, model.ID, command);
                    long check = command.ExecuteNonQuery();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Update Database, FILE MUST BE INITIATED.
        /// </summary>
        /// <param name="connection"></param>
        public void UpdateDatabase(SQLiteConnection connection)
        {
            List <FixtureBeingUsedAreaModel> handle1 = DBFixtureBeingUsedArea.SelectRows(connection, file.ID);
            List <FixtureDetailsModel>       handle2 = DBFixtureDetails.SelectRows(connection, file.ID);
            List <InsertPointModel>          handle3 = DBInsertPoint.SelectRows(connection, file.ID);
            List <FixtureUnitModel>          handle4 = DBFixture_Unit.SelectRows(connection, file.ID);
            List <AreaBorderModel>           handle5 = DBAreaBorder.SelectRows(connection, file.ID);

            List <string> toDelete1 = HandleToDelete(handle1, FixtureBoxSet).ToList();
            List <string> toDelete2 = HandleToDelete(handle2, FixtureDetailSet).ToList();
            List <string> toDelete3 = HandleToDelete(handle3, InsertPointSet).ToList();
            List <string> toDelete4 = HandleToDelete(handle4, FixtureUnitsSet).ToList();
            List <string> toDelete5 = HandleToDelete(handle5, AreaModelSet).ToList();

            foreach (string handle in toDelete1)
            {
                DBFixtureBeingUsedArea.DeleteRow(connection, handle, file.ID);
            }
            foreach (string handle in toDelete2)
            {
                DBFixtureDetails.DeleteRow(connection, handle, file.ID);
            }
            foreach (string handle in toDelete3)
            {
                DBInsertPoint.DeleteRow(connection, handle, file.ID);
            }
            foreach (string handle in toDelete4)
            {
                DBFixture_Unit.DeleteRow(connection, handle, file.ID);
            }
            foreach (string handle in toDelete5)
            {
                DBAreaBorder.DeleteRow(connection, handle, file.ID);
            }

            WriteToDataBase(connection);
        }