Пример #1
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)
        {
            if (this.LastKnownConnectionType == OlymarsDemo.DataClasses.ConnectionType.None)
            {
                throw new InvalidOperationException("You must call the 'Initialize' method before calling this method.");
            }

            this.param = new Params.spS_tblProduct();

            switch (this.LastKnownConnectionType)
            {
            case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                this.param.SetUpConnection(this.connectionString);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                this.param.SetUpConnection(this.sqlConnection);
                break;
            }

            this.param.CommandTimeOut = this.commandTimeOut;


            if (!this.param_Pro_GuidID.IsNull)
            {
                this.param.Param_Pro_GuidID = this.param_Pro_GuidID;
            }


            if (!this.param_Pro_LngCategoryID.IsNull)
            {
                this.param.Param_Pro_LngCategoryID = this.param_Pro_LngCategoryID;
            }


            System.Data.DataSet DS = null;

            SPs.spS_tblProduct SP = new SPs.spS_tblProduct();
            if (SP.Execute(ref this.param, ref DS, startRecord, maxRecords))
            {
                this.DataSource     = DS.Tables[this.tableName].DefaultView;
                this.DataValueField = this.valueMember;
                this.DataTextField  = this.displayMember;
                if (this.doDataBindAfterRefreshData)
                {
                    this.DataBind();
                }

                if (ArrayOf_PrimaryKeys != null)
                {
                    this.SetRecordsChecked(ArrayOf_PrimaryKeys, true);
                }
            }

            else
            {
                SP.Dispose();
                throw new OlymarsDemo.DataClasses.CustomException(this.param, "WebCheckBoxListCustom_spS_tblProduct", "RefreshData");
            }
        }
Пример #2
0
        public Tables.Product GetOne_Product(Guid id)
        {
            Params.spS_tblProduct param = new Params.spS_tblProduct(true);

            param.SetUpConnection(string.Empty);

            param.Param_Pro_GuidID = id;

            using (SPs.spS_tblProduct sp = new SPs.spS_tblProduct(true)) {
                System.Data.SqlClient.SqlDataReader sqlDataReader = null;
                sp.Execute(ref param, out sqlDataReader);
                param.Dispose();

                if (sqlDataReader.Read())
                {
                    Tables.Product record = new Tables.Product();

                    record.Col_Pro_GuidID.UseNull = sqlDataReader.IsDBNull(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_GuidID.ColumnIndex);
                    if (!record.Col_Pro_GuidID.UseNull)
                    {
                        record.Col_Pro_GuidID.Value = sqlDataReader.GetSqlGuid(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_GuidID.ColumnIndex).Value;
                    }

                    record.Name.UseNull = sqlDataReader.IsDBNull(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_StrName.ColumnIndex);
                    if (!record.Name.UseNull)
                    {
                        record.Name.Value = sqlDataReader.GetSqlString(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_StrName.ColumnIndex).Value;
                    }

                    record.Col_Pro_CurPrice.UseNull = sqlDataReader.IsDBNull(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_CurPrice.ColumnIndex);
                    if (!record.Col_Pro_CurPrice.UseNull)
                    {
                        record.Col_Pro_CurPrice.Value = sqlDataReader.GetSqlMoney(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_CurPrice.ColumnIndex).Value;
                    }

                    record.CategoryID.UseNull = sqlDataReader.IsDBNull(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_LngCategoryID.ColumnIndex);
                    if (!record.CategoryID.UseNull)
                    {
                        record.CategoryID.Value = sqlDataReader.GetSqlInt32(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_LngCategoryID.ColumnIndex).Value;
                    }


                    sqlDataReader.Close();
                    sp.Connection.Close();

                    return(record);
                }
                else
                {
                    sqlDataReader.Close();
                    sp.Connection.Close();

                    return(null);
                }
            }
        }
        /// <summary>
        /// Create a new instance of the Abstract_tblProduct class.
        /// </summary>
        /// <param name="connectionString">A valid connection string to the database.</param>
        public Abstract_tblProduct(string connectionString)
        {
            if (connectionString == null)
            {
                throw new ArgumentNullException("connectionString", "connectionString can be an empty string but can not be null.");
            }

#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 = 'tblProduct'";

                    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.", "tblProduct", CurrentRevision, OriginalRevision, System.Environment.NewLine));
                    }
                }
            }
#endif

            this.Param = new Params.spS_tblProduct(true);
            this.Param.SetUpConnection(connectionString);
        }
