Esempio n. 1
0
    private void dg_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e)
    {
        // update input type
        e.Row.Cells.FromKey("InputType").Text = InputFormContainer.GetTypeFromString(e.Row.Cells.FromKey("InputType").Text).ToString();

        // update filter
        if (txtFilter.Text.Length > 0)
        {
            Infragistics.WebUI.UltraWebGrid.UltraGridRow r = e.Row;
            UITools.HiglightGridRowFilter(ref r, txtFilter.Text);
        }
    }
    /// <summary>
    /// delete IFContainer
    /// </summary>
    private void Delete()
    {
        InputFormContainer ifc = InputFormContainer.GetByKey(InputFormContainerId);

        if (!ifc.Delete(HyperCatalog.Shared.SessionState.User.Id))
        {
            lbError.CssClass = "hc_error";
            lbError.Text     = InputFormContainer.LastError;
            lbError.Visible  = true;
        }
        else
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "reloadParent", "<script>ReloadParent('');top.close();</script>");
        }
    }
    private void CheckDependency()
    {
        InputForm inputForm = InputForm.GetByKey(InputFormId);

        if (inputForm != null)
        {
            if (refContainer.ContainerTypeCode == 'F') // feature container
            {
                // Retrieve all container dependencies for this feature container
                string filter = " FeatureContainerId=" + refContainer.Id;
                using (ContainerDependencyList dependencies = ContainerDependency.GetAll(filter))
                {
                    if ((dependencies != null) && (dependencies.Count > 0))
                    {
                        // Create list of tech spec containers (in container dependencies)
                        string techSpecsList = string.Empty;
                        foreach (HyperCatalog.Business.ContainerDependency d in dependencies)
                        {
                            // Current tech spec container
                            HyperCatalog.Business.Container techSpecContainer = d.TechspecContainer;

                            // tech spec container is or not attached to this input form
                            int i = 0;
                            using (InputFormContainerList ifcList = InputFormContainer.GetAll("InputFormId=" + InputFormId + " AND ContainerId=" + techSpecContainer.Id))
                            {
                                if ((ifcList == null) || (ifcList.Count == 0))
                                {
                                    i++;
                                    if (techSpecsList.Length > 0)
                                    {
                                        techSpecsList += "\\n";
                                    }
                                    techSpecsList += " " + i.ToString() + " - " + techSpecContainer.Name + " [" + techSpecContainer.Tag + "]";
                                }
                            }
                        }

                        // Tech specs (in container dependencies) are not attached to this input form
                        if (techSpecsList.Length > 0)
                        {
                            string msg = "REMINDER - are the following tech spec containers in your tech specs input forms?\\n";
                            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "warning", "<script>alert('" + msg + techSpecsList + "');</script>");
                        }
                    }
                }
            }
        }
    }
    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_CARTOGRAPHY))
        {
            try
            {
                if (Request["c"] != null)
                {
                    InputFormContainerId = Convert.ToInt64(Request["c"]);
                }
                if (Request["f"] != null)
                {
                    InputFormId = Convert.ToInt32(Request["f"]);
                }

                InputFormContainer ifc = InputFormContainer.GetByKey(InputFormContainerId);

                Infragistics.WebUI.UltraWebTab.Tab
                    tabProperties     = webTab.Tabs.FromKeyTab("Properties"),
                    tabPossibleValues = webTab.Tabs.FromKeyTab("PossibleValues");
                if (InputFormContainerId == -1)
                {
                    uwToolbar.Items.FromKeyLabel("Action").Text = "Adding container";
                    webTab.Tabs[1].Visible = false;
                }
                else
                {
                    uwToolbar.Items.FromKeyLabel("Action").Text = "Updating [" + ifc.ContainerName + "]";
                    webTab.Tabs[1].Visible = ifc.Type != InputFormContainerType.Normal;
                }
                tabProperties.ContentPane.TargetUrl     = tabProperties.TargetUrl + "?c=" + InputFormContainerId.ToString() + "&f=" + InputFormId;
                tabPossibleValues.ContentPane.TargetUrl = tabPossibleValues.TargetUrl + "?c=" + InputFormContainerId.ToString() + "&f=" + InputFormId;

                Page.DataBind();
                webTab.Visible = true;
            }
            catch
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "close", "<script>window.close();</script>");
            }
        }
        else
        {
            UITools.DenyAccess(DenyMode.Popup);
        }
    }
    /// <summary>
    /// Display data
    /// </summary>
    private void UpdateDataView()
    {
        lbError.Visible = false;
        InputFormContainer ifc = InputFormContainer.GetByKey(InputFormContainerId);

        // list of input form container type
        DDL_InputType.Items.Clear();
        foreach (string t in Enum.GetNames(typeof(InputFormContainerType)))
        {
            DDL_InputType.Items.Add(t);
        }

        if (ifc != null)         // modify input form container
        {
            hlCreator.Visible      = true;
            lbOrganization.Visible = true;
            lbCreatedOn.Visible    = true;
            lbOpening.Visible      = true;
            lbClosing.Visible      = true;

            DDL_InputType.SelectedValue = ifc.Type.ToString();
            DDL_InputType.Enabled       = (ifc.ParentInputForm != null?ifc.ParentInputForm.Items.Count == 0:false);

            cbContainers.Value = ifc.Container.Tag;
            txtContainer.Text  = ifc.Container.Tag;

            cbContainers.Visible = false;
            txtContainer.Visible = true;

            txtComment.Text          = ifc.Comment;
            chkMandatory.Checked     = ifc.Mandatory;
            cbRegionalizable.Checked = ifc.Regionalizable;

            if (ifc.Modifier != null)             // IFContainer already modified
            {
                hlCreator.Text        = ifc.Modifier.FullName;
                hlCreator.NavigateUrl = "mailto:" + UITools.GetDisplayEmail(ifc.Modifier.Email) + Server.HtmlEncode("?subject=InputFormContainers[#" + ifc.InputFormId + " - " + ifc.ContainerTag + "]");
                lbOrganization.Text   = ifc.Modifier.OrgName;
                lbCreatedOn.Text      = "Updated on " + SessionState.User.FormatUtcDate(ifc.ModifyDate.Value, true, SessionState.User.FormatDate + ' ' + SessionState.User.FormatTime);
            }
            else             // IFContainer only created
            {
                hlCreator.Text        = ifc.Creator.FullName;
                hlCreator.NavigateUrl = "mailto:" + UITools.GetDisplayEmail(ifc.Creator.Email) + Server.HtmlEncode("?subject=InputFormContainers[#" + ifc.InputFormId + " - " + ifc.ContainerTag + "]");
                lbOrganization.Text   = ifc.Creator.OrgName;
                lbCreatedOn.Text      = "Created on " + SessionState.User.FormatUtcDate(ifc.CreateDate.Value, true, SessionState.User.FormatDate + ' ' + SessionState.User.FormatTime);
            }

            if (SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_CARTOGRAPHY))
            {
                UITools.ShowToolBarButton(uwToolbar, "Delete");
                UITools.ShowToolBarSeparator(uwToolbar, "DeleteSep");
            }
        }
        else         // attach a container
        {
            hlCreator.Visible      = false;
            lbOrganization.Visible = false;
            lbCreatedOn.Visible    = false;
            lbOpening.Visible      = false;
            lbClosing.Visible      = false;

            DDL_InputType.Enabled = true;

            cbContainers.Visible = true;
            txtContainer.Visible = false;
            txtContainer.Text    = string.Empty;

            UITools.HideToolBarButton(uwToolbar, "Delete");
            UITools.HideToolBarSeparator(uwToolbar, "DeleteSep");
        }
    }
    /// <summary>
    /// Save IFContainer data
    /// </summary>
    private void Save()
    {
        if (cbContainers.Value == null)
        {
            cbContainers.Value = txtContainer.Text;
        }

        refContainer = HyperCatalog.Business.Container.GetByTag(cbContainers.Value);
        if (refContainer != null)
        {
            bool canSave = false;

            InputFormContainer ifc = InputFormContainer.GetByKey(InputFormContainerId);
            if (ifc == null)             // attach new container
            {
                CheckDependency();       // check container dependencies

                ifc = new InputFormContainer(InputFormContainerId, refContainer.Id,
                                             InputFormId, string.Empty,
                                             0,
                                             refContainer.Tag,
                                             refContainer.Name,
                                             refContainer.Regionalizable,
                                             txtComment.Text,
                                             chkMandatory.Checked,
                                             (InputFormContainerType)Enum.Parse(typeof(InputFormContainerType),
                                                                                DDL_InputType.SelectedValue, false),
                                             SessionState.User.Id,
                                             DateTime.UtcNow, -1, null);
                canSave = true;
            }
            else             // modify comment, mandatory or sort
            {
                ifc.ModifierId = SessionState.User.Id;
                ifc.ModifyDate = DateTime.UtcNow;
                ifc.Mandatory  = chkMandatory.Checked;
                ifc.Comment    = txtComment.Text.Trim();
                ifc.Type       = (InputFormContainerType)Enum.Parse(typeof(InputFormContainerType), DDL_InputType.SelectedValue, false);
                canSave        = true;
            }

            // save in database
            if (canSave)
            {
                if (!ifc.Save())
                {
                    // Error
                    lbError.CssClass = "hc_error";
                    lbError.Text     = InputFormContainer.LastError;
                    lbError.Visible  = true;
                }
                else
                {
                    lbError.CssClass     = "hc_success";
                    lbError.Text         = "Data saved!";
                    lbError.Visible      = true;
                    InputFormContainerId = ifc.Id;

                    if (((InputFormContainerType)Enum.Parse(typeof(InputFormContainerType), DDL_InputType.SelectedValue, false) == InputFormContainerType.SingleChoiceList) ||
                        ((InputFormContainerType)Enum.Parse(typeof(InputFormContainerType), DDL_InputType.SelectedValue, false) == InputFormContainerType.MultiChoiceList))
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "reloadWindow", "<script>ReloadParent();DisplayTab(" + ifc.Id + ", " + ifc.InputFormId + ", 1);</script>");                // display new tab
                    }
                    else
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "reloadWindow", "<script>ReloadParent();DisplayTab(" + ifc.Id + ", " + ifc.InputFormId + ", 0);</script>"); // reload tab
                    }
                }
            }
        }
        else
        {
            lbError.CssClass = "hc_error";
            lbError.Text     = "Error: the container [" + cbContainers.Value + "] doesn't exist.";
            lbError.Visible  = true;
        }
    }
