Example #1
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <param name="col_JobId">[To be supplied.]</param>
        /// <param name="parent">[To be supplied.]</param>
        internal void LoadFrom_JobId(System.Data.SqlTypes.SqlInt32 col_JobId, Job_Record parent)
        {
            if (col_JobId.IsNull)
            {
                throw new ArgumentException("Parameter can not be null", "col_JobId");
            }

            if (parent == null)
            {
                throw new ArgumentException("Parameter can not be null", "parent");
            }

            this.col_JobId  = col_JobId;
            this.parent     = parent;
            this.parentType = JobPart_CollectionParentType.Col_JobId;
        }
Example #2
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <param name="record">[To be supplied.]</param>
        public void Remove(IBusinessComponentRecord record)
        {
            Job_Record recordToDelete = record as Job_Record;

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

            bool alreadyOpened = false;

            Params.spD_Job Param = new Params.spD_Job(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_JobId = recordToDelete.Col_JobId;

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

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

            if (internalRecords != null)
            {
                internalRecords.Remove(recordToDelete);
            }
        }
Example #3
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        public new Job_Record MemberwiseClone()
        {
            Job_Record newRecord = new Job_Record();

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

            newRecord.col_JobId = this.col_JobId;


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

            newRecord.col_PriceWasSet     = this.col_PriceWasSet;
            newRecord.col_PriceWasUpdated = this.col_PriceWasUpdated;
            newRecord.col_Price           = this.col_Price;

            newRecord.col_StartDateWasSet     = this.col_StartDateWasSet;
            newRecord.col_StartDateWasUpdated = this.col_StartDateWasUpdated;
            newRecord.col_StartDate           = this.col_StartDate;

            newRecord.col_EndDateWasSet     = this.col_EndDateWasSet;
            newRecord.col_EndDateWasUpdated = this.col_EndDateWasUpdated;
            newRecord.col_EndDate           = this.col_EndDate;

            newRecord.col_CustomerIdWasSet     = this.col_CustomerIdWasSet;
            newRecord.col_CustomerIdWasUpdated = this.col_CustomerIdWasUpdated;
            newRecord.col_CustomerId           = this.col_CustomerId;

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

            newRecord.displayName = this.displayName;

            return(newRecord);
        }
Example #4
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        public void Refresh()
        {
            internalRecords = new System.Collections.ArrayList();

            bool alreadyOpened = false;

            Params.spS_Job_Display Param = new Params.spS_Job_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_CustomerId.IsNull)
            {
                Param.Param_CustomerId = this.col_CustomerId;
            }

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

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

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

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


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

                    if (sqlDataReader.GetFieldType(SPs.spS_Job_Display.Resultset1.Fields.Column_Display.ColumnIndex) == typeof(string))
                    {
                        record.displayName = sqlDataReader.GetString(SPs.spS_Job_Display.Resultset1.Fields.Column_Display.ColumnIndex);
                    }
                    else
                    {
                        record.displayName = sqlDataReader.GetValue(SPs.spS_Job_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.Job_Collection", "Refresh");
            }
        }
Example #5
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <param name="record">[To be supplied.]</param>
        /// <returns>[To be supplied.]</returns>
        public IBusinessComponentRecord Add(IBusinessComponentRecord record)
        {
            Job_Record recordToAdd = record as Job_Record;

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

            switch (this.parentType)
            {
            case Job_CollectionParentType.Col_CustomerId:
                recordToAdd.Col_CustomerId = ((Customer)this.parent).CustomerID;
                break;
            }

            bool alreadyOpened = false;

            Params.spI_Job Param = new Params.spI_Job(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_JobId       = recordToAdd.Col_JobId;
            Param.Param_Description = recordToAdd.Col_Description;
            Param.Param_Price       = recordToAdd.Col_Price;
            Param.Param_StartDate   = recordToAdd.Col_StartDate;
            Param.Param_EndDate     = recordToAdd.Col_EndDate;
            Param.Param_CustomerId  = recordToAdd.Col_CustomerId;

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

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

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

                case Bob.DataClasses.ConnectionType.SqlTransaction:
                    newRecord = new Job_Record(this.sqlTransaction, Param.Param_JobId);
                    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.Job_Collection", "Add");
            }
        }