示例#1
0
 protected void btnChangePL_Click(object sender, System.EventArgs e)
 {
     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()))
         {
             business.TranslationMode = (TRClassTranslationMode)Enum.Parse(typeof(TRClassTranslationMode), rdTranslationMode.SelectedValue);
             business.Save(HyperCatalog.Shared.SessionState.User.Id);
             UpdateClassOptions(business, ddClassRegions.SelectedValue.ToString());
         }
     }
     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";
     }
 }
示例#2
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";
            }
        }