using framework_business; using framework_library; using System; using System.Collections; using System.Data; using System.Data.SqlClient; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Telerik.Web.UI; public partial class controls_admin_surface : System.Web.UI.UserControl { private const string controlPath = "~/controls/"; private const string surfacePath = "~/controls/surface/"; private const string tempPath = "~/upload/temp/"; #region methods /// /// Method to Bind Surface Data /// private void BindSurfaceData() { try { ArrayList SurfaceList = xData.GetTypedCollection("recId", typeof(oSurface), "surface"); rptSurfaceList.DataSource = SurfaceList; rptSurfaceList.DataBind(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Populate Form Values /// /// /// /// REVISION 001: Added field to pal_Surface.isDefaultToForm. Indicates whether default view of surface app is form or grid (for multi surface app functionality) /// AUTHOR: Charlene van Heerden /// DATE MODIFIED: 11 December 2015 /// private void PopulatePageFormValues(ref oSurface _Surface) { try { txtSurface.Value = _Surface.surface; chkActive.Checked = _Surface.isActive; chkModal.Checked = _Surface.isModal; chkPublished.Checked = _Surface.isPublished; chkDefaultToForm.Checked = _Surface.isDefaultToForm; chkIsWizzard.Checked = _Surface.isWizzard; chkIsComparable.Checked = _Surface.isComparable; if (chkIsComparable.Checked) { txtColumnCount.Text = _Surface.columnCount.ToString(); divColumnCount.Visible = true; } chkIsLinkedSurface.Checked = _Surface.isLinkedSurface; chkIsDisableRequired.Checked = _Surface.isDisableRequired; BindLinkedSurfaces(_Surface.recId); divLinkedSurfaces.Visible = chkIsLinkedSurface.Checked; chkLinkUser.Checked = _Surface.linkUser; chkCapitalize.Checked = _Surface.isCapitalizeInput; //CVH 2016-10-21 Adding custom action on surface save chkCustomActionOnSave.Checked = false; foreach (oSurfaceAction act in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceAction), "recId", _Surface.surfaceActionId.ToString())) { if (act.action == "Surface Save") chkCustomActionOnSave.Checked = true; } if (_Surface.isPublished) { btnPublish.Visible = true; btnPublish.Text = "Re-Publish Layout"; if (Debugger.IsAttached) { chkRecreateCode.Visible = true; } } else//only show publish button in dev mode { if (Debugger.IsAttached) { btnPublish.Visible = true; chkRecreateCode.Visible = true; } else { btnPublish.Visible = false; } } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Save Form Values /// /// /// /// REVISION 001: Added field to pal_Surface.isDefaultToForm. Indicates whether default view of surface app is form or grid (for multi surface app functionality) /// AUTHOR: Charlene van Heerden /// DATE MODIFIED: 11 December 2015 /// private void SavePageFormValues(ref oSurface _Surface) { try { _Surface.surface = txtSurface.Value; _Surface.isActive = chkActive.Checked; _Surface.name = utils.stripCharacters(txtSurface.Value).Replace(" ", ""); _Surface.isModal = chkModal.Checked; _Surface.isPublished = chkPublished.Checked; /* Rev 001 isDefaultToForm field added to pal_Surface * Charlene van Heerden * 11 December 2015 */ _Surface.isDefaultToForm = chkDefaultToForm.Checked; _Surface.isWizzard = chkIsWizzard.Checked; _Surface.isComparable = chkIsComparable.Checked; if (divColumnCount.Visible) _Surface.columnCount = Convert.ToInt32(txtColumnCount.Text); _Surface.isLinkedSurface = chkIsLinkedSurface.Checked; _Surface.isDisableRequired = chkIsDisableRequired.Checked; _Surface.linkUser = chkLinkUser.Checked; _Surface.isCapitalizeInput = chkCapitalize.Checked; //CVH 2016-10-21 Adding custom action on surface save _Surface.surfaceActionId = 0; if (chkCustomActionOnSave.Checked) { foreach (oSurfaceAction act in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceAction), "action", "Surface Save")) { _Surface.surfaceActionId = act.recId; break; } } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } private void BindModuleSurface() { oSurface surf = new oSurface(); if (utils.verifySession("surface")) surf = (oSurface)Session["surface"]; ArrayList surfaces = xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "isActive", "1", "surface"); for (int i = surfaces.Count - 1; i >= 0; i--) { if (((oSurface)surfaces[i]).recId == surf.recId) { surfaces.RemoveAt(i); break; } } ddModuleSurface.DataSource = surfaces; ddModuleSurface.DataTextField = "surface"; ddModuleSurface.DataValueField = "recId"; ddModuleSurface.DataBind(); ddModuleSurface.Items.Insert(0, new ListItem("select...", "0")); } private void BindModuleSurfaceFields(int surfaceId) { ArrayList surfaceFields = xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "surfaceId,surfaceFieldTypeId,isActive", surfaceId + "," + pNums.FieldType.Text.GetHashCode() + ",1"); ddModuleSurfaceField.DataSource = surfaceFields; ddModuleSurfaceField.DataTextField = "surfaceFieldDisplay"; ddModuleSurfaceField.DataValueField = "recId"; ddModuleSurfaceField.DataBind(); ddModuleSurfaceField.Items.Insert(0, new ListItem("select...", "0")); } /// /// Method to Toggle Panels /// /// private void TogglePanels(string panelName) { switch (panelName) { case "pnlSurfaceApp": pnlSurfaceApp.Visible = true; pnlSurfaceList.Visible = false; break; case "pnlSurfaceList": pnlSurfaceApp.Visible = false; pnlSurfaceList.Visible = true; break; } //clear result pnlResult.Visible = false; } /// /// Method to Build User Control /// /// private static void BuildControl(oSurface surface) { foreach (oModule moduleItem in xData.GetTypedByCriteriaSpecific("recId", typeof(oModule), "recId", pNums.Module.Surface.GetHashCode().ToString())) { surfaceHandler.BuildSurfaceAppTemplate(surface, controlPath + moduleItem.control, surfacePath, true); } } #endregion #region surface field methods /// /// Bind Parent Fields /// private void BindFilterTabs() { oSurface surface = new oSurface(); try { if (utils.verifySession("surface")) { surface = (oSurface)Session["surface"]; int fieldTypeId = 1;//default to tab DataTable typeData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "surfaceId,surfaceFieldTypeId", surface.recId + "," + fieldTypeId, "sequence"); ddTabs.DataSource = typeData; ddTabs.DataTextField = "surfaceFieldDisplay"; ddTabs.DataValueField = "recId"; ddTabs.DataBind(); ddTabs.Items.Insert(0, new ListItem("tabs..", "0")); } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Bind Parent Fields /// private void BindFilterGroups() { oSurface surface = new oSurface(); try { if (utils.verifySession("surface")) { surface = (oSurface)Session["surface"]; //int fieldTypeId = 2;//groups string fieldTypeId = "2|16"; int parentId = 0; if (ddTabs.SelectedValue != null && ddTabs.SelectedValue != "0") int.TryParse(ddTabs.SelectedValue, out parentId); DataTable typeData = new DataTable(); if (parentId > 0) typeData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "surfaceId,surfaceFieldTypeId,parentId", surface.recId + ",~()" + fieldTypeId + "," + parentId, "sequence"); else typeData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "surfaceId,surfaceFieldTypeId", surface.recId + ",~()" + fieldTypeId, "sequence"); ddGroups.DataSource = typeData; ddGroups.DataTextField = "surfaceFieldDisplay"; ddGroups.DataValueField = "recId"; ddGroups.DataBind(); ddGroups.Items.Insert(0, new ListItem("groups..", "0")); } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Bind Field Types /// private void BindFieldTypes() { try { DataTable typeData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceFieldType), "isActive", "1", "recId"); ddFieldTypes.DataSource = typeData; ddFieldTypes.DataTextField = "surfaceFieldType"; ddFieldTypes.DataValueField = "recId"; ddFieldTypes.DataBind(); ToggleFieldTypes(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Bind Field Types /// private void BindSurfaceDateTypes() { try { DataTable typeData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceDateType), "isActive", "1", "recId"); ddSurfaceDateType.DataSource = typeData; ddSurfaceDateType.DataTextField = "surfaceDateType"; ddSurfaceDateType.DataValueField = "recId"; ddSurfaceDateType.DataBind(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Bind Controls /// private void BindControls() { try { DataTable controlData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oModule), "isActive,isSurfaceField", "1,1", "recId"); ddControls.DataSource = controlData; ddControls.DataTextField = "module"; ddControls.DataValueField = "recId"; ddControls.DataBind(); //ToggleFieldTypes(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Bind Parent Fields /// private void BindParentFields() { oSurface surface = new oSurface(); try { if (utils.verifySession("surface")) { surface = (oSurface)Session["surface"]; string fieldTypeIds = "2|16";//default to group/headergroup if (int.Parse(ddFieldTypes.SelectedValue) == pNums.FieldType.Group.GetHashCode() || int.Parse(ddFieldTypes.SelectedValue) == pNums.FieldType.HeaderGroup.GetHashCode()) fieldTypeIds = "1"; else if (int.Parse(ddFieldTypes.SelectedValue) == pNums.FieldType.Tab.GetHashCode()) fieldTypeIds = "2"; DataTable typeData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "surfaceId,surfaceFieldTypeId", surface.recId + ",~()" + fieldTypeIds, "sequence"); ddParentFields.DataSource = typeData; ddParentFields.DataTextField = "surfaceFieldDisplay"; ddParentFields.DataValueField = "recId"; ddParentFields.DataBind(); //CVH 2017-02-14 Add subtab functionality. If selected field is Tab, allow it to be linked to a group parent ddParentFields.Items.Insert(0, new ListItem("None", "0")); } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Bind Field Types /// private void BindLookupCategories() { try { DataTable lookData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceLookupCategory), "isActive", "1", "lookupCategory"); ddLookupCategory.DataSource = lookData; ddLookupCategory.DataValueField = "recId"; ddLookupCategory.DataTextField = "lookupCategory"; ddLookupCategory.DataBind(); ddLookupCategory.Items.Insert(0, new ListItem("select...", "0")); DataTable moduleLookupData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oModule), "isActive,isPicklist", "1,1", "module"); foreach (DataRow row in moduleLookupData.Rows) { ddModuleLookup.Items.Add(new ListItem(row["module"].ToString(), row["objectName"].ToString())); } ddModuleLookup.Items.Insert(0, new ListItem("select...", "0")); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Method to Bind Surface Data /// private void BindSurfaceFields() { try { if (utils.verifySession("surface")) { oSurface surface = (oSurface)Session["surface"]; ArrayList FieldList = new ArrayList(); int parentId = 0; if (ddGroups.SelectedValue != null && ddGroups.SelectedValue != "0") int.TryParse(ddGroups.SelectedValue, out parentId); else if (ddTabs.SelectedValue != null && ddTabs.SelectedValue != "0") int.TryParse(ddTabs.SelectedValue, out parentId); if (parentId > 0) FieldList = xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "surfaceId, parentId", surface.recId + "," + parentId, "sequence,parentId"); else FieldList = xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "surfaceId", surface.recId.ToString(), "sequence,parentId"); rptSurfaceFields.DataSource = FieldList; rptSurfaceFields.DataBind(); } else { rptSurfaceFields.DataSource = null; rptSurfaceFields.DataBind(); } lblPipe.Visible = rptSurfaceFields.Items.Count > 0; btnGrid.Visible = rptSurfaceFields.Items.Count > 0; upSurface.Update(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Bind Aggregation action Surface /// private void BindAggregationSurface() { try { DataTable dt = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurface), "isActive", "1", "recId"); ddAggregationSurface.DataSource = dt; ddAggregationSurface.DataTextField = "surface"; ddAggregationSurface.DataValueField = "recId"; ddAggregationSurface.DataBind(); ddAggregationSurface.Items.Insert(0, new ListItem("select...", "0")); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["admin"]); Response.Redirect("/error", false); } } /// /// Bind Label Source Surface /// private void BindLabelSourceSurface() { try { DataTable labelSourceSurfaceData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurface), "isActive", "1", "recId"); ddLabelSurface.DataSource = labelSourceSurfaceData; ddLabelSurface.DataTextField = "surface"; ddLabelSurface.DataValueField = "recId"; ddLabelSurface.DataBind(); ddLabelSurface.Items.Insert(0, new ListItem("select...", "0")); ddLabelSurface.Items.Add(new ListItem("Logged User", "user")); ddLabelSurface.Items.Add(new ListItem("Logged Date", "date")); ddLabelSurface.Items.Add(new ListItem("Static Label", "static")); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["admin"]); Response.Redirect("/error", false); } } /// /// Bind Label Source Fields /// /// private void BindLabelSourceFields(string surfaceId) { try { string fieldTypes = pNums.FieldType.Text.GetHashCode().ToString() + "|" + pNums.FieldType.Number.GetHashCode().ToString() + "|" + pNums.FieldType.Decimal.GetHashCode().ToString() + "|" + pNums.FieldType.Picklist.GetHashCode().ToString() + "|" + pNums.FieldType.Date.GetHashCode().ToString() + "|" + pNums.FieldType.Checkbox.GetHashCode().ToString() + "|" + pNums.FieldType.RadioButtonList.GetHashCode().ToString() + "|" + pNums.FieldType.Attachment.GetHashCode().ToString() + "|" + pNums.FieldType.FormulaField.GetHashCode().ToString() + "|" + pNums.FieldType.Image.GetHashCode().ToString() + "|" + pNums.FieldType.Caption.GetHashCode().ToString() + "|" + pNums.FieldType.Note.GetHashCode().ToString() + "|" + pNums.FieldType.Address.GetHashCode().ToString() + "|" + pNums.FieldType.CheckboxList.GetHashCode().ToString() + "|" + pNums.FieldType.MultiPicklist.GetHashCode().ToString(); DataTable labelSourceFieldData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "isActive,surfaceId,surfaceFieldTypeId", "1," + surfaceId + ",~()" + fieldTypes + "", "recId"); labelSourceFieldData.Columns.Add("NameWithDisplay", typeof(string), "surfaceFieldDisplay + ' (' + surfaceFieldName+')'"); ddLabelSource.DataSource = labelSourceFieldData; ddLabelSource.DataTextField = "NameWithDisplay"; ddLabelSource.DataValueField = "recId"; ddLabelSource.DataBind(); ddLabelSource.Items.Insert(0, new ListItem("select...", "0")); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["admin"]); Response.Redirect("/error", false); } } /// /// bind validation types /// private void BindValidationTypes() { try { DataTable validationTypeSource = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceFieldValidationType), "isActive", "1", "recId"); ddlValidationType.DataSource = validationTypeSource; ddlValidationType.DataTextField = "validationType"; ddlValidationType.DataValueField = "recId"; ddlValidationType.DataBind(); ddlValidationType.Items.Insert(0, new ListItem("none", "0")); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["admin"]); Response.Redirect("/error", false); } } /// /// Bind Action Types /// private void BindActionTypes() { try { DataTable actionTypeData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceActionType), "isActive", "1", "recId"); ddActionTypes.DataSource = actionTypeData; ddActionTypes.DataTextField = "actionType"; ddActionTypes.DataValueField = "recId"; ddActionTypes.DataBind(); ddActionTypes.Items.Insert(0, new ListItem("select...", "0")); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["admin"]); Response.Redirect("/error", false); } } /// /// Bind Actions from Action Type /// /// private void BindActions(string actionTypeId) { try { ddActions.ClearSelection(); ddActions.Items.Clear(); ddActions.SelectedValue = null; DataTable actionData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceAction), "isActive,actionType", "1," + actionTypeId, "recId"); ddActions.DataSource = actionData; ddActions.DataTextField = "action"; ddActions.DataValueField = "recId"; ddActions.DataBind(); ddActions.Items.Insert(0, new ListItem("select...", "0")); if (ddActions.Items.Count > 1) actionGroup.Visible = true; } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["admin"]); Response.Redirect("/error", false); } } /// /// Bind Action Source from Action /// /// private void BindActionSource(string fieldTypeIds, int surfaceId = 0, bool bindActionSource2 = false) { try { DataTable actionSourceData = new DataTable(); if (surfaceId == 0) actionSourceData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "isActive,surfaceFieldTypeId", "1,~()" + fieldTypeIds, "recId"); else actionSourceData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "isActive,surfaceId,surfaceFieldTypeId", "1," + surfaceId + ",~()" + fieldTypeIds, "recId"); ddActionSource.DataSource = actionSourceData; ddActionSource.DataTextField = "surfaceFieldName"; ddActionSource.DataValueField = "recId"; ddActionSource.DataBind(); //CVH 2017-07-03 Show group even if dropdown is empty, otherwise it looks buggy //if (ddActionSource.Items.Count > 0) actionSourceGroup.Visible = true; if (bindActionSource2) { //CVH 2017-02-06 Bind second source dropdown with same result (for new calculation action Divide, will only show it if Divide selected as actino) ddActionSource2.DataSource = actionSourceData; ddActionSource2.DataTextField = "surfaceFieldName"; ddActionSource2.DataValueField = "recId"; ddActionSource2.DataBind(); } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["admin"]); Response.Redirect("/error", false); } } private void BindLookupCalcSurface() { try { DataTable lookupSurfaceData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurface), "isActive", "1", "recId"); ddLookupCalcSurface.DataSource = lookupSurfaceData; ddLookupCalcSurface.DataTextField = "surface"; ddLookupCalcSurface.DataValueField = "recId"; ddLookupCalcSurface.DataBind(); ddLookupCalcSurface.Items.Insert(0, new ListItem("select...", "0")); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["admin"]); Response.Redirect("/error", false); } } private void BindLookupCalcSurfaceFields(string surfaceId) { try { string fieldTypes = pNums.FieldType.Text.GetHashCode().ToString() + "|" + pNums.FieldType.Label.GetHashCode().ToString(); ArrayList surfaceFields = xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "surfaceId,surfaceFieldTypeId,isActive", surfaceId + ",~()" + fieldTypes + ",1"); ddLookupCalcSurfaceField.DataSource = surfaceFields; ddLookupCalcSurfaceField.DataTextField = "surfaceFieldDisplay"; ddLookupCalcSurfaceField.DataValueField = "recId"; ddLookupCalcSurfaceField.DataBind(); ddLookupCalcSurfaceField.Items.Insert(0, new ListItem("select...", "0")); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Method to Bind the slide Order Drop down /// private void BindSequence() { try { for (int i = 0; i < 100; i++) { //append sequence item ddSequence.Items.Add(new ListItem(i.ToString(), i.ToString())); ddGridSequence.Items.Add(new ListItem(i.ToString(), i.ToString())); } } catch (Exception ex) { exception.HandleException("Content:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Method to Bind Access Level /// private void BindAccessLevel() { try { DataTable dtUserType = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oUserType), "isActive,userType", "1,~<>Custom User", "sequence"); ddAccessLevel.DataSource = dtUserType; ddAccessLevel.DataTextField = "userType"; ddAccessLevel.DataValueField = "recId"; ddAccessLevel.DataBind(); } catch (Exception ex) { exception.HandleException("Content:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Method to Toggle Panels for Surface Fields /// /// private void TogglePanelsSurfaceFields(string panelName) { switch (panelName) { case "pnlSurfaceField": pnlSurfaceField.Visible = true; pnlSurfaceFields.Visible = false; break; case "pnlSurfaceFields": pnlSurfaceField.Visible = false; pnlSurfaceFields.Visible = true; break; } //clear result pnlResultSurfaceField.Visible = false; } /// /// Populate Form Values /// /// private void PopulateFieldFormValues(ref oSurfaceField _SurfaceField) { try { chkActiveField.Checked = _SurfaceField.isActive; chkGridActive.Checked = _SurfaceField.isGrid; chkIsGrouped.Checked = _SurfaceField.isGrouped; chkFilter.Checked = _SurfaceField.isFilter; chkRequired.Checked = _SurfaceField.required; chkIsAutoPostback.Checked = _SurfaceField.isAutoPostback; chkDefaultCurrent.Checked = _SurfaceField.defaultToCurrent; dtDefaultDate.Text = _SurfaceField.defaultValue; chkHiddenField.Checked = _SurfaceField.isHidden; chkHiddenWizzard.Checked = _SurfaceField.isHiddenFromWizzard; chkHiddenView.Checked = _SurfaceField.isHiddenFromView; chkHiddenForm.Checked = _SurfaceField.isHiddenFromForm; chkReadOnlyField.Checked = _SurfaceField.isReadOnly; //JR Bas-Pro-3 chkUnique.Checked = _SurfaceField.isUnique; chkComparable.Checked = _SurfaceField.isComparable; chkAlternateView.Checked = _SurfaceField.alternateView; chkLabelHidden.Checked = _SurfaceField.isLabelHidden; //CVH 2016-12-12 chkGroupDefaultCollapsed.Checked = false; if (_SurfaceField.surfaceFieldTypeId == pNums.FieldType.Group.GetHashCode()) chkGroupDefaultCollapsed.Checked = _SurfaceField.isControlled; chkNewLine.Checked = _SurfaceField.isOnNewLine; chkBottomBorder.Checked = _SurfaceField.hasBottomBorder; chkFullBorder.Checked = _SurfaceField.hasFullBorder; txtLength.Value = _SurfaceField.length.ToString(); txtDisplay.Value = _SurfaceField.surfaceFieldDisplay; txtPlaceholder.Value = _SurfaceField.placeholder; txtRowLimit.Value = _SurfaceField.relationalValues; if (ddFieldTypes.Items.FindByValue(_SurfaceField.surfaceFieldTypeId.ToString()) != null) ddFieldTypes.SelectedValue = _SurfaceField.surfaceFieldTypeId.ToString(); BindParentFields(); if (ddParentFields.Items.FindByValue(_SurfaceField.parentId.ToString()) != null) ddParentFields.Items.FindByValue(_SurfaceField.parentId.ToString()).Selected = true; if (_SurfaceField.sequence > 0) ddSequence.SelectedItem.Text = _SurfaceField.sequence.ToString(); if (_SurfaceField.gridSequence > 0) ddGridSequence.SelectedItem.Text = _SurfaceField.gridSequence.ToString(); if (_SurfaceField.accessLevel > 0 && ddAccessLevel.Items.FindByValue(_SurfaceField.accessLevel.ToString()) != null) ddAccessLevel.SelectedValue = _SurfaceField.accessLevel.ToString(); ddLookupCategory.SelectedValue = _SurfaceField.lookupCategory.ToString(); ddModuleLookup.ClearSelection(); moduleSurfaceGroup.Visible = false; if (_SurfaceField.relationalObject.ToString().Length > 0 && ddModuleLookup.Items.FindByValue(_SurfaceField.relationalObject.ToString()) != null) { ddModuleLookup.SelectedValue = _SurfaceField.relationalObject.ToString(); if (ddModuleLookup.SelectedItem.Text == "Surface") { moduleSurfaceGroup.Visible = true; ddModuleSurface.ClearSelection(); ddModuleSurface.Items.Clear(); BindModuleSurface(); if (_SurfaceField.relationalFields != String.Empty) { int modSurfField = 0; if (int.TryParse(_SurfaceField.relationalFields, out modSurfField)) { foreach (oSurfaceField fld in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "recId", modSurfField.ToString())) { if (ddModuleSurface.Items.FindByValue(fld.surfaceId.ToString()) != null) { ddModuleSurface.Items.FindByValue(fld.surfaceId.ToString()).Selected = true; ddModuleSurfaceField.ClearSelection(); ddModuleSurfaceField.Items.Clear(); BindModuleSurfaceFields(fld.surfaceId); if (ddModuleSurfaceField.Items.FindByValue(fld.recId.ToString()) != null) ddModuleSurfaceField.Items.FindByValue(fld.recId.ToString()).Selected = true; } break; } } } } } if (_SurfaceField.relationalSurface.ToString().Length > 0 && ddLabelSurface.Items.FindByValue(_SurfaceField.relationalSurface.ToString()) != null) { ddLabelSurface.SelectedValue = _SurfaceField.relationalSurface.ToString(); if (ddLabelSurface.SelectedValue != "user" && ddLabelSurface.SelectedValue != "date" && ddLabelSurface.SelectedValue != "static") { BindLabelSourceFields(ddLabelSurface.SelectedValue); labelSourceGroup.Visible = true; labelStaticGroup.Visible = false; } if (ddLabelSurface.SelectedValue == "static") { labelSourceGroup.Visible = false; labelStaticGroup.Visible = true; txtStaticLabel.Text = _SurfaceField.relationalValues; } } if (_SurfaceField.relationalSurface.ToString().Length > 0 && ddLabelSurface.Items.FindByValue(_SurfaceField.relationalSurface.ToString()) != null && _SurfaceField.relationalFields.ToString().Length > 0 && ddLabelSource.Items.FindByValue(_SurfaceField.relationalFields.ToString()) != null) ddLabelSource.SelectedValue = _SurfaceField.relationalFields.ToString(); ddFieldSize.SelectedValue = "6"; if (_SurfaceField.surfaceFieldSize > 0 && ddFieldSize.Items.FindByValue(_SurfaceField.surfaceFieldSize.ToString()) != null) ddFieldSize.SelectedValue = _SurfaceField.surfaceFieldSize.ToString(); ddLabelSize.SelectedValue = "4"; if (_SurfaceField.labelSize > 0 && ddLabelSize.Items.FindByValue(_SurfaceField.labelSize.ToString()) != null) ddLabelSize.SelectedValue = _SurfaceField.labelSize.ToString(); /* CVH 2016-01-22 RelField */ if (ddSurfaceApps.Items.FindByValue(_SurfaceField.relationalSurface) != null) { ddSurfaceApps.SelectedValue = _SurfaceField.relationalSurface; BindSurfaceAppFields(_SurfaceField.relationalSurface); } else { ddSurfaceApps.SelectedValue = "0"; } /* CVH 2016-01-22 RelField */ if (ddSurfaceAppFields.Items.FindByValue(_SurfaceField.relationalFields) != null) ddSurfaceAppFields.SelectedValue = _SurfaceField.relationalFields; else ddSurfaceAppFields.SelectedValue = "0"; if (_SurfaceField.contentId != 0) { if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Content) ddContent.SelectedValue = _SurfaceField.contentId.ToString(); if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Composite) ddComposite.SelectedValue = _SurfaceField.contentId.ToString(); } chkIsControlled.Checked = _SurfaceField.isControlled; if (chkIsControlled.Checked) { controlledValue.Visible = true; } else controlledValue.Visible = false; txtControlledValue.Value = _SurfaceField.controlledValue; txtControlText.Value = _SurfaceField.controlText; actionTypeGroup.Visible = false; actionGroup.Visible = false; actionSourceGroup.Visible = false; actionValueGroup.Visible = false; actionSourceGroup2.Visible = false; lookupCalcSurfaceGroup.Visible = false; lookupCalcSurfaceFieldGroup.Visible = false; stylingTextColourGroup.Visible = false; //CVH 2017-06-30 Cleanup - Action properties are set in SetActinProperties called from ToggleFieldType (always called after Populate is called) //if (//_SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.Attachment && // _SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.Button && // _SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.Composite && // _SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.Content && // _SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.Debtors && // //_SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.Grid && // _SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.Group && // _SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.HeaderGroup && // _SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.Image && // _SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.Mediswitch && // _SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.Note && // _SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.Placeholder && // _SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.RelationalField && // _SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.Tab && // _SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.Sales && // _SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.Control) //{ // SetActionFieldValues(_SurfaceField); //} mapFieldsGroup.Visible = false; if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Sales || _SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Debtors) mapFieldsGroup.Visible = true; if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Control) { controlsGroup.Visible = true; if (ddControls.Items.FindByValue(_SurfaceField.controlledValue) != null) { ddControls.SelectedValue = _SurfaceField.controlledValue; ToggleControlDisplay(); //CVH 2017-05-23 Surface Notes - Confidential if (_SurfaceField.controlledValue == pNums.Module.SurfaceNotes.GetHashCode().ToString()) { chkIsConfidential.Checked = _SurfaceField.isControlled; chkIsControlled.Checked = false; isControlled.Visible = false; } } else { ddControls.SelectedValue = "0"; } //GR 2017-08-04 Included Configration options for Surface Signature if (int.Parse(ddControls.SelectedValue) == (int)pNums.Module.SurfaceSignature) { foreach (oSurfaceSignatureConfig conf in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceSignatureConfig), "fieldId", _SurfaceField.recId.ToString())) { txtSigLabelText.Value = conf.labelText; txtSigDisclaimerText.Value = conf.disclaimer; chkSigIncludePhoto.Checked = conf.includePhoto; chkSigAllowPhotoEdit.Checked = conf.allowPhotoEdit; chkSigAllowSignatureEdit.Checked = conf.allowSignatureEdit; break; } } } if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Date) { dateTypeGroup.Visible = true; if (ddSurfaceDateType.Items.FindByValue(_SurfaceField.surfaceDateTypeId.ToString()) != null) ddSurfaceDateType.SelectedValue = _SurfaceField.surfaceDateTypeId.ToString(); else ddSurfaceDateType.SelectedIndex = 0; } if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Text) { if (ddlValidationType.Items.FindByValue(_SurfaceField.validationType.ToString()) != null) ddlValidationType.SelectedValue = _SurfaceField.validationType.ToString(); } else ddlValidationType.SelectedValue = "0"; chkBulkUpdate.Checked = _SurfaceField.enableBulkUpdate; chkCurrency.Checked = _SurfaceField.isCurrency; chkVerticalHeader.Checked = _SurfaceField.isVerticalHeader; chkSummaryGrid.Checked = false; if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Grid) chkSummaryGrid.Checked = _SurfaceField.isControlled; chkIsCloneable.Checked = _SurfaceField.isCloneable; //GR 2017-07-04 Custom source chkUseCustomSource.Checked = _SurfaceField.isCustomSource; ToggleCustomSource(); if (_SurfaceField.isCustomSource) { ddCustomSource.SelectedValue = _SurfaceField.relationalObject; BindCustomSourceFields(); String[] fields = _SurfaceField.relationalFields.Split(char.Parse(",")); foreach (string fld in fields) { foreach (ListItem item in lstRelationalFieldDisplay.Items) { if (item.Value == fld) { item.Selected = true; break; } } } if (ddRelationalFieldValue.Items.FindByValue(_SurfaceField.relationalValues.ToString()) != null) ddRelationalFieldValue.SelectedValue = _SurfaceField.relationalValues; txtRelationalOrderBy.Text = _SurfaceField.relationalOrderBy; txtRelationalWhere.Text = _SurfaceField.relationalWhere; } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Replaces SetActionFieldValues /// private void ToggleAction(int surfaceId, int actionType, string action, int actionSource, string actionValue) { try { ClearActionControls(); if (actionType == pNums.ActionType.Button.GetHashCode()) lblActionValue.InnerText = "Copy Button Text"; else lblActionValue.InnerHtml = "Value use delimiter ;"; lblddActionSource2.Text = "Divide By"; switch (action) { case "VAT": BindActionSource(pNums.FieldType.Decimal.GetHashCode().ToString()); if (ddActionSource.Items.FindByValue(actionSource.ToString()) != null) ddActionSource.SelectedValue = actionSource.ToString(); break; case "Age": BindActionSource(pNums.FieldType.Date.GetHashCode().ToString() + "|" + pNums.FieldType.Text.GetHashCode().ToString()); if (ddActionSource.Items.FindByValue(actionSource.ToString()) != null) ddActionSource.SelectedValue = actionSource.ToString(); break; case "Gender": BindActionSource(pNums.FieldType.Text.GetHashCode().ToString()); if (ddActionSource.Items.FindByValue(actionSource.ToString()) != null) ddActionSource.SelectedValue = actionSource.ToString(); break; case "Copy": string destType = ddFieldTypes.SelectedValue; BindActionSource(destType); if (ddActionSource.Items.FindByValue(actionSource.ToString()) != null) ddActionSource.SelectedValue = actionSource.ToString(); txtActionValue.Text = actionValue; actionValueGroup.Visible = true; break; case "Visible": //CVH 2016-10-10 Only catering for fieldtype Checkboxlist and RadioButtonList //CVH 2017-01-18 Add toggle view for picklist //CVH 2017-02-15 Add toggle view for grid BindActionSource(pNums.FieldType.CheckboxList.GetHashCode().ToString() + "|" + pNums.FieldType.RadioButtonList.GetHashCode().ToString() + "|" + pNums.FieldType.Picklist.GetHashCode().ToString() + "|" + pNums.FieldType.Grid.GetHashCode(), surfaceId); if (ddActionSource.Items.FindByValue(actionSource.ToString()) != null) ddActionSource.SelectedValue = actionSource.ToString(); txtActionValue.Text = actionValue; actionValueGroup.Visible = true; break; case "Divide": BindActionSource(pNums.FieldType.Text.GetHashCode().ToString() + "|" + pNums.FieldType.Number.GetHashCode().ToString() + "|" + pNums.FieldType.Decimal.GetHashCode().ToString(), surfaceId, true); if (ddActionSource.Items.FindByValue(actionSource.ToString()) != null) ddActionSource.SelectedValue = actionSource.ToString(); actionSourceGroup2.Visible = true; if (ddActionSource2.Items.FindByValue(actionValue) != null) ddActionSource2.Items.FindByValue(actionValue).Selected = true; break; case "Lookup": BindActionSource(pNums.FieldType.Text.GetHashCode().ToString() + "|" + pNums.FieldType.Number.GetHashCode().ToString() + "|" + pNums.FieldType.Decimal.GetHashCode().ToString() + "|" + pNums.FieldType.FormulaField.GetHashCode().ToString(), surfaceId); if (ddActionSource.Items.FindByValue(actionSource.ToString()) != null) ddActionSource.SelectedValue = actionSource.ToString(); BindLookupCalcSurface(); lookupCalcSurfaceGroup.Visible = true; if (ddLookupCalcSurface.Items.FindByValue(actionValue) != null) ddLookupCalcSurface.Items.FindByValue(actionValue).Selected = true; break; case "Lookup Field": BindActionSource(pNums.FieldType.Text.GetHashCode().ToString() + "|" + pNums.FieldType.Picklist.GetHashCode().ToString() + "|" + pNums.FieldType.Number.GetHashCode().ToString() + "|" + pNums.FieldType.Decimal.GetHashCode().ToString() + "|" + pNums.FieldType.FormulaField.GetHashCode().ToString(), surfaceId); if (ddActionSource.Items.FindByValue(actionSource.ToString()) != null) ddActionSource.SelectedValue = actionSource.ToString(); BindLookupCalcSurface(); lookupCalcSurfaceGroup.Visible = true; if (actionValue != "") { foreach (oSurfaceField lookupField in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "recId", actionValue)) { if (ddLookupCalcSurface.Items.FindByValue(lookupField.surfaceId.ToString()) != null) { ddLookupCalcSurface.Items.FindByValue(lookupField.surfaceId.ToString()).Selected = true; BindLookupCalcSurfaceFields(lookupField.surfaceId.ToString()); lookupCalcSurfaceFieldGroup.Visible = true; if (ddLookupCalcSurfaceField.Items.FindByValue(lookupField.recId.ToString()) != null) ddLookupCalcSurfaceField.Items.FindByValue(lookupField.recId.ToString()).Selected = true; } } } break; case "Sum": //Aggregation Sum (could be a Calculation Sum later) if (actionType == (int)pNums.ActionType.Aggregation) { actionSourceGroup.Visible = false; actionSourceGroup2.Visible = false; BindAggregationSurface(); aggregationSurfaceGroup.Visible = true; if (ddAggregationSurface.Items.FindByValue(actionValue) != null) { ddAggregationSurface.Items.FindByValue(actionValue).Selected = true; BindActionSource(pNums.FieldType.Number.GetHashCode().ToString() + "|" + pNums.FieldType.Decimal.GetHashCode().ToString(), int.Parse(actionValue)); if (ddActionSource.Items.FindByValue(actionSource.ToString()) != null) ddActionSource.Items.FindByValue(actionSource.ToString()).Selected = true; } } else if (actionType == (int)pNums.ActionType.FieldAggregation) { fieldAggregationGroup.Visible = true; BindFieldAggregationList(); foreach (string fields in actionValue.Split('|')) { if (lstFieldAggregation.Items.FindByValue(fields) != null) { lstFieldAggregation.Items.FindByValue(fields).Selected = true; } } } break; case "Text Colour": stylingTextColourGroup.Visible = true; ddStylingTextColourRule.ClearSelection(); txtStylingTextColourValue.Text = ""; ddStylingTextColourColour.ClearSelection(); if (actionValue != String.Empty) { // Rule|Value|Colour eg "<|60|Red" int styleCount = 0; foreach (string style in actionValue.Split('|')) { if (styleCount == 0) { if (style == "<" && ddStylingTextColourRule.Items.FindByValue("Less Than") != null) ddStylingTextColourRule.Items.FindByValue("Less Than").Selected = true; } else if (styleCount == 1) { txtStylingTextColourValue.Text = style; } else if (styleCount == 2) { if (ddStylingTextColourColour.Items.FindByValue(style) != null) ddStylingTextColourColour.Items.FindByValue(style).Selected = true; } styleCount++; } } break; case "Average": if (actionType == (int)pNums.ActionType.FieldAggregation) { fieldAggregationGroup.Visible = true; BindFieldAggregationList(); foreach (string fields in actionValue.Split('|')) { if (lstFieldAggregation.Items.FindByValue(fields) != null) { lstFieldAggregation.Items.FindByValue(fields).Selected = true; } } } break; case "Ranking": BindActionSource(pNums.FieldType.FormulaField.GetHashCode().ToString() + "|" + pNums.FieldType.Number.GetHashCode().ToString() + "|" + pNums.FieldType.Decimal.GetHashCode().ToString(), surfaceId); if (ddActionSource.Items.FindByValue(actionSource.ToString()) != null) ddActionSource.SelectedValue = actionSource.ToString(); DataTable actionSourceData = new DataTable(); if (surfaceId == 0) actionSourceData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "isActive", "1", "recId"); else actionSourceData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "isActive,surfaceId", "1," + surfaceId.ToString(), "recId"); ddActionSource2.DataSource = actionSourceData; ddActionSource2.DataTextField = "surfaceFieldName"; ddActionSource2.DataValueField = "recId"; ddActionSource2.DataBind(); if (ddActionSource2.Items.FindByValue(actionValue) != null) ddActionSource2.Items.FindByValue(actionValue).Selected = true; lblddActionSource2.Text = "Group By"; actionSourceGroup2.Visible = true; break; case "Distinction Count": case "Failed Count": case "Passed Count": if (actionType == (int)pNums.ActionType.FieldAggregation) { fieldAggregationGroup.Visible = true; BindFieldAggregationList(); foreach (string fields in actionValue.Split('|')) { if (lstFieldAggregation.Items.FindByValue(fields) != null) { lstFieldAggregation.Items.FindByValue(fields).Selected = true; } } } break; case "Difference": if (actionType == (int)pNums.ActionType.FieldAggregation) { fieldAggregationGroup.Visible = true; BindFieldAggregationList(); foreach (string fields in actionValue.Split('|')) { if (lstFieldAggregation.Items.FindByValue(fields) != null) { lstFieldAggregation.Items.FindByValue(fields).Selected = true; } } } break; default: break; } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } #region Backup private void SetActionFieldValuesBACKUP(oSurfaceField _SurfaceField) { if (ddActionTypes.Items.FindByValue(_SurfaceField.actionType.ToString()) != null) { ddActionTypes.SelectedValue = _SurfaceField.actionType.ToString(); BindActions(_SurfaceField.actionType.ToString()); if (_SurfaceField.actionType == pNums.ActionType.ToggleView.GetHashCode()) actionValueGroup.Visible = true; else actionValueGroup.Visible = false; actionSourceGroup2.Visible = false; if (ddActions.Items.FindByValue(_SurfaceField.action.ToString()) != null) { ddActions.SelectedValue = _SurfaceField.action.ToString(); string action = ddActions.SelectedItem.Text; switch (action) { case "VAT": BindActionSource(pNums.FieldType.Decimal.GetHashCode().ToString()); break; case "Age": BindActionSource(pNums.FieldType.Date.GetHashCode().ToString() + "|" + pNums.FieldType.Text.GetHashCode().ToString()); break; case "Gender": BindActionSource(pNums.FieldType.Text.GetHashCode().ToString()); break; case "Copy": string destType = ddFieldTypes.SelectedValue; BindActionSource(destType); txtActionValue.Text = _SurfaceField.actionValue; break; case "Visible": //CVH 2016-10-10 Only catering for fieldtype Checkboxlist and RadioButtonList //CVH 2017-01-18 Add toggle view for picklist //CVH 2017-02-15 Add toggle view for grid BindActionSource(pNums.FieldType.CheckboxList.GetHashCode().ToString() + "|" + pNums.FieldType.RadioButtonList.GetHashCode().ToString() + "|" + pNums.FieldType.Picklist.GetHashCode().ToString() + "|" + pNums.FieldType.Grid.GetHashCode(), _SurfaceField.surfaceId); txtActionValue.Text = _SurfaceField.actionValue; break; case "Divide": BindActionSource(pNums.FieldType.Text.GetHashCode().ToString() + "|" + pNums.FieldType.Number.GetHashCode().ToString() + "|" + pNums.FieldType.Decimal.GetHashCode().ToString(), _SurfaceField.surfaceId); actionSourceGroup2.Visible = true; if (ddActionSource2.Items.FindByValue(_SurfaceField.actionValue) != null) ddActionSource2.Items.FindByValue(_SurfaceField.actionValue).Selected = true; break; case "Lookup": BindActionSource(pNums.FieldType.Text.GetHashCode().ToString() + "|" + pNums.FieldType.Number.GetHashCode().ToString() + "|" + pNums.FieldType.Decimal.GetHashCode().ToString() + "|" + pNums.FieldType.FormulaField.GetHashCode().ToString(), _SurfaceField.surfaceId); BindLookupCalcSurface(); lookupCalcSurfaceGroup.Visible = true; if (ddLookupCalcSurface.Items.FindByValue(_SurfaceField.actionValue) != null) ddLookupCalcSurface.Items.FindByValue(_SurfaceField.actionValue).Selected = true; break; case "Sum": //Aggregation Sum (could be a Calculation Sum later) if (_SurfaceField.actionType == (int)pNums.ActionType.Aggregation) { actionSourceGroup.Visible = false; actionSourceGroup2.Visible = false; BindAggregationSurface(); aggregationSurfaceGroup.Visible = true; if (ddAggregationSurface.Items.FindByValue(_SurfaceField.actionValue) != null) { ddAggregationSurface.Items.FindByValue(_SurfaceField.actionValue).Selected = true; BindActionSource(pNums.FieldType.Number.GetHashCode().ToString() + "|" + pNums.FieldType.Decimal.GetHashCode().ToString(), int.Parse(_SurfaceField.actionValue)); if (ddActionSource.Items.FindByValue(_SurfaceField.actionSource.ToString()) != null) ddActionSource.Items.FindByValue(_SurfaceField.actionSource.ToString()).Selected = true; } } break; case "Text Colour": stylingTextColourGroup.Visible = true; ddStylingTextColourRule.ClearSelection(); txtStylingTextColourValue.Text = ""; ddStylingTextColourColour.ClearSelection(); if (_SurfaceField.actionValue != String.Empty) { // Rule|Value|Colour eg "<|60|Red" int styleCount = 0; foreach (string style in _SurfaceField.actionValue.Split('|')) { if (styleCount == 0) { if (style == "<" && ddStylingTextColourRule.Items.FindByValue("Less Than") != null) ddStylingTextColourRule.Items.FindByValue("Less Than").Selected = true; } else if (styleCount == 1) { txtStylingTextColourValue.Text = style; } else if (styleCount == 2) { if (ddStylingTextColourColour.Items.FindByValue(style) != null) ddStylingTextColourColour.Items.FindByValue(style).Selected = true; } styleCount++; } } break; case "Average": if (_SurfaceField.actionType == (int)pNums.ActionType.FieldAggregation) { fieldAggregationGroup.Visible = true; BindFieldAggregationList(); foreach (string fields in _SurfaceField.actionValue.Split('|')) { if (lstFieldAggregation.Items.FindByValue(fields) != null) { lstFieldAggregation.Items.FindByValue(fields).Selected = true; } } } break; case "Ranking": BindActionSource(pNums.FieldType.FormulaField.GetHashCode().ToString() + "|" + pNums.FieldType.Number.GetHashCode().ToString() + "|" + pNums.FieldType.Decimal.GetHashCode().ToString(), _SurfaceField.surfaceId); DataTable actionSourceData = new DataTable(); if (_SurfaceField.surfaceId == 0) actionSourceData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "isActive", "1", "recId"); else actionSourceData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "isActive,surfaceId", "1," + _SurfaceField.surfaceId.ToString(), "recId"); ddActionSource2.DataSource = actionSourceData; ddActionSource2.DataTextField = "surfaceFieldName"; ddActionSource2.DataValueField = "recId"; ddActionSource2.DataBind(); lblddActionSource2.Text = "Group By"; actionSourceGroup2.Visible = true; break; case "Distinction Count": if (_SurfaceField.actionType == (int)pNums.ActionType.FieldAggregation) { fieldAggregationGroup.Visible = true; BindFieldAggregationList(); foreach (string fields in _SurfaceField.actionValue.Split('|')) { if (lstFieldAggregation.Items.FindByValue(fields) != null) { lstFieldAggregation.Items.FindByValue(fields).Selected = true; } } } break; default: break; } if (ddActionSource.Items.FindByValue(_SurfaceField.actionSource.ToString()) != null) { ddActionSource.SelectedValue = _SurfaceField.actionSource.ToString(); } } } } #endregion /// /// Saves new surface field in Grid Surface app, hidden, links to parent (current) surface app /// private void SaveGridFieldSurfaceLink(string gridSurfaceName) { //check if there is existing field ArrayList linkSurface = xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "name", gridSurfaceName); if (linkSurface == null || linkSurface.Count <= 0) throw new Exception("Grid field linked surface could not be determined."); oSurface gridSurface = (oSurface)linkSurface[0]; ArrayList linkFields = xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "surfaceId,surfaceFieldDisplay", gridSurface.recId + ",ParentSurfaceItemId"); if (linkFields != null && linkFields.Count > 0) return; if (utils.verifySession("surface")) { oSurface surface = (oSurface)Session["surface"]; //get first visible group field on grid surface to link hidden field to ArrayList list = xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "surfaceId,isActive,surfaceFieldTypeId", gridSurface.recId + ",1," + pNums.FieldType.Group.GetHashCode(), "sequence"); if (list == null || list.Count <= 0) throw new Exception("Group surface field for grid surface could not be determined."); oSurfaceField gridGroupField = (oSurfaceField)list[0]; oSurfaceField field = new oSurfaceField(); field.defaultToCurrent = false; field.isActive = true; field.isAutoPostback = false; field.isControlled = false; field.isFilter = false; field.isGrid = false; field.isHidden = true; field.isReadOnly = true; field.length = 0; field.lookupCategory = 0; field.parentId = gridGroupField.recId; field.relationalSurface = surface.name; field.sequence = 0; field.surfaceFieldDisplay = "ParentSurfaceItemId"; field.surfaceFieldName = "ParentSurfaceItemId"; field.surfaceFieldTypeId = pNums.FieldType.Number.GetHashCode(); field.surfaceId = gridGroupField.surfaceId; field.recId = xData.SaveTyped("recId", typeof(oSurfaceField), field); } else throw new Exception("Grid field parent surface could not be determined."); } private void UploadImageMapControlImage(ref oSurfaceField _field) { try { if (radImageMapUpload.UploadedFiles.Count > 0) { foreach (UploadedFile file in radImageMapUpload.UploadedFiles) { _field.placeholder = file.FileName; string fileName = _field.placeholder; string uploadPath = Server.MapPath("~/upload/image/"); utils.validateFolder(uploadPath); //upload file file.SaveAs(uploadPath + fileName); } } } catch (Exception ex) { exception.HandleException("Promotions:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Save Form Values /// /// private void SaveFieldFormValues(ref oSurfaceField _SurfaceField) { try { _SurfaceField.isActive = chkActiveField.Checked; _SurfaceField.isFilter = chkFilter.Checked; _SurfaceField.isGrid = chkGridActive.Checked; _SurfaceField.isGrouped = chkIsGrouped.Checked; _SurfaceField.required = chkRequired.Checked; _SurfaceField.isAutoPostback = chkIsAutoPostback.Checked; _SurfaceField.isHidden = chkHiddenField.Checked; _SurfaceField.isHiddenFromWizzard = chkHiddenWizzard.Checked; _SurfaceField.isHiddenFromView = chkHiddenView.Checked; _SurfaceField.isHiddenFromForm = chkHiddenForm.Checked; _SurfaceField.isReadOnly = chkReadOnlyField.Checked; //JR Bas-Pro-3 _SurfaceField.isUnique = chkUnique.Checked; _SurfaceField.isComparable = chkComparable.Checked; _SurfaceField.alternateView = chkAlternateView.Checked; _SurfaceField.isLabelHidden = chkLabelHidden.Checked; _SurfaceField.isOnNewLine = chkNewLine.Checked; _SurfaceField.hasBottomBorder = chkBottomBorder.Checked; _SurfaceField.hasFullBorder = chkFullBorder.Checked; int length = 0; int.TryParse(txtLength.Value, out length); _SurfaceField.length = length; int accessType = 0; int.TryParse(ddAccessLevel.SelectedValue, out accessType); _SurfaceField.accessLevel = accessType; int parent = 0; int.TryParse(ddParentFields.SelectedValue, out parent); _SurfaceField.parentId = parent; int seq = 0; int.TryParse(ddSequence.SelectedItem.Text, out seq); _SurfaceField.sequence = seq; int gSeq = 0; int.TryParse(ddGridSequence.SelectedItem.Text, out gSeq); _SurfaceField.gridSequence = gSeq; _SurfaceField.surfaceFieldDisplay = txtDisplay.Value; _SurfaceField.placeholder = txtPlaceholder.Value; int fieldType = 0; int.TryParse(ddFieldTypes.SelectedValue, out fieldType); _SurfaceField.surfaceFieldTypeId = fieldType; //GR 2017-07-05 reset custom source if not selected as these properties may be used if (!chkUseCustomSource.Checked) { _SurfaceField.relationalObject = String.Empty; _SurfaceField.relationalFields = String.Empty; _SurfaceField.relationalValues = String.Empty; _SurfaceField.relationalOrderBy = String.Empty; _SurfaceField.relationalWhere = String.Empty; } if (ddFieldTypes.SelectedValue != pNums.FieldType.Tab.GetHashCode().ToString()) { if (ddFieldTypes.SelectedValue != pNums.FieldType.Group.GetHashCode().ToString() && ddFieldTypes.SelectedValue != pNums.FieldType.HeaderGroup.GetHashCode().ToString()) { int groupId = 0; string tabName = String.Empty; if (ddParentFields.SelectedValue != null) { groupId = int.Parse(ddParentFields.SelectedValue); foreach (oSurfaceField grp in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "recId", groupId.ToString())) { if (grp.surfaceFieldTypeId != (int)pNums.FieldType.HeaderGroup) foreach (oSurfaceField tab in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "recId", grp.parentId.ToString())) { tabName = utils.stripCharacters(tab.surfaceFieldDisplay).Replace(" ", "") + "_"; } } } _SurfaceField.surfaceFieldName = tabName + utils.stripCharacters(ddParentFields.SelectedItem.Text).Replace(" ", "") + "_" + utils.stripCharacters(txtDisplay.Value).Replace(" ", ""); } else { _SurfaceField.surfaceFieldName = utils.stripCharacters(ddParentFields.SelectedItem.Text).Replace(" ", "") + "_" + utils.stripCharacters(txtDisplay.Value).Replace(" ", ""); } } else { //CVH 2017-02-14 Subtab. No change, will save subtab with just tab name, will ID it by parentId <> 0 _SurfaceField.surfaceFieldName = utils.stripCharacters(txtDisplay.Value).Replace(" ", ""); } _SurfaceField.lookupCategory = int.Parse(ddLookupCategory.SelectedValue); if (ddModuleLookup.SelectedIndex > 0) { _SurfaceField.relationalObject = ddModuleLookup.SelectedValue; if (ddModuleLookup.SelectedItem.Text == "Surface" && moduleSurfaceGroup.Visible && ddModuleSurfaceField.SelectedItem != null) { _SurfaceField.relationalFields = ddModuleSurfaceField.SelectedItem.Value; } } string relationalSurface = ""; if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Grid || _SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.RelationalField) { relationalSurface = ddSurfaceApps.SelectedValue; /* CVH 2016-07-21 Link grid surface app to parent surface by adding hidden field to grid surface */ if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Grid) { SaveGridFieldSurfaceLink(relationalSurface); /* CVH 2016-10-19 Allow option to copy data from master data (where parent Id = 0) */ _SurfaceField.defaultToCurrent = chkDefaultCurrent.Checked; _SurfaceField.relationalValues = txtRowLimit.Value; } } _SurfaceField.relationalSurface = relationalSurface; _SurfaceField.surfaceFieldSize = Convert.ToInt32(ddFieldSize.SelectedValue); _SurfaceField.labelSize = Convert.ToInt32(ddLabelSize.SelectedValue); /* CVH 2016-01-22 RelField */ if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.RelationalField) _SurfaceField.relationalFields = ddSurfaceAppFields.SelectedValue; if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Label) { _SurfaceField.relationalSurface = ddLabelSurface.SelectedValue; _SurfaceField.relationalFields = ddLabelSource.SelectedValue; _SurfaceField.relationalValues = txtStaticLabel.Text; } /*JasR 2016-01-13*/ if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Content) { int contentID = 0; int.TryParse(ddContent.SelectedValue, out contentID); _SurfaceField.contentId = contentID; } /*JasR 2016-01-15*/ if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Date) { _SurfaceField.defaultToCurrent = chkDefaultCurrent.Checked; if (ddSurfaceDateType.SelectedItem != null) _SurfaceField.surfaceDateTypeId = int.Parse(ddSurfaceDateType.SelectedValue); _SurfaceField.defaultValue = dtDefaultDate.Text; } /*JasR 2016-01-15*/ _SurfaceField.isControlled = false; _SurfaceField.controlledValue = ""; if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Number) { _SurfaceField.isControlled = chkIsControlled.Checked; _SurfaceField.controlledValue = txtControlledValue.Value; } else if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Group) { _SurfaceField.isControlled = chkGroupDefaultCollapsed.Checked; } //CVH 2017-02-28 Using isControlled to indicate that grid is summarized values of a child grid else if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Grid) { if (divSummaryGrid.Visible) _SurfaceField.isControlled = chkSummaryGrid.Checked; } //CVH 2017-02-28 Moved this here, to keep all isControlled values together, in case we overriding it unintentionally else if (_SurfaceField.actionType == pNums.ActionType.GenerateCode.GetHashCode()) { _SurfaceField.isControlled = true; } if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Control) { int controlID = 0; int.TryParse(ddControls.SelectedValue, out controlID); _SurfaceField.controlledValue = controlID.ToString(); if (controlID == pNums.Module.ImageMap.GetHashCode()) { UploadImageMapControlImage(ref _SurfaceField); } else if (controlID == pNums.Module.SurfaceNotes.GetHashCode()) { _SurfaceField.isControlled = chkIsConfidential.Checked; } } /*JasR 2016-01-16*/ //if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Button || _SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Checkbox || _SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Mediswitch) //{ _SurfaceField.controlText = txtControlText.Value; //} if (_SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Composite) { int contentID = 0; int.TryParse(ddComposite.SelectedValue, out contentID); _SurfaceField.contentId = contentID; } //CVH 2016-11-14 Only save action values when the div is visible, otherwise it saves values incorrectly if (actionSourceGroup.Visible && ddActionSource.SelectedValue != null && ddActionSource.SelectedValue != "") _SurfaceField.actionSource = Convert.ToInt32(ddActionSource.SelectedValue); else _SurfaceField.actionSource = 0; if (actionGroup.Visible && ddActions.SelectedValue != null && ddActions.SelectedValue != "") _SurfaceField.action = Convert.ToInt32(ddActions.SelectedValue); else _SurfaceField.action = 0; if (actionTypeGroup.Visible && ddActionTypes.SelectedValue != null && ddActionTypes.SelectedValue != "") { _SurfaceField.actionType = Convert.ToInt32(ddActionTypes.SelectedValue); _SurfaceField.actionValue = ""; if (actionValueGroup.Visible && (_SurfaceField.actionType == pNums.ActionType.ToggleView.GetHashCode() || _SurfaceField.actionType == pNums.ActionType.Button.GetHashCode())) { _SurfaceField.actionValue = txtActionValue.Text; } else if (lookupCalcSurfaceGroup.Visible && ddLookupCalcSurface.SelectedItem != null && _SurfaceField.actionType == pNums.ActionType.Calculation.GetHashCode()) { if (lookupCalcSurfaceFieldGroup.Visible && ddLookupCalcSurfaceField.SelectedItem != null) _SurfaceField.actionValue = ddLookupCalcSurfaceField.SelectedItem.Value.ToString(); else _SurfaceField.actionValue = ddLookupCalcSurface.SelectedItem.Value.ToString(); } else if (actionSourceGroup2.Visible && ddActionSource2.SelectedItem != null && _SurfaceField.actionType == pNums.ActionType.Calculation.GetHashCode()) { _SurfaceField.actionValue = ddActionSource2.SelectedItem.Value; } //CVH 2017-02-21 Aggregation Sum if (_SurfaceField.actionType == (int)pNums.ActionType.Aggregation && ddAggregationSurface.SelectedItem != null) { _SurfaceField.actionValue = ddAggregationSurface.SelectedItem.Value; } //CVH 2017-03-16 Styling Text Colour else if (_SurfaceField.actionType == (int)pNums.ActionType.Styling && stylingTextColourGroup.Visible) { // Rule|Value|Colour eg "<|60|Red" string stylingRule = ""; if (ddStylingTextColourRule.SelectedItem != null) { if (ddStylingTextColourRule.SelectedItem.Value == "Less Than") stylingRule = "<"; } string stylingValue = txtStylingTextColourValue.Text; string stylingColour = ""; if (ddStylingTextColourColour.SelectedItem != null) stylingColour = ddStylingTextColourColour.SelectedItem.Value; _SurfaceField.actionValue = stylingRule + "|" + stylingValue + "|" + stylingColour; } else if (_SurfaceField.actionType == (int)pNums.ActionType.FieldAggregation && lstFieldAggregation.SelectedItem != null) { string actionValue = ""; foreach (ListItem item in lstFieldAggregation.Items.GetSelectedItems()) { if (item.Selected) actionValue += item.Value.ToString() + "|"; } _SurfaceField.actionValue = actionValue; } } else { _SurfaceField.actionType = 0; _SurfaceField.actionValue = ""; } _SurfaceField.validationType = Convert.ToInt32(ddlValidationType.SelectedValue); _SurfaceField.enableBulkUpdate = false; if (divBulkUpdate.Visible) _SurfaceField.enableBulkUpdate = chkBulkUpdate.Checked; _SurfaceField.isCurrency = false; if (divCurrency.Visible) _SurfaceField.isCurrency = chkCurrency.Checked; _SurfaceField.isVerticalHeader = chkVerticalHeader.Checked; _SurfaceField.isCloneable = false; if (divIsCloneable.Visible) _SurfaceField.isCloneable = chkIsCloneable.Checked; //GR 2017-07-04 Custom source _SurfaceField.isCustomSource = chkUseCustomSource.Checked; if (_SurfaceField.isCustomSource) { _SurfaceField.relationalObject = ddCustomSource.SelectedValue; var fields = lstRelationalFieldDisplay.Items.GetSelectedItems(); _SurfaceField.relationalFields = String.Join(",", fields.Select(x => x.Value).ToArray()); _SurfaceField.relationalValues = ddRelationalFieldValue.SelectedValue; _SurfaceField.relationalOrderBy = txtRelationalOrderBy.Text; _SurfaceField.relationalWhere = txtRelationalWhere.Text; } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Toggle Field Types /// /// /// REVISION 001: Add Grid field type /// AUTHOR: Charlene van Heerden /// DATE MODIFIED: 10 December 2015 /// private void ToggleFieldTypes() { try { //set default views lookupGroup.Visible = false; moduleLookupGroup.Visible = false; validationGroup.Visible = true; lengthGroup.Visible = true; controlSizeGroup.Visible = true; labelSizeGroup.Visible = true; surfaceApp.Visible = false; surfaceAppFields.Visible = false; content.Visible = false; defaultDataCurrent.Visible = false; isControlled.Visible = false; divConfidentialNotes.Visible = false; controlledValue.Visible = false; controlText.Visible = true; isAutoPostback.Visible = false; parentGroup.Visible = true; //CVH 2017-02-14 Subtab. Get currently selected parent, then rebind parent dropdown, then reselect if list is the same (list depends on field type) string selectedParentId = "0"; if (ddParentFields.SelectedItem != null) selectedParentId = ddParentFields.SelectedItem.Value; BindParentFields(); if (ddParentFields.Items.FindByValue(selectedParentId) != null) ddParentFields.Items.FindByValue(selectedParentId).Selected = true; divGridActive.Visible = true; divIsGrouped.Visible = true; divFilter.Visible = true; divComparable.Visible = true; divHiddenField.Visible = true; divHiddenWizzard.Visible = false; divHiddenView.Visible = false; divHiddenForm.Visible = false; divReadOnlyField.Visible = true; divIsCloneable.Visible = true; //GR 2017-07-04 custom source options customSourceOpt.Visible = false; customSourceLookup.Visible = false; customSourceFieldDisplay.Visible = false; customSourceFieldValue.Visible = false; customSourceWhere.Visible = false; customSourceOrderBy.Visible = false; //GR 2017-08-04 Signature Config pnlSurfaceSignatureConfig.Visible = false; divAlternateView.Visible = false; divNewLine.Visible = true; divBottomBorder.Visible = true; divFullBorder.Visible = true; placeholderGroup.Visible = false; compositeGroup.Visible = false; //JR Bas-Pro-3 divUnique.Visible = false; mapFieldsGroup.Visible = false; controlsGroup.Visible = false; controlsImageMapGroup.Visible = false; dateTypeGroup.Visible = false; labelSurfaceGroup.Visible = false; labelSourceGroup.Visible = false; rowLimitGroup.Visible = false; lblMaxLength.Text = "Max Length"; divLabelHidden.Visible = true; divGroupDefaultCollapsed.Visible = false; validationTypeGroup.Visible = false; //CVH 2017-02-16 Enable for picklists and caption for now. Adding Number and Decimal. divBulkUpdate.Visible = false; divCurrency.Visible = false; //CVH 2017-02-28 Summary grid - summarizes child grid values into this parent grid divSummaryGrid.Visible = false; pNums.FieldType typ = (pNums.FieldType)Enum.ToObject(typeof(pNums.FieldType), int.Parse(ddFieldTypes.SelectedValue)); //CVH 2017-02-28 Set action properties for all field types (will clear it for non action typed) SetActionProperties((int)typ); //change views based on selected field type switch (typ) { case pNums.FieldType.Tab: //CVH 2017-02-14 Subtab. Show parent group //parentGroup.Visible = false; validationGroup.Visible = false; lengthGroup.Visible = false; controlSizeGroup.Visible = false; labelSizeGroup.Visible = false; divGridActive.Visible = false; divIsGrouped.Visible = false; divFilter.Visible = false; divComparable.Visible = false; divHiddenField.Visible = false; divReadOnlyField.Visible = true; divHiddenWizzard.Visible = true; divHiddenView.Visible = true; divHiddenForm.Visible = true; divLabelHidden.Visible = false; divNewLine.Visible = false; divBottomBorder.Visible = false; divFullBorder.Visible = false; isAutoPostback.Visible = true; divIsCloneable.Visible = false; break; case pNums.FieldType.Group: validationGroup.Visible = false; lengthGroup.Visible = false; controlSizeGroup.Visible = false; labelSizeGroup.Visible = false; divGridActive.Visible = false; divIsGrouped.Visible = false; divLabelHidden.Visible = false; divFilter.Visible = false; divComparable.Visible = false; divHiddenField.Visible = true; divReadOnlyField.Visible = false; divNewLine.Visible = false; divBottomBorder.Visible = false; divFullBorder.Visible = false; divGroupDefaultCollapsed.Visible = true; divIsCloneable.Visible = false; break; case pNums.FieldType.HeaderGroup: parentGroup.Visible = false; validationGroup.Visible = false; lengthGroup.Visible = false; controlSizeGroup.Visible = false; labelSizeGroup.Visible = false; divGridActive.Visible = false; divIsGrouped.Visible = false; divFilter.Visible = false; divLabelHidden.Visible = false; divComparable.Visible = false; divHiddenField.Visible = true; divReadOnlyField.Visible = false; divIsCloneable.Visible = false; break; case pNums.FieldType.Text: isAutoPostback.Visible = true; placeholderGroup.Visible = true; //JR Bas-Pro-3 divUnique.Visible = true; validationTypeGroup.Visible = true; break; case pNums.FieldType.Number: isAutoPostback.Visible = true; isControlled.Visible = true; if (chkIsControlled.Checked) controlledValue.Visible = true; //JR Bas-Pro-3 divUnique.Visible = true; divCurrency.Visible = true; divBulkUpdate.Visible = true; break; case pNums.FieldType.Decimal: isAutoPostback.Visible = true; divCurrency.Visible = true; divBulkUpdate.Visible = true; break; case pNums.FieldType.Picklist: lookupGroup.Visible = true; moduleLookupGroup.Visible = true; lblLookupCat.Text = "Picklist Category"; lengthGroup.Visible = false; isAutoPostback.Visible = true; divBulkUpdate.Visible = true; customSourceOpt.Visible = true; break; case pNums.FieldType.MultiPicklist: lookupGroup.Visible = true; moduleLookupGroup.Visible = true; divAlternateView.Visible = true; lblLookupCat.Text = "Picklist Category"; lengthGroup.Visible = false; isAutoPostback.Visible = true; break; case pNums.FieldType.Date: isAutoPostback.Visible = true; lengthGroup.Visible = false; /* CVH 2016-10-19 Using Default Current checkbox for Grid Default data to master data */ lblDefaultCurrent.Text = "Default"; chkDefaultCurrent.Text = "Current"; defaultDataCurrent.Visible = true; dateTypeGroup.Visible = true; break; case pNums.FieldType.Checkbox: lengthGroup.Visible = false; controlText.Visible = true; isAutoPostback.Visible = true; break; case pNums.FieldType.RadioButtonList: isAutoPostback.Visible = true; lookupGroup.Visible = true; lblLookupCat.Text = "RadioButtonList Category"; lengthGroup.Visible = false; divAlternateView.Visible = true; customSourceOpt.Visible = true; break; case pNums.FieldType.Button: lengthGroup.Visible = false; controlText.Visible = true; validationGroup.Visible = false; divIsCloneable.Visible = false; break; case pNums.FieldType.Grid: lengthGroup.Visible = false; surfaceApp.Visible = true; validationGroup.Visible = false; /* CVH 2016-10-19 Using Default Current checkbox for Grid Default data to master data */ lblDefaultCurrent.Text = "Default Data"; chkDefaultCurrent.Text = "Copy from master"; dtDefaultDate.Visible = false; defaultDataCurrent.Visible = true; rowLimitGroup.Visible = true; divSummaryGrid.Visible = true; divIsCloneable.Visible = false; break; case pNums.FieldType.Attachment: lengthGroup.Visible = false; divIsCloneable.Visible = false; break; case pNums.FieldType.RelationalField: lengthGroup.Visible = false; surfaceApp.Visible = true; surfaceAppFields.Visible = true; validationGroup.Visible = false; divAlternateView.Visible = true; divIsCloneable.Visible = false; break; case pNums.FieldType.FormulaField: break; case pNums.FieldType.Content: content.Visible = true; lengthGroup.Visible = false; validationGroup.Visible = false; break; case pNums.FieldType.Placeholder: lengthGroup.Visible = false; divIsCloneable.Visible = false; break; //JasR 2016-01-27 case pNums.FieldType.Caption: isAutoPostback.Visible = false; placeholderGroup.Visible = true; divBulkUpdate.Visible = true; divIsCloneable.Visible = false; break; case pNums.FieldType.Note: lengthGroup.Visible = false; divIsCloneable.Visible = false; break; case pNums.FieldType.Debtors: lengthGroup.Visible = false; mapFieldsGroup.Visible = true; divIsCloneable.Visible = false; break; case pNums.FieldType.Mediswitch: lengthGroup.Visible = false; controlText.Visible = true; divIsCloneable.Visible = false; break; case pNums.FieldType.Composite: lengthGroup.Visible = false; compositeGroup.Visible = true; divIsCloneable.Visible = false; break; case pNums.FieldType.Address: break; case pNums.FieldType.CheckboxList: isAutoPostback.Visible = true; lookupGroup.Visible = true; lblLookupCat.Text = "CheckboxList Category"; lengthGroup.Visible = false; divAlternateView.Visible = true; break; case pNums.FieldType.Sales: lengthGroup.Visible = false; mapFieldsGroup.Visible = true; divIsCloneable.Visible = false; break; case pNums.FieldType.Control: divAlternateView.Visible = true; divIsCloneable.Visible = false; controlsGroup.Visible = true; ToggleControlDisplay(); break; case pNums.FieldType.Label: validationGroup.Visible = false; labelSurfaceGroup.Visible = true; labelSourceGroup.Visible = true; divIsCloneable.Visible = false; break; case pNums.FieldType.Image: lblMaxLength.Text = "Max Height"; break; } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } private void ClearActionControls() { //action source actionSourceGroup.Visible = false; ddActionSource.ClearSelection(); ddActionSource.Items.Clear(); //action source 2 actionSourceGroup2.Visible = false; ddActionSource2.ClearSelection(); ddActionSource2.Items.Clear(); //action value actionValueGroup.Visible = false; txtActionValue.Text = ""; //field aggregation fieldAggregationGroup.Visible = false; lstFieldAggregation.ClearSelection(); lstFieldAggregation.Items.Clear(); //styling text stylingTextColourGroup.Visible = false; txtStylingTextColourValue.Text = ""; //aggregation aggregationSurfaceGroup.Visible = false; ddAggregationSurface.ClearSelection(); ddAggregationSurface.Items.Clear(); //lookup calc lookupCalcSurfaceGroup.Visible = false; ddLookupCalcSurface.ClearSelection(); ddLookupCalcSurface.Items.Clear(); //lookup calc field lookupCalcSurfaceFieldGroup.Visible = false; ddLookupCalcSurfaceField.ClearSelection(); ddLookupCalcSurfaceField.Items.Clear(); } /// /// set action properties /// private void SetActionProperties(int fieldType) { //CVH 2017-06-30 Cleanup. oSurfaceField field = new oSurfaceField(); if (utils.verifySession("surfaceField")) { field = (oSurfaceField)Session["surfaceField"]; } if (field.surfaceId == 0 && utils.verifySession("surfaceId")) field.surfaceId = int.Parse(Session["surfaceId"].ToString()); field.surfaceFieldTypeId = fieldType; //clear all action values //action type actionTypeGroup.Visible = false; ddActionTypes.ClearSelection(); //action actionGroup.Visible = false; ddActions.ClearSelection(); ddActions.Items.Clear(); ClearActionControls(); pNums.FieldType typ = (pNums.FieldType)Enum.ToObject(typeof(pNums.FieldType), field.surfaceFieldTypeId); switch (typ) { case pNums.FieldType.Text: case pNums.FieldType.Number: case pNums.FieldType.Decimal: case pNums.FieldType.Picklist: case pNums.FieldType.MultiPicklist: case pNums.FieldType.Date: case pNums.FieldType.Checkbox: case pNums.FieldType.RadioButtonList: case pNums.FieldType.Grid: case pNums.FieldType.Attachment: case pNums.FieldType.FormulaField: case pNums.FieldType.Caption: case pNums.FieldType.Address: case pNums.FieldType.CheckboxList: actionTypeGroup.Visible = true; if (ddActionTypes.Items.FindByValue(field.actionType.ToString()) != null) { ddActionTypes.SelectedValue = field.actionType.ToString(); BindActions(field.actionType.ToString()); string action = ""; if (ddActions.Items.FindByValue(field.action.ToString()) != null) { ddActions.SelectedValue = field.action.ToString(); if (ddActions.SelectedItem.Value != "0") action = ddActions.SelectedItem.Text; } ToggleAction(field.surfaceId, field.actionType, action, field.actionSource, field.actionValue); } break; } /* actionValueGroup.Visible = false; actionSourceGroup2.Visible = false; actionTypeGroup.Visible = true; if (ddActionTypes.SelectedIndex > 0) { if (ddActionTypes.SelectedValue == pNums.ActionType.ToggleView.GetHashCode().ToString()) actionValueGroup.Visible = true; else if (ddActionTypes.SelectedValue == pNums.ActionType.Button.GetHashCode().ToString()) { actionValueGroup.Visible = true; lblActionValue.InnerText = "Copy Button Text"; } actionGroup.Visible = true; if (ddActions.SelectedIndex > 0) { if (ddActionTypes.SelectedValue == pNums.ActionType.GenerateCode.GetHashCode().ToString() || ddActionTypes.SelectedValue == pNums.ActionType.Styling.GetHashCode().ToString()) actionSourceGroup.Visible = false; else actionSourceGroup.Visible = true; if (ddActions.SelectedItem.Text == "Ranking" || ddActions.SelectedItem.Text == "Divide") actionSourceGroup2.Visible = true; } }*/ } /// /// Bind Surface Apps /// private void BindSurfaceApps() { try { ArrayList surfaceApps = xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "isActive", "1", "surface"); ddSurfaceApps.DataSource = surfaceApps; ddSurfaceApps.DataTextField = "surface"; ddSurfaceApps.DataValueField = "name"; ddSurfaceApps.DataBind(); ddSurfaceApps.Items.Insert(0, new ListItem("Select Surface", "0")); /* CVH 2016-01-22 Add 0 item */ ddSurfaceAppFields.Items.Insert(0, new ListItem("Select Surface Field", "0")); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Bind Surface App Fields /// private void BindSurfaceAppFields(string surfaceName) { try { foreach (oSurface surface in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "name", surfaceName)) { ArrayList surfaceAppFields = xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "surfaceId,isActive,surfaceFieldTypeId", surface.recId + ",1,~>2"); ddSurfaceAppFields.DataSource = surfaceAppFields; ddSurfaceAppFields.DataTextField = "surfaceFieldDisplay"; ddSurfaceAppFields.DataValueField = "recId"; ddSurfaceAppFields.DataBind(); } ddSurfaceAppFields.Items.Insert(0, new ListItem("Select Surface Field", "0")); } catch (Exception ex) { exception.HandleException("canvas:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Bind Content Items /// private void BindContent() { try { ArrayList contentItems = xData.GetTypedByCriteriaSpecific("recId", typeof(oContent), "isActive", "1", "title"); ddContent.DataSource = contentItems; ddContent.DataTextField = "title"; ddContent.DataValueField = "recId"; ddContent.DataBind(); ddContent.Items.Insert(0, new ListItem("Select Content", "0")); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Bind Composite Items /// private void BindComposite() { try { ArrayList compositeItems = xData.GetTypedByCriteriaSpecific("recId", typeof(oComposite), "", "", "composite"); ddComposite.DataSource = compositeItems; ddComposite.DataTextField = "composite"; ddComposite.DataValueField = "canvasId"; ddComposite.DataBind(); ddComposite.Items.Insert(0, new ListItem("Select Composite", "0")); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// toggle Custom source /// private void ToggleCustomSource() { try { if (chkUseCustomSource.Checked) { lookupGroup.Visible = false; moduleLookupGroup.Visible = false; customSourceOpt.Visible = true; customSourceLookup.Visible = true; customSourceFieldDisplay.Visible = true; customSourceFieldValue.Visible = true; customSourceWhere.Visible = true; customSourceOrderBy.Visible = true; } else { lookupGroup.Visible = true; moduleLookupGroup.Visible = true; customSourceLookup.Visible = false; customSourceFieldDisplay.Visible = false; customSourceFieldValue.Visible = false; customSourceWhere.Visible = false; customSourceOrderBy.Visible = false; } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Toggle display for certain control selections /// private void ToggleControlDisplay() { try { //default views controlsImageMapGroup.Visible = false; divConfidentialNotes.Visible = false; pnlSurfaceSignatureConfig.Visible = false; if (ddControls.SelectedValue != null && ddControls.SelectedValue != String.Empty) { pNums.Module mod = (pNums.Module)Enum.ToObject(typeof(pNums.Module), int.Parse(ddControls.SelectedValue)); switch (mod) { case pNums.Module.ImageMap: controlsImageMapGroup.Visible = true; break; case pNums.Module.SurfaceNotes: divConfidentialNotes.Visible = true; break; case pNums.Module.SurfaceSignature: pnlSurfaceSignatureConfig.Visible = true; break; } } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Bind fields for selected custom source table /// private void BindCustomSourceTables() { SqlCommand command = new SqlCommand(); try { DataTable dtTables = constructor.GetTables().Tables[0]; ddCustomSource.DataSource = dtTables; ddCustomSource.DataValueField = "tableName"; ddCustomSource.DataTextField = "tableName"; ddCustomSource.DataBind(); ddCustomSource.Items.Insert(0, new ListItem("select source", "")); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } finally { dataTier.CommandMethods.CompleteSQLCommand(ref command); } } /// /// Bind fields for selected custom source table /// private void BindCustomSourceFields() { SqlCommand command = new SqlCommand(); try { ArrayList fields = new ArrayList(); if (ddCustomSource.SelectedValue != "") { command = dataTier.CommandMethods.BeginSQLCommand(); fields = constructor.GetTableFields(ddCustomSource.SelectedValue, ref command); lstRelationalFieldDisplay.DataTextField = "fieldName"; lstRelationalFieldDisplay.DataValueField = "fieldName"; ddRelationalFieldValue.DataTextField = "fieldName"; ddRelationalFieldValue.DataValueField = "fieldName"; } lstRelationalFieldDisplay.DataSource = fields; lstRelationalFieldDisplay.DataBind(); ddRelationalFieldValue.DataSource = fields; ddRelationalFieldValue.DataBind(); ddRelationalFieldValue.Items.Insert(0, new ListItem("select", "")); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } finally { dataTier.CommandMethods.CompleteSQLCommand(ref command); } } /// /// Toggle Field State for Published Apps /// /// private void ToggleFieldStatePublished(bool isNew) { oSurface _surface = new oSurface(); bool _enable = true; if (utils.verifySession("surface")) { _surface = (oSurface)Session["surface"]; } if (_surface.isPublished && !Debugger.IsAttached)//check if published and not debugging { _enable = isNew; } txtDisplay.Disabled = !_enable; ddFieldTypes.Enabled = _enable; ddParentFields.Enabled = _enable; ddControls.Enabled = _enable; ddSurfaceDateType.Enabled = _enable; ddLabelSurface.Enabled = _enable; ddLabelSource.Enabled = _enable; txtStaticLabel.Enabled = _enable; ddLookupCategory.Enabled = _enable; btnManagePicklists.Enabled = _enable; ddModuleLookup.Enabled = _enable; ddModuleSurface.Enabled = _enable; ddModuleSurfaceField.Enabled = _enable; chkUseCustomSource.Enabled = _enable; ddCustomSource.Enabled = _enable; lstRelationalFieldDisplay.Enabled = _enable; ddRelationalFieldValue.Enabled = _enable; txtRelationalWhere.Enabled = _enable; txtRelationalOrderBy.Enabled = _enable; ddComposite.Enabled = _enable; chkIsControlled.Enabled = _enable; txtControlledValue.Disabled = !_enable; txtLength.Disabled = !_enable; chkActiveField.Enabled = _enable; //chkHiddenField.Enabled = _enable; chkComparable.Enabled = _enable; chkCurrency.Enabled = _enable; chkSummaryGrid.Enabled = _enable; } #endregion #region events /// /// Page Load Event /// /// /// protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { BindSurfaceData(); BindFieldTypes(); BindSurfaceDateTypes(); BindControls(); BindSequence(); BindLookupCategories(); BindSurfaceApps(); BindContent(); BindComposite(); BindActionTypes(); BindLabelSourceSurface(); BindAggregationSurface(); BindAccessLevel(); BindValidationTypes(); BindCustomSourceTables(); } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } private void BindLinkedSurfaces(int surfaceId) { try { DataTable surfaceApps = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurface), "isActive,recId", "1,~<>" + surfaceId.ToString(), "surface"); lstLinkedSurfaces.DataSource = surfaceApps; lstLinkedSurfaces.DataTextField = "surface"; lstLinkedSurfaces.DataValueField = "recId"; lstLinkedSurfaces.DataBind(); foreach (oSurfaceLink surfaceLink in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceLink), "surfaceId", surfaceId.ToString(), "")) { lstLinkedSurfaces.Items.FindByValue(surfaceLink.linkedSurfaceId.ToString()).Selected = true; } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Preview /// /// /// protected void lnkPreview_Click(object sender, EventArgs e) { oSurface Surface = new oSurface(); try { if (utils.verifySession("surface")) { Surface = (oSurface)Session["surface"]; Session["surfaceApp"] = Surface; PlaceHolder plcPreview = (PlaceHolder)Page.Master.FindControl("plcPreview"); UpdatePanel upPreview = (UpdatePanel)Page.Master.FindControl("upPreview"); if (!File.Exists(Server.MapPath(surfacePath + Surface.name + ".ascx.cs"))) { BuildControl(Surface); } plcPreview.Controls.Clear(); //UserControl uc = (UserControl)LoadControl(surfacePath + Surface.name + ".ascx"); ISurfaceBase uc = (ISurfaceBase)LoadControl(surfacePath + Surface.name + ".ascx"); uc.SurfaceApp = Surface; plcPreview.Controls.Add(uc); upPreview.Update(); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myModalPreview", "$('#modPreview').modal();", true); } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// New Surface Click /// /// /// protected void btnNewSurface_Click(object sender, EventArgs e) { try { //show Surface Specific TogglePanels("pnlSurfaceApp"); Session["surfaceId"] = 0; utils.disposeSession("surface"); oSurface Surface = new oSurface(); PopulatePageFormValues(ref Surface); Session["surfaceFieldId"] = 0; utils.disposeSession("surfaceField"); BindSurfaceFields(); BindFilterTabs(); BindFilterGroups(); //show cat list TogglePanelsSurfaceFields("pnlSurfaceFields"); upSurfaceFields.Update(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Edit the Surface page /// /// /// protected void lnkEdit_Click(object sender, EventArgs e) { oSurface _Surface = new oSurface(); ArrayList catList = new ArrayList(); try { if (sender.GetType() == typeof(LinkButton)) { // int recId = int.Parse(((LinkButton)sender).CommandArgument); if (recId > 0) { Session["surfaceId"] = recId; //get cat catList = xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "recId", recId.ToString()); //enumerate list foreach (oSurface cat in catList) { //assign object _Surface = cat; //populate page form PopulatePageFormValues(ref _Surface); Session["surface"] = _Surface; break; } //show Surface Form TogglePanels("pnlSurfaceApp"); BindSurfaceFields(); BindFilterTabs(); BindFilterGroups(); TogglePanelsSurfaceFields("pnlSurfaceFields"); } } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Remove the Surface /// /// /// /// /// REVISION 001: Add function to delete SurfaceGridOptions before deleting SurfaceGrid, otherwise get FK error when deleting Surface /// AUTHOR: Charlene van Heerden /// DATE: 7 December 2015 /// protected void lnkRemove_Click(object sender, EventArgs e) { try { if (sender.GetType() == typeof(LinkButton)) { // int recId = int.Parse(((LinkButton)sender).CommandArgument); foreach (oSurface surfApp in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "recId", recId.ToString())) { //JR 2017-02-22 - it's too risky to delete everything. will just set surface to inactive. so delete needs to have manual developer intervention surfApp.isActive = false; xData.UpdateTyped("recId", surfApp.recId.ToString(), typeof(oSurface), surfApp); ////remove date //if (xData.DeleteTyped("surfaceId", recId.ToString(), typeof(oSurfaceFieldData))) //{ // if (xData.DeleteTyped("surfaceId", recId.ToString(), typeof(oSurfaceItem))) // { // //remove suface app fields // if (xData.DeleteTyped("surfaceId", recId.ToString(), typeof(oSurfaceField))) // { // /* REV 001: Delete SurfaceGridOptions // * Charlene van Heerden // * 7 December 2015 // */ // //Delete surface grid options // if (xData.DeleteTyped("surfaceId", recId.ToString(), typeof(oSurfaceGridOptions))) // { // //Delete surface // if (xData.DeleteTyped("recId", recId.ToString(), typeof(oSurface))) // { // //delete the control // File.Delete(HttpContext.Current.Server.MapPath(surfacePath + surfApp.name + ".ascx")); // File.Delete(HttpContext.Current.Server.MapPath(surfacePath + surfApp.name + ".ascx.cs")); // //rebind pages grid // BindSurfaceData(); // pnlResult.Visible = true; // //display successful result // lblResult.Text = "the selected Surface was deleted successfully."; // } // } // } // } //} //rebind pages grid BindSurfaceData(); pnlResult.Visible = true; //display successful result lblResult.Text = "the selected Surface was deactivated successfully."; } } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Cancel /// /// /// protected void btnCancel_Click(object sender, EventArgs e) { try { Session["surfaceId"] = 0; utils.disposeSession("surface"); BindSurfaceData(); //show cat list TogglePanels("pnlSurfaceList"); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Save Click /// /// /// protected void btnSave_Click(object sender, EventArgs e) { oSurface Surface = new oSurface(); try { if (utils.verifySession("surface"))//update mode { Surface = (oSurface)Session["surface"]; //save form values SavePageFormValues(ref Surface); if (xData.UpdateTyped("recId", Surface.recId.ToString(), typeof(oSurface), Surface)) { SaveLinkedSurfaces(Surface.recId); BuildControl(Surface); Session["surfaceId"] = Surface.recId; Session["surface"] = Surface; BindSurfaceData(); pnlResult.Visible = true; lblResult.Text = "your changes were updated successfully."; } } else { if (!xData.VerifyExists("recId", typeof(oSurface), "name", utils.stripCharacters(txtSurface.Value).Replace(" ", ""))) { Surface.isActive = true; Surface.dateCreated = DateTime.Now; //save form values SavePageFormValues(ref Surface); Surface.recId = xData.SaveTyped("recId", typeof(oSurface), Surface); if (Surface.recId > 0) { SaveLinkedSurfaces(Surface.recId); BuildControl(Surface); Session["surfaceId"] = Surface.recId; Session["surface"] = Surface; BindSurfaceData(); pnlResult.Visible = true; lblResult.Text = "your surface app was created successfully."; } } else { pnlResult.Visible = true; lblResult.Text = "A surface app with this name already exists on the system"; } } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } private void SaveLinkedSurfaces(int recId) { try { foreach (oSurfaceLink linkitem in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceLink), "surfaceId", recId.ToString())) { bool found = false; foreach (ListItem item in lstLinkedSurfaces.Items.GetSelectedItems()) { if (item.Value.ToString() == linkitem.linkedSurfaceId.ToString()) found = true; } if (!found) xData.DeleteTyped("recId", linkitem.recId.ToString(), typeof(oSurfaceLink)); } foreach (ListItem item in lstLinkedSurfaces.Items.GetSelectedItems()) { bool found = false; foreach (oSurfaceLink linkitem in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceLink), "surfaceId,linkedSurfaceId", recId.ToString() + "," + item.Value.ToString())) { found = true; } if (!found) { oSurfaceLink surfaceLink = new oSurfaceLink(); surfaceLink.surfaceId = recId; surfaceLink.linkedSurfaceId = Convert.ToInt32(item.Value.ToString()); xData.SaveTyped("recId", typeof(oSurfaceLink), surfaceLink); } } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Close Picklist Modal /// /// /// protected void btnClosePicklist_Click(object sender, EventArgs e) { try { BindLookupCategories(); upSurfaceFields.Update(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Bind Lookup categories /// /// /// protected void btnClose_Click(object sender, EventArgs e) { try { BindLookupCategories(); upSurfaceFields.Update(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Close Categpry /// /// /// protected void btnCloseCategory_Click(object sender, EventArgs e) { try { BindLookupCategories(); surfaceLookups1.ReloadControl(); upSurfaceFields.Update(); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myPicklistModal", "$('#modLoookups').modal();", true); } catch (Exception ex) { exception.HandleException("surfaceLookups", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Manage Picklists /// /// /// protected void btnManagePicklists_Click(object sender, EventArgs e) { try { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myPicklistModal", "$('#modLoookups').modal();", true); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } protected void btnLookCat_Click(object sender, EventArgs e) { try { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myCatModal", "$('#modLookupCategories').modal();", true); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// manage Grid Options /// /// /// protected void btnGrid_Click(object sender, EventArgs e) { try { btnSave_Click(sender, e); surfaceGrids1.ReloadControl(); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myGridOptionsModal", "$('#modGridOptions').modal();", true); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Close Grid Options /// /// /// protected void btnCloseGridOptions_Click(object sender, EventArgs e) { try { upSurfaceFields.Update(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// File Uploaded /// /// /// protected void radDataUpload_FileUploaded(object sender, FileUploadedEventArgs e) { try { if (utils.verifySession("surface")) { if (File.Exists(Server.MapPath("upload/data/data.xlsx"))) { File.Delete(Server.MapPath("upload/data/data.xlsx")); } oSurface surface = (oSurface)Session["surface"]; utils.validateFolder(Server.MapPath("upload/data/")); radDataUpload.TargetFolder = Server.MapPath("upload/data/"); string newfilename = "data.xlsx"; e.File.SaveAs(radDataUpload.TargetFolder + newfilename, true); } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Upload File /// /// /// protected void lnkUpload_Click(object sender, EventArgs e) { DataTable importData = new DataTable(); try { if (utils.verifySession("surface")) { oSurface surface = (oSurface)Session["surface"]; if (File.Exists(Server.MapPath("upload/data/data.xlsx"))) { importData = utils.getDataTableFromExcel(Server.MapPath("upload/data/data.xlsx")); if (importData.Rows.Count > 0)//we have records { if (surfaceHandler.ImportDataToSurface(importData, surface.recId)) { BuildControl(surface); pnlResultExport.Visible = true; lblResultExport.Text = "Data imported sucessfully."; } } } } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Export Template /// /// /// protected void lnkExportTemplate_Click(object sender, EventArgs e) { try { if (utils.verifySession("surface")) { oSurface surface = (oSurface)Session["surface"]; DataTable data = xData.GetSurfaceDataAll(surface.recId, false); data.Clear(); if (File.Exists(Server.MapPath(tempPath + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx"))) File.Delete(Server.MapPath(tempPath + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx")); data.Columns.Remove("itemID"); data.Columns.Remove("surfaceId"); data.Columns.Remove("isActive"); foreach (DataColumn col in data.Columns) { col.ColumnName = col.ColumnName.Replace("_", "-:-"); } //data.Clear(); utils.ExportDataTabletoExcel(data, Server.MapPath(tempPath + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx")); Response.Clear(); //Set the appropriate ContentType. Response.ContentType = "Application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx" + ""); Response.TransmitFile(Server.MapPath(tempPath + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx")); Response.Flush(); Response.SuppressContent = true; ApplicationInstance.CompleteRequest(); pnlResultExport.Visible = true; lblResultExport.Text = "Template exported sucessfully."; } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Export Data /// /// /// protected void lnkExport_Click(object sender, EventArgs e) { try { if (utils.verifySession("surface")) { oSurface surface = (oSurface)Session["surface"]; DataTable data = xData.GetSurfaceDataAll(surface.recId, false); if (File.Exists(Server.MapPath(tempPath + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx"))) File.Delete(Server.MapPath(tempPath + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx")); data.Columns.Remove("itemID"); data.Columns.Remove("surfaceId"); data.Columns.Remove("isActive"); foreach (DataColumn col in data.Columns) { col.ColumnName = col.ColumnName.Replace("_", "-:-"); } //data.Clear(); utils.ExportDataTabletoExcel(data, Server.MapPath(tempPath + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx")); Response.Clear(); //Set the appropriate ContentType. Response.ContentType = "Application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx" + ""); Response.TransmitFile(Server.MapPath(tempPath + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx")); Response.Flush(); Response.SuppressContent = true; ApplicationInstance.CompleteRequest(); pnlResultExport.Visible = true; lblResultExport.Text = "Data exported sucessfully."; } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// check comparable /// /// /// protected void chkIsComparable_CheckedChanged(object sender, EventArgs e) { divColumnCount.Visible = chkIsComparable.Checked; upSurface.Update(); } #endregion #region surface field events /// /// Tabls Selections Changed /// /// /// protected void ddTabs_SelectedIndexChanged(object sender, EventArgs e) { try { BindFilterGroups(); BindSurfaceFields(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Groups Selection ch /// /// /// protected void ddGroups_SelectedIndexChanged(object sender, EventArgs e) { try { BindSurfaceFields(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Item Databound /// /// /// protected void rptSurfaceFields_ItemDataBound(object sender, RepeaterItemEventArgs e) { try { if (e.Item.ItemIndex != -1) { Label lblFieldType = ((Label)e.Item.FindControl("lblFieldType")); pNums.FieldType typ = (pNums.FieldType)Enum.ToObject(typeof(pNums.FieldType), int.Parse(lblFieldType.Text)); switch (typ) { case pNums.FieldType.RelationalField: lblFieldType.Text = "Relational Field"; break; case pNums.FieldType.Mediswitch: lblFieldType.Text = "Mediswitch MSV"; break; default: lblFieldType.Text = typ.ToString(); break; } } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Add New Field /// /// /// protected void btnNewField_Click(object sender, EventArgs e) { oSurface Surface = new oSurface(); try { if (utils.verifySession("surface")) { TogglePanelsSurfaceFields("pnlSurfaceField"); Session["surfaceFieldId"] = 0; utils.disposeSession("surfaceField"); oSurfaceField SurfaceField = new oSurfaceField(); PopulateFieldFormValues(ref SurfaceField); ToggleFieldTypes(); ToggleFieldStatePublished(true); } else { if (!xData.VerifyExists("recId", typeof(oSurface), "name", utils.stripCharacters(txtSurface.Value).Replace(" ", ""))) { Surface.isActive = true; Surface.dateCreated = DateTime.Now; //save form values SavePageFormValues(ref Surface); Surface.recId = xData.SaveTyped("recId", typeof(oSurface), Surface); if (Surface.recId > 0) { Session["surfaceId"] = Surface.recId; Session["surface"] = Surface; BindSurfaceData(); TogglePanelsSurfaceFields("pnlSurfaceField"); Session["surfaceFieldId"] = 0; utils.disposeSession("surfaceField"); oSurfaceField SurfaceField = new oSurfaceField(); PopulateFieldFormValues(ref SurfaceField); ToggleFieldTypes(); ToggleFieldStatePublished(true); } } else { pnlResult.Visible = true; lblResult.Text = "A surface app with this name already exists on the system"; } } upSurfaceFields.Update(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Save Surface field /// /// /// /// /// REVISION 001: Enable Grid field type. Confirm that surface app loading as Grid Field type is not the current surface app being created /// AUTHOR: Charlene van Heerden /// DATE MODIFIED: 10 December 2015 /// protected void btnSaveSurfaceField_Click(object sender, EventArgs e) { oSurfaceField SurfaceField = new oSurfaceField(); oSurface surface = new oSurface(); try { if (utils.verifySession("surface")) { surface = (oSurface)Session["surface"]; if (utils.verifySession("surfaceField"))//update mode { SurfaceField = (oSurfaceField)Session["surfaceField"]; //save form values SaveFieldFormValues(ref SurfaceField); /* Rev 001 If field type is grid, verify that selected surface app is not same as current surface app * Charlene van Heerden * 10 December 2015 */ if (SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Grid && surface.name == SurfaceField.relationalSurface) { pnlResultSurfaceField.Visible = true; lblResultSurfaceField.Text = "The surface app " + surface.name + " cannot be added as a grid field to the surface app " + surface.name + "."; } else if (SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.RelationalField && SurfaceField.relationalFields == "0") { pnlResultSurfaceField.Visible = true; lblResultSurfaceField.Text = "Please select a Surface Field."; } //not sure why it's here - JR 2017/02/08 //else if (SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.RelationalField && surface.name == SurfaceField.relationalSurface) //{ // pnlResultSurfaceField.Visible = true; // lblResultSurfaceField.Text = "A surface field cannot relate to a field on the same surface app."; //} else if (SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Control && SurfaceField.controlledValue == pNums.Module.ImageMap.GetHashCode().ToString() && SurfaceField.placeholder == String.Empty) { pnlResultSurfaceField.Visible = true; lblResultSurfaceField.Text = "Please upload an image."; } else { if (xData.UpdateTyped("recId", SurfaceField.recId.ToString(), typeof(oSurfaceField), SurfaceField)) { BuildControl(surface); Session["surfaceFieldId"] = SurfaceField.recId; Session["surfaceField"] = SurfaceField; pnlResultSurfaceField.Visible = true; lblResultSurfaceField.Text = "your changes were updated successfully."; } } } else { //save form values SaveFieldFormValues(ref SurfaceField); //CVH 2017-03-02 Max field name length allowed 128, otherwise causes problems in stored procs QUOTENAME (max 128 char allowed) if (SurfaceField.surfaceFieldName.Length > 128) { pnlResultSurfaceField.Visible = true; lblResultSurfaceField.Text = "The total surface field name cannot exceed 128 characters. Please choose a shorter Name, use Display Text to display a longer value."; } else if (SurfaceField.parentId == 0 && SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.Tab && SurfaceField.surfaceFieldTypeId != (int)pNums.FieldType.HeaderGroup) { pnlResultSurfaceField.Visible = true; lblResultSurfaceField.Text = "Parent cannot be \"None\"."; } else if (!xData.VerifyExists("recId", typeof(oSurfaceField), "surfaceId,surfaceFieldName", surface.recId + "," + SurfaceField.surfaceFieldName)) { if (SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Grid && surface.name == SurfaceField.relationalSurface) { pnlResultSurfaceField.Visible = true; lblResultSurfaceField.Text = "The surface app " + surface.name + " cannot be added as a grid field to the surface app " + surface.name + "."; } else if (SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.RelationalField && SurfaceField.relationalFields == "0") { pnlResultSurfaceField.Visible = true; lblResultSurfaceField.Text = "Please select a Surface Field."; } //not sure why it's here - JR 2017/02/08 //else if (SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.RelationalField && surface.name == SurfaceField.relationalSurface) //{ // pnlResultSurfaceField.Visible = true; // lblResultSurfaceField.Text = "A surface field cannot relate to a field on the same surface app."; //} else { SurfaceField.surfaceId = surface.recId; SurfaceField.recId = xData.SaveTyped("recId", typeof(oSurfaceField), SurfaceField); if (SurfaceField.recId > 0) { BuildControl(surface); Session["surfaceFieldId"] = SurfaceField.recId; Session["surfaceField"] = SurfaceField; pnlResultSurfaceField.Visible = true; lblResultSurfaceField.Text = "your surface field was created successfully."; } } } else { pnlResultSurfaceField.Visible = true; lblResultSurfaceField.Text = "A surface field with this name already exists on this surface app."; } } //GR 2017-08-04 Save Surface Signature configuration if (SurfaceField.recId > 0 && SurfaceField.surfaceFieldTypeId == (int)pNums.FieldType.Control && SurfaceField.controlledValue == pNums.Module.SurfaceSignature.GetHashCode().ToString()) { oSurfaceSignatureConfig conf = new oSurfaceSignatureConfig(); foreach (oSurfaceSignatureConfig c in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceSignatureConfig), "fieldId", SurfaceField.recId.ToString())) { conf = c; break; } conf.includePhoto = chkSigIncludePhoto.Checked; conf.labelText = txtSigLabelText.Value; conf.disclaimer = txtSigDisclaimerText.Value; conf.fieldId = SurfaceField.recId; //hardcoded these values for now for a default state of the feature conf.editRoles = "0"; conf.allowPhotoEdit = chkSigAllowPhotoEdit.Checked; conf.allowSignatureEdit = chkSigAllowSignatureEdit.Checked; if (conf.recId > 0) xData.UpdateTyped("recId", conf.recId.ToString(), typeof(oSurfaceSignatureConfig), conf); else xData.SaveTyped("recId", typeof(oSurfaceSignatureConfig), conf); } BindFilterTabs(); if (ddFieldTypes.SelectedValue == pNums.FieldType.Tab.GetHashCode().ToString()) { ddTabs.SelectedValue = SurfaceField.recId.ToString(); BindFilterGroups(); } else if (ddFieldTypes.SelectedValue == pNums.FieldType.Group.GetHashCode().ToString() || ddFieldTypes.SelectedValue == pNums.FieldType.HeaderGroup.GetHashCode().ToString()) { BindFilterGroups(); if (ddGroups.Items.FindByValue(SurfaceField.recId.ToString()) != null) ddGroups.SelectedValue = SurfaceField.recId.ToString(); } else { if (ddGroups.Items.FindByValue(SurfaceField.recId.ToString()) != null) ddGroups.SelectedValue = SurfaceField.recId.ToString(); } BindSurfaceFields(); } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Cancel Surface field /// /// /// protected void btnCancelSurfaceField_Click(object sender, EventArgs e) { try { Session["surfaceFieldId"] = 0; utils.disposeSession("surfaceField"); BindSurfaceFields(); //show cat list TogglePanelsSurfaceFields("pnlSurfaceFields"); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Edit Field /// /// /// protected void lnkEditField_Click(object sender, EventArgs e) { oSurfaceField _SurfaceField = new oSurfaceField(); ArrayList FieldList = new ArrayList(); try { if (sender.GetType() == typeof(LinkButton)) { // int recId = int.Parse(((LinkButton)sender).CommandArgument); if (recId > 0) { Session["surfaceFieldId"] = recId; //get field FieldList = xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "recId", recId.ToString()); ToggleFieldStatePublished(false); //show Surface Form TogglePanelsSurfaceFields("pnlSurfaceField"); ToggleFieldTypes(); //enumerate list foreach (oSurfaceField field in FieldList) { //assign object _SurfaceField = field; //populate page form PopulateFieldFormValues(ref _SurfaceField); break; } Session["surfaceField"] = _SurfaceField; ToggleFieldTypes(); } } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Remove field /// /// /// protected void lnkRemoveField_Click(object sender, EventArgs e) { try { oSurface Surface = new oSurface(); if (utils.verifySession("surface")) { Surface = (oSurface)Session["surface"]; } if (Surface.isPublished && !Debugger.IsAttached) { pnlResultSurfaceField.Visible = true; lblResultSurfaceField.Text = "the field cannot be deleted as the App has been published."; } else if (sender.GetType() == typeof(LinkButton)) { // int recId = int.Parse(((LinkButton)sender).CommandArgument); //Delete field if (xData.DeleteTyped("recId", recId.ToString(), typeof(oSurfaceField))) { //rebind pages grid BindSurfaceFields(); pnlResultSurfaceField.Visible = true; //display successful result lblResultSurfaceField.Text = "the selected field was deleted successfully."; } } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Field Type selection change /// /// /// protected void ddFieldTypes_SelectedIndexChanged(object sender, EventArgs e) { try { ToggleFieldTypes(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Check if number is controlled and then show controlled value /// /// /// protected void chkIsControlled_CheckedChanged(object sender, EventArgs e) { if (chkIsControlled.Checked) { controlledValue.Visible = true; } else controlledValue.Visible = false; } /// /// Load surface app fields /// /// /// protected void ddSurfaceApps_SelectedIndexChanged(object sender, EventArgs e) { /* CVH 2016-01-22 RelField */ try { DropDownList list = (DropDownList)sender; string value = list.SelectedValue.ToString(); //load surface fields drop down BindSurfaceAppFields(value); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Change Action Type /// /// /// protected void ddActionTypes_SelectedIndexChanged(object sender, EventArgs e) { string actionType = ddActionTypes.SelectedValue.ToString(); BindActions(actionType); ClearActionControls(); //CVH 2017-06-30 Cleanup - Do these on Action select /* if (actionType == pNums.ActionType.Button.GetHashCode().ToString()) lblActionValue.InnerText = "Copy Button Text"; else lblActionValue.InnerHtml = "Value use delimiter ;"; lookupCalcSurfaceGroup.Visible = false; fieldAggregationGroup.Visible = false; actionValueGroup.Visible = (actionType == pNums.ActionType.ToggleView.GetHashCode().ToString()); aggregationSurfaceGroup.Visible = (actionType == ((int)pNums.ActionType.Aggregation).ToString()); if (actionType == ((int)pNums.ActionType.FieldAggregation).ToString()) { fieldAggregationGroup.Visible = true; BindFieldAggregationList(); } stylingTextColourGroup.Visible = false; txtActionValue.Text = ""; */ } private void BindFieldAggregationList() { try { if (utils.verifySession("surface")) { oSurface surface = (oSurface)Session["surface"]; DataTable FieldTable = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "surfaceId,surfaceFieldTypeId", surface.recId.ToString() + ",~()4|5|14", "surfaceFieldName"); lstFieldAggregation.DataSource = FieldTable; lstFieldAggregation.DataTextField = "surfaceFieldName"; lstFieldAggregation.DataValueField = "recId"; lstFieldAggregation.DataBind(); } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Change Action /// /// /// protected void ddActions_SelectedIndexChanged(object sender, EventArgs e) { try { oSurfaceField field = new oSurfaceField(); if (utils.verifySession("surfaceField")) field = (oSurfaceField)Session["surfaceField"]; if (field.surfaceId == 0 && utils.verifySession("surfaceId")) field.surfaceId = int.Parse(Session["surfaceId"].ToString()); int actionType = 0; if (ddActionTypes.SelectedItem != null) actionType = int.Parse(ddActionTypes.SelectedItem.Value); string action = ""; if (ddActions.SelectedItem != null && ddActions.SelectedItem.Value != "0") action = ddActions.SelectedItem.Text; ToggleAction(field.surfaceId, actionType, action, field.actionSource, field.actionValue); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } protected void btnMapFields_Click(object sender, EventArgs e) { try { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "modMapFields", "$('#modMapFields').modal();", true); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } protected void ddControls_SelectedIndexChanged(object sender, EventArgs e) { try { ToggleControlDisplay(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } protected void ddLabelSurface_SelectedIndexChanged(object sender, EventArgs e) { if (ddLabelSurface.SelectedValue != "user" && ddLabelSurface.SelectedValue != "date" && ddLabelSurface.SelectedValue != "static") { BindLabelSourceFields(ddLabelSurface.SelectedValue); labelSourceGroup.Visible = true; labelStaticGroup.Visible = false; } if (ddLabelSurface.SelectedValue == "static") { labelSourceGroup.Visible = false; labelStaticGroup.Visible = true; } } /// /// Aggregation Surface drop down selection changed /// /// /// protected void ddAggregationSurface_SelectedIndexChanged(object sender, EventArgs e) { try { if (sender is DropDownList) { DropDownList dd = (DropDownList)sender; if (dd != null) { if (dd.SelectedItem != null) { //BindLabelSourceFields(dd.SelectedItem.Value); //labelSourceGroup.Visible = true; BindActionSource(pNums.FieldType.Number.GetHashCode().ToString() + "|" + pNums.FieldType.Decimal.GetHashCode().ToString(), int.Parse(dd.SelectedItem.Value)); } } } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Custom Source Checked changed event /// /// /// protected void chkUseCustomSource_CheckedChanged(object sender, EventArgs e) { try { ToggleCustomSource(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Custom Source Selcted Index changed event /// /// /// protected void ddCustomSource_SelectedIndexChanged(object sender, EventArgs e) { try { BindCustomSourceFields(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } #endregion //protected void ddLabelSourceType_SelectedIndexChanged(object sender, EventArgs e) //{ //} protected void chkIsLinkedSurface_CheckedChanged(object sender, EventArgs e) { BindLinkedSurfaces(0); divLinkedSurfaces.Visible = chkIsLinkedSurface.Checked; } protected void lnkLinkFilter_Click(object sender, EventArgs e) { try { BindLinkedSurfaceFilters(); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "modLinkFilters", "$('#modLinkFilters').modal();", true); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } private void BindLinkedSurfaceFilters() { try { if (utils.verifySession("surface")) { int surfaceId = ((oSurface)Session["surface"]).recId; DataTable dtLinkedSurfaces = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceLink), "surfaceId", surfaceId.ToString()); grdLinkFilters.DataSource = dtLinkedSurfaces; grdLinkFilters.DataBind(); //upLinkPanel.Update(); } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } protected void grdLinkFilters_RowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView rowView = (DataRowView)e.Row.DataItem; Label lblId = (Label)e.Row.FindControl("lblId"); lblId.Text = rowView["recId"].ToString(); Label lblLinkedSurface = (Label)e.Row.FindControl("lblLinkedSurface"); lblLinkedSurface.Text = ((oSurface)xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "recId", rowView["linkedSurfaceId"].ToString())[0]).surface; DropDownList ddlLinkedFilterField = (DropDownList)e.Row.FindControl("ddlLinkedFilterField"); ListBox lstLinkedFilterValue = (ListBox)e.Row.FindControl("lstLinkedFilterValue"); DataTable dtFilterFields = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "surfaceId,surfaceFieldTypeId", rowView["linkedSurfaceId"].ToString() + ",6"); ddlLinkedFilterField.DataSource = dtFilterFields; ddlLinkedFilterField.DataTextField = "surfaceFieldName"; ddlLinkedFilterField.DataValueField = "recId"; ddlLinkedFilterField.DataBind(); ddlLinkedFilterField.Items.Insert(0, new ListItem("select...", "0")); foreach (oSurfaceLink link in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceLink), "recId", rowView["recId"].ToString())) { if (ddlLinkedFilterField.Items.FindByValue(link.filterField.ToString()) != null) ddlLinkedFilterField.SelectedValue = link.filterField.ToString(); int lookupCatId = 0; foreach (oSurfaceField sfield in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "recId", link.filterField.ToString())) { lookupCatId = sfield.lookupCategory; } DataTable dtFilterValues = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceLookup), "categoryId,isActive", lookupCatId.ToString() + ",1", "sequence"); lstLinkedFilterValue.DataSource = dtFilterValues; lstLinkedFilterValue.DataTextField = "display"; lstLinkedFilterValue.DataValueField = "display"; lstLinkedFilterValue.DataBind(); foreach (string fields in link.filterValue.Split(',')) { if (lstLinkedFilterValue.Items.FindByValue(fields.Replace("'", "")) != null) { lstLinkedFilterValue.Items.FindByValue(fields.Replace("'", "")).Selected = true; } } } } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } protected void ddlLinkedFilterField_SelectedIndexChanged(object sender, EventArgs e) { try { DropDownList ddlLinkedFilterField = sender as DropDownList; string fieldId = ddlLinkedFilterField.SelectedValue; GridViewRow row = (GridViewRow)ddlLinkedFilterField.Parent.Parent; ListBox lstLinkedFilterValue = (ListBox)row.FindControl("lstLinkedFilterValue"); int lookupCatId = ((oSurfaceField)xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "recId", fieldId)[0]).lookupCategory; DataTable dtFilterValues = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceLookup), "categoryId,isActive", lookupCatId.ToString() + ",1", "sequence"); lstLinkedFilterValue.DataSource = dtFilterValues; lstLinkedFilterValue.DataTextField = "display"; lstLinkedFilterValue.DataValueField = "display"; lstLinkedFilterValue.Items.Insert(0, new ListItem("select...")); lstLinkedFilterValue.DataBind(); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } protected void btnSaveLinkFilters_Click(object sender, EventArgs e) { try { foreach (GridViewRow row in grdLinkFilters.Rows) { if (row.RowType == DataControlRowType.DataRow) { Label lblId = (Label)row.FindControl("lblId"); Label lblLinkedSurface = (Label)row.FindControl("lblLinkedSurface"); DropDownList ddlLinkedFilterField = (DropDownList)row.FindControl("ddlLinkedFilterField"); ListBox lstLinkedFilterValue = (ListBox)row.FindControl("lstLinkedFilterValue"); foreach (oSurfaceLink linkItem in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceLink), "recId", lblId.Text.ToString())) { if (ddlLinkedFilterField.SelectedValue != "0") { linkItem.filterField = Convert.ToInt32(ddlLinkedFilterField.SelectedValue); linkItem.filterValue = ""; foreach (ListItem item in lstLinkedFilterValue.Items.GetSelectedItems()) { if (item.Selected) linkItem.filterValue += "'" + item.Value.ToString() + "',"; } if (linkItem.filterValue.Length > 0) { linkItem.filterValue = linkItem.filterValue.Substring(0, linkItem.filterValue.Length - 1); } xData.UpdateTyped("recId", linkItem.recId.ToString(), typeof(oSurfaceLink), linkItem); } } } } ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "modLinkFilters", "$('#modLinkFilters').modal();", true); } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } /// /// Publish App to custom control /// /// /// protected void btnPublish_Click(object sender, EventArgs e) { try { oSurface Surface = new oSurface(); if (utils.verifySession("surface"))//update mode { Surface = (oSurface)Session["surface"]; if (surfaceHandler.PublishSurfaceApp(Surface, chkRecreateCode.Checked)) { Surface.isPublished = true; chkPublished.Checked = true; xData.UpdateTyped("recId", Surface.recId.ToString(), typeof(oSurface), Surface); pnlResult.Visible = true; lblResult.Text = "Your App was published successfully."; Session["surface"] = Surface; } } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } protected void btnRecreateApps_Click(object sender, EventArgs e) { try { foreach (oSurface surf in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "isActive", "1")) { BuildControl(surf); } pnlResult.Visible = true; lblResult.Text = "All Apps have been re-created"; } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } protected void btnRepublishApps_Click(object sender, EventArgs e) { try { foreach (oSurface surf in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "isActive,isPublished", "1,1")) { surfaceHandler.PublishSurfaceApp(surf, false); } pnlResult.Visible = true; lblResult.Text = "All Apps have been re-published"; } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } protected void ddModuleLookup_SelectedIndexChanged(object sender, EventArgs e) { try { if (ddModuleLookup.SelectedItem != null && ddModuleLookup.SelectedItem.Text == "Surface") { moduleSurfaceGroup.Visible = true; ddModuleSurfaceField.ClearSelection(); ddModuleSurfaceField.Items.Clear(); ddModuleSurface.ClearSelection(); ddModuleSurface.Items.Clear(); BindModuleSurface(); } else moduleSurfaceGroup.Visible = false; } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } protected void ddModuleSurface_SelectedIndexChanged(object sender, EventArgs e) { try { ddModuleSurfaceField.ClearSelection(); ddModuleSurfaceField.Items.Clear(); if (ddModuleSurface.SelectedItem != null) { BindModuleSurfaceFields(int.Parse(ddModuleSurface.SelectedItem.Value)); } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } protected void ddLookupCalcSurface_SelectedIndexChanged(object sender, EventArgs e) { try { if (ddActions.SelectedItem != null && ddActions.SelectedItem.Text == "Lookup Field" && ddLookupCalcSurface.SelectedItem.Value != "") { BindLookupCalcSurfaceFields(ddLookupCalcSurface.SelectedItem.Value); lookupCalcSurfaceFieldGroup.Visible = true; } } catch (Exception ex) { exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0); Response.Redirect("/error", false); } } }