本文整理汇总了C#中FormInfo.AddFormItem方法的典型用法代码示例。如果您正苦于以下问题:C# FormInfo.AddFormItem方法的具体用法?C# FormInfo.AddFormItem怎么用?C# FormInfo.AddFormItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormInfo
的用法示例。
在下文中一共展示了FormInfo.AddFormItem方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitCustomTable
/// <summary>
/// Initializes the custom table
/// </summary>
/// <param name="dci">DataClassInfo of the custom table</param>
/// <param name="fi">Form info</param>
/// <param name="tm">Table manager</param>
private void InitCustomTable(DataClassInfo dci, FormInfo fi, TableManager tm)
{
// Created by
if (chkItemCreatedBy.Checked && !fi.FieldExists("ItemCreatedBy"))
{
FormFieldInfo ffi = new FormFieldInfo();
// Fill FormInfo object
ffi.Name = "ItemCreatedBy";
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Created by");
ffi.DataType = FieldDataType.Integer;
ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty);
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty);
ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl;
ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe();
ffi.PrimaryKey = false;
ffi.System = true;
ffi.Visible = false;
ffi.Size = 0;
ffi.AllowEmpty = true;
fi.AddFormItem(ffi);
}
// Created when
if (chkItemCreatedWhen.Checked && !fi.FieldExists("ItemCreatedWhen"))
{
FormFieldInfo ffi = new FormFieldInfo();
// Fill FormInfo object
ffi.Name = "ItemCreatedWhen";
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Created when");
ffi.DataType = FieldDataType.DateTime;
ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty);
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty);
ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl;
ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe();
ffi.PrimaryKey = false;
ffi.System = true;
ffi.Visible = false;
ffi.Size = 0;
ffi.AllowEmpty = true;
fi.AddFormItem(ffi);
}
// Modified by
if (chkItemModifiedBy.Checked && !fi.FieldExists("ItemModifiedBy"))
{
FormFieldInfo ffi = new FormFieldInfo();
// Fill FormInfo object
ffi.Name = "ItemModifiedBy";
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Modified by");
ffi.DataType = FieldDataType.Integer;
ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty);
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty);
ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl;
ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe();
ffi.PrimaryKey = false;
ffi.System = true;
ffi.Visible = false;
ffi.Size = 0;
ffi.AllowEmpty = true;
fi.AddFormItem(ffi);
}
// Modified when
if (chkItemModifiedWhen.Checked && !fi.FieldExists("ItemModifiedWhen"))
{
FormFieldInfo ffi = new FormFieldInfo();
// Fill FormInfo object
ffi.Name = "ItemModifiedWhen";
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Modified when");
ffi.DataType = FieldDataType.DateTime;
ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty);
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty);
ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl;
ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe();
ffi.PrimaryKey = false;
ffi.System = true;
ffi.Visible = false;
ffi.Size = 0;
ffi.AllowEmpty = true;
fi.AddFormItem(ffi);
}
// Item order
if (chkItemOrder.Checked && !fi.FieldExists("ItemOrder"))
{
FormFieldInfo ffi = new FormFieldInfo();
//.........这里部分代码省略.........
示例2: LoadFormDefinition
/// <summary>
/// Loads the from definition from selected parameter into a BasicForm control.
/// </summary>
/// <param name="actual">If true, data from actual hiddens are loaded</param>
private void LoadFormDefinition(bool actual)
{
MacroRuleTree selected = GetSelected((actual ? hdnParamSelected.Value : hdnLastSelected.Value));
if (selected != null)
{
string paramName = (actual ? hdnParam.Value.ToLowerCSafe() : hdnLastParam.Value.ToLowerCSafe());
MacroRuleParameter param = selected.Parameters[paramName];
if (param != null)
{
FormInfo fi = new FormInfo(selected.RuleParameters);
FormFieldInfo ffi = fi.GetFormField(paramName);
if (ffi != null)
{
fi = new FormInfo();
fi.AddFormItem(ffi);
// Add fake DisplayName field
FormFieldInfo displayName = new FormFieldInfo();
displayName.Visible = false;
displayName.Name = "DisplayName";
displayName.DataType = FieldDataType.Text;
fi.AddFormItem(displayName);
DataRow row = fi.GetDataRow().Table.NewRow();
if (ffi.AllowEmpty && String.IsNullOrEmpty(param.Value))
{
if (!DataTypeManager.IsString(TypeEnum.Field, ffi.DataType))
{
row[paramName] = DBNull.Value;
}
}
else
{
// Convert to a proper type
var val = DataTypeManager.ConvertToSystemType(TypeEnum.Field, ffi.DataType, param.Value, CultureHelper.EnglishCulture);
if (val != null)
{
row[paramName] = val;
}
}
formElem.DataRow = row;
formElem.FormInformation = fi;
formElem.ReloadData();
}
}
}
}
示例3: InitCustomTable
/// <summary>
/// Initializes the custom table
/// </summary>
/// <param name="dci">DataClassInfo of the custom table</param>
/// <param name="fi">Form info</param>
private void InitCustomTable(DataClassInfo dci, FormInfo fi)
{
// Created by
if (chkItemCreatedBy.Checked && !fi.FieldExists("ItemCreatedBy"))
{
FormFieldInfo ffi = new FormFieldInfo();
// Fill FormInfo object
ffi.Name = "ItemCreatedBy";
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Created by");
ffi.DataType = FieldDataType.Integer;
ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty);
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty);
ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl;
ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe();
ffi.PrimaryKey = false;
ffi.System = true;
ffi.Visible = false;
ffi.Size = 0;
ffi.AllowEmpty = true;
fi.AddFormItem(ffi);
}
// Created when
if (chkItemCreatedWhen.Checked && !fi.FieldExists("ItemCreatedWhen"))
{
FormFieldInfo ffi = new FormFieldInfo();
// Fill FormInfo object
ffi.Name = "ItemCreatedWhen";
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Created when");
ffi.DataType = FieldDataType.DateTime;
ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty);
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty);
ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl;
ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe();
ffi.PrimaryKey = false;
ffi.System = true;
ffi.Visible = false;
ffi.Size = 0;
ffi.AllowEmpty = true;
fi.AddFormItem(ffi);
}
// Modified by
if (chkItemModifiedBy.Checked && !fi.FieldExists("ItemModifiedBy"))
{
FormFieldInfo ffi = new FormFieldInfo();
// Fill FormInfo object
ffi.Name = "ItemModifiedBy";
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Modified by");
ffi.DataType = FieldDataType.Integer;
ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty);
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty);
ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl;
ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe();
ffi.PrimaryKey = false;
ffi.System = true;
ffi.Visible = false;
ffi.Size = 0;
ffi.AllowEmpty = true;
fi.AddFormItem(ffi);
}
// Modified when
if (chkItemModifiedWhen.Checked && !fi.FieldExists("ItemModifiedWhen"))
{
FormFieldInfo ffi = new FormFieldInfo();
// Fill FormInfo object
ffi.Name = "ItemModifiedWhen";
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Modified when");
ffi.DataType = FieldDataType.DateTime;
ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty);
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty);
ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl;
ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe();
ffi.PrimaryKey = false;
ffi.System = true;
ffi.Visible = false;
ffi.Size = 0;
ffi.AllowEmpty = true;
fi.AddFormItem(ffi);
}
// Item order
if (chkItemOrder.Checked && !fi.FieldExists("ItemOrder"))
{
FormFieldInfo ffi = new FormFieldInfo();
//.........这里部分代码省略.........
示例4: CreateEmptyFormInfo
/// <summary>
/// Creates an empty form info for the new class
/// </summary>
private FormInfo CreateEmptyFormInfo()
{
// Create empty form definition
var fi = new FormInfo();
var ffiPK = new FormFieldInfo();
// Fill FormInfo object
ffiPK.Name = txtPKName.Text;
ffiPK.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, txtPKName.Text);
ffiPK.DataType = FieldDataType.Integer;
ffiPK.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, string.Empty);
ffiPK.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, string.Empty);
ffiPK.FieldType = FormFieldControlTypeEnum.CustomUserControl;
ffiPK.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe();
ffiPK.PrimaryKey = true;
ffiPK.System = false;
ffiPK.Visible = false;
ffiPK.Size = 0;
ffiPK.AllowEmpty = false;
// Add field to form definition
fi.AddFormItem(ffiPK);
return fi;
}
示例5: InitClass
/// <summary>
/// Initializes class.
/// </summary>
/// <param name="dci">DataClassInfo</param>
/// <param name="fi">Form info</param>
private void InitClass(DataClassInfo dci, FormInfo fi)
{
// Get class code name
var pkName = txtPKName.Text.Trim();
var codeName = pkName.Substring(0, pkName.Length - 2);
// Guid
if (chkClassGuid.Checked && !fi.FieldExists(codeName + "Guid"))
{
fi.AddFormItem(CreateGuidField(codeName + "Guid"));
}
// Last modified
if (chkClassLastModified.Checked && !fi.FieldExists(codeName + "LastModified"))
{
FormFieldInfo ffi = new FormFieldInfo();
// Fill FormInfo object
ffi.Name = codeName + "LastModified";
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "Last modified");
ffi.DataType = FieldDataType.DateTime;
ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, String.Empty);
ffi.SetPropertyValue(FormFieldPropertyEnum.FieldDescription, String.Empty);
ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl;
ffi.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe();
ffi.PrimaryKey = false;
ffi.System = true;
ffi.Visible = false;
ffi.Size = 0;
ffi.AllowEmpty = false;
fi.AddFormItem(ffi);
}
UpdateDataClass(dci, fi);
}
示例6: InitForm
/// <summary>
/// Initializes the form.
/// </summary>
private void InitForm()
{
var fi = new FormInfo();
foreach (var settingKey in SettingKeys)
{
fi.AddFormItem(CreateFormFieldInfo(settingKey));
}
form.FormInformation = fi;
form.EnsureMessagesPlaceholder(MessagesPlaceHolder);
form.OnAfterSave += OnAfterSave;
}
示例7: LoadAttributeForm
/// <summary>
/// Loads form with specific settings for rule of type Attribute.
/// </summary>
/// <param name="selectedAttribute">Reference to field selected in attribute drop-down menu</param>
private void LoadAttributeForm(FormFieldInfo selectedAttribute)
{
// Store current selected attribute for further usage within current request
mSelectedAttribute = selectedAttribute;
// Create FormInfo which will be passed to basic form already set in markup
// According to selected attribute specific fields will be loaded into the basic form
var fi = new FormInfo();
fi.AddFormItem(selectedAttribute);
LoadForm(attributeFormCondition, fi);
}
示例8: InitActivitySettings
/// <summary>
/// Initializes controls for activity rule.
/// </summary>
/// <param name="selectedActivity">Activity selected in drop-down menu</param>
private void InitActivitySettings(string selectedActivity)
{
// Init activity selector from edited object if any
LoadEditedActivityRule(ref selectedActivity);
string[] ignoredColumns =
{
"activitytype",
"activitysiteid",
"activityguid",
"activityactivecontactid",
"activityoriginalcontactid",
"pagevisitid",
"pagevisitactivityid",
"searchid",
"searchactivityid"
};
string[] activitiesWithValue =
{
PredefinedActivityType.PURCHASE,
PredefinedActivityType.PURCHASEDPRODUCT,
PredefinedActivityType.RATING,
PredefinedActivityType.POLL_VOTING,
PredefinedActivityType.PRODUCT_ADDED_TO_SHOPPINGCART
};
// Get columns from OM_Activity (i.e. base table for all activities)
ActivityTypeInfo ati = ActivityTypeInfoProvider.GetActivityTypeInfo(selectedActivity);
var fi = new FormInfo();
// Get columns from additional table (if any) according to selected activity type
bool extraFieldsAtEnd = true;
FormInfo additionalFieldsForm = GetActivityAdditionalFields(selectedActivity, ref extraFieldsAtEnd);
// Get the activity form elements
FormInfo filterFieldsForm = FormHelper.GetFormInfo(ActivityInfo.OBJECT_TYPE, true);
IList<IField> elements = filterFieldsForm.GetFormElements(true, false);
FormCategoryInfo newCategory = null;
foreach (IField elem in elements)
{
if (elem is FormCategoryInfo)
{
// Form category
newCategory = (FormCategoryInfo)elem;
}
else if (elem is FormFieldInfo)
{
// Form field
var ffi = (FormFieldInfo)elem;
// Skip ignored columns
if (ignoredColumns.Contains(ffi.Name.ToLowerCSafe()))
{
continue;
}
if ((!ffi.PrimaryKey) && (fi.GetFormField(ffi.Name) == null))
{
// Skip fields with Guid data type
if (ffi.DataType == FieldDataType.Guid)
{
continue;
}
// Sets control name based on given datatype of field. Can be overwritten if more proper control is available
string controlName = GetControlNameForFieldDataType(ffi);
if (!GetControlNameForActivities(ffi, ati, selectedActivity, activitiesWithValue, ref controlName))
{
continue;
}
if (controlName != null)
{
// SKU selector for product
ffi.Settings["controlname"] = controlName;
ffi.Settings["allowempty"] = controlName.EqualsCSafe("skuselector", true);
}
// Ensure the category
if (newCategory != null)
{
fi.AddFormCategory(newCategory);
newCategory = null;
// Extra fields at the beginning
if ((!extraFieldsAtEnd) && (additionalFieldsForm != null))
{
AddExtraActivityFields(ignoredColumns, fi, additionalFieldsForm);
additionalFieldsForm = null;
}
}
fi.AddFormItem(ffi);
//.........这里部分代码省略.........
示例9: AddExtraActivityFields
/// <summary>
/// Adds the extra activity fields to the rule settings form.
/// </summary>
/// <param name="ignoredColumns">Collection of columns, which shouldn't be added</param>
/// <param name="fi">Form info used for adding extra fields</param>
/// <param name="additionalFieldsForm">Collection of extra fields</param>
private static void AddExtraActivityFields(IEnumerable<string> ignoredColumns, FormInfo fi, FormInfo additionalFieldsForm)
{
if (additionalFieldsForm != null)
{
IEnumerable<FormFieldInfo> formFields = additionalFieldsForm.GetFields(true, false)
.Where(f =>
!ignoredColumns.Contains(f.Name.ToLowerCSafe())
);
foreach (FormFieldInfo ffi in formFields)
{
ffi.Settings["controlname"] = GetControlNameForFieldDataType(ffi);
fi.AddFormItem(ffi);
}
}
}