Beispiel #1
0
        /// <summary>
        /// Loads this instance.
        /// </summary>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        public int Load()
        {
            var tableRecordSet = new DatabaseRecordSet(this.Database);

            tableRecordSet.Query.Prepare("SELECT infoareaid, rootinfoareaid, name, haslookup FROM tableinfo");

            TableInfo   tableinfo;
            DatabaseRow row;
            var         ret            = tableRecordSet.Execute();
            var         tableInfoCount = tableRecordSet.GetRowCount();

            for (var i = 0; i < tableInfoCount; i++)
            {
                row       = tableRecordSet.GetRow(i);
                tableinfo = this.AddTableInfo(
                    row.GetColumn(0),
                    row.GetColumn(1),
                    row.GetColumn(2),
                    row.GetColumnInt(3, 0));
                tableinfo.Load(this.Database);
            }

            for (var i = 0; i < tableInfoCount; i++)
            {
                tableinfo = this.TableInfos[i];
                if (!string.IsNullOrEmpty(tableinfo.RootInfoAreaId))
                {
                    var parent = this.Database.GetTableInfoByInfoArea(tableinfo.RootInfoAreaId);
                    parent?.AddSpecialInfoArea(tableinfo);
                }
            }

            var catalogRecordSet = new DatabaseRecordSet(this.Database);

            catalogRecordSet.Query.Prepare("SELECT catnr FROM fixcatinfo");
            catalogRecordSet.Execute();

            var catalogInfoCount = catalogRecordSet.GetRowCount();

            for (var i = 0; i < catalogInfoCount; i++)
            {
                row = catalogRecordSet.GetRow(i);
                this.AddFixedCatalog(row.GetColumnInt(0));
            }

            catalogRecordSet = new DatabaseRecordSet(this.Database);
            catalogRecordSet.Query.Prepare("SELECT catnr, parentcatnr FROM varcatinfo");
            if (ret == 0)
            {
                ret = catalogRecordSet.Execute();
            }

            catalogInfoCount = catalogRecordSet.GetRowCount();
            for (var i = 0; i < catalogInfoCount; i++)
            {
                row = catalogRecordSet.GetRow(i);
                if (row.IsNull(1))
                {
                    this.AddVariableCatalog(row.GetColumnInt(0));
                }
                else
                {
                    this.AddVariableCatalog(row.GetColumnInt(0), row.GetColumnInt(1));
                }
            }

            this.Sort(true);

            return(ret);
        }
Beispiel #2
0
        /// <summary>
        /// Creates the value set.
        /// </summary>
        /// <param name="parentCode">
        /// The parent code.
        /// </param>
        /// <returns>
        /// The <see cref="CatalogValueSet"/>.
        /// </returns>
        public virtual CatalogValueSet CreateValueSet(int parentCode)
        {
            // bool variable, dep;
            // SYS_CHAR tableName[MAX_CATALOG_TABLENAME];
            var catalogValueRecordSet = new DatabaseRecordSet(this.Database);

            var memorybuffer = new StringBuilder();

            memorybuffer.Append("SELECT code, text, sortinfo, access");

            if (this.IsVariable)
            {
                memorybuffer.Append(", extkey, tenant");
            }

            if (this.IsDependent)
            {
                memorybuffer.Append(", parentcode");
            }

            memorybuffer.Append(" FROM ");
            memorybuffer.Append(this.GetDatabaseTableName());

            var parameterCount = 0;

            if (this.IsDependent && parentCode >= 0)
            {
                memorybuffer.Append($" WHERE parentcode = {parentCode}");
                parameterCount = 1;
            }

            var returnString = memorybuffer.ToString();

            int             ret;
            CatalogValueSet values = null;

            if (parameterCount > 0)
            {
                ret = catalogValueRecordSet.Execute(returnString, new[] { $"{parentCode}" }, 0);
            }
            else
            {
                ret = catalogValueRecordSet.Query.Prepare(returnString) ? 0 : 1;
                if (ret == 0)
                {
                    ret = catalogValueRecordSet.Execute();
                }
            }

            if (ret == 0)
            {
                values = new CatalogValueSet {
                    SortFunction = this.GetSortFunction
                };

                int         i, catalogValueCount = catalogValueRecordSet.RowCount;
                DatabaseRow row;
                for (i = 0; i < catalogValueCount; i++)
                {
                    row = catalogValueRecordSet.GetRow(i);
                    if (this.IsDependent)
                    {
                        values.AddDependentCatalogValue(
                            row.GetColumnInt(0),
                            row.GetColumnInt(6),
                            row.GetColumn(1),
                            row.GetColumnInt(5),
                            row.GetColumn(4),
                            row.GetColumnInt(2),
                            row.GetColumnInt(3));
                    }
                    else if (this.IsVariable)
                    {
                        values.AddVariableCatalogValue(
                            row.GetColumnInt(0),
                            row.GetColumn(1),
                            row.GetColumnInt(5),
                            row.GetColumn(4),
                            row.GetColumnInt(2),
                            row.GetColumnInt(3));
                    }
                    else
                    {
                        values.AddFixedCatalogValue(
                            row.GetColumnInt(0),
                            row.GetColumn(1),
                            row.GetColumnInt(2),
                            row.GetColumnInt(3));
                    }
                }
            }

            if (values == null)
            {
                values = new CatalogValueSet();
            }

            values.Sort();
            return(values);
        }