protected override TraderResult internalBuyStock(string code, float price, int num) { const int BUY_TXT_CODE = 0x0408; const int BUY_TXT_PRICE = 0x0409; const int BUY_TXT_NUM = 0x040A; const int BUY_BTN_OK = 0x3EE; ClickBuyTreeViewItem(); // 设定代码,价格,数量 IntPtr hPanel = GetDetailPanel(); IntPtr hCtrl = Win32API.GetDlgItem(hPanel, BUY_TXT_CODE); Win32API.SendMessage(hCtrl, Win32Code.WM_SETTEXT, 0, StockUtil.GetShortCode(code)); hCtrl = Win32API.GetDlgItem(hPanel, BUY_TXT_PRICE); Win32API.SendMessage(hCtrl, Win32Code.WM_SETTEXT, 0, price.ToString()); hCtrl = Win32API.GetDlgItem(hPanel, BUY_TXT_NUM); Win32API.SendMessage(hCtrl, Win32Code.WM_SETTEXT, 0, num.ToString()); // 点击买入按钮 hCtrl = Win32API.GetDlgItem(hPanel, BUY_BTN_OK); Win32API.PostMessage(hCtrl, Win32Code.WM_LBUTTONDOWN, 0, 0); Win32API.PostMessage(hCtrl, Win32Code.WM_LBUTTONUP, 0, 0); ClickQueryDrcjTreeViewItem(); TraderResult result = new TraderResult(); result.Code = TraderResultEnum.SUCCESS; return(result); }
protected override TraderResult internalBuyStock(string code, float price, int num) { int exchange_type = StockUtil.GetExchangeType(code); AccountInfoItem holder = GetStockHolder(exchange_type); StockBuyRequest t = new StockBuyRequest { branch_no = this.resAccountInfo.branch_no, custid = this.resAccountInfo.fund_account, fund_account = this.resAccountInfo.fund_account, op_branch_no = this.resAccountInfo.branch_no, op_station = this.resAccountInfo.op_station, password = this.resAccountInfo.trdpwd, uid = this.resAccountInfo.uid, exchange_type = exchange_type.ToString(), stock_account = holder.stock_account, stock_code = StockUtil.GetShortCode(code), entrust_amount = num, entrust_price = price }; StockBuyResp resp = getResp <StockBuyResp, StockBuyRequest>(t); TraderResult ret = new TraderResult(); if (resp.cssweb_code == SuccessCode) { ret.Code = TraderResultEnum.SUCCESS; ret.EntrustNo = resp.Item[0].entrust_no; } else { ret.Code = TraderResultEnum.ERROR; ret.Message = String.Format("错误代码{0}, 错误内容{1}", resp.cssweb_code, resp.cssweb_msg); } return(ret); }