Ejemplo n.º 1
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("确认删除吗?", "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                using (new WaitCursor())
                {
                    SCA.Model.LoopModel loop = ((SCA.WPF.ViewModelsRoot.ViewModels.DetailInfo.DeviceInfo8001ViewModel) this.DataContext).TheLoop;
                    var selectedItems        = DataGrid_Device.SelectedItems;
                    if (selectedItems != null)
                    {
                        SCA.BusinessLib.BusinessLogic.DeviceService8001 deviceService = new SCA.BusinessLib.BusinessLogic.DeviceService8001();
                        deviceService.TheLoop = loop;

                        foreach (SCA.WPF.ViewModelsRoot.ViewModels.DetailInfo.EditableDeviceInfo8001 r in selectedItems)
                        {
                            if (r != null)
                            {
                                deviceService.DeleteBySpecifiedID(r.ID);
                            }
                        }
                        //刷新界面
                        ((SCA.WPF.ViewModelsRoot.ViewModels.DetailInfo.DeviceInfo8001ViewModel) this.DataContext).DeviceInfoObservableCollection = new SCA.WPF.ViewModelsRoot.ViewModels.DetailInfo.EditableDeviceInfo8001Collection(loop, loop.GetDevices <Model.DeviceInfo8001>());
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            SCA.Model.LoopModel loop = ((SCA.WPF.ViewModelsRoot.ViewModels.DetailInfo.DeviceInfo8003ViewModel) this.DataContext).TheLoop;
            var selectedItems        = DataGrid_Device.SelectedItems;

            if (selectedItems != null)
            {
                SCA.BusinessLib.BusinessLogic.DeviceService8003 deviceService = new SCA.BusinessLib.BusinessLogic.DeviceService8003();
                deviceService.TheLoop = loop;

                foreach (SCA.WPF.ViewModelsRoot.ViewModels.DetailInfo.EditableDeviceInfo8003 r in selectedItems)
                {
                    if (r != null)
                    {
                        deviceService.DeleteBySpecifiedID(r.ID);
                    }
                }
                //刷新界面
                ((SCA.WPF.ViewModelsRoot.ViewModels.DetailInfo.DeviceInfo8003ViewModel) this.DataContext).DeviceInfoObservableCollection = new SCA.WPF.ViewModelsRoot.ViewModels.DetailInfo.EditableDeviceInfo8003Collection(loop, loop.GetDevices <Model.DeviceInfo8003>());
            }
        }