示例#1
0
        private void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            //获取鼠标选择的索引
            int num = dgUsers.SelectedIndex;

            if (num < 0)
            {
                MessageBox.Show("请选择要修改的行!");
            }
            else
            {
                //获取选中行
                AttendanceData user = (AttendanceData)dgUsers.SelectedValue;
                //打开编辑窗口
                EditAttendancePage editAttendance = new EditAttendancePage();
                editAttendance.isAdd = false;
                //设置编号不能编辑
                editAttendance.txtID.IsReadOnly = true;
                //绑定数据
                editAttendance.gridUser.DataContext = user;

                //显示窗口
                editAttendance.ShowDialog();
            }
        }
示例#2
0
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            EditAttendancePage editUser = new EditAttendancePage();

            editUser.isAdd = true;
            editUser.ShowDialog();
            //加载数据
            LoadData();
        }