Ejemplo n.º 1
0
 /// <summary>
 /// 删除plc
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void click_Del_Device(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("确认删除吗", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
     {
         DC_DEVICE device = (DC_DEVICE)(sender as FrameworkElement).Tag;
         try
         {
             dC_Service.DeleteDevice(device);
             MessageBox.Show("删除成功。");
             DC_SERVER server = Servers.First(s => s.Devices.Contains(device));
             server.Devices.Remove(device);
         }
         catch (Exception ex)
         {
             MessageBox.Show("删除异常。" + ex.Message);
         }
     }
 }