/// <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); } } }
/// <summary> /// 开始挂单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { //测试 //PublishForm form = new PublishForm(); //form.Show(); if (false == CheckIsLonginOK()) { MessageBox.Show("请检查是否正常登录状态!"); return; } string strInfo; if (false == VerifyArguments(out strInfo)) { MessageBox.Show("请检查参数挂牌参数是否填写正确:" + strInfo); return; } ListedRequest args = new ListedRequest(); if (DataManager.Instance.LoginData == null) { MessageBox.Show("登陆状态有误,请重新登陆"); return; } args.clientId = DataManager.Instance.LoginData.currentCompany.id + "_pc"; args.mqId = "test"; args.cid = m_contractVo.id; args.operationType = 1; args.commId = null; string cookies = DataManager.Instance.Cookies; args.securityToken = cookies; args.transType = this.radioButton_Buy.Checked ? TransType.Buy : TransType.Sell; //买卖方向 LevelBrand lb = this.comboBox_Brand.SelectedItem as LevelBrand; //品牌 if (lb != null) { args.commBrandId = lb.id; //品牌combox获取 } else { MessageBox.Show("请选择品牌!"); return; } LevelBrandList lbl = this.comboBox_Level.SelectedItem as LevelBrandList;//等级 if (lbl != null) { args.commLevel = lbl.id; //等级combox获取 } else { MessageBox.Show("请选择等级!"); return; } WareHouseInfo wi = this.comboBox_WareHouse.SelectedItem as WareHouseInfo;//仓库 if (wi != null) { args.warehouseId = wi.id; //仓库combox获取 } else { MessageBox.Show("请选择仓库!"); return; } args.commTotalQuantity = this.textBox_Volumn.Text; //成交数 args.minDealQuantity = this.textBox_MinTradeVolumn.Text; //最小成交数量 args.showCompany = this.checkBox_IsCorDisVisual.Checked ? "1" : "0"; //是否显示公司名check获取 0显示 1不显示 args.pricingMethod = this.radioButton_DeadPrice.Checked ? 1 : 0; //固定价:点价 if (args.pricingMethod == 1) { args.contract = ""; args.contractName = ""; args.premium = ""; args.fixedPrice = this.textBox_SpreadPrice.Text; } else { //"clups"用于传给Web-必填字段 if (this.comboBox_ChoiceIns.SelectedItem != null && (this.comboBox_ChoiceIns.SelectedItem as ContractBasePrice) != null) { args.contract = (this.comboBox_ChoiceIns.SelectedItem as ContractBasePrice).category; } //"外盘铜"用于显示-必填字段 args.contractName = this.comboBox_ChoiceIns.Text; args.fixedPrice = ""; args.premium = this.textBox_UpDownPrice.Text; } args.ensureMethod = this.radioButton_Margin.Checked ? 0 : 1;//保证金:实物凭证 if (args.ensureMethod == 1) { args.warehouseReceiptNum = this.textBox_MarginCaret.Text; } args.publisher = "Text_Hanyu"; args.remarks = this.textBox_Remarks.Text; var response = HttpService.PostBrandOrder(args); if (response != null && response.Success) { //重置 ResetControlSettings(); //且在保证金模式下,如果挂单成功还需要刷新资金和使用率 RefrashAvaliableAndRadio(); DataManager.Instance.GetCommodity(); MessageBox.Show("挂单成功!"); //挂单成功对外通知 if (OnPublishSuccessEvent != null) { OnPublishSuccessEvent(this, null); } } else { MessageBox.Show("挂单失败," + response.Msg); return; } }
/// <summary> /// 刷新参数 /// </summary> /// <param name="commodityInfo"></param> private void RefrashArgs(OneListed 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); } //查询结算价 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); } } }