//Снятие заявки
 private void dataGridViewOrders_DoubleClick(object sender, EventArgs e)
 {
     try
     {
         var MouseEvent = (MouseEventArgs)e;
         var dataGrid   = (DataGridView)sender;
         dataGrid.ClearSelection();
         if (MouseEvent.Button == MouseButtons.Right)
         {
             var hti   = dataGrid.HitTest(MouseEvent.X, MouseEvent.Y);
             int index = hti.RowIndex;
             if (index >= 0)
             {
                 DataGridViewRow row = dataGrid.Rows[index];
                 row.Selected = true;
                 Common.Ext.NewThread(() =>
                 {
                     decimal number = Convert.ToDecimal(row.Cells[2].Value.ToString());
                     var sec        = Trader.Objects.Securities.FirstOrDefault(s => s == row.Cells[3].Value);
                     if (sec != null)
                     {
                         Trader.CancelOrder(sec, number);
                     }
                 });
             }
         }
     }
     catch (Exception ee)
     {
         MessageBox.Show(ee.ToString());
     }
 }
Exemple #2
0
 private void labelOrdersBuy_Click(object sender, EventArgs e)
 {
     try
     {
         var MouseEvent = (MouseEventArgs)e;
         if (MouseEvent.Button == MouseButtons.Right)
         {
             var listOrders = Trader.Objects.Orders.Where(o => o.Status == OrderStatus.ACTIVE && o.Direction == OrderDirection.Buy);
             foreach (var ord in listOrders)
             {
                 Trader.CancelOrder(this.TrElement.Security, ord.OrderNumber);
             }
         }
     }
     catch (Exception ee)
     {
         MessageBox.Show(ee.ToString());
     }
 }
Exemple #3
0
        /// <summary> Кликеры по таблице стакана </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridViewDepth_Click(object sender, EventArgs e)
        {
            if (this.TrElement.Security.IsNull())
            {
                return;
            }
            var MouseEvent = (MouseEventArgs)e;
            var dataGrid   = (DataGridView)sender;

            dataGrid.ClearSelection();
            var hti      = dataGrid.HitTest(MouseEvent.X, MouseEvent.Y);
            int indexRow = hti.RowIndex;
            int indexCol = hti.ColumnIndex;

            if (indexRow < 0 || indexCol < 0)
            {
                return;
            }

            DataGridViewCell cell = dataGrid.Rows[indexRow].Cells[indexCol];

            if (MouseEvent.Button == MouseButtons.Left)
            {
                if (cell.Tag != null)
                {
                    int Volume = Convert.ToInt32(numericUpDownVolume.Value);
                    if (Volume == 0)
                    {
                        UpdateTransReply("Не указан объем!");
                    }
                    if (cell.Tag.GetType().ToString().Contains("StructClickDepth"))
                    {
                        var data = (StructClickDepth)cell.Tag;

                        OrderDirection?direction = null;
                        if (data.Flag == "buy")
                        {
                            direction = OrderDirection.Buy;
                        }
                        if (data.Flag == "sell")
                        {
                            direction = OrderDirection.Sell;
                        }
                        var codeClient = comboBoxCodeClient.SelectedText;
                        Common.Ext.NewThread(() =>
                        {
                            Trader.CreateOrder(new Order()
                            {
                                Sec       = this.TrElement.Security,
                                Direction = direction,
                                Price     = data.Price,
                                Volume    = Volume
                            }, codeClient);
                        });
                    }
                }
            }
            if (MouseEvent.Button == MouseButtons.Right)
            {
                if (cell.Tag != null)
                {
                    if (cell.Tag.GetType().ToString().Contains("StructClickDepth"))
                    {
                        var data = (StructClickDepth)cell.Tag;
                        if (data.Flag == "buy" || data.Flag == "sell")
                        {
                            Common.Ext.NewThread(() =>
                            {
                                var ords = Trader.Objects.Orders.Where(o => o.Sec == this.TrElement.Security && o.Price == data.Price && o.Status == OrderStatus.ACTIVE);
                                if (ords.NotIsNull())
                                {
                                    foreach (var ord in ords)
                                    {
                                        Trader.CancelOrder(ord.Sec, ord.OrderNumber);
                                    }
                                }
                            });
                        }
                    }
                }
            }
        }