/// <summary> /// Edit calling window time. /// </summary> /// private void TimeEditBtn_Click(object sender, EventArgs e) { try { if (CallingWindowLV.SelectedItems.Count == 1) { GXDLMSAutoConnect target = Target as GXDLMSAutoConnect; ListViewItem li = CallingWindowLV.SelectedItems[0]; KeyValuePair <GXDateTime, GXDateTime> it = (KeyValuePair <GXDateTime, GXDateTime>)li.Tag; GXDateTimeDlg dlg = new GXDateTimeDlg(it.Key, it.Value); if (dlg.ShowDialog(this) == DialogResult.OK) { li.SubItems[0].Text = it.Key.ToFormatString(); li.SubItems[1].Text = it.Value.ToFormatString(); errorProvider1.SetError(CallingWindowLV, Properties.Resources.ValueChangedTxt); Target.UpdateDirty(5, target.CallingWindow); } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Edit execution time. /// </summary> private void TimeEditBtn_Click(object sender, EventArgs e) { try { if (Time.SelectedItems.Count == 1) { GXDLMSActionSchedule target = Target as GXDLMSActionSchedule; List <GXDateTime> entries = new List <GXDateTime>(); if (target.ExecutionTime != null) { entries.AddRange(target.ExecutionTime); } ListViewItem li = Time.SelectedItems[0]; GXDateTime it = (GXDateTime)li.Tag; GXDateTimeDlg dlg = new GXDateTimeDlg(it); if (dlg.ShowDialog(this) == DialogResult.OK) { li.SubItems[0].Text = it.ToFormatString(); errorProvider1.SetError(Time, Properties.Resources.ValueChangedTxt); target.ExecutionTime = entries.ToArray(); Target.UpdateDirty(4, target.ExecutionTime); } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Add calling window time. /// </summary> private void TimeAddBtn_Click(object sender, EventArgs e) { try { GXDLMSAutoConnect target = Target as GXDLMSAutoConnect; KeyValuePair <GXDateTime, GXDateTime> it = new KeyValuePair <GXDateTime, GXDateTime>(DateTime.Now, DateTime.Now); GXDateTimeDlg dlg = new GXDateTimeDlg(it.Key, it.Value); if (dlg.ShowDialog(this) == DialogResult.OK) { ListViewItem li = CallingWindowLV.Items.Add(it.Key.ToFormatString()); li.SubItems.Add(it.Value.ToFormatString()); li.Tag = it; target.CallingWindow.Add(it); errorProvider1.SetError(CallingWindowLV, Properties.Resources.ValueChangedTxt); Target.UpdateDirty(5, target.CallingWindow); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }