|
//In clsToBUtilities.cs
public bool AddInstrument(uint instrumentID)
{
DataTable table = App.ds.Tables[TableNames.Instruments];
DataRow dr = table.Select("InstrumentID = " + instrumentID).FirstOrDefault();
MARKET_GROUP objMarket = (MARKET_GROUP)dr[nameof(tblInstrument.Market)];
App.mock.SubscribeToTOB(objMarket, instrumentID, newOnTOBSnapshot(OnTOBSnapshot),
new TOBEntryChanged(OnTOBChanged));
//Add the row to the TOB table which is the data source of the grid
App.ds.Tables[TableNames.TOB].ImportRow(dr);
return true;
} |
public bool AddInstrument(uint instrumentID) { DataTable table = App.ds.Tables[TableNames.Instruments]; DataRow dr = table.Select("InstrumentID = " + instrumentID).FirstOrDefault(); MARKET_GROUP objMarket = (MARKET_GROUP)dr[nameof(tblInstrument.Market)];
App.mock.SubscribeToTOB(objMarket, instrumentID, new OnTOBSnapshot(OnTOBSnapshot), new TOBEntryChanged(OnTOBChanged)); #region Arulpriya's code to add an instrument table row to the TOB table -IT WORKS!?!?!?!? ////Add the row to the TOB table which is the data source of the grid //App.ds.Tables[TableNames.TOB].ImportRow(dr); #endregion
#region trying to add a TOB datarow to the TOB table using same key of 970. tblTOB obj = new tblTOB(instrumentID, 0, 0, 0, 0, 0, 0, 0, 0, TimeSpan.MinValue, 0, 0); Type type = typeof(DataTableObjects.tblTOB); PropertyInfo[] properties = type.GetProperties(); object[] values = new object[properties.Length]; for (int iCol = 0; iCol < properties.Length; iCol++) { values[iCol] = properties[iCol].GetValue(obj); }
App.ds.Tables[TableNames.TOB].Rows.Add(values);
#endregion
return true; }
private static void OnTOBSnapshot(MARKET_GROUP market, uint instrumentID, TOBEntry tob) { Type type = typeof(DataTableObjects.tblTOB); PropertyInfo[] properties = type.GetProperties(); if(instrumentID==970) { string s = "970 hit"; } #region Save each properties's value into the DataTable
DataTableObjects.tblTOB instr = new DataTableObjects.tblTOB(tob); object[] values = new object[properties.Length]; for (int iCol = 0; iCol < properties.Length; iCol++) { values[iCol] = properties[iCol].GetValue(instr); } App.ds.Tables[TableNames.TOB].Rows.Add(values); #endregion }|
public void OnTOBChanged(uint instrumentID)
{
#region trying to add a TOB datarow to the TOB table using same key of 970.
tblTOB obj = new tblTOB(instrumentID, 0, 0, 0, 0, 0, 0, 0, 0, TimeSpan.MinValue, 0, 0);
Type type = typeof(DataTableObjects.tblTOB);
PropertyInfo[] properties = type.GetProperties();
object[] values = new object[properties.Length];
for (int iCol = 0; iCol < properties.Length; iCol++)
{
values[iCol] = properties[iCol].GetValue(obj);
}
App.ds.Tables[TableNames.TOB].Rows.Add(values);
#endregion
} |