Example #1
0
 private void Delete()
 {
     using (HyperCatalog.Business.Language lang = HyperCatalog.Business.Language.GetByKey(languageCode))
     {
         if (lang != null)
         {
             if (lang.Delete(HyperCatalog.Shared.SessionState.User.Id))
             {
                 Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "clientScript", "<script>back();</script>");
             }
             else
             {
                 lbError.CssClass = "hc_error";
                 lbError.Text     = HyperCatalog.Business.Language.LastError;
                 lbError.Visible  = true;
             }
         }
         else
         {
             lbError.CssClass = "hc_error";
             lbError.Text     = "Error: Language not found";
             lbError.Visible  = true;
         }
     }
 }
Example #2
0
 private void Save()
 {
     if (languageCode == "-1")
     {
         HyperCatalog.Business.Language l = HyperCatalog.Business.Language.GetByKey(txtLanguageCode.Text.ToUpper().Trim());
         if (l == null)
         {
             // Create new language
             lang = new HyperCatalog.Business.Language(txtLanguageCode.Text.ToUpper().Trim(), txtLanguageName.Text.Trim(), txtDeliveryLanguageName.Text.Trim(),
                                                       cbRtl.Checked, txtEncoding.Text.Trim(), dlTRIsoCode.SelectedValue);
         }
         else
         {
             lbError.CssClass = "hc_error";
             lbError.Text     = "This language code [" + txtLanguageCode.Text.Trim() + "] already exist !";
             lbError.Visible  = true;
             return;
         }
     }
     else
     {
         // update language
         lang              = HyperCatalog.Business.Language.GetByKey(languageCode);
         lang.Name         = txtLanguageName.Text;
         lang.DeliveryName = txtDeliveryLanguageName.Text;
         lang.Encoding     = txtEncoding.Text;
         lang.Rtl          = cbRtl.Checked;
         lang.TRIsoCode    = dlTRIsoCode.SelectedValue;
     }
     if (lang != null)
     {
         if (lang.Save())
         {
             // create/update
             lbError.Text     = "Data saved!";
             lbError.CssClass = "hc_success";
             lbError.Visible  = true;
         }
         else
         {
             lbError.CssClass = "hc_error";
             lbError.Text     = HyperCatalog.Business.Language.LastError;
             lbError.Visible  = true;
         }
         lang.Dispose();
     }
     else
     {
         lbError.CssClass = "hc_error";
         lbError.Text     = "Error: Language not found";
         lbError.Visible  = true;
     }
 }
Example #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region Check Capabilities
        if (SessionState.User.IsReadOnly)
        {
            uwToolbar.Items.FromKeyButton("Save").Enabled   = false;
            uwToolbar.Items.FromKeyButton("Delete").Enabled = false;
        }

        if (!SessionState.User.HasCapability(CapabilitiesEnum.EXTEND_CONTENT_MODEL))
        {
            UITools.HideToolBarButton(uwToolbar, "Save");
            UITools.HideToolBarSeparator(uwToolbar, "SaveSep");
            UITools.HideToolBarButton(uwToolbar, "Delete");
            UITools.HideToolBarSeparator(uwToolbar, "DeleteSep");
        }
        #endregion

        if (Request["l"] != null)
        {
            languageCode = Request["l"].ToString();
            lang         = HyperCatalog.Business.Language.GetByKey(languageCode);
            if (!Page.IsPostBack)
            {
                UpdateDataEdit();
            }
        }

        if (!Page.IsPostBack)
        {
            #region Load dlTRIsoCode
            using (Database dbObj = Utils.GetMainDB())
            {
                using (DataSet ds = dbObj.RunSPReturnDataSet("_CultureIsoCode_GetAvailable", new System.Data.SqlClient.SqlParameter("@LanguageCode", languageCode)))
                {
                    dbObj.CloseConnection();
                    dlTRIsoCode.DataSource = ds;
                    dlTRIsoCode.DataBind();
                    if (dlTRIsoCode.Items.Count == 0)
                    {
                        dlTRIsoCode.Enabled = txtLanguageName.Enabled = txtLanguageCode.Enabled = txtEncoding.Enabled = false;
                        uwToolbar.Items.FromKeyButton("Save").Enabled = false;
                        lbError.Text     = "All TR Iso code are already used. <br/>You cannot create a language without Translation ISO Code. <br/>Please contact support";
                        lbError.CssClass = "hc_error";
                        lbError.Visible  = true;
                    }
                }
            }
            #endregion
        }
    }
