private void SellOrder(DataGridViewRow Dr) { using (var frmord = new frmSpreadOrdEntry()) { frmord.lblSpdOrderMsg.Text = "SELL " + Dr.Cells[SpreadContract.Symbol1].Value + Dr.Cells[SpreadContract.ExpiryDate2].Value;//+ Dr.Cells[SpreadContract.ExpiryDate1].Value; //frmord.lblSpdOrderMsg.BackColor = Color.Green; frmord.BackColor = ControlPaint.Light(Color.IndianRed);//Color.PaleVioletRed; frmord.cmbInstName1.Text = Dr.Cells[SpreadContract.InstrumentName1].Value.ToString(); frmord.cmbInstName2.Text = Dr.Cells[SpreadContract.InstrumentName2].Value.ToString(); frmord.cmbSymbol1.Text = Dr.Cells[SpreadContract.Symbol1].Value.ToString(); frmord.cmbSymbol2.Text = Dr.Cells[SpreadContract.Symbol2].Value.ToString(); frmord.cmbOpType1.Text = Dr.Cells[SpreadContract.OptionType1].Value.ToString(); frmord.cmbOpType2.Text = Dr.Cells[SpreadContract.OptionType2].Value.ToString(); frmord.cmbStrikePrice1.Text = Dr.Cells[SpreadContract.StrikePrice1].Value.ToString(); frmord.cmbStrikePrice2.Text = Dr.Cells[SpreadContract.StrikePrice2].Value.ToString(); frmord.cmbExpiry1.Text = Dr.Cells[SpreadContract.ExpiryDate1].Value.ToString(); frmord.cmbExpiry2.Text = Dr.Cells[SpreadContract.ExpiryDate2].Value.ToString(); frmord.txtPrice1.Text = Dr.Cells[SpreadContract.Bid].Value.ToString(); frmord.txtTotalQty1.Text = "1"; frmord.txtTotalQty2.Text = "1"; frmord.txtMktLot1.Text = Dr.Cells[SpreadContract.BoardLotQuantity1].Value.ToString(); frmord.txtMktLot2.Text = Dr.Cells[SpreadContract.BoardLotQuantity2].Value.ToString(); frmord.cmbBuySell1.Text = "BUY"; frmord.cmbBuySell2.Text = "SELL"; pSpreadOrd.Token1 = Convert.ToInt32(Dr.Cells[SpreadContract.Token1].Value); pSpreadOrd.Token2 = Convert.ToInt32(Dr.Cells[SpreadContract.Token2].Value); // frmord.DesktopLocation = new Point(100, 100); int x = (Screen.PrimaryScreen.WorkingArea.Width - frmord.Width) / 2; int y = (Screen.PrimaryScreen.WorkingArea.Height - frmord.Height) - 50; frmord.Location = new Point(x, y); // var v = Convert.ToInt32(Dr.Cells[SpreadContract.ExpiryDate1].Value); if (frmord.ShowDialog(this) == DialogResult.OK) { if (frmord.FormSpdDialogResult == (int)OrderEntryButtonCase.SUBMIT) { if (MessageBox.Show(this, "Are you sure you Want to Place Buy Order?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { pSpreadOrd = new PlaceSpreadOrder(); pSpreadOrd.SecInfo1.Symbol = frmord.cmbSymbol1.Text; pSpreadOrd.SecInfo2.Symbol = frmord.cmbSymbol2.Text; pSpreadOrd.SecInfo1.InstrumentName = frmord.cmbInstName1.Text; pSpreadOrd.SecInfo2.InstrumentName = frmord.cmbInstName2.Text; pSpreadOrd.SecInfo1.ExpiryDate = Convert.ToInt32(Dr.Cells[SpreadContract.UnixExpiry1].Value); pSpreadOrd.SecInfo2.ExpiryDate = Convert.ToInt32(Dr.Cells[SpreadContract.UnixExpiry2].Value); pSpreadOrd.SecInfo1.OptionType = frmord.cmbOpType1.Text; pSpreadOrd.SecInfo2.OptionType = frmord.cmbOpType2.Text; pSpreadOrd.SecInfo1.StrikePrice = Convert.ToInt32(frmord.cmbStrikePrice1.Text); pSpreadOrd.SecInfo2.StrikePrice = Convert.ToInt32(frmord.cmbStrikePrice2.Text); pSpreadOrd.SecInfo1.CALevel = Convert.ToInt16(Dr.Cells[SpreadContract.CALevel1].Value); pSpreadOrd.SecInfo2.CALevel = Convert.ToInt16(Dr.Cells[SpreadContract.CALevel2].Value); pSpreadOrd.BuySell1 = 1; pSpreadOrd.BuySell2 = 2; pSpreadOrd.Token1 =Convert.ToInt32(Dr.Cells[SpreadContract.Token1].Value); pSpreadOrd.Token2 = Convert.ToInt32(Dr.Cells[SpreadContract.Token2].Value); pSpreadOrd.Price1 = Convert.ToInt32(Convert.ToSingle(frmord.txtPrice1.Text) * 100); pSpreadOrd.Volume1 = Convert.ToInt32(frmord.txtTotalQty1.Text) * Convert.ToInt32(Dr.Cells[SpreadContract.BoardLotQuantity1].Value); pSpreadOrd.Volume2 = Convert.ToInt32(frmord.txtTotalQty2.Text) * Convert.ToInt32(Dr.Cells[SpreadContract.BoardLotQuantity1].Value); NNFInOut.Instance.SP_BOARD_LOT_IN(pSpreadOrd); SpdOrderTableMethods._PriceDiff[pSpreadOrd.Token1] = new Dictionary<Structure.BUYSELL, float>(); SpdOrderTableMethods._PriceDiff[pSpreadOrd.Token1][Structure.BUYSELL.BUY] = Convert.ToSingle(frmord.txtPrice1.Text); } } } } }
void tlsmiModifySelected_Click(object sender, EventArgs e) { obj = new C_Spread_lot_In(); try { int Price1, Volume1; foreach (DataGridViewRow row in dgvSpdOrderBook.SelectedRows) { //compare here with the order stat and place cancel ok sir.. if (Convert.ToString(row.Cells[WatchConst.Status].Value) == AtsEnums.OrderStatus.EPending.ToString() || Convert.ToString(row.Cells[WatchConst.Status].Value) == AtsEnums.OrderStatus.MPending.ToString()) { using (var frmord = new frmSpreadOrdEntry()) { // frmord.lblSpdOrderMsg.Text = "BUY " + Dr.Cells[SpreadContract.Symbol1].Value + Dr.Cells[SpreadContract.ExpiryDate1].Value + Dr.Cells[SpreadContract.ExpiryDate1].Value; //frmord.lblSpdOrderMsg.BackColor = Color.Green; //frmord.BackColor = Color.SeaGreen; // if (row.Cells[SpreadContract.Price_Diff].Value.ToString()) frmord.cmbInstName1.Text = System.Text.ASCIIEncoding.ASCII.GetString(Holder.holderOrder[Convert.ToDouble(Convert.ToInt64(row.Cells[SpreadContract.OrderId].Value))].mS_SPD_OE_REQUEST.ms_oe_obj.InstrumentName); frmord.cmbSymbol1.Text = System.Text.ASCIIEncoding.ASCII.GetString(Holder.holderOrder[Convert.ToDouble(Convert.ToInt64(row.Cells[SpreadContract.OrderId].Value))].mS_SPD_OE_REQUEST.ms_oe_obj.Symbol); frmord.cmbOpType1.Text = System.Text.ASCIIEncoding.ASCII.GetString(Holder.holderOrder[Convert.ToDouble(Convert.ToInt64(row.Cells[SpreadContract.OrderId].Value))].mS_SPD_OE_REQUEST.ms_oe_obj.OptionType); frmord.cmbStrikePrice1.Text = Convert.ToString(Holder.holderOrder[Convert.ToDouble(Convert.ToInt64(row.Cells[SpreadContract.OrderId].Value))].mS_SPD_OE_REQUEST.ms_oe_obj.StrikePrice); frmord.cmbBuySell1.Text = IPAddress.HostToNetworkOrder(Holder.holderOrder[Convert.ToDouble(Convert.ToInt64(row.Cells[SpreadContract.OrderId].Value))].mS_SPD_OE_REQUEST.BuySell1) == 1 ? "BUY" : "Sell"; // frmord.cmbExpiry1 = Convert.ToString(Holder.holderOrder[Convert.ToDouble(Convert.ToInt64(row.Cells[SpreadContract.OrderId]))].mS_SPD_OE_REQUEST.ms_oe_obj.ExpiryDate); frmord.cmbInstName2.Text = System.Text.ASCIIEncoding.ASCII.GetString(Holder.holderOrder[Convert.ToDouble(Convert.ToInt64(row.Cells[SpreadContract.OrderId].Value))].mS_SPD_OE_REQUEST.leg2.ms_oe_obj.InstrumentName); frmord.cmbSymbol2.Text = System.Text.ASCIIEncoding.ASCII.GetString(Holder.holderOrder[Convert.ToDouble(Convert.ToInt64(row.Cells[SpreadContract.OrderId].Value))].mS_SPD_OE_REQUEST.leg2.ms_oe_obj.Symbol); frmord.cmbOpType2.Text = System.Text.ASCIIEncoding.ASCII.GetString(Holder.holderOrder[Convert.ToDouble(Convert.ToInt64(row.Cells[SpreadContract.OrderId].Value))].mS_SPD_OE_REQUEST.leg2.ms_oe_obj.OptionType); frmord.cmbStrikePrice2.Text = Convert.ToString(Holder.holderOrder[Convert.ToDouble(Convert.ToInt64(row.Cells[SpreadContract.OrderId].Value))].mS_SPD_OE_REQUEST.leg2.ms_oe_obj.StrikePrice); frmord.cmbBuySell2.Text = IPAddress.HostToNetworkOrder(Holder.holderOrder[Convert.ToDouble(Convert.ToInt64(row.Cells[SpreadContract.OrderId].Value))].mS_SPD_OE_REQUEST.leg2.BuySell2) == 1 ? "BUY" : "Sell"; // frmord.cmbExpiry1 = Convert.ToString(Holder.holderOrder[Convert.ToDouble(Convert.ToInt64(row.Cells[SpreadContract.OrderId]))].mS_SPD_OE_REQUEST.leg2.ms_oe_obj.ExpiryDate); frmord.txtPrice1.Text = row.Cells[SpreadContract.Price_Diff].Value.ToString(); if (frmord.cmbBuySell1.Text == "Buy") { frmord.txtTotalQty1.Text =Convert.ToString(Convert.ToInt32(row.Cells[SpreadContract.BidQ].Value) / Global.Instance.BoardLotDict[Convert.ToInt32(row.Cells[SpreadContract.Token1].Value)]); } else { frmord.txtTotalQty1.Text = Convert.ToString(Convert.ToInt32(row.Cells[SpreadContract.AskQ].Value) / Global.Instance.BoardLotDict[Convert.ToInt32(row.Cells[SpreadContract.Token1].Value)]); } // frmord.DesktopLocation = new Point(100, 100); int x = (Screen.PrimaryScreen.WorkingArea.Width - frmord.Width) / 2; int y = (Screen.PrimaryScreen.WorkingArea.Height - frmord.Height) - 50; frmord.Location = new Point(x, y); // var v = Convert.ToInt32(Dr.Cells[SpreadContract.ExpiryDate1].Value); if (frmord.ShowDialog(this) == DialogResult.OK) { if (frmord.FormSpdDialogResult == (int)OrderEntryButtonCase.SUBMIT) { if (MessageBox.Show(this, "Are you sure you Want to Place Buy Order?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Price1 = Convert.ToInt32(Convert.ToSingle(frmord.txtPrice1.Text) * 100); Volume1 = Convert.ToInt32(frmord.txtTotalQty1.Text) * (Global.Instance.BoardLotDict[Convert.ToInt32(row.Cells[SpreadContract.Token1].Value)]); //pSpreadOrd.Volume2 = Convert.ToInt32(frmord.txtTotalQty2.Text) * Convert.ToInt32(Dr.Cells[SpreadContract.BoardLotQuantity1].Value); // NNFInOut.Instance.SP_BOARD_LOT_IN(pSpreadOrd); NNFInOut.Instance.SP_ORDER_MOD_IN(Convert.ToInt64(row.Cells[SpreadContract.OrderId].Value), Price1, Volume1); } //NNFInOut.Instance.BOARD_LOT_IN_TR(Convert.ToInt32(Dr.Cells["UniqueIdentifier"].Value), // Dr.Cells["InstrumentName"].Value.ToString(), // Dr.Cells["Symbol"].Value.ToString(), // Convert.ToInt32(Dr.Cells["ExpiryDate"].Value), // Convert.ToInt32(Dr.Cells["StrikePrice"].Value), // Dr.Cells["OptionType"].Value.ToString(), // 1, // frmord.LEG_SIZE * Convert.ToInt32(Dr.Cells["Lotsize"].Value), // Convert.ToInt32(frmord.LEG_PRICE * 100)); } } // OrderProcess.CancelOrder(Convert.ToUInt32(row.Cells[WatchConst.IntOrderNo].Value), Convert.ToUInt16(row.Cells[WatchConst.UniqueId].Value)); } } else { AppGlobal.Logger.ShowToMessageLog("This Order Can not be Cancelled.", color: "Red"); } } } catch (Exception ex) { // AppGlobal.Logger.WriteinFileWindowAndBox(ex, LogEnums.WriteOption.LogWindow_ErrorLogFile, color: AppLog.RedColor); } /* if (dgvOrderBook.SelectedRows.Count == 1) { int rowindex = dgvOrderBook.SelectedRows[0].Index; Keys keycode = Keys.None; if (Convert.ToString(dgvOrderBook[WatchConst.OrderStatus, rowindex].Value) == AtsEnums.OrderStatus.EPending.ToString() && Convert.ToString(dgvOrderBook[WatchConst.BuySell, rowindex].Value) == AtsEnums.BuySell.SELL.ToString()) keycode = Keys.F2; if (Convert.ToString(dgvOrderBook[WatchConst.OrderStatus, rowindex].Value) == AtsEnums.OrderStatus.EPending.ToString() && Convert.ToString(dgvOrderBook[WatchConst.BuySell, rowindex].Value) == AtsEnums.BuySell.BUY.ToString()) keycode = Keys.F1; if (keycode != Keys.None) { CreateOrderInfo(); bool Ismodifypanelvisible; if (Convert.ToString(dgvOrderBook[WatchConst.OrderStatus, rowindex].Value) == AtsEnums.OrderStatus.EPending.ToString()) Ismodifypanelvisible = true; else Ismodifypanelvisible = false; if (!string.IsNullOrEmpty(ContractInfo.TokenNo) && cond != null) { // if (ComData.StrategyCollection.Keys.Contains(AtsEnums.StrategyType.Manual)) { FrmOrderEntry frmOrder = new FrmOrderEntry(keycode, ContractInfo, cond, Convert.ToUInt32(AtsMethods.StringToEnum<AtsEnums.GatewayId>(dgvOrderBook[WatchConst.GatewayId, rowindex].Value.ToString())), orderprice, dgvOrderBook.SelectedRows); frmOrder.ShowInTaskbar = false; frmOrder.IsModifyPanelVisible = Ismodifypanelvisible; OrderpanelSetting(frmOrder); FormSetup.SetupForm(frmOrder); frmOrder.ShowDialog(AppGlobal.frmMain); dgvOrderBook.Focus(); dgvOrderBook.Select(); } //else //{ // AppGlobal.OrderLogger.ShowToErrorMessageLog("Manual Trading Not Allowed."); //} } } else AppGlobal.Logger.ShowToErrorMessageLog("You can not modify this order."); }*/ }