/// <summary>
        /// Initializes the control. You need to specify how to connect to the SQL Server database.
        /// You also need to supply the 'spS_xReadOrderDateAmount' stored procedure parameters.
        /// </summary>
        /// <param name="connectionString">A valid connection string to the database.</param>
        /// <param name="valueMember">name of the field to be used as a primary key.</param>
        /// <param name="displayMember">name of the field to be used for the content display.</param>
        /// <param name="param_Ord_LngCustomerID">Value for the parameter @Ord_LngCustomerID.</param>
        /// <param name="param_ReturnXML">Value for the parameter @ReturnXML.</param>
        public void Initialize(string connectionString, string valueMember, string displayMember, System.Data.SqlTypes.SqlInt32 param_Ord_LngCustomerID, System.Data.SqlTypes.SqlBoolean param_ReturnXML)
        {
            if (connectionString == null)
            {
                throw new ArgumentNullException("connectionString", "connectionString can be an empty string but can not be null.");
            }

            this.connectionString        = connectionString;
            this.LastKnownConnectionType = OlymarsDemo.DataClasses.ConnectionType.ConnectionString;

#if OLYMARS_DEBUG
            object olymarsDebugCheck = System.Configuration.ConfigurationSettings.AppSettings["OlymarsDebugCheck"];
            if (olymarsDebugCheck == null || (string)olymarsDebugCheck == "True")
            {
                string DebugConnectionString = connectionString;

                if (DebugConnectionString.Length == 0)
                {
                    DebugConnectionString = OlymarsDemo.DataClasses.Information.GetConnectionStringFromConfigurationFile;
                }

                if (DebugConnectionString.Length == 0)
                {
                    DebugConnectionString = OlymarsDemo.DataClasses.Information.GetConnectionStringFromRegistry;
                }

                if (DebugConnectionString.Length != 0)
                {
                    System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(DebugConnectionString);

                    sqlConnection.Open();

                    System.Data.SqlClient.SqlCommand sqlCommand = sqlConnection.CreateCommand();

                    sqlCommand.CommandType = System.Data.CommandType.Text;
                    sqlCommand.CommandText = "Select sysobjects.schema_ver from sysobjects where sysobjects.name = 'spS_xReadOrderDateAmount'";

                    int CurrentRevision = (int)sqlCommand.ExecuteScalar();

                    sqlConnection.Close();

                    int OriginalRevision = ((OlymarsDemo.DataClasses.OlymarsInformationAttribute)System.Attribute.GetCustomAttribute(this.GetType(), typeof(OlymarsDemo.DataClasses.OlymarsInformationAttribute), false)).SqlObjectDependancyRevision;
                    if (CurrentRevision != OriginalRevision)
                    {
                        throw new System.InvalidOperationException(System.String.Format("OLYMARS: This code is not in sync anymore with [{0}]. It was generated when [{0}] version was: {2}. Current [{0}] version is: {1}{3}{3}You can either regenerate the code for this class so that it will be based on the new version or edit the configuration file of the class caller application and paste the following code:{3}{3}<?xml version=\"1.0\" encoding=\"utf-8\" ?>{3}<configuration>{3}\t<appSettings>{3}\t\t<add key=\"OlymarsDebugCheck\" value=\"False\" />{3}\t</appSettings>{3}</configuration>{3}{3}You will need to reload the caller application if it is a Windows Forms based application.", "spS_xReadOrderDateAmount", CurrentRevision, OriginalRevision, System.Environment.NewLine));
                    }
                }
            }
#endif

            this.valueMember   = valueMember;
            this.displayMember = displayMember;
            this.tableName     = "spS_xReadOrderDateAmount";

            this.param_Ord_LngCustomerID = param_Ord_LngCustomerID;
            this.param_ReturnXML         = param_ReturnXML;
        }
        /// <summary>
        /// Disposes the current instance of this object.
        /// </summary>
        public override void Dispose()
        {
            this.param_Ord_LngCustomerID = System.Data.SqlTypes.SqlInt32.Null;
            this.param_ReturnXML         = System.Data.SqlTypes.SqlBoolean.Null;
            if (this.param != null)
            {
                this.param.Dispose();
            }

            base.Dispose();
        }
        /// <summary>
        /// Disposes the current instance of this object.
        /// </summary>
        /// <param name="disposing">
        /// true to release both managed and unmanaged resources;
        /// false to release only unmanaged resources.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                this.param_Ord_LngCustomerID = System.Data.SqlTypes.SqlInt32.Null;
                this.param_ReturnXML         = System.Data.SqlTypes.SqlBoolean.Null;
                if (this.param != null)
                {
                    this.param.Dispose();
                }
            }

            base.Dispose(disposing);
        }