Example #4
0
 void UpdateDataEdit(string selLanguageCode)
 {
     panelGrid.Visible      = false;
     webTab.EnableViewState = false;
     webTab.Tabs.GetTab(0).ContentPane.TargetUrl = "./languages/language_Properties.aspx?l=" + selLanguageCode;
     if (selLanguageCode == "-1")
     {
         lbTitle.Text = "Language: New";
     }
     else
     {
         HyperCatalog.Business.Language language = HyperCatalog.Business.Language.GetByKey(selLanguageCode);
         lbTitle.Text = "Language: " + language.Name.ToString();
     }
     webTab.Visible = true;
 }
Example #5
0
        private void SaveCurrentTerm()
        {
            using (TermType business = TermType.GetByKey(Convert.ToChar(ItemKey)))
            {
                #region save BatchDays
                business.RegionCode = ddTermsRegions.SelectedValue.ToString();
                business.MTRDays.Clear();
                foreach (ListItem item in cbMTRDays.Items)
                {
                    if (item.Selected)
                    {
                        business.MTRDays.Add(Convert.ToInt32(item.Value));
                    }
                }
                business.SaveMTRDays();
                #endregion
                #region save MTR Languages
                business.Languages.Clear();
                foreach (ListItem item in cbTermLanguages.Items)
                {
                    if (item.Selected)
                    {
                        using (HyperCatalog.Business.Language l = HyperCatalog.Business.Language.GetByKey(item.Value.ToString()))
                        {
                            business.Languages.Add(l);
                        }
                    }
                }
                business.SaveLanguages();

                //Included for 4179 --Translation settings unique logging issue
                HyperCatalog.Business.ActivityLog.TRActivityLog(business, SessionState.User);

                #endregion
            }
        }
