private void buttonPowerOff_Click(object sender, EventArgs e) { dataGridView1.DataSource = null; string sError = string.Empty; if (DeviceControlClass.TurnOffDevice(1, ref sError, 2, "192.168.1.201", 4370) == true) { MessageBox.Show(@"Powering Off Device...", @"Device Shutdown.", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(sError.ToString()); } }
private void buttonOff_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; try { string sError = string.Empty; if (DeviceControlClass.TurnOffDevice(1, ref sError, 2, sIP, iPort)) { MessageBox.Show(@"Power Off Device...", @"Device Shutdown.", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(@"Cannot connect to the device. " + sError, @"Device Connection Error.", MessageBoxButtons.OK, MessageBoxIcon.Error); } groupBox2.Enabled = false; } catch (Exception) { MessageBox.Show(@"Please make sure the device is connected.", @"Device Connection", MessageBoxButtons.OK, MessageBoxIcon.Information); //throw; } Cursor = Cursors.Default; }