/// <summary> /// 编辑信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEdit_Click(object sender, RoutedEventArgs e) { //获取鼠标选择的索引 int num = dgUsers.SelectedIndex; if (num < 0) { MessageBox.Show("请选择要修改的行!"); } else { //获取选中行 PayData user = (PayData)dgUsers.SelectedValue; //打开编辑窗口 EditPayPage editRecord = new EditPayPage(); editRecord.isAdd = false; //设置编号不能编辑 editRecord.txtID.IsReadOnly = true; //绑定数据 editRecord.gridUser.DataContext = user; //显示窗口 editRecord.ShowDialog(); LoadData(); } }
// 添加信息 private void btnAdd_Click(object sender, RoutedEventArgs e) { // DispatcherTimer timer = new DispatcherTimer(); EditPayPage editUser = new EditPayPage(); editUser.isAdd = true; editUser.ShowDialog(); //加载数据 LoadData(); }