Esempio n. 1
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        public new JobPart_Record MemberwiseClone()
        {
            JobPart_Record newRecord = new JobPart_Record();

            newRecord.recordWasLoadedFromDB = this.recordWasLoadedFromDB;
            newRecord.recordIsLoaded        = this.recordIsLoaded;
            newRecord.connectionString      = this.connectionString;

            newRecord.col_JobPartId = this.col_JobPartId;


            newRecord.col_JobIdWasSet     = this.col_JobIdWasSet;
            newRecord.col_JobIdWasUpdated = this.col_JobIdWasUpdated;
            newRecord.col_JobId           = this.col_JobId;

            newRecord.col_JobId_Record = this.col_JobId_Record.MemberwiseClone();

            newRecord.col_DescriptionWasSet     = this.col_DescriptionWasSet;
            newRecord.col_DescriptionWasUpdated = this.col_DescriptionWasUpdated;
            newRecord.col_Description           = this.col_Description;

            newRecord.col_JobPartTypeIdWasSet     = this.col_JobPartTypeIdWasSet;
            newRecord.col_JobPartTypeIdWasUpdated = this.col_JobPartTypeIdWasUpdated;
            newRecord.col_JobPartTypeId           = this.col_JobPartTypeId;

            newRecord.col_JobPartTypeId_Record = this.col_JobPartTypeId_Record.MemberwiseClone();

            newRecord.col_UnitsWasSet     = this.col_UnitsWasSet;
            newRecord.col_UnitsWasUpdated = this.col_UnitsWasUpdated;
            newRecord.col_Units           = this.col_Units;

            newRecord.col_PricePerUnitWasSet     = this.col_PricePerUnitWasSet;
            newRecord.col_PricePerUnitWasUpdated = this.col_PricePerUnitWasUpdated;
            newRecord.col_PricePerUnit           = this.col_PricePerUnit;

            newRecord.col_TotalPriceWasSet     = this.col_TotalPriceWasSet;
            newRecord.col_TotalPriceWasUpdated = this.col_TotalPriceWasUpdated;
            newRecord.col_TotalPrice           = this.col_TotalPrice;

            newRecord.displayName = this.displayName;

            return(newRecord);
        }
