private void EditWindow_Closed(object sender, EventArgs e) { EditWindow ew = (EditWindow)sender; ListBoxItem lbi = (ListBoxItem)ew.lbi; Baowen bw = (Baowen)lbi.Content; Baowen updateBaowen = this.ss.getBaowen(bw.Id); updateBaowen.Bw = updateBaowen.Bw.Replace(" ", ""); lbi.Content = updateBaowen; }
private void ListBoxItem_MouseDoubleClick(object sender, RoutedEventArgs e) { ListBoxItem lbi = (ListBoxItem)sender; EditWindow ew = new EditWindow(lbi); Baowen bw = (Baowen)lbi.Content; ew.Title = "修改报文: " + bw.Id; ew.Closed += new EventHandler(EditWindow_Closed); ew.Show(); }
private void btn_update_Click(object sender, RoutedEventArgs e) { string bw = input_bw.Text; string pinyin = input_pinyin.Text; string qianming = input_qianming.Text; Baowen baowen = new Baowen(bw, pinyin, qianming); baowen.Id = this.id; this.ss.UpdateBaowen(baowen); update_info.Text = "id " + this.id + " updated!"; }
public EditWindow(ListBoxItem lbi) { InitializeComponent(); Baowen bw = (Baowen)lbi.Content; this.lbi = lbi; this.id = bw.Id; Baowen bw_query = this.ss.getBaowen(this.id); input_bw.Text = bw_query.Bw; input_pinyin.Text = bw_query.Pinyin; input_qianming.Text = bw_query.Qianming; }
private void btn_pre_Click(object sender, RoutedEventArgs e) { Baowen baowen = this.ss.getBaowen(this.currentId - 1); if (baowen != null) { this.currentId = baowen.Id; input_id.Text = Convert.ToString(baowen.Id); input_bw.Text = baowen.Bw; input_pinyin.Text = baowen.Pinyin; input_qianming.Text = baowen.Qianming; } }
private void btn_add_Click(object sender, RoutedEventArgs e) { string id = input_id.Text; string bw = input_bw.Text; string pinyin = input_pinyin.Text; string qianming = input_qianming.Text; Baowen baowen = new Baowen(bw, pinyin, qianming); int newid = this.ss.InsertBaowen(baowen); if (newid != -1) { input_id.Text = Convert.ToString(newid); } }
/// <summary> /// 查询单条报文 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_query_Click(object sender, RoutedEventArgs e) { if (input_id.Text != string.Empty) { int id = Convert.ToInt32(input_id.Text); Baowen baowen = this.ss.getBaowen(id); input_bw.Text = baowen.Bw; input_pinyin.Text = baowen.Pinyin; input_qianming.Text = baowen.Qianming; this.currentId = id; btn_update.IsEnabled = true; } else { btn_update.IsEnabled = false; } }
private void TextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { TextBox textBox = e.Source as TextBox; //MessageBox.Show("enter"); int id = Convert.ToInt32(textBox.Text); Baowen baowen = this.ss.getBaowen(id); baowen.Bw = baowen.Bw.Replace(" ", ""); ContentPresenter cp = textBox.TemplatedParent as ContentPresenter; Border bd = (Border)cp.Parent; //只有修改listboxitem的content以后才能更新控件 ListBoxItem item = (ListBoxItem)bd.TemplatedParent; //list.ItemContainerGenerator int index = listBox_bw.ItemContainerGenerator.IndexFromContainer(item); if (baowen.Id != 0) { this.listB[index] = baowen; item.Content = baowen; } } }