/// <summary> /// 取消编辑语言 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void dpCancel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { LanManagerWindow.dpDetail.Children.Clear(); LanManagerWindow.spOperator.Children.RemoveAt(1); UC_DBOpeartionDefault defaultWin2 = new UC_DBOpeartionDefault(LanManagerWindow); LanManagerWindow.spOperator.Children.Add(defaultWin2); UC_LanguageInfo lanInfo = new UC_LanguageInfo(App.GLstLanguageItemInEdit, LanManagerWindow); LanManagerWindow.dpDetail.Children.Add(lanInfo); }
void lvLanguage_SelectionChanged(object sender, SelectionChangedEventArgs e) { #region 准备数据 LanguageInfo row = lvLanguage.SelectedItem as LanguageInfo; if (row == null) { return; } string strMessageId = row.MessageID; List <LanguageInfo> lstLans = lstViewrSource.Where(p => p.MessageID == strMessageId).ToList(); App.GLstLanguageItemInEdit.Clear(); App.GLstLanguageItemInEdit = lstLans; #endregion #region 加载控件 UC_LanguageInfo uc_Lan; if (LanManagerWindow.dpDetail.Children.Count > 0) { try { //如果dpDetail中加载的是UC_LanguageInfo控件 则直接填充控件 而不New一个新的UC_LanguageInfo uc_Lan = LanManagerWindow.dpDetail.Children[0] as UC_LanguageInfo; uc_Lan.lstLanguageInfos = lstLans; uc_Lan.InitControl(); } catch { //反之 则new一个新的 加载到dpDetail uc_Lan = new UC_LanguageInfo(lstLans, LanManagerWindow); LanManagerWindow.dpDetail.Children.Clear(); LanManagerWindow.dpDetail.Children.Add(uc_Lan); } LanManagerWindow.spOperator.Children.RemoveAt(1); UC_DBOpeartionDefault edit = new UC_DBOpeartionDefault(LanManagerWindow); LanManagerWindow.spOperator.Children.Add(edit); } else { uc_Lan = new UC_LanguageInfo(lstLans, LanManagerWindow); LanManagerWindow.dpDetail.Children.Clear(); LanManagerWindow.dpDetail.Children.Add(uc_Lan); } #endregion }
/// <summary> /// 保存编辑语言 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void dpSave_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { List <string> lstParams; List <LanguageInfo> lstLans = GetLanguagesEdited(); ReturnResult result = null; for (int i = 0; i < lstLans.Count; i++) { lstParams = new List <string>(); lstParams.Add(App.GCurrentDBServer.DbType.ToString()); lstParams.Add(App.GCurrentDBServer.Host); lstParams.Add(App.GCurrentDBServer.Port); lstParams.Add(App.GCurrentDBServer.ServiceName); lstParams.Add(App.GCurrentDBServer.LoginName); lstParams.Add(App.GCurrentDBServer.Password); lstParams.Add(lstLans[i].LanguageCode); lstParams.Add(lstLans[i].MessageID); if (lstLans[i].DisplayMessage.Length > 1024) { lstParams.Add(lstLans[i].DisplayMessage.Substring(0, 1024)); lstParams.Add(lstLans[i].DisplayMessage.Substring(1024)); } else { lstParams.Add(lstLans[i].DisplayMessage); lstParams.Add(string.Empty); } if (lstLans[i].TipMessage.Length > 1024) { lstParams.Add(lstLans[i].TipMessage.Substring(0, 1024)); lstParams.Add(lstLans[i].TipMessage.Substring(1024)); } else { lstParams.Add(lstLans[i].TipMessage); lstParams.Add(string.Empty); } result = AboutLanguagesInServer.WCFOperationMthodA("HTTP", App.GCurrentUmpServer.Host, App.GCurrentUmpServer.Port , 3, lstParams); if (!result.BoolReturn) { MessageBox.Show(lstLans[i].LanguageCode + this.TryFindResource("SaveLanguageItemError").ToString(), this.TryFindResource("ErrorMsgTitle").ToString(), MessageBoxButton.OK, MessageBoxImage.Error); } else { UC_LanguageInfo uc_Info = new UC_LanguageInfo(lstLans, LanManagerWindow); LanManagerWindow.dpDetail.Children.Clear(); LanManagerWindow.dpDetail.Children.Add(uc_Info); LanManagerWindow.spOperator.Children.RemoveAt(1); UC_DBOpeartionDefault uc_Default = new UC_DBOpeartionDefault(LanManagerWindow); LanManagerWindow.spOperator.Children.Add(uc_Default); } } TreeView tree = LanManagerWindow.spContent.Children[2] as TreeView; TreeViewItem item = tree.SelectedItem as TreeViewItem; string strContextValue = item.DataContext.ToString(); string strSelectedLanCode = string.Empty; if (strContextValue.StartsWith("Lan-")) { DataRow row = item.Tag as DataRow; strSelectedLanCode = row["C002"].ToString(); } UC_LanguageData data = LanManagerWindow.dpData.Children[0] as UC_LanguageData; Common.RefershData(data.lvLanguage, strSelectedLanCode); data.lstViewrSource = data.lvLanguage.ItemsSource as List <LanguageInfo>; List <LanguageInfo> lstSingleLans = null; if (!string.IsNullOrEmpty(strSelectedLanCode)) { lstSingleLans = data.lstViewrSource.Where(p => p.LanguageCode == strSelectedLanCode).ToList(); data.lvLanguage.ItemsSource = null; data.lvLanguage.ItemsSource = lstSingleLans; } }