private void button_DownloadEarning_Click(object sender, EventArgs e) { db_manager.DBConnect(); CompanyProfilePage cpp = new CompanyProfilePage(); // cpp.DownloadEarningInfoAll(db_manager.getConnection(), "2379"); //from 98-102. profit margin cpp.DownloadEpsInfo(db_manager.getConnection(), "2379", 100, 1); //eps cpp.DownloadMonthRevenue(db_manager.getConnection(), "2379", 100, 1); //revenue cpp.DownloadEpsInfo(db_manager.getConnection(), "2379", 102, 1); //eps cpp.DownloadMonthRevenue(db_manager.getConnection(), "2379", 102, 1); //revenue int rev = cpp.GetMonthRevenue(db_manager.getConnection(), "2379", 102, 1); EarningInfo ei = cpp.GetSeasonEarning(db_manager.getConnection(), "2379", 102, 1); YearSeasonMonth ysm = cpp.GetLatestRevenueInfoDate(db_manager.getConnection(), "2379"); ysm = cpp.GetLatestEarningInfoDate(db_manager.getConnection(), "2379"); }
public YearSeasonMonth GetLatestRevenueInfoDate(MySqlConnection conn, String stock_index) { YearSeasonMonth res = new YearSeasonMonth(); string qstr = "SELECT * FROM " + companyRevenue_db_name + " WHERE stock_index=\'" + stock_index + "\' ORDER by month,year DESC LIMIT 1"; MySqlCommand cmd = new MySqlCommand(qstr, conn); MySqlDataReader rdr = cmd.ExecuteReader(); if (rdr.Read()) { res.year = (int)rdr["year"]; res.month = (int)rdr["month"]; } else { res = null; } rdr.Close(); return(res); }
private void backgroundWorker_downloadrevenue_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker downloadrevenue_worker = sender as BackgroundWorker; List <String> stocks = GetAllStocks(); DateTime current = DateTime.Now; YearSeasonMonth currentYSM = new YearSeasonMonth(current, true); CompanyProfilePage cpp = new CompanyProfilePage(); backgroundWorker_downloadrevenue_inprogress = true; foreach (String stock_idx in stocks) { if (downloadrevenue_worker.CancellationPending) { Logger.v("cancelling databases update"); backgroundWorker_downloadrevenue_inprogress = false; break; } //earning YearSeasonMonth latestEarning = cpp.GetLatestEarningInfoDate(db_manager.getConnection(), stock_idx); List <YearSeasonMonth> EPS2download = new List <YearSeasonMonth>(); YearSeasonMonth nextEarning; if ((latestEarning == null) || (latestEarning.year < 102)) { cpp.DownloadEarningInfo_beforeIFRS(db_manager.getConnection(), stock_idx, EPS2download); nextEarning = IfrsStart; } else { nextEarning = latestEarning.NextSeason(); } downloadrevenue_index++; for (int y = nextEarning.year; y <= (current.Year - 1911); y++) { cpp.DownloadEarningInfo(db_manager.getConnection(), stock_idx, y, EPS2download); downloadrevenue_index++; } //eps info is from another page foreach (YearSeasonMonth season in EPS2download) { cpp.DownloadEpsInfo(db_manager.getConnection(), stock_idx, season.year, season.season); downloadrevenue_index++; int loop; for (loop = 0; loop < 10; loop++) { if (cpp.isEPS_Null(db_manager.getConnection(), stock_idx, season.year, season.season)) { cpp.DownloadEpsInfo(db_manager.getConnection(), stock_idx, season.year, season.season); downloadrevenue_index++; } } } YearSeasonMonth latestRevenue = cpp.GetLatestRevenueInfoDate(db_manager.getConnection(), stock_idx); if (latestRevenue == null) { latestRevenue = EarningStart; } for (YearSeasonMonth month = latestRevenue; month < currentYSM; month.NextMonth()) { cpp.DownloadMonthRevenue(db_manager.getConnection(), stock_idx, month.year, month.month); downloadrevenue_index++; } } }