Esempio n. 2
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <param name="record">[To be supplied.]</param>
        public void Remove(IBusinessComponentRecord record)
        {
            JobPart_Record recordToDelete = record as JobPart_Record;

            if (recordToDelete == null)
            {
                throw new ArgumentException("Invalid record type. Must be 'Bob.BusinessComponents.JobPart_Record'.", "record");
            }

            bool alreadyOpened = false;

            Params.spD_JobPart Param = new Params.spD_JobPart(true);
            Param.CommandTimeOut = this.deleteCommandTimeOut;
            switch (this.lastKnownConnectionType)
            {
            case Bob.DataClasses.ConnectionType.ConnectionString:
                Param.SetUpConnection(this.connectionString);
                break;

            case Bob.DataClasses.ConnectionType.SqlConnection:
                Param.SetUpConnection(this.sqlConnection);
                alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open);
                break;

            case Bob.DataClasses.ConnectionType.SqlTransaction:
                Param.SetUpConnection(this.sqlTransaction);
                break;
            }

            Param.Param_JobPartId = recordToDelete.Col_JobPartId;

            SPs.spD_JobPart Sp = new SPs.spD_JobPart(true);

            Sp.Execute(ref Param);
            CloseConnection(Sp.Connection, alreadyOpened);

            if (internalRecords != null)
            {
                internalRecords.Remove(recordToDelete);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        public void Refresh()
        {
            internalRecords = new System.Collections.ArrayList();

            bool alreadyOpened = false;

            Params.spS_JobPart_Display Param = new Params.spS_JobPart_Display(true);
            Param.CommandTimeOut = this.selectCollectionCommandTimeOut;
            switch (this.lastKnownConnectionType)
            {
            case Bob.DataClasses.ConnectionType.ConnectionString:
                Param.SetUpConnection(this.connectionString);
                break;

            case Bob.DataClasses.ConnectionType.SqlConnection:
                Param.SetUpConnection(this.sqlConnection);
                alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open);
                break;

            case Bob.DataClasses.ConnectionType.SqlTransaction:
                Param.SetUpConnection(this.sqlTransaction);
                break;
            }

            if (!this.col_JobId.IsNull)
            {
                Param.Param_JobId = this.col_JobId;
            }

            if (!this.col_JobPartTypeId.IsNull)
            {
                Param.Param_JobPartTypeId = this.col_JobPartTypeId;
            }

            System.Data.SqlClient.SqlDataReader sqlDataReader = null;
            SPs.spS_JobPart_Display             Sp            = new SPs.spS_JobPart_Display(false);
            if (Sp.Execute(ref Param, out sqlDataReader))
            {
                while (sqlDataReader.Read())
                {
                    JobPart_Record record = null;

                    switch (this.lastKnownConnectionType)
                    {
                    case Bob.DataClasses.ConnectionType.ConnectionString:
                        record = new JobPart_Record(this.connectionString, sqlDataReader.GetSqlInt32(SPs.spS_JobPart_Display.Resultset1.Fields.Column_ID1.ColumnIndex));
                        break;

                    case Bob.DataClasses.ConnectionType.SqlConnection:
                        record = new JobPart_Record(this.sqlConnection, sqlDataReader.GetSqlInt32(SPs.spS_JobPart_Display.Resultset1.Fields.Column_ID1.ColumnIndex));
                        break;

                    case Bob.DataClasses.ConnectionType.SqlTransaction:
                        record = new JobPart_Record(this.sqlTransaction, sqlDataReader.GetSqlInt32(SPs.spS_JobPart_Display.Resultset1.Fields.Column_ID1.ColumnIndex));
                        break;
                    }


                    record.UpdateCommandTimeOut = this.updateCommandTimeOut;
                    record.SelectCommandTimeOut = this.selectCommandTimeOut;

                    if (sqlDataReader.GetFieldType(SPs.spS_JobPart_Display.Resultset1.Fields.Column_Display.ColumnIndex) == typeof(string))
                    {
                        record.displayName = sqlDataReader.GetString(SPs.spS_JobPart_Display.Resultset1.Fields.Column_Display.ColumnIndex);
                    }
                    else
                    {
                        record.displayName = sqlDataReader.GetValue(SPs.spS_JobPart_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 Bob.DataClasses.CustomException(Param, "Bob.BusinessComponents.JobPart_Collection", "Refresh");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <param name="record">[To be supplied.]</param>
        /// <returns>[To be supplied.]</returns>
        public IBusinessComponentRecord Add(IBusinessComponentRecord record)
        {
            JobPart_Record recordToAdd = record as JobPart_Record;

            if (recordToAdd == null)
            {
                throw new ArgumentException("Invalid record type. Must be 'Bob.BusinessComponents.JobPart_Record'.", "record");
            }

            switch (this.parentType)
            {
            case JobPart_CollectionParentType.Col_JobId:
                recordToAdd.Col_JobId = ((Job_Record)this.parent).Col_JobId;
                break;

            case JobPart_CollectionParentType.Col_JobPartTypeId:
                recordToAdd.Col_JobPartTypeId = ((JobPartType_Record)this.parent).Col_JobPartTypeId;
                break;
            }

            bool alreadyOpened = false;

            Params.spI_JobPart Param = new Params.spI_JobPart(true);
            Param.CommandTimeOut = this.insertCommandTimeOut;
            switch (this.lastKnownConnectionType)
            {
            case Bob.DataClasses.ConnectionType.ConnectionString:
                Param.SetUpConnection(this.connectionString);
                break;

            case Bob.DataClasses.ConnectionType.SqlConnection:
                Param.SetUpConnection(this.sqlConnection);
                alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open);
                break;

            case Bob.DataClasses.ConnectionType.SqlTransaction:
                Param.SetUpConnection(this.sqlTransaction);
                break;
            }

            Param.Param_JobPartId     = recordToAdd.Col_JobPartId;
            Param.Param_JobId         = recordToAdd.Col_JobId;
            Param.Param_Description   = recordToAdd.Col_Description;
            Param.Param_JobPartTypeId = recordToAdd.Col_JobPartTypeId;
            Param.Param_Units         = recordToAdd.Col_Units;
            Param.Param_PricePerUnit  = recordToAdd.Col_PricePerUnit;
            Param.Param_TotalPrice    = recordToAdd.Col_TotalPrice;

            SPs.spI_JobPart Sp = new SPs.spI_JobPart(false);
            if (Sp.Execute(ref Param))
            {
                JobPart_Record newRecord = null;

                switch (this.lastKnownConnectionType)
                {
                case Bob.DataClasses.ConnectionType.ConnectionString:
                    newRecord = new JobPart_Record(this.connectionString, Param.Param_JobPartId);
                    break;

                case Bob.DataClasses.ConnectionType.SqlConnection:
                    newRecord = new JobPart_Record(this.sqlConnection, Param.Param_JobPartId);
                    break;

                case Bob.DataClasses.ConnectionType.SqlTransaction:
                    newRecord = new JobPart_Record(this.sqlTransaction, Param.Param_JobPartId);
                    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 Bob.DataClasses.CustomException(Param, "Bob.BusinessComponents.JobPart_Collection", "Add");
            }
        }