private void Init() { dicLangaugeList = new Dictionary <string, LanguageWord>(); try { string strFileName = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "language.mdb"); string strConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Password=;Data Source=" + strFileName + ";Persist Security Info=True"; OleDbConnection conn = new OleDbConnection(strConnectionString); conn.Open(); OleDbDataAdapter da = new OleDbDataAdapter("select * from Control", conn); DataTable tb = new DataTable(); da.Fill(tb); conn.Close(); for (int i = 0; i < tb.Rows.Count; i++) { LanguageWord word = new LanguageWord(); word.ControlID = tb.Rows[i]["ControlID"].ToString(); word.ControlENText = tb.Rows[i]["ControlENText"].ToString(); word.ControlCHSText = tb.Rows[i]["ControlCHSText"].ToString(); word.ControlCHTText = tb.Rows[i]["ControlCHTText"].ToString(); dicLangaugeList.Add(word.ControlID.ToUpper(), word); } } catch (Exception ex) { throw ex; } }
public static string GetLanguageWord(string controlID) { if (dicLangaugeList == null) { LanguagePack pack = new LanguagePack(); pack.Init(); } string strText = ""; if (dicLangaugeList.ContainsKey(controlID.ToUpper()) == true) { LanguageWord word = dicLangaugeList[controlID.ToUpper()]; if (SystemVariable.CurrentLangaugeCode == LanguageType.SimplifiedChinese) { strText = word.ControlCHSText; } else if (SystemVariable.CurrentLangaugeCode == LanguageType.English) { strText = word.ControlENText; } else if (SystemVariable.CurrentLangaugeCode == LanguageType.TraditionalChinese) { strText = word.ControlCHTText; } else { strText = word.ControlCHSText; } } return(strText); }