Esempio n. 7
0
    protected void Page_Load(object sender, System.EventArgs e)
    {
        string cultureCode = string.Empty;
        int    containerId = -1;
        long   itemId      = -1;
        bool   isMandatory = false;
        int    inputformId = -1;
        string extraParam  = string.Empty;
        bool   isRegion    = false;

        try
        {
            #region try
            itemId      = QDEUtils.GetQueryItemIdFromRequest();
            containerId = Convert.ToInt32(Request["d"]);
            if (Request["m"] != null)
            {
                isMandatory = Convert.ToBoolean(Request["m"]);
            }
            using (Culture curCulture = QDEUtils.UpdateCultureCodeFromRequest())
            {
                cultureCode = curCulture.Code;
                if (Request["ifcid"] != null && Request["ifcid"].ToString() != "-1")
                {
                    using (InputFormContainer ifc = InputFormContainer.GetByKey(Convert.ToInt32(Request["ifcid"])))
                    {
                        if (ifc != null)
                        {
                            inputformId = ifc.InputFormId;
                        }
                    }
                }
                bool simpleView = SessionState.User.GetOptionById((int)OptionsEnum.OPT_SHOW_SIMPLIFIED_CHUNK_WINDOW).Value;
                Tab
                    tabChunk           = webTab.Tabs.FromKeyTab("Chunk"),
                    tabMaster          = webTab.Tabs.FromKeyTab("Master"),
                    tabContainer       = webTab.Tabs.FromKeyTab("Container"),
                    tabHistory         = webTab.Tabs.FromKeyTab("History"),
                    tabRegionalization = webTab.Tabs.FromKeyTab("Regionalization"),
                    tabTranslation     = webTab.Tabs.FromKeyTab("Translation"),
                    tabPossibleValues  = webTab.Tabs.FromKeyTab("PossibleValues"),
                    tabInheritance     = webTab.Tabs.FromKeyTab("Inheritance"),
                    tabImage           = webTab.Tabs.FromKeyTab("Image");
                if (curCulture.CountryCode != string.Empty)
                {
                    uwToolbar.Items.FromKeyLabel("Culture").Image = "/hc_v4/img/flags/" + curCulture.CountryCode + ".gif";
                }
                GetChunk(itemId, containerId, cultureCode);
                uwToolbar.Items.FromKeyLabel("Culture").Text = curCulture.Name;
                container = SessionState.QDEContainer;
                if (container == null)
                {
                    throw new Exception("An error occurred when retrieving data. Container is null[id = " + containerId.ToString() + "]");
                }
                // *************************************************************************
                // Only show master tab if culture code is not master
                // *************************************************************************
                if ((curCulture.Type != CultureType.Master))
                {
                    tabMaster.ContentPane.TargetUrl = tabMaster.ContentPane.TargetUrl + "?d=" + containerId.ToString() + "&i=" + itemId.ToString() + "&c=" + curCulture.Code;
                    using (Chunk masterChunk = Chunk.GetByKey(itemId, containerId, curCulture.FallbackCode))
                    {
                        tabMaster.Visible = masterChunk != null;
                        if (masterChunk != null && !masterChunk.Text.Equals(HyperCatalog.Business.Chunk.BlankValue))
                        {
                            extraParam = "&hf=1"; // Has Fallback = 1. This will be used in the Chunk button bar to accelerate the code.
                        }
                    }
                }

                // Change Tab height according to hidden field (to avoid recompiling)
                webTab.Height = Unit.Pixel(Convert.ToInt16(chunkHeight.Value));
                // *************************************************************************
                // Determine what we are currently doing: New or Update
                // *************************************************************************
                // SHOW/HIdE Possible values tab
                using (Item item = QDEUtils.GetItemIdFromRequest())
                {
                    if (!simpleView && container != null && curCulture.Type == CultureType.Master)
                    {
                        // Get count of possible values from parent
                        //int possibleValueCount = container.PossibleValuesCount(cultureCode, item.ParentId, inputformId);
                        tabPossibleValues.Visible = true;
                        //(phil - performances)tabPossibleValues.Text = tabPossibleValues.Text + " (" + possibleValueCount + ")";
                        tabPossibleValues.ContentPane.TargetUrl = tabPossibleValues.ContentPane.TargetUrl + "?d=" + container.Id.ToString() + "&i=" + itemId.ToString() + "&c=" + cultureCode + "&f=" + inputformId.ToString();
                    }

                    // SHOW Inheritance tab
                    if (item != null && item.Level.Id <= ItemLevel.GetSkuLevel().Id)
                    {
                        tabInheritance.Visible = (!simpleView && (container.InheritanceMethodId > 0));
                        tabInheritance.ContentPane.TargetUrl = tabInheritance.ContentPane.TargetUrl + "?i=" + itemId.ToString() + "&d=" + container.Id.ToString() + "&c=" + cultureCode;
                    }
                }
                if (SessionState.QDEChunk != null)
                {
                    uwToolbar.Items.FromKeyLabel("Action").Text = container.Group.Path + container.Group.Name + "/" + container.Tag;
                    tabHistory.Visible = SessionState.QDEChunk.HistoryCount > 0 && !simpleView;
                    tabHistory.Text    = tabHistory.Text + " (" + SessionState.QDEChunk.HistoryCount.ToString() + ")";
                    tabHistory.ContentPane.TargetUrl = tabHistory.ContentPane.TargetUrl + "?d=" + container.Id.ToString() + "&i=" + SessionState.QDEChunk.ItemId.ToString() + "&c=" + cultureCode;
                    uwToolbar.Items.FromKeyLabel("Action").ToolTip = container.Group.Path + container.Group.Name + "/" + container.Tag + " [" + container.Name + "]";
                }
                else // Create
                {
                    uwToolbar.Items.FromKeyLabel("Action").Text = container.Group.Path + container.Group.Name + "/" + container.Tag;
                    tabHistory.Visible = false;
                }

                if (!simpleView)
                {
                    // SHOW/HIDE Regionalization Tab
                    int nbRegionalization = HyperCatalog.Business.Chunk.GetRegionalizationsCount(itemId, container.Id, cultureCode);
                    tabRegionalization.Visible = nbRegionalization > 0;
                    tabRegionalization.ContentPane.TargetUrl = tabRegionalization.ContentPane.TargetUrl + "?d=" + containerId.ToString() + "&i=" + itemId.ToString() + "&c=" + cultureCode;
                    tabRegionalization.Text = tabRegionalization.Text + " (" + nbRegionalization + ")";

                    // SHOW/HIDE Translation Tab
                    int nbTranslation = HyperCatalog.Business.Chunk.GetTranslationsCount(itemId, container.Id, cultureCode);
                    tabTranslation.Visible = nbTranslation > 0;
                    tabTranslation.ContentPane.TargetUrl = tabTranslation.ContentPane.TargetUrl + "?d=" + containerId.ToString() + "&i=" + itemId.ToString() + "&c=" + cultureCode;
                    tabTranslation.Text = tabTranslation.Text + " (" + nbTranslation + ")";
                }
                /////////////////////////////////////////////////////////////
                //Determine which kind of interface we should show
                /////////////////////////////////////////////////////////////
                string masterCultureCode = HyperCatalog.Shared.SessionState.MasterCulture.Code;
                //get code for regions and master culture
                HyperCatalog.Business.CultureList allCultures = HyperCatalog.Business.Culture.GetAll("CultureTypeId IN (0,1)");
                foreach (HyperCatalog.Business.Culture culcode in allCultures)
                {
                    if (curCulture.Code == culcode.Code)
                    {
                        isRegion = true;
                    }
                }

                switch (Convert.ToChar(container.DataType.Code))
                {
                case 'D': tabChunk.ContentPane.TargetUrl = "Chunk_Date.aspx";
                    break;

                case 'L':// List is not supported
                    tabChunk.ContentPane.TargetUrl = "Chunk_Text.aspx";
                    break;

                case 'N': tabChunk.ContentPane.TargetUrl = "Chunk_Number.aspx";
                    break;

                case 'B': tabChunk.ContentPane.TargetUrl = "Chunk_Boolean.aspx";
                    break;

                // A MODIFIER ICI POUR PHOTOS
                case 'U': goto case 'S';

                case 'P': goto case 'S';

                case 'R':
                case 'S': goto case 'T';

                case 'T': tabChunk.ContentPane.TargetUrl = "Chunk_Text.aspx";
                    break;
                }
                // IF containe type is Photo, override dataTyping
                //2007/01/19 - modif greg - old : if (container.ContainerTypeCode == 'P' || container.ContainerTypeCode == 'L')
                if (container.ContainerTypeCode == 'P' || container.DataTypeCode == 'P')
                {
                    tabChunk.ContentPane.TargetUrl = "Chunk_Resource.aspx";
                    if (SessionState.QDEChunk != null && SessionState.QDEChunk.Text != HyperCatalog.Business.Chunk.BlankValue)
                    {
                        // SHOW Image preview tab
                        /************ Ref QC#871 (Making Image preview tab visible) ********************/
                        tabImage.Visible = true;
                        tabImage.ContentPane.TargetUrl = tabImage.ContentPane.TargetUrl + "?d=" + container.Id.ToString() + "&i=" + SessionState.QDEChunk.ItemId.ToString() + "&c=" + cultureCode;
                    }
                }
                if (container.InputMask != string.Empty && masterCultureCode == curCulture.Code)
                {
                    tabChunk.ContentPane.TargetUrl = "Chunk_InputMask.aspx";
                }

                //if (container.LookupId >= 0 && masterCultureCode == curCulture.Code)
                if (container.LookupId >= 0 && isRegion) // Prabhu Fix for HPeZilla Bug 69251 - LUT not showing up in regions for editing
                {
                    tabChunk.ContentPane.TargetUrl = "Chunk_Lookup.aspx";
                    if (Request["ifcid"] != null && Request["ifcid"].ToString() != "-1")
                    {
                        using (InputFormContainer inputFormContainer = InputFormContainer.GetByKey(Convert.ToInt32(Request["ifcid"])))
                        {
                            if (inputFormContainer != null)
                            {
                                extraParam += "&t=" + InputFormContainer.GetTypeFromEnum(inputFormContainer.Type);
                            }
                        }
                    }
                }

                /* Alternate for CR 5096(Removal of rejections)
                 * if (SessionState.QDEChunk != null && SessionState.QDEChunk.Status == ChunkStatus.Rejected)
                 * {
                 * tabChunk.ContentPane.TargetUrl = "Chunk_Rejected.aspx";
                 * tabMaster.Visible = tabHistory.Visible = tabRegionalization.Visible = tabTranslation.Visible =
                 * tabPossibleValues.Visible = tabInheritance.Visible = tabImage.Visible = false;
                 * }
                 */
                tabChunk.ContentPane.TargetUrl = tabChunk.ContentPane.TargetUrl + "?d=" + container.Id.ToString() + "&c=" + cultureCode + "&i=" + itemId.ToString() + "&m=" + isMandatory.ToString() + extraParam;

                // If chunk is coming from List in Input Form, force type to list
                if (Request["ifcid"] != null && Request["ifcid"].ToString() != "-1")
                {
                    InputFormContainer inputFormContainer = InputFormContainer.GetByKey(Convert.ToInt32(Request["ifcid"]));
                    if (inputFormContainer != null)
                    {
                        //if (inputFormContainer.Type != InputFormContainerType.Normal && masterCultureCode == curCulture.Code)
                        if (inputFormContainer.Type != InputFormContainerType.Normal && isRegion)// Prabhu Fix for HPeZilla Bug 69251 - LUT not showing up in regions for editing
                        {
                            tabChunk.ContentPane.TargetUrl = "Chunk_Lookup.aspx?d=" + container.Id.ToString() + "&c=" + cultureCode + "&i=" + itemId.ToString() + "&m=" + isMandatory.ToString() + "&t=" + InputFormContainer.GetTypeFromEnum(inputFormContainer.Type) + "&ifid=" + Request["ifcid"].ToString() + extraParam;
                        }
                    }
                }

                if (tabTranslation.Visible)
                {
                    tabChunk.ContentPane.TargetUrl = tabChunk.ContentPane.TargetUrl + "&ht=1"; // HasTranslations
                }
                if (SessionState.CurrentItemIsUserItem)
                {
                    tabChunk.ContentPane.TargetUrl = tabChunk.ContentPane.TargetUrl + "&ui=1"; // HasItemInScope
                }

                tabContainer.ContentPane.TargetUrl = tabContainer.ContentPane.TargetUrl + "?d=" + container.Id.ToString();
                tabContainer.Visible = !simpleView;
                Page.DataBind();
            }
            #endregion
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
            Response.End();
        }
    }
    protected void dlDataType_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (dlDataType.SelectedValue == "P")// Photo
        {
            dlLookupField.Enabled = false;
            txtInputMask.Enabled  = false;
            txtMaxLength.Enabled  = false;
            lbLookupField.Visible = lbInputMask.Visible = lbMaxLength.Visible = true;
        }
        else
        {
            lbLookupField.Visible = lbInputMask.Visible = lbMaxLength.Visible = false;
            txtInputMask.Enabled  = dlLookupField.Enabled = true;
            using (InputFormContainerList IFCList = InputFormContainer.GetAll("ContainerId = " + containerId.ToString()))
            {
                if (IFCList != null)
                {
                    foreach (InputFormContainer ifc in IFCList)
                    {
                        if (ifc.Type != InputFormContainerType.Normal)
                        {
                            dlLookupField.SelectedIndex = 0;
                            dlLookupField.Enabled       = false;
                            break;
                        }
                    }
                }
            }

            if (container != null)
            {
                // all content
                using (Database db = Utils.GetMainDB())
                {
                    if (db != null)
                    {
                        txtMaxLength.Enabled = true;
                        int r = db.RunSPReturnInteger("dbo._Container_HasNotContent",
                                                      new SqlParameter("@ContainerId", container.Id),
                                                      new SqlParameter("@CultureTypeId", (int)CultureType.Master));
                        if (r < 0)
                        {
                            UITools.HideToolBarButton(uwToolbar, "Delete");
                            UITools.HideToolBarSeparator(uwToolbar, "DeleteSep");

                            txtTag.Enabled              = false;
                            dlContainerType.Enabled     = false;
                            dlInheritanceMethod.Enabled = false;
                            dlDataType.Enabled          = false;
                            if (txtMaxLength.ValueDouble > 0)
                            {
                                txtMaxLength.MinValue = txtMaxLength.ValueDouble;
                            }
                            else
                            {
                                txtMaxLength.Enabled = false;
                            }
                        }
                        else
                        {
                            txtMaxLength.Enabled = true;
                        }
                    }
                }
            }
        }
    }
    protected void UpdateDataEdit()
    {
        #region Load ContainerGroups drop down
        ddlContainerGroups.Items.Clear();
        if (container == null)
        {
            ddlContainerGroups.Items.Add(new ListItem("--> Please choose a group <--", "-1"));
        }
        for (int i = 0; i < SessionState.AppContainersGroups.Count; i++)
        {
            if (SessionState.AppContainersGroups[i].SubGroupCount == 0)
            {
                ddlContainerGroups.Items.Add(new ListItem(SessionState.AppContainersGroups[i].Path + SessionState.AppContainersGroups[i].Name, SessionState.AppContainersGroups[i].Id.ToString()));
            }
        }
        #endregion

        dlDataType.DataSource = SessionState.AppDataTypes;
        dlDataType.DataBind();
        dlContainerType.DataSource = SessionState.AppContainerTypes;
        dlContainerType.DataBind();
        dlLookupField.DataSource = SessionState.AppLookupGroups;
        dlLookupField.DataBind();
        dlInheritanceMethod.DataSource = SessionState.AppInheritanceMethods;
        dlInheritanceMethod.DataBind();
        using (Database dbObj = Utils.GetMainDB())
        {
            ddlSegments.DataSource     = SessionState.AppContainerSegments;
            ddlSegments.DataTextField  = "SegmentName";
            ddlSegments.DataValueField = "SegmentId";
            ddlSegments.DataBind();

            dlLookupField.Items.Insert(0, new ListItem("None", ""));
            if (container != null)
            {
                ddlContainerGroups.SelectedValue = container.GroupId.ToString();
                txtContainerId.Text   = container.Id.ToString();
                txtTag.Text           = container.Tag;
                txtContainerName.Text = container.Name;
                txtDefinition.Text    = container.Definition;
                txtEntryRule.Text     = container.EntryRule;
                txtMaxLength.Value    = container.MaxLength;
                txtSample.Text        = container.Sample;
                cbLabel.Value         = container.Label;
                tbWWXPath.Text        = container.WWXPath;
                if (container.Creator != null)
                {
                    hlCreator.NavigateUrl = "mailto:" + UITools.GetDisplayEmail(container.Creator.Email);
                    hlCreator.Text        = "Created by " + container.Creator.FullName + " on " + SessionState.User.FormatUtcDate(container.CreateDate.Value, true, SessionState.User.FormatDate + ' ' + SessionState.User.FormatTime) + "<br/><br/>";
                    if (container.Modifier != null && container.ModifyDate.HasValue)
                    {
                        hlModifier.NavigateUrl = "mailto:" + UITools.GetDisplayEmail(container.Modifier.Email);
                        hlModifier.Text        = "Modified by " + container.Modifier.FullName + " on " + SessionState.User.FormatUtcDate(container.ModifyDate.Value, true, SessionState.User.FormatDate + ' ' + SessionState.User.FormatTime) + "<br/><br/>";
                    }
                }
                cbPublishable.Checked     = container.Publishable;
                cbRegionalizable.Checked  = container.Regionalizable;
                cbLocalizable.Checked     = container.Localizable;
                cbTranslatable.Checked    = container.Translatable;
                cbReadOnly.Checked        = container.ReadOnly;
                cbKeepIfObsolete.Checked  = container.KeepIfObsolete;
                cbMECD.Checked            = container.Mecd;
                cbMMD.Checked             = container.Mmd;
                cbCDM.Checked             = container.Cdm;
                ddlSegments.SelectedValue = container.SegmentId.ToString();
                txtSort.Value             = container.Sort;
                txtInputMask.Text         = container.InputMask;
                if (container.Lookup != null)
                {
                    dlLookupField.SelectedValue = container.LookupId.ToString();
                }
                using (InputFormContainerList IFCList = InputFormContainer.GetAll("ContainerId = " + containerId.ToString()))
                {
                    if (IFCList != null)
                    {
                        foreach (InputFormContainer ifc in IFCList)
                        {
                            if (ifc.Type != InputFormContainerType.Normal)
                            {
                                dlLookupField.SelectedIndex = 0;
                                dlLookupField.Enabled       = false;
                                break;
                            }
                        }
                    }
                }

                dlDataType.SelectedValue          = container.DataTypeCode.ToString();
                dlContainerType.SelectedValue     = container.ContainerTypeCode.ToString();
                dlInheritanceMethod.SelectedValue = container.InheritanceMethodId.ToString();

                panelId.Visible     = true;
                ViewState["action"] = "update";

                if (SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_DICTIONARY))
                {
                    UITools.ShowToolBarButton(uwToolbar, "Delete");
                    UITools.ShowToolBarSeparator(uwToolbar, "DeleteSep");
                }

                // Update field Enable/Disable
                if (cbReadOnly.Checked)
                {
                    cbTranslatable.Enabled = cbRegionalizable.Enabled = cbLocalizable.Enabled = false;
                }

                // all content
                if (dbObj != null)
                {
                    int r = dbObj.RunSPReturnInteger("dbo._Container_HasNotContent",
                                                     new SqlParameter("@ContainerId", container.Id),
                                                     new SqlParameter("@CultureTypeId", (int)CultureType.Master));
                    if (r < 0)
                    {
                        UITools.HideToolBarButton(uwToolbar, "Delete");
                        UITools.HideToolBarSeparator(uwToolbar, "DeleteSep");

                        txtTag.Enabled              = false;
                        dlContainerType.Enabled     = false;
                        dlInheritanceMethod.Enabled = false;
                        dlDataType.Enabled          = false;
                        txtInputMask.Enabled        = false;

                        if (txtMaxLength.ValueDouble > 0)
                        {
                            txtMaxLength.MinValue = txtMaxLength.ValueDouble;
                        }
                        else
                        {
                            txtMaxLength.Enabled = false;
                        }
                    }

                    // regionalized content
                    r = dbObj.RunSPReturnInteger("dbo._Container_HasNotContent",
                                                 new SqlParameter("@ContainerId", container.Id),
                                                 new SqlParameter("@CultureTypeId", (int)CultureType.Regionale));
                    if (r < 0 && cbRegionalizable.Checked)
                    {
                        cbRegionalizable.Enabled = false;
                    }

                    // localized content (or translated content)
                    r = dbObj.RunSPReturnInteger("dbo._Container_HasNotContent",
                                                 new SqlParameter("@ContainerId", container.Id),
                                                 new SqlParameter("@CultureTypeId", (int)CultureType.Locale));
                    if (r < 0)
                    {
                        if (cbTranslatable.Checked)
                        {
                            cbTranslatable.Enabled = false;
                        }
                        if (cbLocalizable.Checked)
                        {
                            cbLocalizable.Enabled = false;
                        }
                    }
                }
            }
            else
            {
                ViewState["action"] = "create";
                ddlContainerGroups.SelectedIndex = 0;
                dlDataType.SelectedValue         = "T";
                txtMaxLength.Value = 0;
                hlCreator.Text     = "";
                dlLookupField.Items.Insert(0, new ListItem("", ""));
                cbLocalizable.Checked             = false;
                cbRegionalizable.Checked          = false;
                cbPublishable.Checked             = false;
                cbTranslatable.Checked            = true;
                txtSort.Text                      = "0";
                dlContainerType.SelectedValue     = "*";
                dlInheritanceMethod.SelectedValue = "1";
                tbWWXPath.Text                    = string.Empty;
                cbKeepIfObsolete.Checked          = false;
                ddlSegments.SelectedIndex         = 0;
                cbReadOnly.Checked                = false;
                cbMECD.Checked                    = false;
                cbMMD.Checked                     = false;
                cbCDM.Checked                     = false;

                UITools.HideToolBarButton(uwToolbar, "Delete");
                UITools.HideToolBarSeparator(uwToolbar, "DeleteSep");
            }
        }
        //ChiantiUpdate();
    }
