private void tabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { string userxml; windowLogin windowlogin; TabControl tabControl = sender as TabControl; if (tabControl == null) { return; } TabItem tabItem = tabControl.SelectedItem as TabItem; if (tabItem == null) { return; } if (tabItem.Tag.ToString() == "JGMarket") { try { if (IsLogin_Nop == false) { windowlogin = new windowLogin(); if (windowlogin.ShowDialog() == true) { userxml = Globals.nopClient.Login(windowlogin.UserName, windowlogin.UserPassword); //更换列表 //Globals.nopCateGory = Globals.nopClient.GetCateGory(); Globals.nopCateGory = Globals.nopClient.GetProductInfoList(); LoadProductInfoList(Globals.nopCateGory); //LoadCateGory(Globals.nopCateGory); if (userxml == "") { tabControl.SelectedIndex = 0; } else { NopUser = GetUserInfo(userxml); IsLogin_Nop = true; } } else { tabControl.SelectedIndex = 0; } } } catch (Exception ex) { log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); log.Error(ex.Message + "\r\n" + ex.StackTrace); } } }
NopUserInfo GetUserInfo(string xml) { XmlNodeList node; NopUserInfo info = new NopUserInfo(); XmlDocument xmlDoc = new XmlDocument(); try { xmlDoc.LoadXml(xml); node = xmlDoc.GetElementsByTagName("UserState"); if (node != null && node.Count > 0) { info.UserState = node[0].InnerText; } node = xmlDoc.GetElementsByTagName("UserId"); if (node != null && node.Count > 0) { info.UserId = node[0].InnerText; } node = xmlDoc.GetElementsByTagName("Name"); if (node != null && node.Count > 0) { info.Name = node[0].InnerText; } node = xmlDoc.GetElementsByTagName("Integral"); if (node != null && node.Count > 0) { info.Integral = double.Parse(node[0].InnerText); } node = xmlDoc.GetElementsByTagName("Balance"); if (node != null && node.Count > 0) { info.Balance = float.Parse(node[0].InnerText); } } catch (Exception ex) { log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); log.Error(ex.Message + "\r\n" + ex.StackTrace); } return(info); }