コード例 #1
0
        private static DataTable GetTable(string tableSchema, string tableName, string tableColumn, string displayViews,
                                          bool useDisplayViewsAsParent)
        {
            if (useDisplayViewsAsParent)
            {
                //Get the expression value of display view from comma seprated list of expressions.
                //The expression must be a valid fully qualified table or view name.
                string viewRelation = GetExpressionValue(displayViews, tableSchema, tableName, tableColumn);

                string schema = viewRelation.Split('.').First();
                string view   = viewRelation.Split('.').Last();

                //Sanitize the schema and the view
                schema = Sanitizer.SanitizeIdentifierName(schema);
                view   = Sanitizer.SanitizeIdentifierName(view);

                if (string.IsNullOrWhiteSpace(schema) || string.IsNullOrWhiteSpace(view))
                {
                    return(FormHelper.GetTable(tableSchema, tableName, "1"));
                }

                return(FormHelper.GetTable(schema, view, "1"));
            }

            return(FormHelper.GetTable(tableSchema, tableName, "1"));
        }
コード例 #2
0
        public static void AddDropDownList(HtmlTable htmlTable, string resourceClassName, string itemSelectorPath, string columnName, bool isNullable, string tableSchema, string tableName, string tableColumn, string defaultValue, string displayFields, string displayViews, string selectedValues)
        {
            var label = LocalizationHelper.GetResourceString(resourceClassName, columnName);

            var dropDownList = GetDropDownList(columnName + "_dropdownlist");

            HtmlAnchor itemSelectorAnchor;

            using (var table = FormHelper.GetTable(tableSchema, tableName))
            {
                SetDisplayFields(dropDownList, table, tableSchema, tableName, tableColumn, displayFields);
                itemSelectorAnchor = GetItemSelector(dropDownList.ClientID, table, itemSelectorPath, tableSchema, tableName, tableColumn, displayViews);
            }

            SetSelectedValue(dropDownList, tableSchema, tableName, tableColumn, defaultValue, selectedValues);

            if (isNullable)
            {
                dropDownList.Items.Insert(0, new ListItem(String.Empty, String.Empty));
                ScrudFactoryHelper.AddRow(htmlTable, label, dropDownList, itemSelectorAnchor);
            }
            else
            {
                var required = ScrudFactoryHelper.GetRequiredFieldValidator(dropDownList);
                ScrudFactoryHelper.AddRow(htmlTable, label + ScrudResource.RequiredFieldIndicator, dropDownList, required, itemSelectorAnchor);
            }
        }