private void buttonExecute_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; try { int iYear = Convert.ToInt16(comboBoxYear.Text); int iMonth = comboBoxMonth.SelectedIndex + 1; int iDay = Convert.ToInt16(comboBoxDay.Text); int iHour = Convert.ToInt16(comboBoxHour.Text); int iMin = Convert.ToInt16(comboBoxMin.Text); int iSec = Convert.ToInt16(comboBoxSec.Text); if (DeviceControlClass.SetDeviceTime(1, 2, iYear, iMonth, iDay, iHour, iMin, iSec, sIP, iPort)) { string sCurrntTime = string.Empty; if (DeviceControlClass.GetDeviceTime(1, 2, out sCurrntTime, sIP, iPort)) { textBoxNew.Text = sCurrntTime; MessageBox.Show(@"Device time sync successfull.", @"Time Sychronization", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { textBoxNew.Text = @"No Time Set."; } } } catch (Exception ex) { Console.WriteLine(@"Error - " + ex.Message); //throw; } Cursor.Current = Cursors.Default; }
private void buttonSetTime02_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; try { groupBox2.Enabled = true; comboBoxYear.DataSource = UtilityClass.FillYear(); comboBoxMonth.DataSource = UtilityClass.FillMonth(); comboBoxDay.DataSource = UtilityClass.FillDays(); comboBoxHour.DataSource = UtilityClass.FillHours(); comboBoxMin.DataSource = UtilityClass.FillMins(); comboBoxSec.DataSource = UtilityClass.FillSecs(); comboBoxYear.SelectedIndex = 0; comboBoxMonth.SelectedIndex = 0; comboBoxDay.SelectedIndex = 0; comboBoxHour.SelectedIndex = 0; comboBoxMin.SelectedIndex = 0; comboBoxSec.SelectedIndex = 0; string sCurrentTime; if (DeviceControlClass.GetDeviceTime(1, 2, out sCurrentTime, sIP, iPort)) { textBoxCurrent.Text = sCurrentTime; } } catch (Exception) { MessageBox.Show(@"Please make sure the device is connected.", @"Device", MessageBoxButtons.OK, MessageBoxIcon.Information); //throw; } Cursor = Cursors.Default; }