private void Control_OnBeforeSave(object sender, EventArgs e) { UIForm form = (UIForm)sender; FormUserControlInfo formControl = form.EditedObject as FormUserControlInfo; if (formControl != null) { if (form.IsInsertMode) { FormEngineUserControl fileName = form.FieldControls["UserControlFileName"]; FormEngineUserControl parentId = form.FieldControls["UserControlParentID"]; if ((fileName != null) && (parentId != null) && fileName.Visible && !parentId.Visible && (ValidationHelper.GetInteger(parentId.Value, 0) > 0)) { // Reset inheritance setting if it's not visible formControl.SetValue("UserControlParentID", null); } } else { // Set control's priority formControl.UserControlPriority = ValidationHelper.GetBoolean(form.GetFieldValue(FIELD_PRIORITY), false) ? (int)ObjectPriorityEnum.High : (int)ObjectPriorityEnum.Low; // Set which (data) types the control can be used for. Individual values are field types var values = GetFieldValues(form, FIELD_FOR); foreach (var group in DataTypeManager.GetFieldGroups()) { var col = FormHelper.GetDataTypeColumnForGroup(group); formControl.SetValue(col, values.Contains(group)); } // Set which resources the control can be shown in values = GetFieldValues(form, FIELD_SHOWIN); formControl.UserControlShowInDocumentTypes = values.Contains(SHOWIN_PAGETYPE); formControl.UserControlShowInBizForms = values.Contains(SHOWIN_FORM); values = GetFieldValues(form, FIELD_SHOWIN2); formControl.UserControlShowInCustomTables = values.Contains(SHOWIN_CUSTOMTABLE); formControl.UserControlShowInSystemTables = values.Contains(SHOWIN_SYSTEMTABLE); formControl.UserControlShowInReports = values.Contains(SHOWIN_REPORT); formControl.UserControlShowInWebParts = values.Contains(SHOWIN_CONTROL); } } }
private static string GetControlForValue(FormUserControlInfo formControl) { var values = new List <string>(); // Build the list of enabled field types from the control properties foreach (var group in DataTypeManager.GetFieldGroups()) { var col = FormHelper.GetDataTypeColumnForGroup(group); if (ValidationHelper.GetBoolean(formControl.GetValue(col), false)) { values.Add(group); } } return(String.Join("|", values)); }
private void Control_OnBeforeSave(object sender, EventArgs e) { UIForm form = (UIForm)sender; FormUserControlInfo formControl = form.EditedObject as FormUserControlInfo; if (formControl != null) { if (form.IsInsertMode) { var parentIdControl = form.FieldControls[FIELD_PARENTID]; // Reset inheritance setting if it's not visible if (parentIdControl == null || !parentIdControl.Visible) { formControl.SetValue(FIELD_PARENTID, null); } // Ensure that form definition of parameters is not empty if (string.IsNullOrWhiteSpace(formControl.UserControlParameters)) { formControl.UserControlParameters = FormInfo.GetEmptyFormDocument().OuterXml; } } else { // Reset filename if field not available var fileNameControl = form.FieldControls[FIELD_FILENAME]; if (fileNameControl == null || !fileNameControl.Visible) { formControl.SetValue(FIELD_FILENAME, String.Empty); } // Reset class name if field not available var assemblyControl = form.FieldControls[FIELD_ASSEMBLYNAME]; if (assemblyControl == null || !assemblyControl.Visible) { formControl.SetValue(FIELD_ASSEMBLYNAME, null); formControl.SetValue(FIELD_CLASSNAME, null); } // Set control's priority formControl.UserControlPriority = ValidationHelper.GetBoolean(form.GetFieldValue(FIELD_PRIORITY), false) ? (int)ObjectPriorityEnum.High : (int)ObjectPriorityEnum.Low; // Set which (data) types the control can be used for. Individual values are field types var values = GetFieldValues(form, FIELD_FOR); foreach (var group in DataTypeManager.GetFieldGroups()) { var col = FormHelper.GetDataTypeColumnForGroup(group); formControl.SetValue(col, values.Contains(group)); } // Set which resources the control can be shown in values = GetFieldValues(form, FIELD_SHOWIN); formControl.UserControlShowInDocumentTypes = values.Contains(SHOWIN_PAGETYPE); formControl.UserControlShowInBizForms = values.Contains(SHOWIN_FORM); values = GetFieldValues(form, FIELD_SHOWIN2); formControl.UserControlShowInCustomTables = values.Contains(SHOWIN_CUSTOMTABLE); formControl.UserControlShowInSystemTables = values.Contains(SHOWIN_SYSTEMTABLE); formControl.UserControlShowInReports = values.Contains(SHOWIN_REPORT); formControl.UserControlShowInWebParts = values.Contains(SHOWIN_CONTROL); } } }