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

            Reset();

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


            this.col_JobPartId = col_JobPartId;

            this.Param.Reset();

            this.Param.Param_JobPartId = this.col_JobPartId;

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

            if (SP.Execute(ref this.Param, out DR))
            {
                Status = false;
                if (DR.Read())
                {
                    if (!DR.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_JobId.ColumnIndex))
                    {
                        this.col_JobId = DR.GetSqlInt32(SPs.spS_JobPart.Resultset1.Fields.Column_JobId.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_Description.ColumnIndex))
                    {
                        this.col_Description = DR.GetSqlString(SPs.spS_JobPart.Resultset1.Fields.Column_Description.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_JobPartTypeId.ColumnIndex))
                    {
                        this.col_JobPartTypeId = DR.GetSqlInt32(SPs.spS_JobPart.Resultset1.Fields.Column_JobPartTypeId.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_Units.ColumnIndex))
                    {
                        this.col_Units = DR.GetSqlDecimal(SPs.spS_JobPart.Resultset1.Fields.Column_Units.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_PricePerUnit.ColumnIndex))
                    {
                        this.col_PricePerUnit = DR.GetSqlMoney(SPs.spS_JobPart.Resultset1.Fields.Column_PricePerUnit.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_TotalPrice.ColumnIndex))
                    {
                        this.col_TotalPrice = DR.GetSqlMoney(SPs.spS_JobPart.Resultset1.Fields.Column_TotalPrice.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_JobPart", "Refresh");
            }
        }
Beispiel #2
0
        /// <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="ArrayOf_PrimaryKeys">Primary keys of the records you want to be checked 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[] ArrayOf_PrimaryKeys, 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_JobPart();

            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_JobPartId.IsNull)
            {
                this.param.Param_JobPartId = this.param_JobPartId;
            }


            if (!this.param_JobId.IsNull)
            {
                this.param.Param_JobId = this.param_JobId;
            }


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


            System.Data.DataSet DS = null;

            SPs.spS_JobPart SP = new SPs.spS_JobPart();
            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 (ArrayOf_PrimaryKeys != null && ArrayOf_PrimaryKeys.Length > 0)
                {
                    this.SetRecordsCheckState(ArrayOf_PrimaryKeys, System.Windows.Forms.CheckState.Checked);
                }
                else
                {
                    base.OnSelectedIndexChanged(EventArgs.Empty);
                }

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

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

            this.col_JobIdWasUpdated = false;
            this.col_JobIdWasSet     = false;
            this.col_JobId           = System.Data.SqlTypes.SqlInt32.Null;

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

            this.col_JobPartTypeIdWasUpdated = false;
            this.col_JobPartTypeIdWasSet     = false;
            this.col_JobPartTypeId           = System.Data.SqlTypes.SqlInt32.Null;

            this.col_UnitsWasUpdated = false;
            this.col_UnitsWasSet     = false;
            this.col_Units           = System.Data.SqlTypes.SqlDecimal.Null;

            this.col_PricePerUnitWasUpdated = false;
            this.col_PricePerUnitWasSet     = false;
            this.col_PricePerUnit           = System.Data.SqlTypes.SqlMoney.Null;

            this.col_TotalPriceWasUpdated = false;
            this.col_TotalPriceWasSet     = false;
            this.col_TotalPrice           = System.Data.SqlTypes.SqlMoney.Null;

            bool alreadyOpened = false;

            Params.spS_JobPart Param = new Params.spS_JobPart(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_JobPartId.IsNull)
            {
                Param.Param_JobPartId = this.col_JobPartId;
            }


            System.Data.SqlClient.SqlDataReader sqlDataReader = null;
            SPs.spS_JobPart Sp = new SPs.spS_JobPart(false);
            if (Sp.Execute(ref Param, out sqlDataReader))
            {
                if (sqlDataReader.Read())
                {
                    if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_JobId.ColumnIndex))
                    {
                        this.col_JobId = sqlDataReader.GetSqlInt32(SPs.spS_JobPart.Resultset1.Fields.Column_JobId.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_Description.ColumnIndex))
                    {
                        this.col_Description = sqlDataReader.GetSqlString(SPs.spS_JobPart.Resultset1.Fields.Column_Description.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_JobPartTypeId.ColumnIndex))
                    {
                        this.col_JobPartTypeId = sqlDataReader.GetSqlInt32(SPs.spS_JobPart.Resultset1.Fields.Column_JobPartTypeId.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_Units.ColumnIndex))
                    {
                        this.col_Units = sqlDataReader.GetSqlDecimal(SPs.spS_JobPart.Resultset1.Fields.Column_Units.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_PricePerUnit.ColumnIndex))
                    {
                        this.col_PricePerUnit = sqlDataReader.GetSqlMoney(SPs.spS_JobPart.Resultset1.Fields.Column_PricePerUnit.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_TotalPrice.ColumnIndex))
                    {
                        this.col_TotalPrice = sqlDataReader.GetSqlMoney(SPs.spS_JobPart.Resultset1.Fields.Column_TotalPrice.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.JobPart_Record", "Refresh");
            }
        }