Ejemplo n.º 1
0
        public void UpdateContent(string isin, QEngine qengine)
        {
            DataTable income            = new DataTable();
            DataTable balance           = new DataTable();
            DataTable transposedIncome  = new DataTable();
            DataTable transposedBalance = new DataTable();
            int       removeRowCount    = 0;
            bool      isFinance         = false;

            isFinance = edenIF.GetProperty(isin, "Category") == "금융" ? true : false;

            if (isFinance == false)
            {
                Revenue         = new Financial("Revenue", "매출액");
                OperatingProfit = new Financial("OperatingProfit", "영업이익");
            }
            else
            {
                OperatingProfitAndLoss = new Financial("OperatingProfitAndLoss", "영업손익");
            }
            NetProfit        = new Financial("NetProfit", "당기순이익");
            AssetTotal       = new Financial("AssetTotal", "자산총계");
            LiabilitiesTotal = new Financial("LiabilitiesTotal", "부채총계");

            // make income statement
            if (edenIF.ContainsFinancials(isin, AccountingStandard.IFRS_CON) == true)
            {
                income = edenIF.GetIncomeStatement(isin, AccountingStandard.IFRS_CON);
            }
            else if (edenIF.ContainsFinancials(isin, AccountingStandard.IFRS_SEP) == true)
            {
                income = edenIF.GetIncomeStatement(isin, AccountingStandard.IFRS_SEP);
            }
            removeRowCount = income.Rows.Count - FinancialVisualMaxCount;

            if (removeRowCount > 0)
            {
                for (int index = 0; index < removeRowCount; index++)
                {
                    income.Rows.RemoveAt(0);
                }
            }
            transposedIncome = edenIF.GenerateTransposedTable(income);

            foreach (DataColumn column in transposedIncome.Columns)
            {
                DateTime date = new DateTime();
                if (DateTime.TryParse(column.ColumnName, out date) == true)
                {
                    column.ColumnName = Convert.ToDateTime(column.ColumnName).ToShortDateString();
                }
            }

            foreach (DataRow row in transposedIncome.Rows)
            {
                string convertedName = Financial.ConvertFinancialNameTo(row[0].ToString(), Synapse.Globalization.eNation.eKR);
                row[0] = convertedName;

                for (int index = 1; index < row.ItemArray.Count(); index++)
                {
                    row[index] = Convert.ToDouble(row[index]).ToString("#,##0.00");
                }
            }

            DgIncomeStatement.ItemsSource = transposedIncome.DefaultView;

            foreach (DataRow row in income.Rows)
            {
                if (isFinance == false)
                {
                    Revenue.Add(new Synapse.Financials.Figure()
                    {
                        Date        = Convert.ToDateTime(row["Date"]),
                        Value       = Convert.ToDouble(row["Revenue"]),
                        Currency    = Currency.KRW,
                        Unit        = Unit.Million,
                        ColumnIndex = 0
                    });
                    OperatingProfit.Add(new Synapse.Financials.Figure()
                    {
                        Date        = Convert.ToDateTime(row["Date"]),
                        Value       = Convert.ToDouble(row["OperatingProfit"]),
                        Currency    = Currency.KRW,
                        Unit        = Unit.Million,
                        ColumnIndex = 0
                    });
                }
                else
                {
                    OperatingProfitAndLoss.Add(new Synapse.Financials.Figure()
                    {
                        Date        = Convert.ToDateTime(row["Date"]),
                        Value       = Convert.ToDouble(row["OperatingProfitAndLoss"]),
                        Currency    = Currency.KRW,
                        Unit        = Unit.Million,
                        ColumnIndex = 0
                    });
                }
                NetProfit.Add(new Synapse.Financials.Figure()
                {
                    Date        = Convert.ToDateTime(row["Date"]),
                    Value       = Convert.ToDouble(row["NetProfit"]),
                    Currency    = Currency.KRW,
                    Unit        = Unit.Million,
                    ColumnIndex = 0
                });
            }

            // make balance sheet
            if (edenIF.ContainsFinancials(isin, AccountingStandard.IFRS_CON) == true)
            {
                balance = edenIF.GetBalanceSheet(isin, AccountingStandard.IFRS_CON);
            }
            else if (edenIF.ContainsFinancials(isin, AccountingStandard.IFRS_SEP) == true)
            {
                balance = edenIF.GetBalanceSheet(isin, AccountingStandard.IFRS_SEP);
            }
            removeRowCount = balance.Rows.Count - FinancialVisualMaxCount;

            if (removeRowCount > 0)
            {
                for (int index = 0; index < removeRowCount; index++)
                {
                    balance.Rows.RemoveAt(0);
                }
            }
            transposedBalance = edenIF.GenerateTransposedTable(balance);

            foreach (DataColumn column in transposedBalance.Columns)
            {
                DateTime date = new DateTime();
                if (DateTime.TryParse(column.ColumnName, out date) == true)
                {
                    column.ColumnName = Convert.ToDateTime(column.ColumnName).ToShortDateString();
                }
            }

            foreach (DataRow row in transposedBalance.Rows)
            {
                string convertedName = Financial.ConvertFinancialNameTo(row[0].ToString(), Synapse.Globalization.eNation.eKR);
                row[0] = convertedName;

                for (int index = 1; index < row.ItemArray.Count(); index++)
                {
                    row[index] = Convert.ToDouble(row[index]).ToString("#,##0.00");
                }
            }

            foreach (DataRow row in balance.Rows)
            {
                AssetTotal.Add(new Synapse.Financials.Figure()
                {
                    Date        = Convert.ToDateTime(row["Date"]),
                    Value       = Convert.ToDouble(row["AssetTotal"]),
                    Currency    = Currency.KRW,
                    Unit        = Unit.Million,
                    ColumnIndex = 0
                });
                LiabilitiesTotal.Add(new Synapse.Financials.Figure()
                {
                    Date        = Convert.ToDateTime(row["Date"]),
                    Value       = Convert.ToDouble(row["LiabilitiesTotal"]),
                    Currency    = Currency.KRW,
                    Unit        = Unit.Million,
                    ColumnIndex = 0
                });
            }

            DgBalanceSheet.ItemsSource = transposedBalance.DefaultView;

            UpdateChart(isin);
        }