示例#1
0
        public Common.Item[] GetAllDisplay_Categories_Array()
        {
            Params.spS_tblCategory_Display param = new Params.spS_tblCategory_Display(true);

            param.SetUpConnection(string.Empty);


            using (SPs.spS_tblCategory_Display sp = new SPs.spS_tblCategory_Display(true)) {
                System.Collections.ArrayList records = new System.Collections.ArrayList();

                System.Data.SqlClient.SqlDataReader sqlDataReader = null;
                sp.Execute(ref param, out sqlDataReader);

                while (sqlDataReader.Read())
                {
                    records.Add(new Common.Item(sqlDataReader.GetInt32(SPs.spS_tblCategory_Display.Resultset1.Fields.Column_ID1.ColumnIndex), sqlDataReader.GetString(SPs.spS_tblCategory_Display.Resultset1.Fields.Column_Display.ColumnIndex)));
                }

                sqlDataReader.Close();

                if (sp.Connection.State == System.Data.ConnectionState.Open)
                {
                    sp.Connection.Close();
                }

                sp.Dispose();
                param.Dispose();

                return((Common.Item[])records.ToArray(typeof(Common.Item)));
            }
        }
示例#2
0
        public System.Data.DataSet GetAllDisplay_Categories_DataSet()
        {
            Params.spS_tblCategory_Display param = new Params.spS_tblCategory_Display(true);

            param.SetUpConnection(string.Empty);


            using (SPs.spS_tblCategory_Display sp = new SPs.spS_tblCategory_Display(true)) {
                System.Data.DataSet dataSet = null;
                sp.Execute(ref param, ref dataSet);
                param.Dispose();

                return(dataSet);
            }
        }
示例#3
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        public void Refresh()
        {
            internalRecords = new System.Collections.ArrayList();

            bool alreadyOpened = false;

            Params.spS_tblCategory_Display Param = new Params.spS_tblCategory_Display(true);
            Param.CommandTimeOut = this.selectCollectionCommandTimeOut;
            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;
            }

            System.Data.SqlClient.SqlDataReader sqlDataReader = null;
            SPs.spS_tblCategory_Display         Sp            = new SPs.spS_tblCategory_Display(false);
            if (Sp.Execute(ref Param, out sqlDataReader))
            {
                while (sqlDataReader.Read())
                {
                    Category record = null;

                    switch (this.lastKnownConnectionType)
                    {
                    case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                        record = new Category(this.connectionString, sqlDataReader.GetSqlInt32(SPs.spS_tblCategory_Display.Resultset1.Fields.Column_ID1.ColumnIndex));
                        break;

                    case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                        record = new Category(this.sqlConnection, sqlDataReader.GetSqlInt32(SPs.spS_tblCategory_Display.Resultset1.Fields.Column_ID1.ColumnIndex));
                        break;

                    case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction:
                        record = new Category(this.sqlTransaction, sqlDataReader.GetSqlInt32(SPs.spS_tblCategory_Display.Resultset1.Fields.Column_ID1.ColumnIndex));
                        break;
                    }


                    record.UpdateCommandTimeOut = this.updateCommandTimeOut;
                    record.SelectCommandTimeOut = this.selectCommandTimeOut;

                    if (sqlDataReader.GetFieldType(SPs.spS_tblCategory_Display.Resultset1.Fields.Column_Display.ColumnIndex) == typeof(string))
                    {
                        record.displayName = sqlDataReader.GetString(SPs.spS_tblCategory_Display.Resultset1.Fields.Column_Display.ColumnIndex);
                    }
                    else
                    {
                        record.displayName = sqlDataReader.GetValue(SPs.spS_tblCategory_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 OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.BusinessComponents.Categories", "Refresh");
            }
        }
示例#4
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_tblCategory_Display Param = new Params.spS_tblCategory_Display(true);

                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;
                }

                Param.Param_Cat_LngID = this.col_Cat_LngID;

                System.Data.SqlClient.SqlDataReader sqlDataReader = null;
                SPs.spS_tblCategory_Display         Sp            = new SPs.spS_tblCategory_Display(false);
                if (Sp.Execute(ref Param, out sqlDataReader))
                {
                    if (sqlDataReader.Read())
                    {
                        if (!sqlDataReader.IsDBNull(SPs.spS_tblCategory_Display.Resultset1.Fields.Column_Display.ColumnIndex))
                        {
                            if (sqlDataReader.GetFieldType(SPs.spS_tblCategory_Display.Resultset1.Fields.Column_Display.ColumnIndex) == typeof(string))
                            {
                                this.displayName = sqlDataReader.GetString(SPs.spS_tblCategory_Display.Resultset1.Fields.Column_Display.ColumnIndex);
                            }
                            else
                            {
                                this.displayName = sqlDataReader.GetValue(SPs.spS_tblCategory_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 OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.BusinessComponents.Category", "ToString");
                }
            }

            return(this.displayName);
        }