/// <summary> /// Edit token gateway. /// </summary> private void TokenGatewayEdit_Click(object sender, EventArgs e) { try { if (TokenGatewayView.SelectedItems.Count == 1) { GXDLMSAccount target = Target as GXDLMSAccount; ListViewItem li = TokenGatewayView.SelectedItems[0]; GXTokenGatewayConfiguration item = li.Tag as GXTokenGatewayConfiguration; GXDLMSTokenGatewayConfigurationDlg dlg = new GXDLMSTokenGatewayConfigurationDlg(item, target.Parent); if (dlg.ShowDialog(this) == DialogResult.OK) { li.SubItems[0].Text = item.CreditReference; li.SubItems[1].Text = item.TokenProportion.ToString(); errorProvider1.SetError(CreditChargeView, Properties.Resources.ValueChangedTxt); Target.UpdateDirty(12, target.CreditChargeConfigurations); } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Constructor. /// </summary> /// <param name="caption">Window caption.</param> /// <param name="target">Selected objects.</param> /// <param name="objects">List of COSEM objects.</param> public GXDLMSTokenGatewayConfigurationDlg(GXTokenGatewayConfiguration target, GXDLMSObjectCollection objects) { Target = target; InitializeComponent(); foreach (GXDLMSObject it in objects.GetObjects(Enums.ObjectType.Credit)) { TargetCb.Items.Add(it); if (it.LogicalName == target.CreditReference) { TargetCb.SelectedItem = it; } } ProportionTb.Text = target.TokenProportion.ToString(); }
/// <summary> /// Remove token gateway. /// </summary> private void TokenGatewayRemove_Click(object sender, EventArgs e) { try { GXDLMSAccount target = Target as GXDLMSAccount; while (TokenGatewayView.SelectedItems.Count != 0) { ListViewItem li = TokenGatewayView.SelectedItems[0]; GXTokenGatewayConfiguration item = li.Tag as GXTokenGatewayConfiguration; TokenGatewayView.Items.Remove(li); errorProvider1.SetError(TokenGatewayView, Properties.Resources.ValueChangedTxt); Target.UpdateDirty(12, target.TokenGatewayConfigurations); target.TokenGatewayConfigurations.Remove(item); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }