private void MenuItem_Click_AddInstrument(object sender, RoutedEventArgs e) { AddInstrumentWindow instrWindow = new AddInstrumentWindow(); int ind = DataGridInstruments.SelectedIndex; if (ind > -1) { VMInstrument instrData = (VMInstrument)DataGridInstruments.Items[ind]; instrWindow.ComboboxServerDB.ItemsSource = _dataSource.CollVMDBCon; if (instrData.ServerId > 0) { instrWindow.ComboboxServerDB.SelectedIndex = instrData.ServerId - 1; } instrWindow.ComboboxStockExch.ItemsSource = _dataSource.CollVMStockExchId; int i = -1; foreach (var el in _dataSource.CollVMStockExchId) { i++; if (el.StockExchId == instrData.StockExchId) { break; } } instrWindow.ComboboxStockExch.SelectedIndex = i; // System.Threading.Thread.Sleep(0); } else { instrWindow.ComboboxServerDB.SelectedIndex = 0; } CUtilWin.ShowDialogOnCenter(instrWindow, this); }
private void MenuItem_Click_DeleteInstrument(object sender, RoutedEventArgs e) { int ind = DataGridInstruments.SelectedIndex; if (ind < 0) { return; } VMInstrument instrData = (VMInstrument)DataGridInstruments.Items[ind]; CCmdDataDeleteInstrument cmd = new CCmdDataDeleteInstrument { Instrument = instrData.instrument, StockExchId = instrData.StockExchId, ServerId = instrData.ServerId }; CCommands.CmdDeleteInstrument.Execute(cmd, this); }