Example #6
0
        private void SaveCurrentBusiness()
        {
            try
            {
                //using (TRClass business = TRClass.GetByKey(Convert.ToInt64(ItemKey), ddClassRegions.SelectedValue.ToString()))
                //Modified by Venkata 07 oct 16
                using (TRClass business = GetTRClassByKey(Convert.ToInt64(ItemKey), ddClassRegions.SelectedValue.ToString()))
                {
                    #region update Item if necessary
                    if (rdTranslationMode.SelectedValue != business.TranslationMode.ToString())
                    {
                        business.TranslationMode = (TRClassTranslationMode)Enum.Parse(typeof(TRClassTranslationMode), rdTranslationMode.SelectedValue);
                        business.Save(HyperCatalog.Shared.SessionState.User.Id, false, false, false);
                    }
                    #endregion
                    #region save BatchDays
                    business.BatchDays.Clear();
                    foreach (ListItem item in cbCTRDays.Items)
                    {
                        if (item.Selected)
                        {
                            business.BatchDays.Add(new TRBatchDay(business.Id, ddClassRegions.SelectedValue.ToString(), Convert.ToInt32(item.Value), TRBatchDayType.CTR));
                        }
                    }
                    foreach (ListItem item in cbMTRDays.Items)
                    {
                        if (item.Selected)
                        {
                            business.BatchDays.Add(new TRBatchDay(business.Id, ddClassRegions.SelectedValue.ToString(), Convert.ToInt32(item.Value), TRBatchDayType.MTR));
                        }
                    }
                    business.SaveBatchDays();
                    #endregion
                    #region save CTR Languages
                    business.CTRLanguages.Clear();
                    foreach (ListItem item in cbCTRLanguages.Items)
                    {
                        if (item.Selected)
                        {
                            using (HyperCatalog.Business.Language l = HyperCatalog.Business.Language.GetByKey(item.Value.ToString()))
                            {
                                business.CTRLanguages.Add(l);
                            }
                        }
                    }
                    business.SaveCTRLanguages();

                    //Included for 4179 --Translation settings unique logging issue
                    HyperCatalog.Business.ActivityLog.TRActivityLog(business, SessionState.User);


                    #endregion
                    #region save PL if necessary
                    // clear selection for current language
                    //for (int i = 0; i < business.PLLanguages.Count; i++)
                    //{
                    //    if (business.PLLanguages[i].LanguageCode == CurrentPL)
                    //   {
                    //      business.PLLanguages[i].Delete(SessionState.User.Id);
                    //     i--; // ensure couting is always correct
                    //   }
                    //}
                    if (rdTranslationMode.SelectedIndex == 1)
                    {
                        // QC 2028 -> PL Languages in TRSettings not getting saved properly
                        business.PLLanguages.Clear();
                        foreach (ListItem item in cbPLLanguages.Items)
                        {
                            if (item.Selected)
                            {
                                Trace.Warn("Adding PL [" + CurrentPL + "] for id " + business.Id.ToString() + " and value = " + item.Value);
                                business.PLLanguages.Add(new TRProductLineLanguage(CurrentPL, business.Id, ddClassRegions.SelectedValue.ToString(), item.Value));
                            }
                        }
                        business.SaveProductLinesByPL(CurrentPL);

                        //Included for 4179 --Translation settings unique logging issue
                        //	  HyperCatalog.Business.ActivityLog.SaveProductLinesByPL(business, SessionState.User, CurrentPL);
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                lbError.Visible = true;
                if (ex.Message.ToString() == "Object reference not set to an instance of an object.")
                {
                    lbError.Text = "No TRClass exists for this Class,RegionCode combination.Contact Support.Please verify TRClassSettings table.";
                }
                lbError.Text    += "ERROR:" + ex.Message;
                lbError.CssClass = "hc_error";
            }
        }
 protected void Page_Load(object sender, System.EventArgs e)
 {
     #region Check Capabilities
     if ((SessionState.User.IsReadOnly) || (!SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_TERM_BASE)))
     {
         uwToolbar.Items.FromKeyButton("Save").Enabled   = false;
         uwToolbar.Items.FromKeyButton("Delete").Enabled = false;
     }
     #endregion
     termId       = Convert.ToInt64(Request["t"]);
     languageCode = Request["c"];
     if (!Page.IsPostBack)
     {
         try
         {
             using (HyperCatalog.Business.Language currentLanguage = HyperCatalog.Business.Language.GetByKey(languageCode))
             {
                 string languageName = currentLanguage.Name;
                 if (currentLanguage.Rtl)
                 {
                     txtTermValue.CssClass = "hc_rtledit";
                 }
                 lbLanguage.Text = "[" + languageCode + "] " + languageName;
                 using (Term t = Term.GetByKey(termId))
                 {
                     if (t != null)
                     {
                         txtTermValueMaster.Text = t.Value;
                         using (TermTranslation tt = TermTranslation.GetByKey(termId, languageCode))
                         {
                             if (tt == null)
                             {
                                 #region New translation
                                 uwToolbarTitle.Items.FromKeyLabel("Action").Text = "Creating";
                                 hlCreator.Text         = UITools.GetDisplayName(t.User.FullName);
                                 hlCreator.NavigateUrl  = "mailto:" + UITools.GetDisplayEmail(t.User.Email) + Server.HtmlEncode("?subject=TermTranslation[#" + t.Id.ToString() + " - " + t.LanguageCode + "]");;
                                 lbOrganization.Text    = t.User.OrgName;
                                 lbOrganization.Visible = hlCreator.Text == t.User.FullName;
                                 lbCreatedOn.Text       = SessionState.User.FormatUtcDate(t.ModifyDate.Value, true, SessionState.User.FormatDate + ' ' + SessionState.User.FormatTime);
                                 UITools.HideToolBarButton(uwToolbar, "Delete");
                                 UITools.HideToolBarSeparator(uwToolbar, "SepDelete");
                                 #endregion
                             }
                             else
                             {
                                 #region Update translation
                                 uwToolbarTitle.Items.FromKeyLabel("Action").Text = "Updating";
                                 txtTermValue.Text     = tt.Value;
                                 hlCreator.Text        = tt.User.FullName;
                                 hlCreator.NavigateUrl = "mailto:" + UITools.GetDisplayEmail(tt.User.Email) + Server.HtmlEncode("?subject=TermTranslation");;
                                 lbOrganization.Text   = tt.User.OrgName;
                                 lbCreatedOn.Text      = SessionState.User.FormatUtcDate(tt.ModifyDate.Value, true, SessionState.User.FormatDate + ' ' + SessionState.User.FormatTime);
                                 UITools.ShowToolBarButton(uwToolbar, "Delete");
                                 UITools.ShowToolBarSeparator(uwToolbar, "SepDelete");
                                 #endregion
                             }
                         }
                     }
                     else
                     {
                         Response.Write("<script>alert('An error occurred when retrieving translation term [" + Request["t"] + "]' );window.close();</script>");
                         Response.End();
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             Response.Write("<script>alert('An error occurred when retrieving translation term:" + ex.Message + " [" + Request["t"] + "]' );window.close();</script>");
             Response.End();
         }
     }
 }