/// <summary>
        /// Load or reloads all the table content. You can specify which records you want to be checked by default.
        /// In order to successfully call this method, you need to call first the Initialize method.
        /// </summary>
        /// <param name="ArrayOf_PK_JobPartId">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(System.Data.SqlTypes.SqlInt32[] ArrayOf_PK_JobPartId, int startRecord, int maxRecords)
        {
            this.CreateControl();

            this.param = new Params.spS_JobPart_Display(true);

            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;

            default:
                throw new InvalidOperationException("This control has not been initialized. You must call the Initialize method before calling this method.");
            }

            this.param.CommandTimeOut      = this.commandTimeOut;
            this.param.Param_JobId         = this.FK_JobId;
            this.param.Param_JobPartTypeId = this.FK_JobPartTypeId;

            System.Data.DataSet DS = null;

            SPs.spS_JobPart_Display SP = new SPs.spS_JobPart_Display(false);

            if (SP.Execute(ref this.param, ref DS, startRecord, maxRecords))
            {
                this.BeginUpdate();
                this.bindingInProgress = true;
                this.DataSource        = DS.Tables["spS_JobPart_Display"].DefaultView;
                this.ValueMember       = SPs.spS_JobPart_Display.Resultset1.Fields.Column_ID1.ColumnName;
                this.DisplayMember     = SPs.spS_JobPart_Display.Resultset1.Fields.Column_Display.ColumnName;
                this.bindingInProgress = false;

                System.Data.DataView dataView = DS.Tables["spS_JobPart_Display"].DefaultView;

                if (ArrayOf_PK_JobPartId != null && ArrayOf_PK_JobPartId.Length > 0)
                {
                    this.SetRecordsCheckState(ArrayOf_PK_JobPartId, System.Windows.Forms.CheckState.Checked);
                }
                else
                {
                    base.OnSelectedIndexChanged(EventArgs.Empty);
                }
                this.EndUpdate();
                SP.Dispose();
            }
            else
            {
                SP.Dispose();
                throw new Bob.DataClasses.CustomException(this.param, "WinCheckedListBox_JobPart : System.Windows.Forms.CheckedListBox", "RefreshData");
            }
        }
Exemplo n.º 2
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");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <returns>[To be supplied.]</returns>
        public override string ToString()
        {
            if (!this.recordWasLoadedFromDB)
            {
                throw new ArgumentException("No record was loaded from the database. The DisplayName is not available.");
            }

            if (this.displayName == null)
            {
                bool alreadyOpened = false;

                Params.spS_JobPart_Display Param = new Params.spS_JobPart_Display(true);

                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 = this.col_JobPartId;

                System.Data.SqlClient.SqlDataReader sqlDataReader = null;
                SPs.spS_JobPart_Display             Sp            = new SPs.spS_JobPart_Display(false);
                if (Sp.Execute(ref Param, out sqlDataReader))
                {
                    if (sqlDataReader.Read())
                    {
                        if (!sqlDataReader.IsDBNull(SPs.spS_JobPart_Display.Resultset1.Fields.Column_Display.ColumnIndex))
                        {
                            if (sqlDataReader.GetFieldType(SPs.spS_JobPart_Display.Resultset1.Fields.Column_Display.ColumnIndex) == typeof(string))
                            {
                                this.displayName = sqlDataReader.GetString(SPs.spS_JobPart_Display.Resultset1.Fields.Column_Display.ColumnIndex);
                            }
                            else
                            {
                                this.displayName = sqlDataReader.GetValue(SPs.spS_JobPart_Display.Resultset1.Fields.Column_Display.ColumnIndex).ToString();
                            }
                        }
                    }

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

                    CloseConnection(Sp.Connection, alreadyOpened);
                }
                else
                {
                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);

                    throw new Bob.DataClasses.CustomException(Param, "Bob.BusinessComponents.JobPart_Record", "ToString");
                }
            }

            return(this.displayName);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Load or reloads a subset of the table content. You can specify which record you want to be selected
        /// by default. In order to successfully call this method, you need to call first the Initialize method.
        /// </summary>
        /// <param name="PK_JobPartId">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(System.Data.SqlTypes.SqlInt32 PK_JobPartId, int startRecord, int maxRecords)
        {
            this.CreateControl();

            if (!PK_JobPartId.IsNull && this.SelectionMode == System.Windows.Forms.SelectionMode.None)
            {
                throw new ArgumentException("You cannot supply a value to this parameter when SelectionMode property is set to None.", "PK_JobPartId");
            }

            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_Display(true);

            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;

            default:
                throw new InvalidOperationException("This control has not been initialized. You must call the Initialize method before calling this method.");
            }

            this.param.CommandTimeOut      = this.commandTimeOut;
            this.param.Param_JobId         = this.FK_JobId;
            this.param.Param_JobPartTypeId = this.FK_JobPartTypeId;

            System.Data.DataSet DS = null;

            SPs.spS_JobPart_Display SP = new SPs.spS_JobPart_Display(false);

            if (SP.Execute(ref this.param, ref DS, startRecord, maxRecords))
            {
                this.BeginUpdate();
                this.bindingInProgress = true;
                this.DataSource        = DS.Tables["spS_JobPart_Display"].DefaultView;
                this.ValueMember       = SPs.spS_JobPart_Display.Resultset1.Fields.Column_ID1.ColumnName;
                this.DisplayMember     = SPs.spS_JobPart_Display.Resultset1.Fields.Column_Display.ColumnName;
                this.bindingInProgress = false;

                if (!PK_JobPartId.IsNull)
                {
                    this.SelectedValue = PK_JobPartId.Value;
                }
                else
                {
                    base.OnSelectedIndexChanged(EventArgs.Empty);
                }

                this.EndUpdate();
                SP.Dispose();
            }
            else
            {
                SP.Dispose();
                throw new Bob.DataClasses.CustomException(this.param, "WinListBox_JobPart : System.Windows.Forms.ListBox", "RefreshData");
            }
        }