using MMoneyCoderSharp.Data.Request;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static MMoneyCoderSharp.DBDefine;

namespace MMoneyCoderSharp.DB
{
    /// <summary>
    /// </summary>
    internal class upjong_5dan : ADataObject
    {

        internal upjong_5dan(국내시장종류 recvDataType)
        {
            this.mDataType = recvDataType;

        }

        국내시장종류 mDataType;

        #region 쿼리
        //코스피 상단
        string queryKOSPI = @"select 
                b.f_part_name, 
                a.F_PART_IDX/100 part_idx, 
                a.F_CHG_TYPE, 
                a.F_PART_CHG/100 part_chg, 
                round(a.f_part_chg / decode(a.f_chg_type, '+', (a.f_part_idx / 100) - (a.f_part_chg / 100), '-', (a.f_part_idx / 100) + (a.f_part_chg / 100)), 2) rate 
            from t_index a, t_part b 
            where a.f_part_code = b.f_part_code and a.f_part_code <> '001' 
            order by a.f_part_code";



        string queryKOSDAQ = @"select 
                b.f_part_name, 
                a.F_PART_IDX/100 part_idx, 
                a.F_CHG_TYPE, 
                a.F_PART_CHG/100 part_chg, 
                round(a.f_part_chg / decode(a.f_chg_type, '+', (a.f_part_idx / 100) - (a.f_part_chg / 100), '-', (a.f_part_idx / 100) + (a.f_part_chg / 100)), 2) rate 
            from t_kosdaq_index a, t_kosdaq_part b 
            where a.f_part_code = b.f_part_code and a.f_part_code <> '001' 
            order by a.f_part_code";




        #endregion

        public override IDataRequest buildData()
        {


            switch (this.mDataType)
            {
                case 국내시장종류.KOSPI:
                    mRequestQuery.Add("", queryKOSPI);
                    break;
                case 국내시장종류.KOSDAQ:
                    mRequestQuery.Add("", queryKOSDAQ);
                    break;
            }


            return this;
        }
    }
}