Beispiel #4
0
 /// <summary>
 /// This method allows to clear all the properties previously loaded by a call to the Refresh method.
 /// </summary>
 public void Reset()
 {
     this.col_CustomerID  = System.Data.SqlTypes.SqlInt32.Null;
     this.col_CompanyName = System.Data.SqlTypes.SqlString.Null;
     this.col_ContactName = System.Data.SqlTypes.SqlString.Null;
     this.col_TitleId     = System.Data.SqlTypes.SqlInt32.Null;
     this.col_Address     = System.Data.SqlTypes.SqlString.Null;
     this.col_City        = System.Data.SqlTypes.SqlString.Null;
     this.col_PostalCode  = System.Data.SqlTypes.SqlString.Null;
     this.col_Phone       = System.Data.SqlTypes.SqlString.Null;
     this.col_Email       = System.Data.SqlTypes.SqlString.Null;
     this.col_WebAddress  = System.Data.SqlTypes.SqlString.Null;
     this.col_Fax         = System.Data.SqlTypes.SqlString.Null;
     this.col_Active      = System.Data.SqlTypes.SqlBoolean.Null;
 }
        /// <summary>
        /// This method allows you to reset the parameter object. Please note that this
        /// method resets all the parameters members except the connection information and
        /// the command time-out which are left in their current state.
        /// </summary>
        public void Reset()
        {
            this.internal_Param_RETURN_VALUE = System.Data.SqlTypes.SqlInt32.Null;

            this.internal_Param_Cat_LngID = System.Data.SqlTypes.SqlInt32.Null;
            this.internal_Param_Cat_LngID_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Cat_StrName = System.Data.SqlTypes.SqlString.Null;
            this.internal_Param_Cat_StrName_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_ConsiderNull_Cat_StrName = System.Data.SqlTypes.SqlBoolean.Null;
            this.internal_Param_ConsiderNull_Cat_StrName_UseDefaultValue = this.useDefaultValue;

            this.errorSource    = ErrorSource.NotAvailable;
            this.sqlException   = null;
            this.otherException = null;
        }
        /// <summary>
        /// Initializes the control. You need to specify how to connect to the SQL Server database.
        /// You also need to supply the spS_xReadOrderDateAmount stored procedure parameters.
        /// </summary>
        /// <param name="sqlConnection">A valid SqlConnection object. If it is not opened, it will be opened when used then closed again after the job is done.</param>
        /// <param name="primaryKey">The field that represents a primary key.</param>
        /// <param name="tableName">name of the table to use to populate the control.</param>
        /// <param name="param_Ord_LngCustomerID">Value for the parameter @Ord_LngCustomerID.</param>
        /// <param name="param_ReturnXML">Value for the parameter @ReturnXML.</param>
        public void Initialize(System.Data.SqlClient.SqlConnection sqlConnection, string primaryKey, string tableName, System.Data.SqlTypes.SqlInt32 param_Ord_LngCustomerID, System.Data.SqlTypes.SqlBoolean param_ReturnXML)
        {
            this.sqlConnection           = sqlConnection;
            this.LastKnownConnectionType = OlymarsDemo.DataClasses.ConnectionType.SqlConnection;
            this.primaryKey = primaryKey;
            this.tableName  = tableName;

#if OLYMARS_DEBUG
            object olymarsDebugCheck = System.Configuration.ConfigurationSettings.AppSettings["OlymarsDebugCheck"];
            if (olymarsDebugCheck == null || (string)olymarsDebugCheck == "True")
            {
                bool NotAlreadyOpened = false;
                if (sqlConnection.State == System.Data.ConnectionState.Closed)
                {
                    NotAlreadyOpened = true;
                    sqlConnection.Open();
                }

                System.Data.SqlClient.SqlCommand sqlCommand = sqlConnection.CreateCommand();

                sqlCommand.CommandType = System.Data.CommandType.Text;
                sqlCommand.CommandText = "Select sysobjects.schema_ver from sysobjects where sysobjects.name = 'spS_xReadOrderDateAmount'";

                int CurrentRevision = (int)sqlCommand.ExecuteScalar();

                if (NotAlreadyOpened)
                {
                    sqlConnection.Close();
                }

                int OriginalRevision = ((OlymarsDemo.DataClasses.OlymarsInformationAttribute)System.Attribute.GetCustomAttribute(this.GetType(), typeof(OlymarsDemo.DataClasses.OlymarsInformationAttribute), false)).SqlObjectDependancyRevision;
                if (CurrentRevision != OriginalRevision)
                {
                    throw new System.InvalidOperationException(System.String.Format("OLYMARS: This code is not in sync anymore with [{0}]. It was generated when [{0}] version was: {2}. Current [{0}] version is: {1}{3}{3}You can either regenerate the code for this class so that it will be based on the new version or edit the configuration file of the class caller application and paste the following code:{3}{3}<?xml version=\"1.0\" encoding=\"utf-8\" ?>{3}<configuration>{3}\t<appSettings>{3}\t\t<add key=\"OlymarsDebugCheck\" value=\"False\" />{3}\t</appSettings>{3}</configuration>{3}{3}You will need to reload the caller application if it is a Windows Forms based application.", "spS_xReadOrderDateAmount", CurrentRevision, OriginalRevision, System.Environment.NewLine));
                }
            }
#endif

            this.param_Ord_LngCustomerID = param_Ord_LngCustomerID;
            this.param_ReturnXML         = param_ReturnXML;
        }
Beispiel #7
0
        /// <summary>
        /// This method allows you to reset the parameter object. Please note that this
        /// method resets all the parameters members except the connection information and
        /// the command time-out which are left in their current state.
        /// </summary>
        public void Reset()
        {
            this.internal_Param_RETURN_VALUE = System.Data.SqlTypes.SqlInt32.Null;

            this.internal_Param_JobPartTypeId = System.Data.SqlTypes.SqlInt32.Null;
            this.internal_Param_JobPartTypeId_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_Description = System.Data.SqlTypes.SqlString.Null;
            this.internal_Param_Description_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_ConsiderNull_Description = System.Data.SqlTypes.SqlBoolean.Null;
            this.internal_Param_ConsiderNull_Description_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_GeneralUnitCost = System.Data.SqlTypes.SqlMoney.Null;
            this.internal_Param_GeneralUnitCost_UseDefaultValue = this.useDefaultValue;

            this.internal_Param_ConsiderNull_GeneralUnitCost = System.Data.SqlTypes.SqlBoolean.Null;
            this.internal_Param_ConsiderNull_GeneralUnitCost_UseDefaultValue = this.useDefaultValue;

            this.errorSource    = ErrorSource.NotAvailable;
            this.sqlException   = null;
            this.otherException = null;
        }
Beispiel #8
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");
            }
        }