Esempio n. 1
0
 /// <summary>
 /// 挂牌
 /// </summary>
 public static ListedResponse PostBrandOrder(ListedRequest require)
 {
     if (DataManager.Instance.Cookies != null)
     {
         string cookies = DataManager.Instance.Cookies;
         string url     = Helper.GetURL(HTTPServiceUrlCollection.PostBrandOrderRequireInfoUrl);
         string data    = Helper.Serialize(require);
         string hr      = PostData(url, cookies, data);
         if (hr != null)
         {
             try
             {
                 var bi = Helper.Deserialize <ListedResponse>(hr);
                 return(bi);
             }
             catch (Exception err)
             {
                 Logger.LogError(err.ToString());
             }
         }
     }
     return(null);
 }
        /// <summary>
        /// 开始挂单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            //TestGDIForm form = new TestGDIForm();
            //form.Initialize();
            //form.ShowDialog();


            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;
            }
        }