Пример #1
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <returns>[To be supplied.]</returns>
        public bool Refresh()
        {
            this.displayName = null;

            this.col_CompanyNameWasUpdated = false;
            this.col_CompanyNameWasSet     = false;
            this.col_CompanyName           = System.Data.SqlTypes.SqlString.Null;

            this.col_ContactNameWasUpdated = false;
            this.col_ContactNameWasSet     = false;
            this.col_ContactName           = System.Data.SqlTypes.SqlString.Null;

            this.col_TitleIdWasUpdated = false;
            this.col_TitleIdWasSet     = false;
            this.col_TitleId           = System.Data.SqlTypes.SqlInt32.Null;

            this.col_AddressWasUpdated = false;
            this.col_AddressWasSet     = false;
            this.col_Address           = System.Data.SqlTypes.SqlString.Null;

            this.col_CityWasUpdated = false;
            this.col_CityWasSet     = false;
            this.col_City           = System.Data.SqlTypes.SqlString.Null;

            this.col_PostalCodeWasUpdated = false;
            this.col_PostalCodeWasSet     = false;
            this.col_PostalCode           = System.Data.SqlTypes.SqlString.Null;

            this.col_PhoneWasUpdated = false;
            this.col_PhoneWasSet     = false;
            this.col_Phone           = System.Data.SqlTypes.SqlString.Null;

            this.col_EmailWasUpdated = false;
            this.col_EmailWasSet     = false;
            this.col_Email           = System.Data.SqlTypes.SqlString.Null;

            this.col_WebAddressWasUpdated = false;
            this.col_WebAddressWasSet     = false;
            this.col_WebAddress           = System.Data.SqlTypes.SqlString.Null;

            this.col_FaxWasUpdated = false;
            this.col_FaxWasSet     = false;
            this.col_Fax           = System.Data.SqlTypes.SqlString.Null;

            this.col_ActiveWasUpdated = false;
            this.col_ActiveWasSet     = false;
            this.col_Active           = System.Data.SqlTypes.SqlBoolean.Null;

            bool alreadyOpened = false;

            Params.spS_Customers Param = new Params.spS_Customers(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_CustomerID.IsNull)
            {
                Param.Param_CustomerID = this.col_CustomerID;
            }


            System.Data.SqlClient.SqlDataReader sqlDataReader = null;
            SPs.spS_Customers Sp = new SPs.spS_Customers(false);
            if (Sp.Execute(ref Param, out sqlDataReader))
            {
                if (sqlDataReader.Read())
                {
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_CompanyName.ColumnIndex))
                    {
                        this.col_CompanyName = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_CompanyName.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_ContactName.ColumnIndex))
                    {
                        this.col_ContactName = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_ContactName.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_TitleId.ColumnIndex))
                    {
                        this.col_TitleId = sqlDataReader.GetSqlInt32(SPs.spS_Customers.Resultset1.Fields.Column_TitleId.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Address.ColumnIndex))
                    {
                        this.col_Address = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Address.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_City.ColumnIndex))
                    {
                        this.col_City = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_City.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_PostalCode.ColumnIndex))
                    {
                        this.col_PostalCode = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_PostalCode.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Phone.ColumnIndex))
                    {
                        this.col_Phone = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Phone.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Email.ColumnIndex))
                    {
                        this.col_Email = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Email.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_WebAddress.ColumnIndex))
                    {
                        this.col_WebAddress = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_WebAddress.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Fax.ColumnIndex))
                    {
                        this.col_Fax = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Fax.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Active.ColumnIndex))
                    {
                        this.col_Active = sqlDataReader.GetSqlBoolean(SPs.spS_Customers.Resultset1.Fields.Column_Active.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.Customer", "Refresh");
            }
        }
Пример #2
0
        /// <summary>
        /// Allows you to load a specific record of the [Customers] table.
        /// </summary>
        /// <param name="col_CustomerID">Customer unique identifier</param>
        public bool Refresh(System.Data.SqlTypes.SqlInt32 col_CustomerID)
        {
            bool Status;

            Reset();

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


            this.col_CustomerID = col_CustomerID;

            this.Param.Reset();

            this.Param.Param_CustomerID = this.col_CustomerID;

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

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

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_ContactName.ColumnIndex))
                    {
                        this.col_ContactName = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_ContactName.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_TitleId.ColumnIndex))
                    {
                        this.col_TitleId = DR.GetSqlInt32(SPs.spS_Customers.Resultset1.Fields.Column_TitleId.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Address.ColumnIndex))
                    {
                        this.col_Address = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Address.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_City.ColumnIndex))
                    {
                        this.col_City = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_City.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_PostalCode.ColumnIndex))
                    {
                        this.col_PostalCode = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_PostalCode.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Phone.ColumnIndex))
                    {
                        this.col_Phone = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Phone.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Email.ColumnIndex))
                    {
                        this.col_Email = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Email.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_WebAddress.ColumnIndex))
                    {
                        this.col_WebAddress = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_WebAddress.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Fax.ColumnIndex))
                    {
                        this.col_Fax = DR.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Fax.ColumnIndex);
                    }

                    if (!DR.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Active.ColumnIndex))
                    {
                        this.col_Active = DR.GetSqlBoolean(SPs.spS_Customers.Resultset1.Fields.Column_Active.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_Customers", "Refresh");
            }
        }
Пример #3
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="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_Customers();

            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_CustomerID.IsNull)
            {
                this.param.Param_CustomerID = this.param_CustomerID;
            }


            if (!this.param_TitleId.IsNull)
            {
                this.param.Param_TitleId = this.param_TitleId;
            }


            System.Data.DataSet DS = null;

            SPs.spS_Customers SP = new SPs.spS_Customers();
            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_Customers", "RefreshData");
            }
        }