/// <summary>
        /// Allows you to load a specific record of the [JobPartType] table.
        /// </summary>
        /// <param name="col_JobPartTypeId">Update this description in the &quot;Olymars/Description&quot; extended property of the &quot;JobPartTypeId&quot; column.</param>
        public bool Refresh(System.Data.SqlTypes.SqlInt32 col_JobPartTypeId)
        {
            bool Status;

            Reset();

            if (col_JobPartTypeId.IsNull)
            {
                throw new ArgumentNullException("col_JobPartTypeId", "The primary key 'col_JobPartTypeId' can not have a Null value!");
            }


            this.col_JobPartTypeId = col_JobPartTypeId;

            this.Param.Reset();

            this.Param.Param_JobPartTypeId = this.col_JobPartTypeId;

            System.Data.SqlClient.SqlDataReader DR;
            SPs.spS_JobPartType SP = new SPs.spS_JobPartType(false);

            if (SP.Execute(ref this.Param, out DR))
            {
                Status = false;
                if (DR.Read())
                {
                    if (!DR.IsDBNull(SPs.spS_JobPartType.Resultset1.Fields.Column_Description.ColumnIndex))
                    {
                        this.col_Description = DR.GetSqlString(SPs.spS_JobPartType.Resultset1.Fields.Column_Description.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_JobPartType.Resultset1.Fields.Column_GeneralUnitCost.ColumnIndex))
                    {
                        this.col_GeneralUnitCost = DR.GetSqlMoney(SPs.spS_JobPartType.Resultset1.Fields.Column_GeneralUnitCost.ColumnIndex);
                    }

                    Status = true;
                }

                if (DR != null && !DR.IsClosed)
                {
                    DR.Close();
                }

                if (CloseConnectionAfterUse && SP.Connection != null && SP.Connection.State == System.Data.ConnectionState.Open)
                {
                    SP.Connection.Close();
                    SP.Connection.Dispose();
                }

                return(Status);
            }

            else
            {
                if (DR != null && !DR.IsClosed)
                {
                    DR.Close();
                }

                if (CloseConnectionAfterUse && SP.Connection != null && SP.Connection.State == System.Data.ConnectionState.Open)
                {
                    SP.Connection.Close();
                    SP.Connection.Dispose();
                }

                throw new Bob.DataClasses.CustomException(this.Param, "Bob.AbstractClasses.Abstract_JobPartType", "Refresh");
            }
        }
        /// <summary>
        /// Load or reloads a subset of the chosen resultset returned by the stored procedure.
        /// You can specify which record you want to be checked by default.
        /// </summary>
        /// <param name="PrimaryKey">Primary key of the record you want to be selected by default.</param>
        /// <param name="startRecord">The zero-based record number to start with.</param>
        /// <param name="maxRecords">The maximum number of records to retrieve.</param>
        public void RefreshData(object PrimaryKey, int startRecord, int maxRecords)
        {
            this.CreateControl();

            if (this.LastKnownConnectionType == Bob.DataClasses.ConnectionType.None)
            {
                throw new InvalidOperationException("You must call the 'Initialize' method before calling this method.");
            }

            this.param = new Params.spS_JobPartType();

            switch (this.LastKnownConnectionType)
            {
            case Bob.DataClasses.ConnectionType.ConnectionString:
                this.param.SetUpConnection(this.connectionString);
                break;

            case Bob.DataClasses.ConnectionType.SqlConnection:
                this.param.SetUpConnection(this.sqlConnection);
                break;
            }

            this.param.CommandTimeOut = this.commandTimeOut;


            if (!this.param_JobPartTypeId.IsNull)
            {
                this.param.Param_JobPartTypeId = this.param_JobPartTypeId;
            }


            System.Data.DataSet DS = null;

            SPs.spS_JobPartType SP = new SPs.spS_JobPartType();
            if (SP.Execute(ref this.param, ref DS, startRecord, maxRecords))
            {
                this.BeginUpdate();
                this.bindingInProgress = true;
                this.DataSource        = DS.Tables[this.tableName].DefaultView;
                this.ValueMember       = this.valueMember;
                this.DisplayMember     = this.displayMember;
                this.bindingInProgress = false;

                if (PrimaryKey != null)
                {
                    this.SelectedValue = PrimaryKey;
                }
                else
                {
                    base.OnSelectedIndexChanged(EventArgs.Empty);
                }

                this.EndUpdate();
                SP.Dispose();
            }

            else
            {
                SP.Dispose();
                throw new Bob.DataClasses.CustomException(this.param, "WinListBoxCustom_spS_JobPartType", "RefreshData");
            }
        }
示例#3
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <returns>[To be supplied.]</returns>
        public bool Refresh()
        {
            this.displayName = null;

            this.col_DescriptionWasUpdated = false;
            this.col_DescriptionWasSet     = false;
            this.col_Description           = System.Data.SqlTypes.SqlString.Null;

            this.col_GeneralUnitCostWasUpdated = false;
            this.col_GeneralUnitCostWasSet     = false;
            this.col_GeneralUnitCost           = System.Data.SqlTypes.SqlMoney.Null;

            bool alreadyOpened = false;

            Params.spS_JobPartType Param = new Params.spS_JobPartType(true);
            Param.CommandTimeOut = this.selectCommandTimeOut;
            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_JobPartTypeId.IsNull)
            {
                Param.Param_JobPartTypeId = this.col_JobPartTypeId;
            }


            System.Data.SqlClient.SqlDataReader sqlDataReader = null;
            SPs.spS_JobPartType Sp = new SPs.spS_JobPartType(false);
            if (Sp.Execute(ref Param, out sqlDataReader))
            {
                if (sqlDataReader.Read())
                {
                    if (!sqlDataReader.IsDBNull(SPs.spS_JobPartType.Resultset1.Fields.Column_Description.ColumnIndex))
                    {
                        this.col_Description = sqlDataReader.GetSqlString(SPs.spS_JobPartType.Resultset1.Fields.Column_Description.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_JobPartType.Resultset1.Fields.Column_GeneralUnitCost.ColumnIndex))
                    {
                        this.col_GeneralUnitCost = sqlDataReader.GetSqlMoney(SPs.spS_JobPartType.Resultset1.Fields.Column_GeneralUnitCost.ColumnIndex);
                    }

                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);

                    this.recordIsLoaded = true;

                    return(true);
                }
                else
                {
                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);

                    this.recordIsLoaded = false;

                    return(false);
                }
            }
            else
            {
                if (sqlDataReader != null && !sqlDataReader.IsClosed)
                {
                    sqlDataReader.Close();
                }

                CloseConnection(Sp.Connection, alreadyOpened);

                throw new Bob.DataClasses.CustomException(Param, "Bob.BusinessComponents.JobPartType_Record", "Refresh");
            }
        }