private void btnSendStockOrderAsync_Click(object sender, EventArgs e) { if (m_UserAccount == "") { MessageBox.Show("請選擇證券帳號"); return; } string strStockNo; int nPrime; int nBidAsk; int nPeriod; int nFlag; string strPrice; int nQty; if (txtStockNo.Text.Trim() == "") { MessageBox.Show("請輸入商品代碼"); return; } strStockNo = txtStockNo.Text.Trim(); if (boxPrime.SelectedIndex < 0) { MessageBox.Show("請選擇上市櫃-興櫃"); return; } nPrime = boxPrime.SelectedIndex; if (boxBidAsk.SelectedIndex < 0) { MessageBox.Show("請選擇買賣別"); return; } nBidAsk = boxBidAsk.SelectedIndex; if (boxPeriod.SelectedIndex < 0) { MessageBox.Show("請選擇委託條件"); return; } nPeriod = boxPeriod.SelectedIndex; if (boxFlag.SelectedIndex < 0) { MessageBox.Show("請選擇當沖與否"); return; } nFlag = boxFlag.SelectedIndex; double dPrice = 0.0; if (double.TryParse(txtPrice.Text.Trim(), out dPrice) == false && txtPrice.Text.Trim() != "M" && txtPrice.Text.Trim() != "H" && txtPrice.Text.Trim() != "h" && txtPrice.Text.Trim() != "C" && txtPrice.Text.Trim() != "c" && txtPrice.Text.Trim() != "L" && txtPrice.Text.Trim() != "l") { MessageBox.Show("委託價請輸入數字"); return; } strPrice = txtPrice.Text.Trim(); if (int.TryParse(txtQty.Text.Trim(), out nQty) == false) { MessageBox.Show("委託量請輸入數字"); return; } if (m_bOrderM) { int nCond, nSpecTradeType; if (boxCond.SelectedIndex < 0) { MessageBox.Show("請選擇委託條件(R/I/F)"); return; } nCond = boxCond.SelectedIndex; if (boxSpecialTradeType.SelectedIndex < 0) { MessageBox.Show("請選擇委託價格類型(限/市價)"); return; } nSpecTradeType = boxSpecialTradeType.SelectedIndex; SKCOMLib.STOCKORDER pOrder = new STOCKORDER(); pOrder.bstrFullAccount = m_UserAccount; pOrder.bstrPrice = strPrice; pOrder.bstrStockNo = strStockNo; pOrder.nQty = nQty; pOrder.sPrime = (short)nPrime; pOrder.sBuySell = (short)nBidAsk; pOrder.sFlag = (short)nFlag; pOrder.sPeriod = (short)nPeriod; pOrder.nTradeType = nCond; pOrder.nSpecialTradeType = nSpecTradeType; if (OnOrderSignal != null) { OnOrderSignal(m_UserID, true, pOrder); } } else { SKCOMLib.STOCKORDER pOrder = new STOCKORDER(); pOrder.bstrFullAccount = m_UserAccount; pOrder.bstrPrice = strPrice; pOrder.bstrStockNo = strStockNo; pOrder.nQty = nQty; pOrder.sPrime = (short)nPrime; pOrder.sBuySell = (short)nBidAsk; pOrder.sFlag = (short)nFlag; pOrder.sPeriod = (short)nPeriod; if (OnOrderSignal != null) { OnOrderSignal(m_UserID, true, pOrder); } } }
//---------------------------------------------------------------------- // Component Event //---------------------------------------------------------------------- private void btnSendStockOrder_Click(object sender, EventArgs e) { if (m_UserAccount == "") { MessageBox.Show("請選擇證券帳號"); return; } string strStockNo; int nPrime; int nBidAsk; int nPeriod; int nFlag; string strPrice; int nQty; if (txtStockNo.Text.Trim() == "") { MessageBox.Show("請輸入商品代碼"); return; } strStockNo = txtStockNo.Text.Trim(); if (boxPrime.SelectedIndex < 0) { MessageBox.Show("請選擇上市櫃-興櫃"); return; } nPrime = boxPrime.SelectedIndex; if (boxBidAsk.SelectedIndex < 0) { MessageBox.Show("請選擇買賣別"); return; } nBidAsk = boxBidAsk.SelectedIndex; if (boxPeriod.SelectedIndex < 0) { MessageBox.Show("請選擇委託條件"); return; } nPeriod = boxPeriod.SelectedIndex; if (boxFlag.SelectedIndex < 0) { MessageBox.Show("請選擇當沖與否"); return; } nFlag = boxFlag.SelectedIndex; double dPrice = 0.0; if (double.TryParse(txtPrice.Text.Trim(), out dPrice) == false) { MessageBox.Show("委託價請輸入數字"); return; } strPrice = txtPrice.Text.Trim(); if (int.TryParse(txtQty.Text.Trim(), out nQty) == false) { MessageBox.Show("委託量請輸入數字"); return; } SKCOMLib.STOCKORDER pOrder = new STOCKORDER(); pOrder.bstrFullAccount = m_UserAccount; pOrder.bstrPrice = strPrice; pOrder.bstrStockNo = strStockNo; pOrder.nQty = nQty; pOrder.sPrime = (short)nPrime; pOrder.sBuySell = (short)nBidAsk; pOrder.sFlag = (short)nFlag; pOrder.sPeriod = (short)nPeriod; if (OnOrderSignal != null) { OnOrderSignal(m_UserID, false, pOrder); } }
private void stockOrderControl1_OnOrderSignal(string strLogInID, bool bAsyncOrder, STOCKORDER pStock) { string strMessage = ""; m_nCode = m_pSKOrder.SendStockOrder(strLogInID, bAsyncOrder, pStock, out strMessage); WriteMessage("證券委託 :" + strMessage); SendReturnMessage("Order", m_nCode, "SendStockOrder"); }