private void Workers_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (Workers.SelectedItem != null) { TeamWorkers teamWorkers = (TeamWorkers)Workers.SelectedItem; ID = teamWorkers.Id; Worker.Text = teamWorkers.WorkerName; } else { Clear(); } }
private void buttonAdd_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(Worker.Text)) { MessageBox.Show("请输入团队成员姓名!", "错误"); return; } dataContext = new DataClassesProjectClassifyDataContext(); TeamWorkers teamWorkers = new TeamWorkers(); teamWorkers.ProjectID = projectID; teamWorkers.WorkerName = Worker.Text; dataContext.TeamWorkers.InsertOnSubmit(teamWorkers); dataContext.SubmitChanges(); Workers.DataContext = dataContext.TeamWorkers.Where(t => t.ProjectID.Equals(projectID)); ((MainWindow)(this.Owner)).DialogR = true; }
private void buttonRemove_Click(object sender, RoutedEventArgs e) { if (ID == 0) { MessageBox.Show("请选择团队成员!", "错误"); return; } if (MessageBox.Show("该团队成员将被删除!确认要删除该团队成员信息?", "警告", MessageBoxButton.YesNo) == MessageBoxResult.No) { return; } dataContext = new DataClassesProjectClassifyDataContext(); TeamWorkers teamWorkers = (TeamWorkers)Workers.SelectedItem; dataContext.TeamWorkers.DeleteOnSubmit(teamWorkers); dataContext.SubmitChanges(); dataContext = new DataClassesProjectClassifyDataContext(); Workers.DataContext = dataContext.TeamWorkers.Where(t => t.ProjectID.Equals(projectID)); ((MainWindow)(this.Owner)).DialogR = true; Clear(); }