protected void ddPL_SelectedIndexChanged(object sender, System.EventArgs e) { SaveCurrentItem(); if (ddPL.SelectedIndex == 0) { cbPLLanguages.ClearSelection(); cbPLLanguages.Enabled = false; } else { cbPLLanguages.Enabled = true; 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())) { DisplayPLOptions(business, ddPL.SelectedValue); } } 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"; } } }
public TRClass GetTRClassByKey(System.Int64 classId, string regionCode) { TRClass.CleanError(); using (Database dbObj = Utils.GetMainDB()) { using (IDataReader rs = dbObj.RunSPReturnRS("dbo._TRClass_GetAll", new SqlParameter("@Filter", "ClassId = " + classId.ToString() + " AND RegionCode = '" + regionCode + "'"), new SqlParameter("@Company", SessionState.CompanyName))) { if (dbObj.LastError != null && dbObj.LastError.Length == 0) { HyperCatalog.DataAccessLayer.SqlDataAccessLayer.GenerateCollectionFromReader col = new HyperCatalog.DataAccessLayer.SqlDataAccessLayer.GenerateCollectionFromReader(GenerateTRClassCollectionFromReader); TRClassList objCol = (TRClassList)col(rs); rs.Close(); if (objCol.Count > 0) { return(objCol[0]); } else { return(null); } } else { throw new DataException("SQLDataAccessLayer: GetTRClassByKey-> " + dbObj.LastError); } } } }
private CollectionBase GenerateTRClassCollectionFromReader(IDataReader rs) { TRClassList col = new TRClassList(); while (rs.Read()) { //Modified by Sateesh for Setting Scope and MTR Dates (PCF: ACQ 8.10) - 28/05/2009 TRClass obj = new TRClass(Convert.ToInt64(rs["ClassId"]), rs["RegionCode"].ToString().Trim(), TRClass.GetTranslationModeFromString(rs["TranslationMode"].ToString().Trim()), Convert.ToInt32(rs["ModifierId"]), GetProperDate(rs["ModifyDate"])); col.Add(obj); } return(col); }
//end private void UpdateOptions(string itemKey) { ItemKey = itemKey; string regionCode = string.Empty; if (Utils.IsWholeNumber(ItemKey)) { regionCode = ddClassRegions.SelectedValue.ToString(); //QC 2746 -- Modified by Sateesh on 20 July 2009 GetLanguagesByRegion(regionCode); //QC 2746 -- Modified by Sateesh on 20 July 2009 CurrentItemType = CurrentItemTypeEnum.Class; try { //using (TRClass t = TRClass.GetByKey(Convert.ToInt64(ItemKey), regionCode)) //Modified by Venkata 07 oct 16 using (TRClass t = GetTRClassByKey(Convert.ToInt64(ItemKey), regionCode)) { //ddClassRegions.Visible = true; //ddTermsRegions.Visible = false; pnl_ClassPanel.Visible = true; pnl_TermsPanel.Visible = false; UpdateClassOptions(t, regionCode); } } 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"; } } else { CurrentItemType = CurrentItemTypeEnum.Term; //QC 2746 -- Modified by Sateesh on 20 July 2009 regionCode = ddTermsRegions.SelectedValue.ToString(); //QC 2746 -- Modified by Sateesh on 20 July 2009 GetLanguagesByRegion(regionCode); using (TermType tt = TermType.GetByKey(Convert.ToChar(ItemKey))) { pnl_ClassPanel.Visible = false; pnl_TermsPanel.Visible = true; UpdateTermOptions(tt, regionCode); } } }
private void DisplayPLOptions(TRClass business, string plCode) { CurrentPL = plCode; cbPLLanguages.ClearSelection(); foreach (TRProductLineLanguage t in business.PLLanguages) { if (t.ProductLineCode == plCode) { ListItem li = cbPLLanguages.Items.FindByValue(t.LanguageCode); if (li != null) { li.Selected = true; } } } }
private void UpdateClassOptions(TRClass business, string regionCode) { lbItemName.Text = business.Name; rdTranslationMode.SelectedValue = business.TranslationMode.ToString(); panelCTRSettings.Visible = panelTranslationMode.Visible = true; panelPLSettings.Visible = business.TranslationMode == TRClassTranslationMode.PL; panelTermLanguages.Visible = false; // PL Settings if (panelPLSettings.Visible) { cbPLLanguages.ClearSelection(); ddPL.SelectedIndex = 0; cbPLLanguages.Enabled = false; } // CTR/MTR Settings cbMTRDays.ClearSelection(); cbCTRDays.ClearSelection(); foreach (TRBatchDay d in business.BatchDays) { if (d.Type == TRBatchDayType.MTR) { cbMTRDays.Items[d.DayOfMonth - 1].Selected = true; } else { cbCTRDays.Items[d.DayOfMonth - 1].Selected = true; } } // CTR Languages cbCTRLanguages.ClearSelection(); foreach (HyperCatalog.Business.Language cul in business.CTRLanguages) { ListItem li = cbCTRLanguages.Items.FindByValue(cul.Code); if (li != null) { li.Selected = true; } } // PL Options DisplayPLOptions(business, ddPL.SelectedValue); //btnChangePL.Attributes.Add("onclick", "ConfirmPLChange('" + rdTranslationMode.SelectedValue + "')"); }
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"; } }
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"; } }