private static void DeleteOthers(AreaBorderModel model, SQLiteConnection connection) { if (model != null) { DBPoint3D.DeleteRow(connection, model.file.ID); DBMatrix3d.DeleteRow(connection, model.matrixTransform.ID); if (model.position != null) { DBPoint3D.DeleteRow(connection, model.position.ID); } if (model.origin != null) { DBPoint3D.DeleteRow(connection, model.origin.ID); } if (model.pointTop != null) { DBPoint3D.DeleteRow(connection, model.pointTop.ID); } if (model.pointBottom != null) { DBPoint3D.DeleteRow(connection, model.pointBottom.ID); } if (model.matrixTransform != null) { DBMatrix3d.DeleteRow(connection, model.matrixTransform.ID); } } }
public void WriteToDatabase(SQLiteConnection connection) { var temp = this; WriteToDatabase0(connection); origin.WriteToDatabase(connection); pointBottom.WriteToDatabase(connection); pointTop.WriteToDatabase(connection); if (!DBAreaBorder.HasRow(connection, handle, file.ID)) { WriteToDatabase0(connection); origin.ID = DBPoint3D.InsertRow(ref origin, connection); pointTop.ID = DBPoint3D.InsertRow(ref pointTop, connection); pointBottom.ID = DBPoint3D.InsertRow(ref pointBottom, connection); } else { AreaBorderModel model = DBAreaBorder.SelectRow(connection, handle, file.ID); ID = model.ID; UpdateToDatabase0(model.matrixTransform.ID, model.position.ID, connection); origin.ID = model.ID; pointTop.ID = model.ID; pointBottom.ID = model.ID; DBPoint3D.UpdateRow(origin, connection); DBPoint3D.UpdateRow(pointTop, connection); DBPoint3D.UpdateRow(pointBottom, connection); DBAreaBorder.UpdateRow(connection, this); } }
/// <summary> /// Get ID from database FROM DATABASE, just to get ID. /// </summary> /// <param name="matrix"></param> /// <param name="position"></param> /// <param name="connection"></param> protected virtual void UpdateToDatabase0(long DBMatrixID, long DBPositionID, SQLiteConnection connection) { this.position.ID = DBMatrixID; this.matrixTransform.ID = DBPositionID; DBPoint3D.UpdateRow(position, connection); DBMatrix3d.Update(connection, matrixTransform); }
private static FixtureUnitModel getItem(SQLiteDataReader reader, SQLiteConnection connection) { FixtureUnitModel model = new FixtureUnitModel(); long POSITION_ID = (long)reader[DBFixtureUnitName.POSITION_ID]; long TRANSFORM_ID = (long)reader[DBFixtureUnitName.MATRIX_ID]; model.handle = (string)reader[DBFixtureUnitName.HANDLE]; model.INDEX = (double)reader[DBFixtureUnitName.INDEX]; model.TAG = (string)reader[DBFixtureUnitName.TAG]; model.NUMBER = (string)reader[DBFixtureUnitName.NUMBER]; model.CW_DIA = (double)reader[DBFixtureUnitName.CW_DIA]; model.HW_DIA = (double)reader[DBFixtureUnitName.HW_DIA]; model.WASTE_DIA = (double)reader[DBFixtureUnitName.WASTE_DIA]; model.VENT_DIA = (double)reader[DBFixtureUnitName.VENT_DIA]; model.STORM_DIA = (double)reader[DBFixtureUnitName.STORM_DIA]; model.WSFU = (double)reader[DBFixtureUnitName.WSFU]; model.CWSFU = (double)reader[DBFixtureUnitName.CWSFU]; model.HWSFU = (double)reader[DBFixtureUnitName.HWSFU]; model.DFU = (double)reader[DBFixtureUnitName.DFU]; model.ID = (long)reader[DBFixtureUnitName.ID]; long FILE_ID = (long)reader[DBFixtureUnitName.FILE_ID]; model.A2 = (double)reader[DBFixtureUnitName.A2]; model.Y2 = (double)reader[DBFixtureUnitName.Y2]; model.X2 = (double)reader[DBFixtureUnitName.X2]; model.X2_2 = (double)reader[DBFixtureUnitName.X2_2]; model.A3 = (double)reader[DBFixtureUnitName.A3]; model.A1 = (double)reader[DBFixtureUnitName.A1]; model.D1 = (double)reader[DBFixtureUnitName.D1]; long tagID = (long)reader[DBFixtureUnitName.tagPos]; long ventID = (long)reader[DBFixtureUnitName.ventPos]; long hotStubID = (long)reader[DBFixtureUnitName.hotStub]; long coldStubID = (long)reader[DBFixtureUnitName.coldStub]; long drainPosID = (long)reader[DBFixtureUnitName.drainPos]; long M_ID = (long)reader[DBFixtureUnitName.M_ID]; long R1_ID = (long)reader[DBFixtureUnitName.R1_ID]; long V_ID = (long)reader[DBFixtureUnitName.V_ID]; model.matrixTransform = DBMatrix3d.SelectRow(connection, TRANSFORM_ID); model.position = DBPoint3D.SelectRow(connection, POSITION_ID); model.file = DBDwgFile.SelectRow(connection, FILE_ID); model.tagPos = DBPoint3D.SelectRow(connection, tagID); model.ventPos = DBPoint3D.SelectRow(connection, ventID); model.hotStub = DBPoint3D.SelectRow(connection, hotStubID); model.coldStub = DBPoint3D.SelectRow(connection, coldStubID); model.drainPos = DBPoint3D.SelectRow(connection, drainPosID); model.M = DBPoint3D.SelectRow(connection, M_ID); model.R1 = DBPoint3D.SelectRow(connection, R1_ID); model.V = DBPoint3D.SelectRow(connection, V_ID); return(model); }
private static void DeleteOthers(FixtureUnitModel model, SQLiteConnection connection) { if (model != null) { DBPoint3D.DeleteRow(connection, model.file.ID); DBMatrix3d.DeleteRow(connection, model.matrixTransform.ID); if (model.matrixTransform != null) { DBMatrix3d.DeleteRow(connection, model.matrixTransform.ID); } ; if (model.position != null) { DBPoint3D.DeleteRow(connection, model.position.ID); } ; if (model.tagPos != null) { DBPoint3D.DeleteRow(connection, model.tagPos.ID); } ; if (model.ventPos != null) { DBPoint3D.DeleteRow(connection, model.ventPos.ID); } ; if (model.hotStub != null) { DBPoint3D.DeleteRow(connection, model.hotStub.ID); } ; if (model.coldStub != null) { DBPoint3D.DeleteRow(connection, model.coldStub.ID); } ; if (model.drainPos != null) { DBPoint3D.DeleteRow(connection, model.drainPos.ID); } ; if (model.R1 != null) { DBPoint3D.DeleteRow(connection, model.R1.ID); } if (model.V != null) { DBPoint3D.DeleteRow(connection, model.V.ID); } if (model.M != null) { DBPoint3D.DeleteRow(connection, model.M.ID); } } }
public static void UpdateRow(SQLiteConnection connection, TableModel model) { using (SQLiteCommand command = connection.CreateCommand()) { DBTableCommands.UpdateRow(command, model); long check = command.ExecuteNonQuery(); DBPoint3D.UpdateRow(model.position, connection); DBMatrix3d.Update(connection, model.matrixTransform); } }
public void ReadFromDatabase(SQLiteConnection connection, long ID) { Point3dModel point3dM = DBPoint3D.SelectRow(connection, ID); if (point3dM != null) { X = point3dM.X; Y = point3dM.Y; Z = point3dM.Z; this.ID = point3dM.ID; } }
public void WriteToDatabase(SQLiteConnection connection) { if (!DBPoint3D.HasRow(connection, ID)) { var temp = this; ID = DBPoint3D.InsertRow(ref temp, connection); } else { DBPoint3D.UpdateRow(this, connection); } }
private static TableModel CreateModel(SQLiteDataReader reader, SQLiteConnection connection) { TableModel model = new TableModel(); model.ID = Convert.ToInt64(reader[DBTableName.ID]); model.handle = Convert.ToString(reader[DBTableName.HANDLE]); model.matrixTransform = DBMatrix3d.SelectRow(connection, Convert.ToInt64(reader[DBTableName.MATRIX_ID])); model.position = DBPoint3D.SelectRow(connection, Convert.ToInt64(reader[DBTableName.POSITION_ID])); model.ALIAS = Convert.ToString(reader[DBTableName.ALIAS]); model.A_VALUE = Convert.ToString(reader[DBTableName.A_VALUE]); model.file = DBDwgFile.SelectRow(connection, Convert.ToInt64(reader[DBTableName.FILE_ID])); return(model); }
private static void DeleteOthers(TableModel model, SQLiteConnection connection) { if (model != null) { if (model.matrixTransform != null) { DBMatrix3d.DeleteRow(connection, model.matrixTransform.ID); } ; if (model.position != null) { DBPoint3D.DeleteRow(connection, model.position.ID); } ; } }
private static AreaBorderModel GetModelFromReader(SQLiteDataReader reader, SQLiteConnection connection) { AreaBorderModel model = new AreaBorderModel(); model.ID = (long)reader[DBAreaBorderNames.ID]; model.handle = (string)reader[DBAreaBorderNames.HANDLE]; model.position = DBPoint3D.SelectRow(connection, (long)reader[DBAreaBorderNames.POSITION_ID]); model.pointTop = DBPoint3D.SelectRow(connection, (long)reader[DBAreaBorderNames.POINT_TOP_ID]); model.pointBottom = DBPoint3D.SelectRow(connection, (long)reader[DBAreaBorderNames.POINT_BOTTOM_ID]); model.origin = DBPoint3D.SelectRow(connection, (long)reader[DBAreaBorderNames.ORIGIN_ID]); model.matrixTransform = DBMatrix3d.SelectRow(connection, (long)reader[DBAreaBorderNames.MATRIX_ID]); model.X = (double)reader[DBAreaBorderNames.X]; model.Y = (double)reader[DBAreaBorderNames.Y]; model.file = DBDwgFile.SelectRow(connection, (long)reader[DBAreaBorderNames.FILE_ID]); if (model.ID == ConstantName.invalidNum) { model = null; } return(model); }