Esempio n. 1
0
 protected void wBtnReplace_Click(object sender, Infragistics.WebUI.WebDataInput.ButtonEventArgs e)
 {
     if (ddlScopes.SelectedIndex > 0)
     {
         for (int i = 0; i < cblLanguageScope.Items.Count; i++)
         {
             cblLanguageScope.Items[i].Selected = false;
         }
         TRScope scope = TRScope.GetByKey(Convert.ToInt32(ddlScopes.SelectedValue));
         if (scope != null)
         {
             foreach (TRScopeLanguage l in scope.Languages)
             {
                 for (int i = 0; i < cblLanguageScope.Items.Count; i++)
                 {
                     if (cblLanguageScope.Items[i].Value == l.LanguageCode)
                     {
                         cblLanguageScope.Items[i].Selected = true;
                     }
                 }
             }
         }
         ddlScopes.SelectedIndex = 0;
     }
 }
Esempio n. 2
0
        private void Delete()
        {
            TRScope trScope = TRScope.GetByKey(wneScopeId.ValueInt);

            if (trScope != null)
            {
                if (trScope.Delete(HyperCatalog.Shared.SessionState.User.Id))
                {
                    lbError.Visible = false;
                    lbError.Text    = string.Empty;

                    panelEdit.Visible = false;
                    panelGrid.Visible = true;

                    UpdateDataView();
                }
                else
                {
                    lbError.CssClass = "hc_error";
                    lbError.Text     = "Error: " + TRScope.LastError;
                    lbError.Visible  = true;
                }
            }
            else
            { // Already deleted
                UpdateDataView();
            }
        }
Esempio n. 3
0
        private void Save()
        {
            lbError.Text = string.Empty;
            TRScope trScope = null;

            if (PanelId.Visible)
            {
                //Update
                trScope         = TRScope.GetByKey(wneScopeId.ValueInt);
                trScope.Name    = txtName.Text;
                trScope.Comment = txtComment.Text;
            }
            else
            {
                //Add
                if (ddRegions.SelectedValue.ToString() != "<-- Select a Region -->")
                {
                    trScope = new TRScope(-1, ddRegions.SelectedValue.ToString(), txtName.Text, txtComment.Text, HyperCatalog.Shared.SessionState.User.Id, DateTime.UtcNow);
                }

                UITools.HideToolBarButton(uwToolBarEdit, "Delete");
                UITools.HideToolBarSeparator(uwToolBarEdit, "DeleteSep");
            }
            if (trScope != null)
            {
                trScope.Languages.Clear();
                foreach (ListItem obj in cblLanguageScope.Items)
                {
                    if (obj.Selected)
                    {
                        trScope.Languages.Add(new TRScopeLanguage(trScope.Id, obj.Value));
                    }
                }
                if (trScope.Languages.Count == 0)
                {
                    lbError.CssClass = "hc_error";
                    lbError.Text     = "Error: you must choose at least ONE language";
                    lbError.Visible  = true;
                }
                else
                {
                    if (trScope.Save(HyperCatalog.Shared.SessionState.User.Id))
                    {
                        wneScopeId.Value            = trScope.Id;
                        wneScopeId.Text             = trScope.Id.ToString();
                        PanelId.Visible             = true;
                        PanelRegionDDL.Visible      = false;
                        PanelRegionReadonly.Visible = true;
                        wteRegionCode.Value         = trScope.RegionCode;
                        wteRegionCode.Text          = trScope.RegionCode.ToString();
                        UITools.ShowToolBarButton(uwToolBarEdit, "Delete");
                        UITools.ShowToolBarSeparator(uwToolBarEdit, "DeleteSep");
                        lbError.Text     = "Data saved!";
                        lbError.CssClass = "hc_success";
                        lbError.Visible  = true;
                    }
                    else
                    {
                        lbError.CssClass = "hc_error";
                        lbError.Text     = "Error: " + TRScope.LastError;
                        lbError.Visible  = true;
                    }
                }
            }
            else
            {
                if (ddRegions.SelectedValue.ToString() == "<-- Select a Region -->")
                {
                    lbError.CssClass = "hc_error";
                    lbError.Text     = "Error: Scope could not be created, please make sure that the u Selected a Region.";
                    lbError.Visible  = true;
                }
                else
                {
                    lbError.CssClass = "hc_error";
                    lbError.Text     = "Error: Scope could not be created, please make sure that the name is not already in use.";
                    lbError.Visible  = true;
                }
            }
        }
Esempio n. 4
0
        private void UpdateDataEdit(string selTRScopeId)
        {
            cblLanguageScope.ClearSelection();
            TRScope trScope = null;

            if (selTRScopeId.Length > 0)
            {
                trScope = TRScope.GetByKey(Convert.ToInt32(selTRScopeId));
            }

            if (trScope == null)
            {
                lbTitle.Text                = "TR Scope: New";
                wneScopeId.Value            = "-1";
                PanelRegionDDL.Visible      = true;
                PanelRegionReadonly.Visible = false;
                PanelId.Visible             = false;

                //RPM_Sateesh
                using (HyperCatalog.Business.CultureList culturesList = HyperCatalog.Business.Culture.GetAll("CultureCode IN (SELECT DISTINCT FallbackCode FROM Cultures(NOLOCK) WHERE CountryCode IN (SELECT CountryCode FROM Countries(NOLOCK) WHERE PLCDrivenTranslation = 0))"))
                {
                    culturesList.Sort("Name");
                    ddRegions.Items.Add("<-- Select a Region -->");
                    foreach (HyperCatalog.Business.Culture c in culturesList)
                    {
                        ddRegions.Items.Add(c.Code);
                    }
                }
                //RPM_Sateesh

                UITools.HideToolBarButton(uwToolBarEdit, "Delete");
                UITools.HideToolBarSeparator(uwToolBarEdit, "DeleteSep");
            }
            else
            {
                lbTitle.Text                = "TR Scope: " + trScope.Name;
                wneScopeId.Value            = trScope.Id;
                PanelRegionDDL.Visible      = false;
                PanelRegionReadonly.Visible = true;
                wteRegionCode.Value         = trScope.RegionCode;
                txtName.Text                = trScope.Name;
                txtComment.Text             = trScope.Comment;
                PanelId.Visible             = true;
                //RPM_Sateesh
                //ddRegions.Text = trScope.Name;
                //RPM_Sateesh
                lbTRScopeId.Visible = true;
                wneScopeId.Visible  = true;
                wneScopeId.Enabled  = false;

                using (HyperCatalog.Business.LanguageList languageList = HyperCatalog.Business.Language.GetAll("LanguageCode NOT IN (Select LanguageCode FROM Cultures WHERE CultureTypeId = 0) AND LanguageCode IN (SELECT LanguageCode FROM Cultures(NOLOCK) WHERE FallbackCode ='" + trScope.RegionCode + "')"))
                {
                    languageList.Sort("Name");
                    cblLanguageScope.DataSource = languageList;
                    cblLanguageScope.DataBind();
                }

                foreach (HyperCatalog.Business.TRScopeLanguage cul in trScope.Languages)
                {
                    foreach (ListItem item in cblLanguageScope.Items)
                    {
                        if (item.Value == cul.LanguageCode)
                        {
                            item.Selected = true;
                        }
                    }
                }
            }
            panelEdit.Visible = true;
            panelGrid.Visible = false;
        }