Exemplo n.º 1
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <returns>[To be supplied.]</returns>
        public bool Refresh()
        {
            this.displayName = null;

            this.col_TitleWasUpdated = false;
            this.col_TitleWasSet     = false;
            this.col_Title           = System.Data.SqlTypes.SqlString.Null;

            bool alreadyOpened = false;

            Params.spS_Title Param = new Params.spS_Title(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_TitleId.IsNull)
            {
                Param.Param_TitleId = this.col_TitleId;
            }


            System.Data.SqlClient.SqlDataReader sqlDataReader = null;
            SPs.spS_Title Sp = new SPs.spS_Title(false);
            if (Sp.Execute(ref Param, out sqlDataReader))
            {
                if (sqlDataReader.Read())
                {
                    if (!sqlDataReader.IsDBNull(SPs.spS_Title.Resultset1.Fields.Column_Title.ColumnIndex))
                    {
                        this.col_Title = sqlDataReader.GetSqlString(SPs.spS_Title.Resultset1.Fields.Column_Title.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.Title", "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="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_Title();

            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_TitleId.IsNull)
            {
                this.param.Param_TitleId = this.param_TitleId;
            }


            System.Data.DataSet DS = null;

            SPs.spS_Title SP = new SPs.spS_Title();
            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_Title", "RefreshData");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Allows you to load a specific record of the [Title] table.
        /// </summary>
        /// <param name="col_TitleId">Unique Identifier</param>
        public bool Refresh(System.Data.SqlTypes.SqlInt32 col_TitleId)
        {
            bool Status;

            Reset();

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


            this.col_TitleId = col_TitleId;

            this.Param.Reset();

            this.Param.Param_TitleId = this.col_TitleId;

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

            if (SP.Execute(ref this.Param, out DR))
            {
                Status = false;
                if (DR.Read())
                {
                    if (!DR.IsDBNull(SPs.spS_Title.Resultset1.Fields.Column_Title.ColumnIndex))
                    {
                        this.col_Title = DR.GetSqlString(SPs.spS_Title.Resultset1.Fields.Column_Title.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_Title", "Refresh");
            }
        }