private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.listView1.SelectedItems.Count > 0)
     {
         //if (MessageBox.Show("是否删除该设备类型?") == DialogResult.OK)
         if (MessageBox.Show("确定要删除该设备类型吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             if (this.listView1.SelectedItems[0].Tag is DeviceType)
             {
                 var deviceType = this.listView1.SelectedItems[0].Tag as DeviceType;
                 var serialnum  = deviceType.Serialnum;
                 List <ControlDeviceUnit> controlDeviceUnitList =
                     ControlDeviceUnit.FindAllByDeviceTypeSerialnum(serialnum);
                 if (controlDeviceUnitList != null)
                 {
                     MessageBox.Show("该设备类型已经在使用,不能删除");
                     return;
                 }
                 DeviceType.Delete(deviceType);
                 this.InitDeviceTypeListView();
                 this.deviceTypeSerialnum = null;
             }
         }
     }
 }