Esempio n. 10
0
    private void Save()
    {
        lbError.Visible = false;
        Trace.Warn("Save");
        if (dg != null && dg.Rows != null && dg.Rows.Count > 0)
        {
            Trace.Warn("Entering loop");
            TemplatedColumn col     = (TemplatedColumn)dg.Rows[0].Cells.FromKey("Select").Column;
            TemplatedColumn colMand = (TemplatedColumn)dg.Rows[0].Cells.FromKey("Mandatory").Column;
            TemplatedColumn colType = (TemplatedColumn)dg.Rows[0].Cells.FromKey("ifcType").Column;

            if (col != null)
            {
                for (int i = 0; i < col.CellItems.Count; i++)
                {
                    try
                    {
                        CellItem cellItem = (CellItem)col.CellItems[i];
                        Infragistics.WebUI.UltraWebGrid.UltraGridRow r = cellItem.Cell.Row;
                        CheckBox cb = (CheckBox)cellItem.FindControl("g_sd");
                        cellItem = (CellItem)colMand.CellItems[i];
                        CheckBox chkMandatory = (CheckBox)cellItem.FindControl("g_m");
                        cellItem = (CellItem)colType.CellItems[i];
                        DropDownList ddType = (DropDownList)cellItem.FindControl("ddType");

                        if (cb != null)
                        {
                            Trace.Warn("Testing for " + dg.Rows[i].Cells.FromKey("Tag").Text + "=>" + cb.Checked.ToString());
                            if (cb.Checked && cb.Enabled)
                            {
                                using (InputFormContainer ifc = new InputFormContainer(-1, Convert.ToInt32(dg.Rows[i].Cells.FromKey("Id").Text),
                                                                                       inputFormId, ddlGroups.Text,
                                                                                       0,
                                                                                       dg.Rows[i].Cells.FromKey("Tag").Text,
                                                                                       dg.Rows[i].Cells.FromKey("ContainerName").Text,
                                                                                       (bool)dg.Rows[i].Cells.FromKey("isReg").Value,
                                                                                       dg.Rows[i].Cells.FromKey("Comment").Value != null ? dg.Rows[i].Cells.FromKey("Comment").Value.ToString() : string.Empty,
                                                                                       chkMandatory.Checked,
                                                                                       (InputFormContainerType)Enum.Parse(typeof(InputFormContainerType), ddType.SelectedValue, false),
                                                                                       SessionState.User.Id,
                                                                                       DateTime.UtcNow, -1, null))
                                {
                                    Trace.Warn("  -> Saving for " + dg.Rows[i].Cells.FromKey("Tag").Text);
                                    if (!ifc.Save())
                                    {
                                        // Error
                                        lbError.CssClass = "hc_error";
                                        lbError.Text    += ifc.ContainerName + " -> " + InputFormContainer.LastError + "<br/>" + Environment.NewLine;
                                        lbError.Visible  = true;
                                        Trace.Warn("  -> Error " + ifc.ContainerName + " -> " + InputFormContainer.LastError);
                                    }
                                    Trace.Warn("  -> Success ");
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Trace.Warn("UNEXPECTED Error " + ex.ToString());
                    }
                }
                //ifcl.Dispose();
                //Cache.Remove("ifcl");
                UpdateDataView();
                if (!lbError.Visible)
                {
                    lbError.CssClass = "hc_success";
                    lbError.Text     = "Data saved!";
                    lbError.Visible  = true;
                }
            }
        }
    }
    protected void Page_Load(object sender, System.EventArgs e)
    {
        //#ACQ8.20 Starts
        try
        {
            if ("1".Equals(Convert.ToString(ApplicationSettings.Parameters["TermsIsTranslatableDefault"].Value)))
            {
                IsTranslateDefaultOption = true;
            }
            else
            {
                IsTranslateDefaultOption = false;
            }
        }
        catch (Exception ex) { }
        //#ACQ8.20 Ends
        Page.Form.Attributes["autocomplete"] = "off";
        #region Spell Checker
        WebSpellChecker1.SpellOptions.AllowCaseInsensitiveSuggestions = true;
        WebSpellChecker1.SpellOptions.AllowMixedCase       = false;
        WebSpellChecker1.SpellOptions.AllowWordsWithDigits = true;
        WebSpellChecker1.SpellOptions.AllowXML             = true;
        WebSpellChecker1.SpellOptions.CheckHyphenatedText  = true;
        WebSpellChecker1.SpellOptions.IncludeUserDictionaryInSuggestions       = true;
        WebSpellChecker1.SpellOptions.PerformanceOptions.AllowCapitalizedWords = true;
        WebSpellChecker1.SpellOptions.PerformanceOptions.CheckCompoundWords    = false;
        WebSpellChecker1.SpellOptions.PerformanceOptions.ConsiderationRange    = -1;
        WebSpellChecker1.SpellOptions.PerformanceOptions.SplitWordThreshold    = 3;
        WebSpellChecker1.SpellOptions.PerformanceOptions.SuggestSplitWords     = true;
        WebSpellChecker1.SpellOptions.SeparateHyphenWords = false;
        #endregion

        if (SessionState.User.IsReadOnly)
        {
            uwToolbar.Items.FromKeyButton("Save").Enabled   = false;
            uwToolbar.Items.FromKeyButton("Delete").Enabled = false;
        }
        if (!SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_CARTOGRAPHY))
        {
            UITools.HideToolBarSeparator(uwToolbar, "SaveSep");
            UITools.HideToolBarButton(uwToolbar, "Save");
            UITools.HideToolBarSeparator(uwToolbar, "DeleteSep");
            UITools.HideToolBarButton(uwToolbar, "Delete");
        }
        try
        {
            if (Request["c"] != null)
            {
                InputFormContainerId = Convert.ToInt64(Request["c"]);
            }
            ifcObj = InputFormContainer.GetByKey(InputFormContainerId);
            if (Request["f"] != null)
            {
                InputFormId = Convert.ToInt32(Request["f"]);
            }

            if (!Page.IsPostBack)
            {
                UpdateDataEdit();
                WebSpellChecker1.WebSpellCheckerDialogPage += "?i=0&c=" + ifcObj.ContainerId.ToString();
            }
            dgValues.DisplayLayout.ClientSideEvents.ColumnHeaderClickHandler = "dgValues_ColumnHeaderClickHandler";
        }
        catch
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "close", "<script>parent.close();</script>");
        }
    }
