//添加记录 private void AddRelationRecord(object sender, RoutedEventArgs e) { //创建编辑窗口 RelationEditWindow relationEditWindow = new RelationEditWindow(); bool?flag = relationEditWindow.ShowDialog(); //获取新数据 if (flag == true) { List <string> lines = new List <string>(File.ReadAllLines(FileTools.relationFilePath)); string[] data = lines[lines.Count - 1].Split(new char[] { ';' }); Relation_ListView.Items.Add(new { number = data[0], template = data[1], printer = data[2] }); } }
//编辑记录 private void ChangeRelationRecord(object sender, RoutedEventArgs e) { //创建编辑窗口 RelationEditWindow relationEditWindow = new RelationEditWindow(Relation_ListView.SelectedIndex); relationEditWindow.ShowDialog(); //更新数据 List <string> lines = new List <string>(File.ReadAllLines(FileTools.relationFilePath)); string[] data = lines[Relation_ListView.SelectedIndex].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (data.Length == 3) { Relation_ListView.Items[Relation_ListView.SelectedIndex] = new { number = data[0], template = data[1], printer = data[2] } } ; }
//编辑记录 private void ChangeRelationRecord(object sender, RoutedEventArgs e) { try { RelationEditWindow relationEditWindow = new RelationEditWindow(Relation_ListView.SelectedIndex); relationEditWindow.ShowDialog(); //更新数据 List <string> lines = new List <string>(File.ReadAllLines(FileTools.relationFilePath)); //string[] data = lines[Relation_ListView.SelectedIndex].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); //if (data.Length == 3) // Relation_ListView.Items[Relation_ListView.SelectedIndex] = new { number = data[0], template = data[1], printer = data[2] }; LoadData(); } catch (Exception ex) { MessageBox.Show(ex.Message, this.Title, MessageBoxButton.OK); } //创建编辑窗口 }
//添加记录 private void AddRelationRecord(object sender, RoutedEventArgs e) { try { //创建编辑窗口 RelationEditWindow relationEditWindow = new RelationEditWindow(); bool?flag = relationEditWindow.ShowDialog(); //获取新数据 if (flag == true) { List <string> lines = new List <string>(File.ReadAllLines(FileTools.relationFilePath)); //string[] data = lines[lines.Count - 1].Split(new char[] { ';' }); //Relation_ListView.Items.Add(new { number = data[0], template = data[1], printer = data[2] }); LoadData(); } } catch (Exception ex) { MessageBox.Show(ex.Message, this.Title, MessageBoxButton.OK); } }