IBE.SQL.EliteDBIO.switchLanguage C# (CSharp) Method

switchLanguage() public method

Switch the language, updating the loccommodity-string in tbCommodities.
public switchLanguage ( String Language ) : void
Language String new language for viewing
return void
        public void switchLanguage(String Language)
        {
            String sqlString;
            
            try
            {
                // commodities
                sqlString = String.Format(
                            "update tbcommodity C, (select C1.ID, if(Loc1.LocName is null, C1.Commodity, Loc1.LocName) As loccommodity" + 
                            "                          from tbCommodity C1 left join  (" +
                            "                               select * from tbCommodityLocalization L2, tbLanguage La2" +
							"				                 where L2.Language_id = La2.id" +
							"				                 and La2.language     = {0}) Loc1" + 
							"	                        on C1.id = loc1.Commodity_id) Loc" +
							" set C.loccommodity = Loc.loccommodity" +
							" where C.id = Loc.ID", DBConnector.SQLAString(Language)); 

                Program.DBCon.Execute(sqlString);

                // categories
                sqlString = String.Format(
                            "update tbCategory C, (select C1.ID, if(Loc1.LocName is null, C1.Category, Loc1.LocName) As locCategory" + 
                            "                          from tbCategory C1 left join  (" +
                            "                               select * from tbCategoryLocalization L2, tbLanguage La2" +
							"				                 where L2.Language_id = La2.id" +
							"				                 and La2.language     = {0}) Loc1" + 
							"	                        on C1.id = loc1.Category_id) Loc" +
							" set C.locCategory = Loc.locCategory" +
							" where C.id = Loc.ID", DBConnector.SQLAString(Language)); 

                Program.DBCon.Execute(sqlString);

                // economy levels
                sqlString = String.Format(
                            "update tbEconomyLevel C, (select C1.ID, if(Loc1.LocName is null, C1.Level, Loc1.LocName) As locEconomyLevel" +
                            "                              from tbEconomyLevel C1 left join  (" +
                            "                                   select * from tbLevelLocalization L2, tbLanguage La2" +
                            "                                    where L2.Language_id = La2.id" +
                            "                                    and   La2.language   = {0}) Loc1" +
                            "                               on C1.id = loc1.EconomyLevel_id) Loc " +
                            " set C.locLevel = Loc.locEconomyLevel " +
                            " where C.id = Loc.ID", DBConnector.SQLAString(Language)); 

                Program.DBCon.Execute(sqlString);
            }
            catch (Exception ex)
            {
                throw new Exception("Error while switching the language to <" + Language + ">", ex);
            }
        }