protected override void OnCellValueChanged(DataGridViewCellEventArgs e) { bool IsLastRow = e.RowIndex == Rows.Count - 1; if (ElementShowed != null) { switch (e.ColumnIndex) { case DataGridViewAccountingStatics.Column_Amount: if (!IsLastRow && ElementShowed.GetNodeType() == NodeType.Institution) { var valueAmount = Rows[e.RowIndex].Cells[e.ColumnIndex].Value; try { ElementShowed.ModifyAmount(FXMarketUsed, AssetMarketUsed, Rows[e.RowIndex].Cells[0].Value.ToString(), ValueFromStringToDouble(valueAmount)); } catch { } } break; case DataGridViewAccountingStatics.Column_Currency: var valueCcy = Rows[e.RowIndex].Cells[e.ColumnIndex].Value; ICcyAsset ccyAsset = new Currency(valueCcy); if (Assets.Contains(valueCcy)) { ccyAsset = new Asset(valueCcy); } ElementShowed.ModifyCcy(FXMarketUsed, AssetMarketUsed, Rows[e.RowIndex].Cells[0].Value.ToString(), ccyAsset, IsLastRow); break; } ShowElement(ElementShowed); } else if (TotalShowed != null) { switch (e.ColumnIndex) { case DataGridViewAccountingStatics.Column_Currency: var valueCcy = Rows[e.RowIndex].Cells[e.ColumnIndex].Value; TotalShowed.ModifyCcy(valueCcy); break; } ShowTotalEventHandler?.Invoke(this, e); } }
public void ShowElement(IAccountingElement iElmt, TreeViewMappingElement tvme = null, Dictionary <string, double?> lastTotal = null) { if (tvme == null) { tvme = _Memory; } else { _Memory = tvme; } SetLastTotalMemoryAmount(lastTotal); Rows.Clear(); foreach (IAccountingElement item in iElmt.GetItemList(tvme)) { AddRow(item, iElmt.CcyRef, lastTotal: GetLastTotalMemoryAmount(item.GetName())); } AddRow(iElmt.GetTotalAccount(FXMarketUsed, AssetMarketUsed, iElmt.CcyRef, overrideName: "Total", lastTotal: GetLastTotalMemoryAmount()), isTotalRow: iElmt.GetNodeType() != NodeType.Account); ElementShowed = iElmt; TotalShowed = null; Rows[0].Cells[0].Selected = false; }