private void button1_Click(object sender, EventArgs e) { string accountID, password, accountType; accountID = textBox1.Text; password = textBox2.Text; accountType = types[comboBox3.SelectedIndex]; WindData wd = w.tlogon("0000", "0", accountID, password, accountType, ""); this.Visible = false; if (wd.errorCode == 0) { //MessageBox.Show("登录成功!"); Form1 bmain = new Form1(); DialogResult dr = bmain.ShowDialog(); if (dr == DialogResult.Cancel && showLogon) { this.Visible = true; } else { this.Close(); } } else { MessageBox.Show(Convert.ToString(((object[, ])wd.data)[4, 0])); this.Visible = true; } }
public void DoIt() { string strErrorMsg; WindAPI w = new WindAPI(); //登录WFT int nRetCode = w.start(); if (0 != nRetCode)//登录失败 { strErrorMsg = w.getErrorMsg(nRetCode); Console.Write(strErrorMsg); return; } //登录账号 Console.Write("\r\ntlogon……"); WindData wd = w.tlogon("0000", "0", "w081496501", "******", "SHSZ"); string strLogonId = wd.GetLogonId(); wd = w.tquery("Trade"); return; //下单浦发银行 wd = w.torder("600000.SH", "Buy", "12.0", "200", "OrderType=LMT;LogonID=" + strLogonId);//单账户登录可以不指定LogonId=1 //获取下单ID string strRequestID1 = wd.GetOrderRequestID(); Console.WriteLine("RequestID=" + strRequestID1); //下单白云机场 wd = w.torder("600004.SH", "Buy", "12.00", "300", "OrderType=LMT;LogonID=" + strLogonId);//单账户登录可以不指定LogonId=1 //获取下单ID string strRequestID2 = wd.GetOrderRequestID(); //查询 Console.WriteLine("query……"); wd = w.tquery("Order", "RequestID=" + strRequestID1); //获取浦发银行OrderNumber string strOrderNumber = wd.GetOrderNumber(); //浦发银行撤单 Console.WriteLine("cancel……"); wd = w.tcancel(strOrderNumber); //再次查询 Console.WriteLine("query after cancel……"); wd = w.tquery("Order"); string strQueryInfoAfter = WindDataMethod.WindDataToString(wd, "tquery"); Console.Write(strQueryInfoAfter); //登出 Console.WriteLine("tlogout……"); w.tlogout(); //退出WindAPI w.stop(); }