/// <summary> /// Read Node File From Database, Fill Out The NODEDWG /// Path must be FULL PATH of a DWG from the database /// </summary> /// <param name="connection"></param> /// <param name="path">Note PATH</param> public void ReadFromDatabase(SQLiteConnection connection, string pathDwg) { FixtureBoxSet.Clear(); InsertPointSet.Clear(); FixtureDetailSet.Clear(); TableDataSet.Clear(); string relPath = GoodiesPath.MakeRelativePath(pathDwg); file = DBDwgFile.SelectRow(connection, relPath); if (file == null || file.ID == ConstantName.invalidNum) { MessageBox.Show("NODEDWG -> ReadFromDatabase -> File Not Found"); return; } foreach (FixtureBeingUsedAreaModel fixtureBox in DBFixtureBeingUsedArea.SelectRows(connection, file.ID)) { FixtureBeingUsedArea fixtureArea = new FixtureBeingUsedArea(fixtureBox); //this line is very important. You have to make sure they have file model in each fixtureArea; //this won't complicate the program as we pass the pointer. FixtureBoxSet.Add(fixtureArea); } foreach (FixtureDetailsModel detailModel in DBFixtureDetails.SelectRows(connection, file.ID)) { FixtureDetails fd = new FixtureDetails(detailModel); FixtureDetailSet.Add(fd); } foreach (InsertPointModel insertPointModel in DBInsertPoint.SelectRows(connection, file.ID)) { InsertPoint ip = new InsertPoint(insertPointModel); InsertPointSet.Add(ip); } foreach (TableModel model in DBTable.SelectRows(connection, file.ID)) { TableData table = new TableData(model); TableDataSet.Add(table); } }
/// <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); }