Exemplo n.º 1
0
 private void EditBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (PassiveChargePerUnits.SelectedItems.Count == 1)
         {
             ListViewItem     li            = PassiveChargePerUnits.SelectedItems[0];
             byte[]           index         = GXDLMSTranslator.HexToBytes(li.SubItems[0].Text);
             Int16            chargePerUnit = Int16.Parse(li.SubItems[1].Text);
             GXDLMSCharge     target        = Target as GXDLMSCharge;
             GXChargeTableDlg dlg           = new GXChargeTableDlg(index, chargePerUnit, false);
             if (dlg.ShowDialog(this) == DialogResult.OK)
             {
                 GXChargeTable t = (GXChargeTable)li.Tag;
                 t.Index             = GXDLMSTranslator.ToHex(dlg.Index);
                 t.ChargePerUnit     = dlg.ChargePerUnit;
                 li.SubItems[0].Text = t.Index;
                 li.SubItems[1].Text = dlg.ChargePerUnit.ToString();
                 errorProvider1.SetError(PassiveChargePerUnits, Properties.Resources.ValueChangedTxt);
                 Target.UpdateDirty(6, target.UnitChargePassive.ChargeTables);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 2
0
 private void AddBtn_Click(object sender, EventArgs e)
 {
     try
     {
         GXDLMSCharge     target = Target as GXDLMSCharge;
         GXChargeTableDlg dlg    = new GXChargeTableDlg(null, 0, false);
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             List <GXChargeTable> list = new List <GXChargeTable>();
             if (target.UnitChargePassive.ChargeTables != null)
             {
                 list.AddRange(target.UnitChargePassive.ChargeTables);
             }
             GXChargeTable t = new GXChargeTable();
             t.Index         = GXDLMSTranslator.ToHex(dlg.Index);
             t.ChargePerUnit = dlg.ChargePerUnit;
             ListViewItem li = new ListViewItem(t.Index);
             li.Tag = t;
             li.SubItems.Add(t.ChargePerUnit.ToString());
             list.Add(t);
             target.UnitChargePassive.ChargeTables = list.ToArray();
             PassiveChargePerUnits.Items.Add(li);
             errorProvider1.SetError(PassiveChargePerUnits, Properties.Resources.ValueChangedTxt);
             Target.UpdateDirty(6, target.UnitChargePassive.ChargeTables);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }