⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 metadataxmlprovider.cs

📁 EpiInfo 开源的导航系统远程序,不知道在哪里下的了,分享一下,有兴趣的
💻 CS
📖 第 1 页 / 共 5 页
字号:
        /// <summary>
        /// Gets a related view based on a relate button
        /// </summary>
        /// <param name="field">The relate button field</param>
        /// <returns>The related view</returns>
        public View GetChildView(RelatedViewField field)
        {
            try
            {
                Query query = db.CreateQuery("SELECT V.[ViewId], V.[Name], V.[CheckCodeBefore], V.[CheckCodeAfter], V.[RecordCheckCodeBefore], V.[RecordCheckCodeAfter], V.[CheckCodeVariableDefinitions], V.[IsRelatedView] FROM metaViews V " +
                    "INNER JOIN metaFields F On F.[RelatedViewId] = V.[ViewId] " +
                    "WHERE F.[FieldId] = @FieldId");
                query.Parameters.Add(new QueryParameter("@FieldId", DbType.Int32, field.Id));
                DataTable table = db.Select(query);
                if (table.Rows.Count > 0)
                {
                    return new View(table.Rows[0], field.GetProject());
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                throw new GeneralException("Could not retrieve related view", ex);
            }
        }

        /// <summary>
        /// Gets all the controls belonging to a page
        /// </summary>
        /// <param name="pageId">Id of the page</param>
        /// <returns>Datatable containing control info</returns>
        public DataTable GetControlsForPage(int pageId)
        {
            try
            {

                #region Input Validation
                if (pageId < 1)
                {
                    throw new ArgumentOutOfRangeException("PageId");
                }
                #endregion

                Query query = db.CreateQuery("SELECT [FieldTypeId], [Name] As FieldName, [ControlTopPositionPercentage] As ControlTop, " +
                    "[ControlLeftPositionPercentage] As ControlLeft, [ControlHeightPercentage], [ControlWidthPercentage], [PromptText], [PromptFontSize], " +
                    "[PromptTopPositionPercentage] AS LabelTop, [PromptLeftPositionPercentage] As LabelLeft, [FieldId] " +
                    "FROM metaFields " +
                    //				DbQuery query = db.CreateQuery("SELECT F.[FieldTypeId], F.[Name] AS FieldName, C.[TopPosition] AS ControlTop, C.[LeftPosition] AS ControlLeft, C.[Height], C.[Width], L.[Text], L.[FontSize], L.[TopPosition] AS LabelTop, L.[LeftPosition] AS LabelLeft, C.[ControlId], L.[LabelId], F.[FieldId] " +
                    //					"FROM (metaFields F LEFT JOIN metaControls C ON C.[FieldId] = F.[FieldId]) LEFT JOIN metaLabels L ON L.[FieldId] = F.[FieldId] " +
                    "WHERE [PageId] = @PageId " +
                    "ORDER BY [FieldTypeId]");
                query.Parameters.Add(new QueryParameter("@PageId", DbType.Int32, pageId));
                return db.Select(query);
            }
            catch (Exception ex)
            {
                throw new GeneralException("Could not retrieve controls", ex);
            }
        }

        /// <summary>
        /// Gets the system fields belonging to a view
        /// </summary>
        /// <param name="viewId">Id of the view</param>
        /// <returns>Datatable containing field info</returns>
        public DataTable GetSystemFields(int viewId)
        {
            try
            {
                #region Input Validation
                if (viewId < 1)
                {
                    throw new ArgumentOutOfRangeException("ViewId");
                }
                #endregion

                Query query = db.CreateQuery("SELECT F.[Name], F.[PageId], F.[FieldId], F.[FieldTypeId], F.[CheckCodeAfter] As ControlAfterCheckCode, F.[CheckCodeBefore] As ControlBeforeCheckCode,  " +
                    "F.[ControlTopPositionPercentage], F.[ControlLeftPositionPercentage], F.[ControlHeightPercentage], F.[ControlWidthPercentage] , F.[ControlFontFamily], F.[ControlFontSize], F.[ControlFontStyle], F.[ControlScriptName], " +
                    "F.[PromptTopPositionPercentage], F.[PromptLeftPositionPercentage], F.[PromptText], F.[PromptFontFamily], F.[PromptFontSize], F.[PromptFontStyle], F.[ControlFontFamily], F.[ControlFontSize], F.[ControlFontStyle], F.[PromptScriptName], " +
                    "F.[ShouldRepeatLast], F.[IsRequired], F.[IsReadOnly],  " +
                    "F.[ShouldRetainImageSize], F.[Pattern], F.[MaxLength], F.[ShowTextOnRight], " +
                    "F.[Lower], F.[Upper], F.[RelateCondition], F.[ShouldReturnToParent], F.[RelatedViewId], " +
                    "F.[SourceTableName], F.[CodeColumnName], F.[TextColumnName], " +
                    "F.[Sort], F.[IsExclusiveTable], F.[TabIndex], F.[HasTabStop],F.[SourceFieldId] " +
                    "FROM metaFields F " +
                    "WHERE F.[ViewId] = @ViewId AND F.[PageId] IS NULL");
                query.Parameters.Add(new QueryParameter("@ViewId", DbType.Int32, viewId));
                return db.Select(query);
            }
            catch (Exception ex)
            {
                throw new GeneralException("Could not retrieve fields", ex);
            }
        }

        ///// <summary>
        ///// Gets the system fields in a view
        ///// </summary>
        ///// <param name="view">A view object</param>
        ///// <returns>A collection of fields</returns>
        //public  NamedObjectCollection<Field> GetSystemFields(View view)
        //{
        //    try
        //    {
        //        NamedObjectCollection<Field> fields = new NamedObjectCollection<Field>();
        //        DataTable table = GetSystemFields(view.Id);
        //        foreach (DataRow row in table.Rows)
        //        {
        //            switch((MetaFieldType)row["FieldTypeId"])
        //            {
        //                case MetaFieldType.RecStatus:
        //                    fields.Add(new RecStatusField(row, view));
        //                    break;
        //                case MetaFieldType.UniqueKey:
        //                    fields.Add(new UniqueKeyField(row, view));
        //                    break;
        //                default:
        //                    break;
        //            }

        //        }
        //        return (fields);
        //    }
        //    catch (Exception ex)
        //    {
        //        throw new GeneralException("Could not retrieve Field collection", ex);
        //    }
        //}

        /// <summary>
        /// Gets all fields belonging to a page
        /// </summary>
        /// <param name="pageId">Id of the page</param>
        /// <returns>Datatable containing field info</returns>
        public DataTable GetFieldsOnPageAsDataTable(int pageId)
        {
            try
            {
                #region Input Validation
                if (pageId < 1)
                {
                    throw new ArgumentOutOfRangeException("PageId");
                }
                #endregion

                Query query = db.CreateQuery("SELECT F.[Name], F.[PageId], F.[FieldId], F.[FieldTypeId], F.[CheckCodeAfter] As ControlAfterCheckCode, F.[CheckCodeBefore] As ControlBeforeCheckCode,  " +
                    "P.[Name] AS PageName, P.[CheckCodeBefore] As PageBeforeCheckCode, P.[CheckCodeAfter] As PageAfterCheckCode, P.[Position], " +
                    "F.[ControlTopPositionPercentage], F.[ControlLeftPositionPercentage], F.[ControlHeightPercentage], F.[ControlWidthPercentage] , F.[ControlFontFamily], F.[ControlFontSize], F.[ControlFontStyle], F.[ControlScriptName], " +
                    "F.[PromptTopPositionPercentage], F.[PromptLeftPositionPercentage], F.[PromptText], F.[PromptFontFamily], F.[PromptFontSize], F.[PromptFontStyle], F.[ControlFontFamily], F.[ControlFontSize], F.[ControlFontStyle], F.[PromptScriptName], " +
                    "F.[ShouldRepeatLast], F.[IsRequired], F.[IsReadOnly],  " +
                    "F.[ShouldRetainImageSize], F.[Pattern], F.[MaxLength], F.[ShowTextOnRight], " +
                    "F.[Lower], F.[Upper], F.[RelateCondition], F.[ShouldReturnToParent], F.[RelatedViewId], " +
                    "F.[SourceTableName], F.[CodeColumnName], F.[TextColumnName], " +
                    "F.[Sort], F.[IsExclusiveTable], F.[TabIndex], F.[HasTabStop],F.[SourceFieldId] " +
                    "FROM ((metaFields F " +
                    "LEFT JOIN metaPages P on P.[PageId] = F.[PageId]) " +
                    "LEFT JOIN metaViews V on V.[ViewId] = P.[ViewId]) " +
                    "WHERE F.[PageId] = @pageID " +
                    "ORDER BY F.[ControlTopPositionPercentage], F.[ControlLeftPositionPercentage]");
                query.Parameters.Add(new QueryParameter("@pageID", DbType.Int32, pageId));
                return db.Select(query);
            }
            catch (Exception ex)
            {
                throw new GeneralException("Could not retrieve fields", ex);
            }
        }

        /// <summary>
        /// Returns view's fields as a data table
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        public DataTable GetFieldsAsDataTable(View view)
        {
            try
            {
                string queryString =
                    "SELECT F.[FieldId], F.[Name] As Name, F.[PageId], F.[ViewId], F.[FieldTypeId], F.[CheckCodeAfter] As ControlAfterCheckCode, F.[CheckCodeBefore] As ControlBeforeCheckCode,  " +
                    "F.[ControlTopPositionPercentage], F.[ControlLeftPositionPercentage], F.[ControlHeightPercentage], F.[ControlWidthPercentage], " +
                    "F.[ControlFontFamily] As ControlFontFamily, F.[ControlFontSize] As ControlFontSize, F.[ControlFontStyle] As ControlFontStyle, F.[ControlScriptName], " +
                    "F.[PromptTopPositionPercentage], F.[PromptLeftPositionPercentage], F.[PromptText], F.[PromptFontFamily], F.[PromptFontSize], F.[PromptFontStyle], F.[ControlFontFamily], F.[ControlFontSize], F.[ControlFontStyle], F.[PromptScriptName], " +
                    "F.[ShouldRepeatLast], F.[IsRequired], F.[IsReadOnly],  " +
                    "F.[ShouldRetainImageSize], F.[Pattern], F.[MaxLength], F.[ShowTextOnRight], " +
                    "F.[Lower], F.[Upper], F.[RelateCondition], F.[ShouldReturnToParent], F.[RelatedViewId], " +
                    "F.[SourceTableName], F.[CodeColumnName], F.[TextColumnName], " +
                    "F.[Sort], F.[IsExclusiveTable], F.[TabIndex], F.[HasTabStop],F.[SourceFieldId], F.[DataTableName] " +
                    "FROM metaFields F Where F.[ViewId] = @viewId " +
                    "ORDER BY F.[ControlTopPositionPercentage], F.[ControlLeftPositionPercentage]";

                Query query = db.CreateQuery(queryString);
                query.Parameters.Add(new QueryParameter("@viewID", DbType.Int32, view.Id));
                return db.Select(query);
            }
            //catch (Exception ex)
            //{
            //	throw new GeneralException("Could not retrieve fields", ex);
            //}
            finally
            {
            }
        }

        /// <summary>
        /// Gets all the fields in a view
        /// </summary>
        /// <param name="view">the view object</param>
        /// <returns>A collection of fields</returns>
        public virtual FieldCollectionMaster GetFields(View view)
        {
            try
            {
                FieldCollectionMaster fields = new FieldCollectionMaster();
                DataTable table = GetFieldsAsDataTable(view);
                foreach (DataRow row in table.Rows)
                {
                    MetaFieldType fieldTypeId = (MetaFieldType)row[ColumnNames.FIELD_TYPE_ID];
                    Field field = null;
                    switch (fieldTypeId)
                    {
                        case MetaFieldType.Text:
                            field = new SingleLineTextField(view);
                            break;
                        case MetaFieldType.LabelTitle:
                            field = new LabelField(view);
                            break;
                        case MetaFieldType.TextUppercase:
                            field = new UpperCaseTextField(view);
                            break;
                        case MetaFieldType.Multiline:
                            field = new MultilineTextField(view);
                            break;
                        case MetaFieldType.Number:
                            field = new NumberField(view);
                            break;
                        case MetaFieldType.PhoneNumber:
                            field = new PhoneNumberField(view);
                            break;
                        case MetaFieldType.Date:
                            field = new DateField(view);
                            break;
                        case MetaFieldType.Time:
                            field = new TimeField(view);
                            break;
                        case MetaFieldType.DateTime:
                            field = new DateTimeField(view);
                            break;
                        case MetaFieldType.Checkbox:
                            field = new CheckBoxField(view);
                            break;
                        case MetaFieldType.YesNo:
                            field = new YesNoField(view);
                            break;
                        case MetaFieldType.Option:
                            field = new OptionField(view);
                            break;
                        case MetaFieldType.CommandButton:
                            field = new CommandButtonField(view);
                            break;
                        case MetaFieldType.Image:
                            field = new ImageField(view);
                            break;
                        case MetaFieldType.Mirror:
                            field = new MirrorField(view);
                            break;
                        case MetaFieldType.Grid:
                            field = new GridField(view);
                            break;
                        case MetaFieldType.LegalValues:
                            field = new DDLFieldOfLegalValues(view);
                            break;
                        case MetaFieldType.Codes:
                            field = new DDLFieldOfCodes(view);
                            break;
                        case MetaFieldType.CommentLegal:
                            field = new DDLFieldOfCommentLegal(view);
                            break;
                        case MetaFieldType.Relate:
                            field = new RelatedViewField(view);
                            break;
                        case MetaFieldType.RecStatus:
                            field = new RecStatusField(view);
                            break;
                        case MetaFieldType.UniqueKey:
                            field = new UniqueKeyField(view);
                            break;
                        default:
                            throw new GeneralException("Invalid Field Type");
                    }
                    field.LoadFromRow(row);
                    fields.Add(field);
                }
                return (fields);
            }
            finally
            {
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public List<GridColumn> GetGridColumnCollection(GridField field)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -