GHDataSources.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. using System;
  2. using System.Data;
  3. using System.Collections;
  4. namespace GHTTests
  5. {
  6. /// <summary>
  7. /// Summary description for GHDataSources.
  8. /// </summary>
  9. public class GHDataSources
  10. {
  11. public GHDataSources()
  12. {
  13. //
  14. // TODO: Add constructor logic here
  15. //
  16. }
  17. public static Array DSArray()
  18. {
  19. return new string[] { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" } ;
  20. }
  21. public static ArrayList DSArrayHash()
  22. {
  23. ArrayList list1 = new ArrayList();
  24. ArrayList list3 = DSArrayList();
  25. IEnumerator enumerator1 = list3.GetEnumerator();
  26. while (enumerator1.MoveNext())
  27. {
  28. Hashtable hashtable1 = new Hashtable();
  29. hashtable1.Add("number", enumerator1.Current.ToString());
  30. hashtable1.Add("number_up", enumerator1.Current.ToString().ToUpper());
  31. hashtable1.Add("number_number", enumerator1.Current.ToString() + "_" + enumerator1.Current.ToString());
  32. list1.Add(hashtable1);
  33. }
  34. return list1;
  35. }
  36. public static ArrayList DSArrayList()
  37. {
  38. ArrayList list1 = new ArrayList();
  39. list1.Add("one");
  40. list1.Add("two");
  41. list1.Add("three");
  42. list1.Add("four");
  43. list1.Add("five");
  44. list1.Add("six");
  45. list1.Add("seven");
  46. list1.Add("eight");
  47. list1.Add("nine");
  48. list1.Add("ten");
  49. return list1;
  50. }
  51. public static DataTable DSDataTable()
  52. {
  53. return DSDataTable(0, 1);
  54. }
  55. public static DataTable DSDataTable(int startPage, int pages)
  56. {
  57. return DSDataTable(startPage, pages, "");
  58. }
  59. public static DataTable DSDataTable(int startPage, int pages, string text)
  60. {
  61. return DSDataTable(startPage, pages, text, true);
  62. }
  63. public static DataTable DSDataTable(int startPage, int pages, string text, bool numPages)
  64. {
  65. DataTable table2 = new DataTable("Customers");
  66. DataColumn column1 = table2.Columns.Add("ID", typeof(int));
  67. column1.AllowDBNull = false;
  68. column1.AutoIncrement = true;
  69. column1.AutoIncrementSeed = 1;
  70. column1.AutoIncrementStep = 1;
  71. column1.Unique = true;
  72. DataColumn[] columnArray1 = new DataColumn[] { column1 } ;
  73. table2.PrimaryKey = columnArray1;
  74. column1 = table2.Columns.Add("Name", typeof(string));
  75. column1.MaxLength = 100;
  76. column1.DefaultValue = "nobody";
  77. column1 = table2.Columns.Add("Company", typeof(string));
  78. column1.MaxLength = 100;
  79. column1.DefaultValue = "nonexistent";
  80. ArrayList list1 = DSArrayList();
  81. IEnumerator enumerator1 = list1.GetEnumerator();
  82. for (int i = startPage; i < startPage+pages; i++)
  83. {
  84. enumerator1.Reset();
  85. while (enumerator1.MoveNext())
  86. {
  87. string page_num = "";
  88. if (numPages)
  89. page_num = i.ToString() + "_";
  90. DataRow row1 = table2.NewRow();
  91. row1["Name"] = text + "n_" + page_num + (string)(enumerator1.Current);
  92. row1["Company"] = text + "c_" + page_num + (string)(enumerator1.Current);
  93. table2.Rows.Add(row1);
  94. }
  95. }
  96. return table2;
  97. }
  98. public static DataSet DSDataSet()
  99. {
  100. DataSet set1 = new DataSet("CustOrdersDS");
  101. DataTable table1 = new DataTable("Customers");
  102. set1.Tables.Add(table1);
  103. DataTable table2 = new DataTable("Orders");
  104. set1.Tables.Add(table2);
  105. DataColumn column1 = table1.Columns.Add("ID", typeof(int));
  106. column1.AllowDBNull = false;
  107. column1.AutoIncrement = true;
  108. column1.AutoIncrementSeed = 1;
  109. column1.AutoIncrementStep = 1;
  110. column1.Unique = true;
  111. DataColumn[] columnArray1 = new DataColumn[] { column1 } ;
  112. table1.PrimaryKey = columnArray1;
  113. column1 = table1.Columns.Add("Name", typeof(string));
  114. column1.MaxLength = 14;
  115. column1.DefaultValue = "nobody";
  116. column1 = table1.Columns.Add("Company", typeof(string));
  117. column1.MaxLength = 14;
  118. column1.DefaultValue = "nonexistent";
  119. ArrayList list1 = DSArrayList();
  120. IEnumerator enumerator1 = list1.GetEnumerator();
  121. while (enumerator1.MoveNext())
  122. {
  123. DataRow row1 = table1.NewRow();
  124. row1["Name"] = "n_" + (string)(enumerator1.Current);
  125. row1["Company"] = "c_" + (string)(enumerator1.Current);
  126. table1.Rows.Add(row1);
  127. }
  128. column1 = table2.Columns.Add("ID", typeof(int));
  129. column1.AllowDBNull = false;
  130. column1.AutoIncrement = true;
  131. column1.AutoIncrementSeed = 1;
  132. column1.AutoIncrementStep = 1;
  133. column1.Unique = true;
  134. table2.Columns.Add("CustID", typeof(int));
  135. table2.Columns.Add("Date", typeof(DateTime));
  136. table2.Columns.Add("Total", typeof(decimal));
  137. int num1 = 1;
  138. do
  139. {
  140. DataRow row2 = table2.NewRow();
  141. row2["CustID"] = num1;
  142. row2["Date"] = new DateTime(0x3aac5ed800);
  143. row2["Total"] = num1 * num1;
  144. table2.Rows.Add(row2);
  145. num1++;
  146. }
  147. while (num1 <= 10);
  148. columnArray1 = new DataColumn[] { column1 } ;
  149. table2.PrimaryKey = columnArray1;
  150. return set1;
  151. }
  152. }
  153. }