예제 #1
0
        /// <summary>
        /// 挂牌行情表调用,获取参数,准备摘牌操作
        /// </summary>
        /// <param name="commodityInfo"></param>
        public void SetDefultFieldToDelistBrand(OneListed commodityInfo)
        {
            if (commodityInfo == null)
            {
                MessageBox.Show("摘牌参数不能为空");
                return;
            }

            m_commodityInfo = commodityInfo;

            CreditQuotaRequest args = new CreditQuotaRequest()
            {
                compId = commodityInfo.publisherId,
            };


            decimal canUseAvaliableMoney = 0m;
            //信用额度
            CreditQuotaResponse avaliableQuatityArgs = HttpService.GetDelistAditQuatity(args);

            if (avaliableQuatityArgs != null && avaliableQuatityArgs.data != null && avaliableQuatityArgs.data.creditLineAmt != null &&
                avaliableQuatityArgs.data.creditLineAmt != "")
            {
                canUseAvaliableMoney = Convert.ToDecimal(avaliableQuatityArgs.data.creditLineAmt) - Convert.ToDecimal(avaliableQuatityArgs.data.creditUsedAmt);
                this.label_AvaliableCridetCash.Text = string.Format("{0:C}", (Convert.ToDecimal(avaliableQuatityArgs.data.creditLineAmt) - Convert.ToDecimal(avaliableQuatityArgs.data.creditUsedAmt)));
            }
            else
            {
                canUseAvaliableMoney = 0m;
                this.label_AvaliableCridetCash.Text = string.Format("{0:C}", 0m);
            }

            //品牌-中文显示(原来是ID,现在切换为Name)
            this.label_Brand.Text = HttpService.QueryHttpBrandName(commodityInfo);

            //升贴水
            if (commodityInfo.premium == null)
            {
                this.label_UpDownPrice.Text = "---";
            }
            else
            {
                this.label_UpDownPrice.Text = commodityInfo.premium;
            }
            //else if (Convert.ToDecimal(commodityInfo.premium) > 0m)
            //{
            //    this.label_UpDownPrice.Text = "+" + commodityInfo.premium;
            //}
            //else
            //{
            //    this.label_UpDownPrice.Text = "-" + commodityInfo.premium;
            //}

            //成交量
            this.comboBox_VolumnChoice.Items.Clear();
            this.comboBox_VolumnChoice.Text = "";

            int min;

            int.TryParse(commodityInfo.minDealQuantity, out min);
            int all;

            int.TryParse(commodityInfo.commAvailableQuantity, out all);
            for (int i = min; i < all; i += min)
            {
                this.comboBox_VolumnChoice.Items.Add(i.ToString());
            }
            this.comboBox_VolumnChoice.Items.Add(all.ToString());
            if (comboBox_VolumnChoice.Items.Count > 0)
            {
                comboBox_VolumnChoice.SelectedIndex = 0;
            }

            //查询结算价
            Dictionary <string, ContractCategoryDic> vo = DataManager.Instance.GetContractcCategoryVo();

            if (vo == null || vo.Values.Count <= 0)
            {
                this.label_StandPrice.Text = "---";
            }
            else
            {
                foreach (KeyValuePair <string, ContractCategoryDic> kv in vo)
                {
                    if (kv.Value.contractMonthMap == null || kv.Value.contractMonthMap.Count <= 0)
                    {
                        continue;
                    }
                    if (kv.Value.id != commodityInfo.cid)
                    {
                        continue;
                    }

                    foreach (KeyValuePair <string, ContractBasePrice> kvMonth in kv.Value.contractMonthMap)
                    {
                        decimal d;
                        decimal.TryParse(kvMonth.Value.preSettlementPrice, out d);
                        this.label_StandPrice.Text = string.Format("{0:C}", d);
                        break;
                    }
                }
            }

            //需要保证金/应付保证金
            //需要保证金比例目前所有的都为10%-[hanyu]保证金比例目前查询有误
            decimal needMarginAll = Convert.ToDecimal(this.label_StandPrice.Text.Replace("¥", "").Replace(",", "")) * Convert.ToDecimal(this.comboBox_VolumnChoice.SelectedItem) * 0.1m;

            this.label_NeedMagin2.Text = string.Format("{0:C}", needMarginAll);

            //应该付 = 总需要 - 可用金额
            decimal shouldMarginLeave = needMarginAll - (Convert.ToDecimal(avaliableQuatityArgs.data.creditLineAmt) - Convert.ToDecimal(avaliableQuatityArgs.data.creditUsedAmt));

            if (shouldMarginLeave <= 0m)
            {
                this.label_NeedMargin1.Text = string.Format("{0:C}", 0m);
            }
            else
            {
                this.label_NeedMargin1.Text = string.Format("{0:C}", shouldMarginLeave);
            }

            //可用余额
            Funds accountData = HttpService.GetAccountDataInfos();

            if (accountData == null || accountData.availableAmount == "" || accountData.availableAmount == null)
            {
                this.label1_LeaveCash.Text = string.Format("{0:C}", 0m);
            }
            else
            {
                decimal avaliableAccountNum = 0m;
                decimal.TryParse(accountData.availableAmount, out avaliableAccountNum);

                if (avaliableAccountNum == 0m)
                {
                    this.label1_LeaveCash.Text = string.Format("{0:C}", 0m);
                }
                else
                {
                    this.label1_LeaveCash.Text = string.Format("{0:C}", avaliableAccountNum);
                }
            }
        }