private void FrmSetHoldingRate_Load(object sender, EventArgs e)
        {
            M_HoldRule mhr = new M_HoldRule();
            DataTable  dt  = HoldRule.GetList("1=1 order by UpdateTime desc").Tables[0];

            if (dt.Rows.Count > 0)
            {
                mhr = HoldRule.DataRowToModel(dt.Rows[0]);
            }
            txtSZlowest.Text      = mhr.LowPrice.ToString();
            txtSZhighest.Text     = mhr.HightPrice.ToString();
            txtSZnow.Text         = mhr.NowPrice.ToString();
            dtpSZupdateDate.Value = mhr.UpdateTime;
        }
Beispiel #2
0
        /// <summary>
        /// 获取持仓参考的值
        /// </summary>
        private void GetHoldRef()
        {
            M_HoldRule mhr = new M_HoldRule();
            DataTable  dt  = HoldRule.GetList("1=1 order by UpdateTime desc").Tables[0];

            if (dt.Rows.Count > 0)
            {
                mhr = HoldRule.DataRowToModel(dt.Rows[0]);
                //公式:参考持仓比率=(1-(现值-最低值)/(最高值-最低值))*%100;
                double holdRef = (1 - (mhr.NowPrice - mhr.LowPrice) / (mhr.HightPrice - mhr.LowPrice)) * 100;
                d_holdrate = holdRef / 100;
                string strHoldRef = Math.Round(holdRef, 2) + "%";
                txtHoldRef.Text = strHoldRef;
            }
        }
        private void btnCommit_Click(object sender, EventArgs e)
        {
            CheckData();
            if (!GetData())
            {
                return;
            }
            M_HoldRule mhr = new M_HoldRule();

            mhr.HightPrice = highestPrice;
            mhr.LowPrice   = lowestPrice;
            mhr.NowPrice   = nowPrice;
            mhr.UpdateTime = date;
            HoldRule.Add(mhr);
            if (SetHoldRef != null)
            {
                SetHoldRef();
            }
            this.Close();
        }