public static void ShowResult(System.Data.DataTable tblTeam, System.Data.DataTable tblMatches) { Console.Clear(); var matrixList = new List <MatrixItem>(); int i = 0; foreach (System.Data.DataRow horzRow in tblTeam.Rows) { int x = 0; int j = 0; foreach (System.Data.DataRow vertRow in tblTeam.Rows) { string col = string.Empty; if (i > 0 & j > 0) { var rs = tblMatches.Select(string.Format("(Host={0} and guest={1}) or (Host={1} and guest={0})", horzRow["TeamCode"], vertRow["TeamCode"])); if (rs.Length > 0) { col = "*"; } } if (i == 0 & j == 0) { col = " "; } if ((i == 0) && (j > 0)) { col = vertRow["TeamName"].ToString(); } if ((i > 0) && (j == 0)) { col = horzRow["TeamName"].ToString(); } var m = new MatrixItem() { ColData = col, X = x, Y = i }; x += 25; matrixList.Add(m); j++; } i++; } printMatrix(matrixList); Console.ReadKey(); }
public static List <MatrixItem> CreateSample() { var list = new List <MatrixItem>(); var countries = new string[] { " ", "England ", "Germany ", "Holland ", "Spain ", "Germany ", "Russia ", "Japan" }; for (int i = 0; i < countries.Length; i++) { int x = 0; int j = 0; foreach (var item in countries) { var col = item; if (i > 0) { col = string.Empty; } if (x == 0) { col = countries[i]; } if ((j == i) && (i > 0)) { col = "*"; } var m = new MatrixItem() { ColData = col, X = x, Y = i }; x += item.Length; list.Add(m); j++; } } return(list); }
public static List <MatrixItem> ToMatrix(System.Data.DataTable tbl) { var result = new List <MatrixItem>(); int i = 0; foreach (System.Data.DataColumn column in tbl.Columns) { int j = 0; int x = 0; foreach (System.Data.DataRow item in tbl.Rows) { var col = item[column].ToString(); if (i > 0) { col = string.Empty; } if (x == 0) { col = column.ColumnName; } if ((j == i) && (i > 0)) { col = "*"; } var m = new MatrixItem() { ColData = col, X = x, Y = i }; x += 15; result.Add(m); j++; } i++; } return(result); }