public void Load(ArgInfo argInfo) { _argInfo = argInfo; _origArg = new ArgInfo {upLimit = argInfo.upLimit, downLimit = argInfo.downLimit, argDataSql = argInfo.argDataSql,argName = argInfo.argName,argNo = argInfo.argNo}; argPanel.DataContext = _argInfo; BindData(); }
public static void ShowArgInfoControl(ArgInfo argInfo, TemplateInfoControl templateInfoControl, TemplateInfo templateInfo) { var w = new MetroWindow {Height = 430, Width = 600, EnableDWMDropShadow = true, ResizeMode = ResizeMode.NoResize}; w.LostFocus += (ss, ee) => w.Focus(); w.Title = "参数信息"; w.WindowStartupLocation = WindowStartupLocation.CenterScreen; var control = new ArgInfoControl(); control.Load(argInfo); control.OnCancelClose += (sender, args) => w.Close(); control.OnOkClose += (ss, ee) => { if (Tools.UpdateArgConfig(argInfo) != "") { return; } templateInfoControl.Load(templateInfo, true); w.Close(); }; w.Content = control; w.ShowDialog(); }
public static string UpdateArgConfig(ArgInfo argInfo) { var origArgInfoList = WindowsTools.XmlDeseerializer(typeof (List<ArgInfo>), ArgConfigPath, out _tmpResult) as List<ArgInfo>; if (origArgInfoList == null || _tmpResult != "") { return _tmpResult; } origArgInfoList.Remove(origArgInfoList.Single(p => p.argID == argInfo.argID)); origArgInfoList.Add(argInfo); origArgInfoList = origArgInfoList.OrderBy(p => p.templateID).ThenBy(p => p.argType).OrderBy(p => p.argName).ToList(); WindowsTools.XmlSerialize(origArgInfoList, ArgConfigPath, out _tmpResult); return _tmpResult; }
void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { var listBox = sender as ListBox; if (listBox == null) { return; } _selectedArgInfo = listBox.SelectedItem as ArgInfo; }
/// <summary> /// /// </summary> /// <param name="argInfo"></param> /// <param name="condition"></param> /// <param name="regionPath"></param> /// <returns></returns> public static string AddCondition(ArgInfo argInfo, string condition, string regionPath = "4=4") { var sql = argInfo.argDataSql; string result; if (string.IsNullOrEmpty(sql)) { result = ""; } else { sql = sql.Replace("\"", ""); sql = sql.Replace("1=1", (condition == "") ? "1=1" : condition); sql = sql.Replace("2=2", string.IsNullOrEmpty(argInfo.downLimit) ? "2=2" : argInfo.downLimit); sql = sql.Replace("3=3", string.IsNullOrEmpty(argInfo.upLimit) ? "3=3" : argInfo.upLimit); sql = sql.Replace("4=4", regionPath); sql.Insert(6, " top 10 "); result = sql; } return result; }