private void SaveFinISFromCsv(int companyId, string csv, FinancialsSpans span) { /* csv = "C1,C2,C3,C4,C5," + csv; //csv = csv.Replace(", plant", "plant"); DataTable dt = Csv2DataTable(csv); for (int i = 1; i <= 5; i++) { DataColumn col = dt.Columns[i]; string fiscalEnd = dt.Rows[0][col] as string; string[] feParts = fiscalEnd.Split('-'); int year = int.Parse(feParts[0]); int quarter = int.Parse(feParts[1]) / 3; if (quarter == 0) { quarter = 1; } SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); SqlCommand insertCommand = new SqlCommand("InsertIntoIncomeStatement", conn); insertCommand.CommandType = CommandType.StoredProcedure; Stopwatch w = new Stopwatch(); w.Start(); conn.Open(); SqlCommandBuilder.DeriveParameters(insertCommand); conn.Close(); w.Stop(); foreach (SqlParameter param in insertCommand.Parameters) { param.Value = DBNull.Value; } insertCommand.Parameters["@CompanyId"].Value = companyId; insertCommand.Parameters["@Year"].Value = year; if (span == FinancialsSpans.Quarterly) { insertCommand.Parameters["@Quarter"].Value = quarter; } Dictionary<string, string> paramMapping = new Dictionary<string, string>() { {"Revenue", "Revenue" }, {"Cost of revenue", "CostOfRevenue" }, {"Gross profit", "GrossProfit" }, {"Research and development", "OpExpResearchDevelopment" }, {"Sales, General and administrative", "OpExpSalesGeneralAdministrative" }, {"Other operating expenses", "OpExpOther" }, {"Interest Expense", "IncOperating" }, {"Other income (expense)", "IncOther" }, {"Income before taxes", "IncBeforeTaxes" }, {"Provision for income taxes", "IncTaxesProvision" }, {"Net income from continuing operations", "IncContinuingOperationsNet" }, {"Net income available to common shareholders", "IncAvailableToCommonShareholdersNet" }, {"Net income", "IncNet" }, {"BasicEPS", "EarningsPerShareBasic" }, {"DilutedEPS", "EarningsPerShareDiluted" }, {"BasicWASO", "WeightedAvgShareOutstandingBasic" }, {"DilutedWASO", "WeightedAvgShareOutstandingDiluted" }, {"EBITDA", "EBITDA" }, }; var dte = dt.AsEnumerable(); DataRow firstDIT = dte.FirstOrDefault(r => r[0] as string == "Basic" && dte.TakeWhile(x => x != r).All(previous => previous[0] as string != "Weighted average shares outstanding")); if (firstDIT != null) { firstDIT[0] = "BasicEPS"; } DataRow secondDIT = dte.FirstOrDefault(r => r[0] as string == "Basic" && dte.Reverse().TakeWhile(x => x != r).All(previous => previous[0] as string != "Weighted average shares outstanding")); if (secondDIT != null) { secondDIT[0] = "BasicWASO"; } DataRow firstDR = dte.FirstOrDefault(r => r[0] as string == "Diluted" && dte.TakeWhile(x => x != r).All(previous => previous[0] as string != "Weighted average shares outstanding")); if (firstDR != null) { firstDR[0] = "DilutedEPS"; } DataRow secondDR = dte.FirstOrDefault(r => r[0] as string == "Diluted" && dte.Reverse().TakeWhile(x => x != r).All(previous => previous[0] as string != "Weighted average shares outstanding")); if (secondDR != null) { secondDR[0] = "DilutedWASO"; } Dictionary<string, string> realParams = new Dictionary<string, string>(); foreach (string key in paramMapping.Keys) { string paramKey = "@" + RemoveQuotedCommas(String.Format("\"{0}\"", paramMapping[key])).Replace("\"", ""); var r = dt.AsEnumerable().FirstOrDefault(row => row[0] as string == key); if (r != null && !String.IsNullOrEmpty(r[col] as string)) { insertCommand.Parameters[paramKey].Value = float.Parse(r[col] as string); } } try { conn.Open(); insertCommand.ExecuteNonQuery(); } finally { conn.Close(); } } */ }
private void SaveFinCFFromCsv(int companyId, string csv, FinancialsSpans span) { /* csv = "C1,C2,C3,C4,C5," + csv; //csv = csv.Replace(", plant", "plant"); DataTable dt = Csv2DataTable(csv); for (int i = 1; i <= 5; i++) { DataColumn col = dt.Columns[i]; string fiscalEnd = dt.Rows[0][col] as string; string[] feParts = fiscalEnd.Split('-'); int year = int.Parse(feParts[0]); int quarter = int.Parse(feParts[1]) / 3; if (quarter == 0) { quarter = 1; } SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); SqlCommand insertCommand = new SqlCommand("InsertIntoCashFlow", conn); insertCommand.CommandType = CommandType.StoredProcedure; Stopwatch w = new Stopwatch(); w.Start(); conn.Open(); SqlCommandBuilder.DeriveParameters(insertCommand); conn.Close(); w.Stop(); foreach (SqlParameter param in insertCommand.Parameters) { param.Value = DBNull.Value; } insertCommand.Parameters["@CompanyId"].Value = companyId; insertCommand.Parameters["@Year"].Value = year; if (span == FinancialsSpans.Quarterly) { insertCommand.Parameters["@Quarter"].Value = quarter; } Dictionary<string, string> paramMapping = new Dictionary<string, string>() { {"Net income", "NetIncome" }, {"Depreciation & amortization", "DepriciationAmmortizationOA" }, {"Investment/asset impairment charges", "InvestmentAssetImpairmentChargesOA" }, {"Investments losses (gains)", "InvestmentsLossesOA" }, {"Stock based compensation", "StockBasedCompensationOA" }, {"Accounts receivable", "AccountsReceivableOA" }, {"Deferred income taxes", "DeferredIncomeTaxesOA" }, {"Inventory", "InventoryOA" }, {"Accounts payable", "AccountsPayableOA" }, {"Other working capital", "OtherWorkingCapitalOA" }, {"Other non-cash items", "OhterNonCashItemsOA" }, {"Net cash provided by operating activities", "NetCashProvidedByOA" }, {"Investments in property, plant, and equipment", "InvestmentsInPropertyPlantEquipmentIA" }, {"Property, plant, and equipment reductions", "PropertyPlantEquipmentReductionsIA" }, {"Acquisitions, net", "AcquisitionsNetIA" }, {"Purchases of investments", "PurchasesIA" }, {"Sales/Maturities of investments", "SalesMaturitiesIA" }, {"Other investing activities", "OtherIA" }, {"Net cash used for investing activities", "NetCashIA" }, {"Debt issued", "DebtIssuedFA" }, {"Debt repayment", "DebtRepaymentFA" }, {"Common stock issued", "CommonStockIssuedFA" }, {"Common stock repurchased", "CommonStockRepurchasedFA" }, {"Excess tax benefit from stock based compensation", "ExcessTaxBenefitStockBasedCompensationFA" }, {"Dividend paid", "Divident" }, {"Other financing activities", "OtherFA" }, {"Net cash provided by (used for) financing activities", "NetCashFA" }, {"Effect of exchange rate changes", "EchangeRateChangesEvents" }, {"Net change in cash", "NetChangeInCash" }, {"Cash at beginning of period", "BeginningPeriodCash" }, {"Cash at end of period", "EndPeriodCash" }, {"Operating cash flow", "OperatingCashFlow" }, {"Capital expenditure", "CapitalExpenditure" }, {"Free cash flow", "FreeCashFlow" }, }; Dictionary<string, string> realParams = new Dictionary<string, string>(); foreach (string key in paramMapping.Keys) { string paramKey = "@" + RemoveQuotedCommas(String.Format("\"{0}\"", paramMapping[key])).Replace("\"", ""); var r = dt.AsEnumerable().FirstOrDefault(row => row[0] as string == key); if (r != null && !String.IsNullOrEmpty(r[col] as string)) { insertCommand.Parameters[paramKey].Value = float.Parse(r[col] as string); } } try { conn.Open(); insertCommand.ExecuteNonQuery(); } finally { conn.Close(); } } */ }
private void SaveFinBSFromCsv(int companyId, string csv, FinancialsSpans span) { /* csv = "C1,C2,C3,C4,C5," + csv; //csv = csv.Replace(", plant", "plant"); DataTable dt = Csv2DataTable(csv); for (int i = 1; i <= 5; i++) { DataColumn col = dt.Columns[i]; string fiscalEnd = dt.Rows[0][col] as string; string[] feParts = fiscalEnd.Split('-'); int year = int.Parse(feParts[0]); int quarter = int.Parse(feParts[1]) / 3; if (quarter == 0) { quarter = 1; } SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); SqlCommand insertCommand = new SqlCommand("InsertIntoBalanceSheet", conn); insertCommand.CommandType = CommandType.StoredProcedure; Stopwatch w = new Stopwatch(); w.Start(); conn.Open(); SqlCommandBuilder.DeriveParameters(insertCommand); conn.Close(); w.Stop(); foreach (SqlParameter param in insertCommand.Parameters) { param.Value = DBNull.Value; } insertCommand.Parameters["@CompanyId"].Value = companyId; insertCommand.Parameters["@Year"].Value = year; if (span == FinancialsSpans.Quarterly) { insertCommand.Parameters["@Quarter"].Value = quarter; } Dictionary<string, string> paramMapping = new Dictionary<string, string>() { {"Cash and cash equivalents", "CashAndEquivalentCA" }, {"Short-term investments", "ShortTermInvestmentsCA" }, {"Receivables", "ReceivablesCA" }, {"Inventories", "InventoriesCA" }, {"Deferred income taxesCA", "DeferredIncomeTaxesCA" }, {"Prepaid expenses", "PrepaidExpensesCA" }, {"Other current assets", "OtherCA" }, {"Gross property, plant and equipment", "GrossPropertyPlantEquipmentNCA" }, {"Accumulated Depreciation", "AccumulatedDepreciationNCA" }, {"Net property, plant and equipment", "NetPropertyPlantEquipmentNCA" }, {"Equity and other investments", "EquityOtherInvestmentsNCA" }, {"Goodwill", "GoodwillNCA" }, {"Intangible assets", "IntangibleNCA" }, {"Deferred income taxesNCA", "DeferredIncomeTaxesNCA" }, {"Other long-term assets", "OtherNCA" }, {"Short-term debt", "ShortTermDebtCL" }, {"Accounts payable", "AccountsPayableCL" }, {"Taxes payable", "TaxesPayableCL" }, {"Accrued liabilities", "AccruedLiabilitiesCL" }, {"Deferred revenuesCL", "DeferredRevenuesCL" }, {"Other current liabilities", "OtherCL" }, {"Long-term debt", "LongTermDebtNCL" }, {"Deferred revenuesNCL", "DeferredRevenuesNCL" }, {"Pensions and other benefits", "PensionsAndOtherBenefitsNCL" }, {"Minority interest", "MinorityInterestNCL" }, {"Other long-term liabilities", "OtherNCL" }, {"Common stock", "CommonStockSE" }, {"Retained earnings", "RetainedEarningsSE" }, {"Treasury stock", "TreasuryStockSE" }, {"Accumulated other comprehensive income", "AccumulatedOtherComprehensiveIncome" } }; var dte = dt.AsEnumerable(); DataRow firstDIT = dte.FirstOrDefault(r => r[0] as string == "Deferred income taxes" && dte.TakeWhile(x => x != r).All(previous => previous[0] as string != "Non-current assets")); if (firstDIT != null) { firstDIT[0] = "Deferred income taxesCA"; } DataRow secondDIT = dte.FirstOrDefault(r => r[0] as string == "Deferred income taxes" && dte.Reverse().TakeWhile(x => x != r).All(previous => previous[0] as string != "Non-current assets")); if (secondDIT != null) { secondDIT[0] = "Deferred income taxesNCA"; } DataRow firstDR = dte.FirstOrDefault(r => r[0] as string == "Deferred income taxes" && dte.TakeWhile(x => x != r).All(previous => previous[0] as string != "Non-current liabilities")); if (firstDR != null) { firstDR[0] = "Deferred revenuesCL"; } DataRow secondDR = dte.FirstOrDefault(r => r[0] as string == "Deferred income taxes" && dte.Reverse().TakeWhile(x => x != r).All(previous => previous[0] as string != "Non-current liabilities")); if (secondDR != null) { secondDR[0] = "Deferred revenuesNCL"; } /* if (dt.AsEnumerable().Any(r => r[0] as string == "Deferred income taxes")) { dt.AsEnumerable().First(r => r[0] as string == "Deferred income taxes")[0] = "Deferred income taxesCA"; dt.AsEnumerable().First(r => r[0] as string == "Deferred income taxes")[0] = "Deferred income taxesNCA"; } if (dt.AsEnumerable().Any(r => r[0] as string == "Deferred revenues")) { dt.AsEnumerable().First(r => r[0] as string == "Deferred revenues")[0] = "Deferred revenuesCL"; dt.AsEnumerable().First(r => r[0] as string == "Deferred revenues")[0] = "Deferred revenuesNCL"; } */ /* Dictionary<string, string> realParams = new Dictionary<string, string>(); foreach(string key in paramMapping.Keys) { string paramKey = "@" + RemoveQuotedCommas(String.Format("\"{0}\"", paramMapping[key])).Replace("\"", ""); var r = dt.AsEnumerable().FirstOrDefault(row => row[0] as string == key); if (r != null && !String.IsNullOrEmpty(r[col] as string)) { insertCommand.Parameters[paramKey].Value = float.Parse(r[col] as string); } } try { conn.Open(); insertCommand.ExecuteNonQuery(); } finally { conn.Close(); } } */ }
private void SaveFinISFromCsv(int companyId, string csv, FinancialsSpans span) { /* * csv = "C1,C2,C3,C4,C5," + csv; * //csv = csv.Replace(", plant", "plant"); * DataTable dt = Csv2DataTable(csv); * for (int i = 1; i <= 5; i++) * { * DataColumn col = dt.Columns[i]; * string fiscalEnd = dt.Rows[0][col] as string; * string[] feParts = fiscalEnd.Split('-'); * * int year = int.Parse(feParts[0]); * int quarter = int.Parse(feParts[1]) / 3; * if (quarter == 0) * { * quarter = 1; * } * * * SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); * * SqlCommand insertCommand = new SqlCommand("InsertIntoIncomeStatement", conn); * insertCommand.CommandType = CommandType.StoredProcedure; * * Stopwatch w = new Stopwatch(); * w.Start(); * conn.Open(); * SqlCommandBuilder.DeriveParameters(insertCommand); * conn.Close(); * w.Stop(); * * * foreach (SqlParameter param in insertCommand.Parameters) * { * param.Value = DBNull.Value; * } * * insertCommand.Parameters["@CompanyId"].Value = companyId; * insertCommand.Parameters["@Year"].Value = year; * if (span == FinancialsSpans.Quarterly) * { * insertCommand.Parameters["@Quarter"].Value = quarter; * } * * * Dictionary<string, string> paramMapping = new Dictionary<string, string>() * { * {"Revenue", * "Revenue" * }, * {"Cost of revenue", * "CostOfRevenue" * }, * {"Gross profit", * "GrossProfit" * }, * {"Research and development", * "OpExpResearchDevelopment" * }, * {"Sales, General and administrative", * "OpExpSalesGeneralAdministrative" * }, * {"Other operating expenses", * "OpExpOther" * }, * {"Interest Expense", * "IncOperating" * }, * {"Other income (expense)", * "IncOther" * }, * {"Income before taxes", * "IncBeforeTaxes" * }, * {"Provision for income taxes", * "IncTaxesProvision" * }, * {"Net income from continuing operations", * "IncContinuingOperationsNet" * }, * {"Net income available to common shareholders", * "IncAvailableToCommonShareholdersNet" * }, * {"Net income", * "IncNet" * }, * {"BasicEPS", * "EarningsPerShareBasic" * }, * {"DilutedEPS", * "EarningsPerShareDiluted" * }, * {"BasicWASO", * "WeightedAvgShareOutstandingBasic" * }, * {"DilutedWASO", * "WeightedAvgShareOutstandingDiluted" * }, * {"EBITDA", * "EBITDA" * }, * }; * * * var dte = dt.AsEnumerable(); * * DataRow firstDIT = dte.FirstOrDefault(r => r[0] as string == "Basic" && dte.TakeWhile(x => x != r).All(previous => previous[0] as string != "Weighted average shares outstanding")); * if (firstDIT != null) * { * firstDIT[0] = "BasicEPS"; * } * DataRow secondDIT = dte.FirstOrDefault(r => r[0] as string == "Basic" && dte.Reverse().TakeWhile(x => x != r).All(previous => previous[0] as string != "Weighted average shares outstanding")); * if (secondDIT != null) * { * secondDIT[0] = "BasicWASO"; * } * * DataRow firstDR = dte.FirstOrDefault(r => r[0] as string == "Diluted" && dte.TakeWhile(x => x != r).All(previous => previous[0] as string != "Weighted average shares outstanding")); * if (firstDR != null) * { * firstDR[0] = "DilutedEPS"; * } * DataRow secondDR = dte.FirstOrDefault(r => r[0] as string == "Diluted" && dte.Reverse().TakeWhile(x => x != r).All(previous => previous[0] as string != "Weighted average shares outstanding")); * if (secondDR != null) * { * secondDR[0] = "DilutedWASO"; * } * * * Dictionary<string, string> realParams = new Dictionary<string, string>(); * * foreach (string key in paramMapping.Keys) * { * string paramKey = "@" + RemoveQuotedCommas(String.Format("\"{0}\"", paramMapping[key])).Replace("\"", ""); * * var r = dt.AsEnumerable().FirstOrDefault(row => row[0] as string == key); * if (r != null && !String.IsNullOrEmpty(r[col] as string)) * { * insertCommand.Parameters[paramKey].Value = float.Parse(r[col] as string); * } * * } * * * try * { * conn.Open(); * insertCommand.ExecuteNonQuery(); * } * finally * { * conn.Close(); * } * * * } */ }
private void SaveFinCFFromCsv(int companyId, string csv, FinancialsSpans span) { /* * csv = "C1,C2,C3,C4,C5," + csv; * //csv = csv.Replace(", plant", "plant"); * DataTable dt = Csv2DataTable(csv); * for (int i = 1; i <= 5; i++) * { * DataColumn col = dt.Columns[i]; * string fiscalEnd = dt.Rows[0][col] as string; * string[] feParts = fiscalEnd.Split('-'); * * int year = int.Parse(feParts[0]); * int quarter = int.Parse(feParts[1]) / 3; * if (quarter == 0) * { * quarter = 1; * } * * * SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); * * SqlCommand insertCommand = new SqlCommand("InsertIntoCashFlow", conn); * insertCommand.CommandType = CommandType.StoredProcedure; * * Stopwatch w = new Stopwatch(); * w.Start(); * conn.Open(); * SqlCommandBuilder.DeriveParameters(insertCommand); * conn.Close(); * w.Stop(); * * * foreach (SqlParameter param in insertCommand.Parameters) * { * param.Value = DBNull.Value; * } * * insertCommand.Parameters["@CompanyId"].Value = companyId; * insertCommand.Parameters["@Year"].Value = year; * if (span == FinancialsSpans.Quarterly) * { * insertCommand.Parameters["@Quarter"].Value = quarter; * } * * * Dictionary<string, string> paramMapping = new Dictionary<string, string>() * { * {"Net income", * "NetIncome" * }, * {"Depreciation & amortization", * "DepriciationAmmortizationOA" * }, * {"Investment/asset impairment charges", * "InvestmentAssetImpairmentChargesOA" * }, * {"Investments losses (gains)", * "InvestmentsLossesOA" * }, * {"Stock based compensation", * "StockBasedCompensationOA" * }, * {"Accounts receivable", * "AccountsReceivableOA" * }, * {"Deferred income taxes", * "DeferredIncomeTaxesOA" * }, * {"Inventory", * "InventoryOA" * }, * {"Accounts payable", * "AccountsPayableOA" * }, * {"Other working capital", * "OtherWorkingCapitalOA" * }, * {"Other non-cash items", * "OhterNonCashItemsOA" * }, * {"Net cash provided by operating activities", * "NetCashProvidedByOA" * }, * {"Investments in property, plant, and equipment", * "InvestmentsInPropertyPlantEquipmentIA" * }, * {"Property, plant, and equipment reductions", * "PropertyPlantEquipmentReductionsIA" * }, * {"Acquisitions, net", * "AcquisitionsNetIA" * }, * {"Purchases of investments", * "PurchasesIA" * }, * {"Sales/Maturities of investments", * "SalesMaturitiesIA" * }, * {"Other investing activities", * "OtherIA" * }, * {"Net cash used for investing activities", * "NetCashIA" * }, * {"Debt issued", * "DebtIssuedFA" * }, * {"Debt repayment", * "DebtRepaymentFA" * }, * {"Common stock issued", * "CommonStockIssuedFA" * }, * {"Common stock repurchased", * "CommonStockRepurchasedFA" * }, * {"Excess tax benefit from stock based compensation", * "ExcessTaxBenefitStockBasedCompensationFA" * }, * {"Dividend paid", * "Divident" * }, * {"Other financing activities", * "OtherFA" * }, * {"Net cash provided by (used for) financing activities", * "NetCashFA" * }, * {"Effect of exchange rate changes", * "EchangeRateChangesEvents" * }, * {"Net change in cash", * "NetChangeInCash" * }, * {"Cash at beginning of period", * "BeginningPeriodCash" * }, * {"Cash at end of period", * "EndPeriodCash" * }, * {"Operating cash flow", * "OperatingCashFlow" * }, * {"Capital expenditure", * "CapitalExpenditure" * }, * {"Free cash flow", * "FreeCashFlow" * }, * }; * * * Dictionary<string, string> realParams = new Dictionary<string, string>(); * * foreach (string key in paramMapping.Keys) * { * string paramKey = "@" + RemoveQuotedCommas(String.Format("\"{0}\"", paramMapping[key])).Replace("\"", ""); * * var r = dt.AsEnumerable().FirstOrDefault(row => row[0] as string == key); * if (r != null && !String.IsNullOrEmpty(r[col] as string)) * { * insertCommand.Parameters[paramKey].Value = float.Parse(r[col] as string); * } * * } * * * try * { * conn.Open(); * insertCommand.ExecuteNonQuery(); * } * finally * { * conn.Close(); * } * } */ }
private void SaveFinBSFromCsv(int companyId, string csv, FinancialsSpans span) { /* * csv = "C1,C2,C3,C4,C5," + csv; * //csv = csv.Replace(", plant", "plant"); * DataTable dt = Csv2DataTable(csv); * for (int i = 1; i <= 5; i++) * { * DataColumn col = dt.Columns[i]; * string fiscalEnd = dt.Rows[0][col] as string; * string[] feParts = fiscalEnd.Split('-'); * * int year = int.Parse(feParts[0]); * int quarter = int.Parse(feParts[1]) / 3; * if (quarter == 0) * { * quarter = 1; * } * * * SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); * * SqlCommand insertCommand = new SqlCommand("InsertIntoBalanceSheet", conn); * insertCommand.CommandType = CommandType.StoredProcedure; * * Stopwatch w = new Stopwatch(); * w.Start(); * conn.Open(); * SqlCommandBuilder.DeriveParameters(insertCommand); * conn.Close(); * w.Stop(); * * * foreach (SqlParameter param in insertCommand.Parameters) * { * param.Value = DBNull.Value; * } * * insertCommand.Parameters["@CompanyId"].Value = companyId; * insertCommand.Parameters["@Year"].Value = year; * if (span == FinancialsSpans.Quarterly) * { * insertCommand.Parameters["@Quarter"].Value = quarter; * } * * * Dictionary<string, string> paramMapping = new Dictionary<string, string>() * { * {"Cash and cash equivalents", * "CashAndEquivalentCA" * }, * {"Short-term investments", * "ShortTermInvestmentsCA" * }, * {"Receivables", * "ReceivablesCA" * }, * {"Inventories", * "InventoriesCA" * }, * {"Deferred income taxesCA", * "DeferredIncomeTaxesCA" * }, * {"Prepaid expenses", * "PrepaidExpensesCA" * }, * {"Other current assets", * "OtherCA" * }, * {"Gross property, plant and equipment", * "GrossPropertyPlantEquipmentNCA" * }, * {"Accumulated Depreciation", * "AccumulatedDepreciationNCA" * }, * {"Net property, plant and equipment", * "NetPropertyPlantEquipmentNCA" * }, * {"Equity and other investments", * "EquityOtherInvestmentsNCA" * }, * {"Goodwill", * "GoodwillNCA" * }, * {"Intangible assets", * "IntangibleNCA" * }, * {"Deferred income taxesNCA", * "DeferredIncomeTaxesNCA" * }, * {"Other long-term assets", * "OtherNCA" * }, * {"Short-term debt", * "ShortTermDebtCL" * }, * {"Accounts payable", * "AccountsPayableCL" * }, * {"Taxes payable", * "TaxesPayableCL" * }, * {"Accrued liabilities", * "AccruedLiabilitiesCL" * }, * {"Deferred revenuesCL", * "DeferredRevenuesCL" * }, * {"Other current liabilities", * "OtherCL" * }, * {"Long-term debt", * "LongTermDebtNCL" * }, * {"Deferred revenuesNCL", * "DeferredRevenuesNCL" * }, * {"Pensions and other benefits", * "PensionsAndOtherBenefitsNCL" * }, * {"Minority interest", * "MinorityInterestNCL" * }, * {"Other long-term liabilities", * "OtherNCL" * }, * {"Common stock", * "CommonStockSE" * }, * {"Retained earnings", * "RetainedEarningsSE" * }, * {"Treasury stock", * "TreasuryStockSE" * }, * {"Accumulated other comprehensive income", * "AccumulatedOtherComprehensiveIncome" * } * }; * * * var dte = dt.AsEnumerable(); * * DataRow firstDIT = dte.FirstOrDefault(r => r[0] as string == "Deferred income taxes" && dte.TakeWhile(x => x != r).All(previous => previous[0] as string != "Non-current assets")); * if (firstDIT != null) * { * firstDIT[0] = "Deferred income taxesCA"; * } * DataRow secondDIT = dte.FirstOrDefault(r => r[0] as string == "Deferred income taxes" && dte.Reverse().TakeWhile(x => x != r).All(previous => previous[0] as string != "Non-current assets")); * if (secondDIT != null) * { * secondDIT[0] = "Deferred income taxesNCA"; * } * * DataRow firstDR = dte.FirstOrDefault(r => r[0] as string == "Deferred income taxes" && dte.TakeWhile(x => x != r).All(previous => previous[0] as string != "Non-current liabilities")); * if (firstDR != null) * { * firstDR[0] = "Deferred revenuesCL"; * } * DataRow secondDR = dte.FirstOrDefault(r => r[0] as string == "Deferred income taxes" && dte.Reverse().TakeWhile(x => x != r).All(previous => previous[0] as string != "Non-current liabilities")); * if (secondDR != null) * { * secondDR[0] = "Deferred revenuesNCL"; * } * * /* * if (dt.AsEnumerable().Any(r => r[0] as string == "Deferred income taxes")) * { * dt.AsEnumerable().First(r => r[0] as string == "Deferred income taxes")[0] = "Deferred income taxesCA"; * dt.AsEnumerable().First(r => r[0] as string == "Deferred income taxes")[0] = "Deferred income taxesNCA"; * } * if (dt.AsEnumerable().Any(r => r[0] as string == "Deferred revenues")) * { * dt.AsEnumerable().First(r => r[0] as string == "Deferred revenues")[0] = "Deferred revenuesCL"; * dt.AsEnumerable().First(r => r[0] as string == "Deferred revenues")[0] = "Deferred revenuesNCL"; * } */ /* * Dictionary<string, string> realParams = new Dictionary<string, string>(); * * foreach(string key in paramMapping.Keys) * { * string paramKey = "@" + RemoveQuotedCommas(String.Format("\"{0}\"", paramMapping[key])).Replace("\"", ""); * * var r = dt.AsEnumerable().FirstOrDefault(row => row[0] as string == key); * if (r != null && !String.IsNullOrEmpty(r[col] as string)) * { * insertCommand.Parameters[paramKey].Value = float.Parse(r[col] as string); * } * * } * * * try * { * conn.Open(); * insertCommand.ExecuteNonQuery(); * } * finally * { * conn.Close(); * } * } */ }