Ejemplo n.º 1
0
        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 EarningInfo GetSeasonEarning(MySqlConnection conn, String stock_index, int year, int season)
        {
            EarningInfo     res  = new EarningInfo();
            string          qstr = "SELECT * FROM " + companyEarning_db_name + " WHERE stock_index=\'" + stock_index + "\' and year=" + String.Format("{0}", year) + " and season=" + String.Format("{0}", season) + ";";
            MySqlCommand    cmd  = new MySqlCommand(qstr, conn);
            MySqlDataReader rdr  = null;

            try
            {
                rdr = cmd.ExecuteReader();
                if (rdr.Read())
                {
                    res.grossProfitMargin        = rdr.GetDouble(rdr.GetOrdinal("grossProfitMargin"));
                    res.operatingProfitMargin    = rdr.GetDouble(rdr.GetOrdinal("operatingProfitMargin"));
                    res.netProfitMarginBeforeTax = rdr.GetDouble(rdr.GetOrdinal("netProfitMarginBeforeTax"));
                    res.netProfitMargin          = rdr.GetDouble(rdr.GetOrdinal("netProfitMargin"));
                    if (rdr.IsDBNull(rdr.GetOrdinal("eps")) == false)
                    {
                        res.eps = rdr.GetDouble(rdr.GetOrdinal("eps"));
                    }
                }
                else
                {
                    res = null;
                }
            }
            catch (Exception ex)
            {
                Logger.e("GetSeasonEarning:" + stock_index + "(" + year + "," + season + ")  failed");
            }
            finally
            {
                if (rdr != null)
                {
                    rdr.Close();
                }
            }
            return(res);
        }