Пример #4
0
        /// <summary>
        /// Load or reloads a subset of the table content. In order to successfully call this method, you need to call first
        /// the Initialize method.
        /// </summary>
        /// <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(int startRecord, int maxRecords)
        {
            if (this.LastKnownConnectionType == OlymarsDemo.DataClasses.ConnectionType.None)
            {
                throw new InvalidOperationException("You must call the 'Initialize' method before calling this method.");
            }

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

            switch (this.LastKnownConnectionType)
            {
            case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                this.param.SetUpConnection(this.connectionString);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                this.param.SetUpConnection(this.sqlConnection);
                break;
            }

            if (!this.FK_Pro_LngCategoryID.IsNull)
            {
                this.param.Param_Pro_LngCategoryID = this.FK_Pro_LngCategoryID;
            }

            System.Data.DataSet DS = null;

            SPs.spS_tblProduct SP = new SPs.spS_tblProduct(false);
            if (SP.Execute(ref this.param, ref DS, startRecord, maxRecords))
            {
                this.DataSource   = DS.Tables["spS_tblProduct"].DefaultView;
                this.DataKeyField = "Pro_GuidID";
                if (this.doDataBindAfterRefreshData)
                {
                    this.DataBind();
                }

                SP.Dispose();
            }

            else
            {
                SP.Dispose();
                throw new OlymarsDemo.DataClasses.CustomException(this.param, "WebDataGrid_tblProduct : System.Web.UI.WebControls.DataGrid", "RefreshData");
            }
        }
Пример #5
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 == OlymarsDemo.DataClasses.ConnectionType.None)
            {
                throw new InvalidOperationException("You must call the 'Initialize' method before calling this method.");
            }

            this.param = new Params.spS_tblProduct();

            switch (this.LastKnownConnectionType)
            {
            case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                this.param.SetUpConnection(this.connectionString);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                this.param.SetUpConnection(this.sqlConnection);
                break;
            }

            this.param.CommandTimeOut = this.commandTimeOut;


            if (!this.param_Pro_GuidID.IsNull)
            {
                this.param.Param_Pro_GuidID = this.param_Pro_GuidID;
            }


            if (!this.param_Pro_LngCategoryID.IsNull)
            {
                this.param.Param_Pro_LngCategoryID = this.param_Pro_LngCategoryID;
            }


            System.Data.DataSet DS = null;

            SPs.spS_tblProduct SP = new SPs.spS_tblProduct();
            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 OlymarsDemo.DataClasses.CustomException(this.param, "WinListBoxCustom_spS_tblProduct", "RefreshData");
            }
        }
Пример #6
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <returns>[To be supplied.]</returns>
        public bool Refresh()
        {
            this.displayName = null;

            this.col_Pro_StrNameWasUpdated = false;
            this.col_Pro_StrNameWasSet     = false;
            this.col_Pro_StrName           = System.Data.SqlTypes.SqlString.Null;

            this.col_Pro_CurPriceWasUpdated = false;
            this.col_Pro_CurPriceWasSet     = false;
            this.col_Pro_CurPrice           = System.Data.SqlTypes.SqlMoney.Null;

            this.col_Pro_LngCategoryIDWasUpdated = false;
            this.col_Pro_LngCategoryIDWasSet     = false;
            this.col_Pro_LngCategoryID           = System.Data.SqlTypes.SqlInt32.Null;

            bool alreadyOpened = false;

            Params.spS_tblProduct Param = new Params.spS_tblProduct(true);
            Param.CommandTimeOut = this.selectCommandTimeOut;
            switch (this.lastKnownConnectionType)
            {
            case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                Param.SetUpConnection(this.connectionString);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                Param.SetUpConnection(this.sqlConnection);
                alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction:
                Param.SetUpConnection(this.sqlTransaction);
                break;
            }

            if (!this.col_Pro_GuidID.IsNull)
            {
                Param.Param_Pro_GuidID = this.col_Pro_GuidID;
            }


            System.Data.SqlClient.SqlDataReader sqlDataReader = null;
            SPs.spS_tblProduct Sp = new SPs.spS_tblProduct(false);
            if (Sp.Execute(ref Param, out sqlDataReader))
            {
                if (sqlDataReader.Read())
                {
                    if (!sqlDataReader.IsDBNull(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_StrName.ColumnIndex))
                    {
                        this.col_Pro_StrName = sqlDataReader.GetSqlString(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_StrName.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_CurPrice.ColumnIndex))
                    {
                        this.col_Pro_CurPrice = sqlDataReader.GetSqlMoney(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_CurPrice.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_LngCategoryID.ColumnIndex))
                    {
                        this.col_Pro_LngCategoryID = sqlDataReader.GetSqlInt32(SPs.spS_tblProduct.Resultset1.Fields.Column_Pro_LngCategoryID.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 OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.BusinessComponents.Product", "Refresh");
            }
        }