/// <summary> /// [To be supplied.] /// </summary> /// <param name="record">[To be supplied.]</param> public void Remove(IBusinessComponentRecord record) { tblSupplierProduct_Record recordToDelete = record as tblSupplierProduct_Record; if (recordToDelete == null) { throw new ArgumentException("Invalid record type. Must be 'OlymarsDemo.BusinessComponents.tblSupplierProduct_Record'.", "record"); } bool alreadyOpened = false; Params.spD_tblSupplierProduct Param = new Params.spD_tblSupplierProduct(true); Param.CommandTimeOut = this.deleteCommandTimeOut; switch (this.lastKnownConnectionType) { case OlymarsDemo.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case OlymarsDemo.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open); break; case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction: Param.SetUpConnection(this.sqlTransaction); break; } Param.Param_Spr_GuidProductID = recordToDelete.Col_Spr_GuidProductID; Param.Param_Spr_GuidSupplierID = recordToDelete.Col_Spr_GuidSupplierID; SPs.spD_tblSupplierProduct Sp = new SPs.spD_tblSupplierProduct(true); Sp.Execute(ref Param); CloseConnection(Sp.Connection, alreadyOpened); if (internalRecords != null) { internalRecords.Remove(recordToDelete); } }
/// <summary> /// [To be supplied.] /// </summary> public new tblSupplierProduct_Record MemberwiseClone() { tblSupplierProduct_Record newRecord = new tblSupplierProduct_Record(); newRecord.recordWasLoadedFromDB = this.recordWasLoadedFromDB; newRecord.connectionString = this.connectionString; newRecord.col_Spr_GuidProductID = this.col_Spr_GuidProductID; newRecord.col_Spr_GuidSupplierID = this.col_Spr_GuidSupplierID; newRecord.col_Spr_GuidProductID_Record = this.col_Spr_GuidProductID_Record.MemberwiseClone(); newRecord.col_Spr_GuidSupplierID_Record = this.col_Spr_GuidSupplierID_Record.MemberwiseClone(); newRecord.displayName = this.displayName; return(newRecord); }
/// <summary> /// [To be supplied.] /// </summary> public void Refresh() { internalRecords = new System.Collections.ArrayList(); bool alreadyOpened = false; Params.spS_tblSupplierProduct_Display Param = new Params.spS_tblSupplierProduct_Display(true); Param.CommandTimeOut = this.selectCollectionCommandTimeOut; switch (this.lastKnownConnectionType) { case OlymarsDemo.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case OlymarsDemo.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open); break; case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction: Param.SetUpConnection(this.sqlTransaction); break; } if (!this.col_Spr_GuidProductID.IsNull) { Param.Param_Spr_GuidProductID = this.col_Spr_GuidProductID; } if (!this.col_Spr_GuidSupplierID.IsNull) { Param.Param_Spr_GuidSupplierID = this.col_Spr_GuidSupplierID; } System.Data.SqlClient.SqlDataReader sqlDataReader = null; SPs.spS_tblSupplierProduct_Display Sp = new SPs.spS_tblSupplierProduct_Display(false); if (Sp.Execute(ref Param, out sqlDataReader)) { while (sqlDataReader.Read()) { tblSupplierProduct_Record record = null; switch (this.lastKnownConnectionType) { case OlymarsDemo.DataClasses.ConnectionType.ConnectionString: record = new tblSupplierProduct_Record(this.connectionString, sqlDataReader.GetSqlGuid(SPs.spS_tblSupplierProduct_Display.Resultset1.Fields.Column_ID1.ColumnIndex), sqlDataReader.GetSqlGuid(SPs.spS_tblSupplierProduct_Display.Resultset1.Fields.Column_ID2.ColumnIndex)); break; case OlymarsDemo.DataClasses.ConnectionType.SqlConnection: record = new tblSupplierProduct_Record(this.sqlConnection, sqlDataReader.GetSqlGuid(SPs.spS_tblSupplierProduct_Display.Resultset1.Fields.Column_ID1.ColumnIndex), sqlDataReader.GetSqlGuid(SPs.spS_tblSupplierProduct_Display.Resultset1.Fields.Column_ID2.ColumnIndex)); break; case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction: record = new tblSupplierProduct_Record(this.sqlTransaction, sqlDataReader.GetSqlGuid(SPs.spS_tblSupplierProduct_Display.Resultset1.Fields.Column_ID1.ColumnIndex), sqlDataReader.GetSqlGuid(SPs.spS_tblSupplierProduct_Display.Resultset1.Fields.Column_ID2.ColumnIndex)); break; } record.UpdateCommandTimeOut = this.updateCommandTimeOut; record.SelectCommandTimeOut = this.selectCommandTimeOut; if (sqlDataReader.GetFieldType(SPs.spS_tblSupplierProduct_Display.Resultset1.Fields.Column_Display.ColumnIndex) == typeof(string)) { record.displayName = sqlDataReader.GetString(SPs.spS_tblSupplierProduct_Display.Resultset1.Fields.Column_Display.ColumnIndex); } else { record.displayName = sqlDataReader.GetValue(SPs.spS_tblSupplierProduct_Display.Resultset1.Fields.Column_Display.ColumnIndex).ToString(); } internalRecords.Add(record); } if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordsAreLoaded = true; } else { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordsAreLoaded = false; throw new OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.BusinessComponents.tblSupplierProduct_Collection", "Refresh"); } }
/// <summary> /// [To be supplied.] /// </summary> /// <param name="record">[To be supplied.]</param> /// <returns>[To be supplied.]</returns> public IBusinessComponentRecord Add(IBusinessComponentRecord record) { tblSupplierProduct_Record recordToAdd = record as tblSupplierProduct_Record; if (recordToAdd == null) { throw new ArgumentException("Invalid record type. Must be 'OlymarsDemo.BusinessComponents.tblSupplierProduct_Record'.", "record"); } switch (this.parentType) { case tblSupplierProduct_CollectionParentType.Col_Spr_GuidProductID: recordToAdd.Col_Spr_GuidProductID = ((Product)this.parent).Col_Pro_GuidID; break; case tblSupplierProduct_CollectionParentType.Col_Spr_GuidSupplierID: recordToAdd.Col_Spr_GuidSupplierID = ((Supplier)this.parent).Col_Sup_GuidID; break; } bool alreadyOpened = false; Params.spI_tblSupplierProduct Param = new Params.spI_tblSupplierProduct(true); Param.CommandTimeOut = this.insertCommandTimeOut; switch (this.lastKnownConnectionType) { case OlymarsDemo.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case OlymarsDemo.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open); break; case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction: Param.SetUpConnection(this.sqlTransaction); break; } Param.Param_Spr_GuidProductID = recordToAdd.Col_Spr_GuidProductID; Param.Param_Spr_GuidSupplierID = recordToAdd.Col_Spr_GuidSupplierID; SPs.spI_tblSupplierProduct Sp = new SPs.spI_tblSupplierProduct(false); if (Sp.Execute(ref Param)) { tblSupplierProduct_Record newRecord = null; switch (this.lastKnownConnectionType) { case OlymarsDemo.DataClasses.ConnectionType.ConnectionString: newRecord = new tblSupplierProduct_Record(this.connectionString, Param.Param_Spr_GuidProductID, Param.Param_Spr_GuidSupplierID); break; case OlymarsDemo.DataClasses.ConnectionType.SqlConnection: newRecord = new tblSupplierProduct_Record(this.sqlConnection, Param.Param_Spr_GuidProductID, Param.Param_Spr_GuidSupplierID); break; case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction: newRecord = new tblSupplierProduct_Record(this.sqlTransaction, Param.Param_Spr_GuidProductID, Param.Param_Spr_GuidSupplierID); break; } CloseConnection(Sp.Connection, alreadyOpened); if (internalRecords != null) { internalRecords.Add(newRecord); } if (this.addedRecords == null) { this.addedRecords = new System.Collections.ArrayList(); } this.addedRecords.Add(newRecord); return(newRecord); } else { throw new OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.BusinessComponents.tblSupplierProduct_Collection", "Add"); } }