DatasetWatchFrm.cs
上传用户:jfy123
上传日期:2021-10-28
资源大小:14k
文件大小:5k
源码类别:

网络截获/分析

开发平台:

C++ Builder

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. namespace DSWatch
  7. {
  8. /// <summary>
  9. /// Summary description for DatasetWatchFrm.
  10. /// </summary>
  11. public class DatasetWatchFrm : System.Windows.Forms.Form
  12. {
  13. private System.Windows.Forms.TabControl tabControl1;
  14. /// <summary>
  15. /// Required designer variable.
  16. /// </summary>
  17. private System.ComponentModel.Container components = null;
  18. private System.Windows.Forms.TabPage tabPage1;
  19. private System.Windows.Forms.TextBox XMLtextBox;
  20. private System.Data.DataSet ds;
  21. public DatasetWatchFrm()
  22. {
  23. //
  24. // Required for Windows Form Designer support
  25. //
  26. InitializeComponent();
  27. //
  28. // TODO: Add any constructor code after InitializeComponent call
  29. //
  30. }
  31. /// <summary>
  32. /// Clean up any resources being used.
  33. /// </summary>
  34. protected override void Dispose( bool disposing )
  35. {
  36. if( disposing )
  37. {
  38. if(components != null)
  39. {
  40. components.Dispose();
  41. }
  42. }
  43. base.Dispose( disposing );
  44. }
  45. #region Windows Form Designer generated code
  46. /// <summary>
  47. /// Required method for Designer support - do not modify
  48. /// the contents of this method with the code editor.
  49. /// </summary>
  50. private void InitializeComponent()
  51. {
  52. this.tabControl1 = new System.Windows.Forms.TabControl();
  53. this.tabPage1 = new System.Windows.Forms.TabPage();
  54. this.XMLtextBox = new System.Windows.Forms.TextBox();
  55. this.tabControl1.SuspendLayout();
  56. this.tabPage1.SuspendLayout();
  57. this.SuspendLayout();
  58. // 
  59. // tabControl1
  60. // 
  61. this.tabControl1.Appearance = System.Windows.Forms.TabAppearance.Buttons;
  62. this.tabControl1.Controls.Add(this.tabPage1);
  63. this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
  64. this.tabControl1.Location = new System.Drawing.Point(0, 0);
  65. this.tabControl1.Name = "tabControl1";
  66. this.tabControl1.SelectedIndex = 0;
  67. this.tabControl1.Size = new System.Drawing.Size(512, 285);
  68. this.tabControl1.TabIndex = 1;
  69. // 
  70. // tabPage1
  71. // 
  72. this.tabPage1.BackColor = System.Drawing.SystemColors.AppWorkspace;
  73. this.tabPage1.Controls.Add(this.XMLtextBox);
  74. this.tabPage1.ForeColor = System.Drawing.SystemColors.AppWorkspace;
  75. this.tabPage1.Location = new System.Drawing.Point(4, 25);
  76. this.tabPage1.Name = "tabPage1";
  77. this.tabPage1.Size = new System.Drawing.Size(504, 256);
  78. this.tabPage1.TabIndex = 0;
  79. this.tabPage1.Text = "XML";
  80. // 
  81. // XMLtextBox
  82. // 
  83. this.XMLtextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  84. this.XMLtextBox.Dock = System.Windows.Forms.DockStyle.Fill;
  85. this.XMLtextBox.Location = new System.Drawing.Point(0, 0);
  86. this.XMLtextBox.Multiline = true;
  87. this.XMLtextBox.Name = "XMLtextBox";
  88. this.XMLtextBox.Size = new System.Drawing.Size(504, 256);
  89. this.XMLtextBox.TabIndex = 0;
  90. this.XMLtextBox.Text = "";
  91. // 
  92. // DatasetWatchFrm
  93. // 
  94. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  95. this.ClientSize = new System.Drawing.Size(512, 285);
  96. this.Controls.Add(this.tabControl1);
  97. this.Name = "DatasetWatchFrm";
  98. this.Text = "DatasetWatchFrm";
  99. this.Load += new System.EventHandler(this.DatasetWatchFrm_Load);
  100. this.tabControl1.ResumeLayout(false);
  101. this.tabPage1.ResumeLayout(false);
  102. this.ResumeLayout(false);
  103. }
  104. #endregion
  105. private void DatasetWatchFrm_Load(object sender, System.EventArgs e)
  106. {
  107. }
  108. public void getXml(string Xmlstr)
  109. {
  110. Xmlstr=Xmlstr.Trim('"');
  111. Xmlstr=Xmlstr.Replace("\r\n","rn"); 
  112. Xmlstr=Xmlstr.Replace( "x5C"","""); 
  113. //System.Windows.Forms.MessageBox.Show(Xmlstr );
  114. XMLtextBox.Text =Xmlstr;
  115. ds=new System.Data.DataSet ("time");
  116. System.IO.StringReader xmlReader;
  117. xmlReader=new System.IO.StringReader(Xmlstr);
  118. ds.ReadXml( xmlReader);
  119. this.Text="Tables for DataSet ""+ds.DataSetName+"""; 
  120. if (ds.Tables.Count>0)
  121. {
  122. intTables(ds);
  123. }
  124. else
  125. {
  126. System.Windows.Forms.MessageBox.Show("This Dataset dos not have any table" );
  127. this.Hide();  
  128. }
  129. }
  130. private void intTables(System.Data.DataSet ds)
  131. {
  132. for(int i=0;i<ds.Tables.Count ;i++)
  133. {
  134. System.Windows.Forms.TabPage t; 
  135. t=new TabPage(ds.Tables[i].TableName +" ( "+ ds.Tables[i].Rows.Count.ToString()   +" )"  );
  136. System.Windows.Forms.DataGrid dataGrid1;
  137. dataGrid1=new DataGrid();
  138. dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
  139. dataGrid1.DataSource=ds.Tables[i];
  140. t.Controls.Add(dataGrid1);  
  141. tabControl1.TabPages.Add (t);
  142. }
  143. }
  144. }
  145. }