Esempio n. 12
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                containerId = Convert.ToInt32(Request["d"]);
                if (Request["m"] != null)
                {
                    isMandatory = Convert.ToBoolean(Request["m"]);
                }
                culture           = QDEUtils.UpdateCultureCodeFromRequest();
                item              = QDEUtils.GetItemIdFromRequest();
                itemId            = item.Id;
                chunk             = ChunkWindow.GetChunk(itemId, containerId, culture.Code);
                uwToolbar.Enabled = Request["ui"] != null;

                if (Request["ifid"] != null)
                {
                    ifContainer = InputFormContainer.GetByKey(Convert.ToInt32(Request["ifid"]));
                }

                /*#ACQ10.0 Starts --Commented
                 * Commented to bring out ILB for all catalogue irespective of mandatory status
                 * if (!isMandatory || culture.Type == CultureType.Regionale)
                 * {
                 * UITools.HideToolBarButton(uwToolbar, "ilb");
                 * }
                 */
                UITools.HideToolBarButton(uwToolbar, "ilb");
                //#ACQ10.0 Ends

                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "blanktext", "<script>ILBText = '" + HyperCatalog.Business.Chunk.BlankText + "';</script>");

                //Modified this line for QCs# 839 and 1028
                ChunkButtonBar.Chunk = chunk;
                //Modified this line for QCs# 839 and 1028

                ChunkButtonBar.Container = SessionState.QDEContainer;
                ChunkButtonBar.User      = SessionState.User;
                ChunkButtonBar.Culture   = culture;
                ChunkButtonBar.Item      = item;
                if (!Page.IsPostBack)
                {
                    //Added these lines for QCs# 839 and 1028
                    ChunkComment1.Chunk  = chunk;
                    ChunkModifier1.Chunk = chunk;
                    //Added these lines for QCs# 839 and 1028

                    lbResult.Text = string.Empty;
                    UpdateDataView();
                }
                else
                {
                    if (Request["__EVENTTARGET"] != null) // Check if user is trying to sort a group
                    {
                        if (Request["__EVENTTARGET"].ToString() == "rowup" || Request["__EVENTTARGET"].ToString() == "rowdown")
                        {
                            SortRow(Request["__EVENTTARGET"].ToString() == "rowup", Convert.ToInt32(Request["__EVENTARGUMENT"]));
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "close", "<script>alert('" + UITools.CleanJSString(ex.ToString()) + "');top.window.close();</script>");
            }
        }