Exemplo n.º 1
0
        private void DelOrg_Click(object sender, RoutedEventArgs e)
        {
            ActivityOrganization org = xDataGrid.SelectedItem as ActivityOrganization;

            if (org == null)
            {
                MessageBox.Show("请先选中要删除的单位信息,然后再次点击删除按钮", "操作提示");
                return;
            }
            else if (Equipments.Length > 0)
            {
                MessageBox.Show(string.Format("当前活动下,{0}已经包含设备,请先删除设备后再执行删除该单位的操作。", org.Name), "操作提示");
                return;
            }
            try
            {
                DataOperator.DeleteOrgByGuid(org.Guid);
                Organization[] orgs = xDataGrid.ItemsSource as Organization[];

                xDataGrid.ItemsSource = null;
                xDataGrid.ItemsSource = orgs.Where(p => p.Guid != org.Guid).ToArray();
                MessageBox.Show("删除成功");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetExceptionMessage(), "删除失败");
            }
        }