public static databases.tmpDS.codeListDataTable GetTradeActions() { databases.tmpDS.codeListDataTable tbl = new databases.tmpDS.codeListDataTable(); databases.tmpDS.codeListRow row; foreach (AppTypes.TradeActions item in Enum.GetValues(typeof(AppTypes.TradeActions))) { row = tbl.NewcodeListRow(); row.code = ((byte)item).ToString(); row.byteValue = (byte)item; row.description = AppTypes.Type2Text(item); tbl.AddcodeListRow(row); } return(tbl); }
private static DataTable CreateDataTable(StringCollection timeRangeList, StringCollection strategyList) { // Define the new datatable DataTable tbl = new DataTable(); // Define columns DataColumn col = new DataColumn("item"); tbl.Columns.Add(col); for (int idx = 0; idx < timeRangeList.Count; idx++) { string colName = timeRangeList[idx]; col = new DataColumn(colName, typeof(Decimal)); col.Caption = AppTypes.Type2Text(AppTypes.TimeRangeFromCode(timeRangeList[idx])); tbl.Columns.Add(col); } for (int rowId = 0; rowId < strategyList.Count; rowId++) { tbl.Rows.Add(strategyList[rowId]); } return(tbl); }
private DataTable CreateCriteriaTable() { //Type data DataTable typeTbl = new DataTable(); DataColumn col1 = new DataColumn("code", typeof(byte)); typeTbl.Columns.Add(col1); DataColumn col2 = new DataColumn("description"); typeTbl.Columns.Add(col2); foreach (AppTypes.ScreeningCriteriaTypes item in Enum.GetValues(typeof(AppTypes.ScreeningCriteriaTypes))) { DataRow row = typeTbl.Rows.Add((byte)item); row[1] = AppTypes.Type2Text(item); } //Binding this.scrTypeCol.DataPropertyName = "type"; this.scrTypeCol.DisplayMember = typeTbl.Columns[1].ColumnName; this.scrTypeCol.ValueMember = typeTbl.Columns[0].ColumnName; this.scrTypeCol.DataSource = typeTbl; this.scrMinCol.DataPropertyName = "min"; this.scrMaxCol.DataPropertyName = "max"; //Grid datasource DataTable tbl = new DataTable(); tbl.Columns.Add(new DataColumn("type", typeof(byte))); tbl.Columns.Add(new DataColumn("min", typeof(double))); tbl.Columns.Add(new DataColumn("max", typeof(double))); scrCriteriaGrid.DataSource = tbl; common.system.AutoFitGridColumn(scrCriteriaGrid, this.scrTypeCol.Name); return(tbl); }
private static DataTable CreateDataTable(StringCollection timeRangeList, string[] strategyList) { // Define the new datatable DataTable tbl = new DataTable(); // Define columns DataColumn col = new DataColumn("item"); tbl.Columns.Add(col); for (int idx = 0; idx < timeRangeList.Count; idx++) { string colName = timeRangeList[idx]; col = new DataColumn(colName, typeof(Decimal)); col.Caption = AppTypes.Type2Text(AppTypes.TimeRangeFromCode(timeRangeList[idx])); tbl.Columns.Add(col); } application.Strategy.StrategyMeta meta; for (int rowId = 0; rowId < strategyList.Length; rowId++) { meta = application.Strategy.StrategyLibs.FindMetaByCode(strategyList[rowId]); tbl.Rows.Add(meta.Name.Trim()); } return(tbl); }
//Swicth language. Note that the order of items must be preserved public static void SetLanguage(ComboBox.ObjectCollection items, Type type) { StringCollection saveKeys = new StringCollection(); for (int idx = 0; idx < items.Count; idx++) { common.myComboBoxItem item = (common.myComboBoxItem)items[idx]; saveKeys.Add(item.Value); } if (type == typeof(AppTypes.TimeScale)) { items.Clear(); for (int idx = 0; idx < saveKeys.Count; idx++) { object obj = FindTimeScaleByCode(saveKeys[idx]); if (obj == null) { continue; } AppTypes.TimeScale item = (AppTypes.TimeScale)obj; items.Add(new common.myComboBoxItem(item.Description, item.Code)); } return; } if (type == typeof(AppTypes.TradeActions)) { items.Clear(); for (int idx = 0; idx < saveKeys.Count; idx++) { object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.TradeActions)); if (obj == null) { continue; } AppTypes.TradeActions item = (AppTypes.TradeActions)obj; items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString())); } return; } if (type == typeof(AppTypes.TimeRanges)) { items.Clear(); for (int idx = 0; idx < saveKeys.Count; idx++) { object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.TimeRanges)); if (obj == null) { continue; } AppTypes.TimeRanges item = (AppTypes.TimeRanges)obj; items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString())); } return; } if (type == typeof(AppTypes.StrategyTypes)) { items.Clear(); for (int idx = 0; idx < saveKeys.Count; idx++) { object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.StrategyTypes)); if (obj == null) { continue; } AppTypes.StrategyTypes item = (AppTypes.StrategyTypes)obj; items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString())); } return; } if (type == typeof(AppTypes.Sex)) { items.Clear(); for (int idx = 0; idx < saveKeys.Count; idx++) { object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.Sex)); if (obj == null) { continue; } AppTypes.Sex item = (AppTypes.Sex)obj; items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString())); } return; } if (type == typeof(AppTypes.CommonStatus)) { items.Clear(); for (int idx = 0; idx < saveKeys.Count; idx++) { object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.CommonStatus)); if (obj == null) { continue; } AppTypes.CommonStatus item = (AppTypes.CommonStatus)obj; items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString())); } return; } if (type == typeof(AppTypes.ChartTypes)) { items.Clear(); for (int idx = 0; idx < saveKeys.Count; idx++) { object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.ChartTypes)); if (obj == null) { continue; } AppTypes.ChartTypes item = (AppTypes.ChartTypes)obj; items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString())); } return; } if (type == typeof(AppTypes.BizSectorTypes)) { items.Clear(); for (int idx = 0; idx < saveKeys.Count; idx++) { object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.BizSectorTypes)); if (obj == null) { continue; } AppTypes.BizSectorTypes item = (AppTypes.BizSectorTypes)obj; items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString())); } return; } }