Form1.cs
Upload User: chinafred
Upload Date: 2007-08-14
Package Size: 10127k
Code Size: 4k
Category:

ADO-ODBC

Development Platform:

C#

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7. using ch8_3.localhost;
  8. namespace ch8_3
  9. {
  10. /// <summary>
  11. /// Form1 的摘要说明。
  12. /// </summary>
  13. public class Form1 : System.Windows.Forms.Form
  14. {
  15. private System.Windows.Forms.Label label1;
  16. private System.Windows.Forms.Label label2;
  17. private System.Windows.Forms.TextBox textBox1;
  18. private System.Windows.Forms.TextBox textBox2;
  19. private System.Windows.Forms.Button button1;
  20. /// <summary>
  21. /// 必需的设计器变量。
  22. /// </summary>
  23. private System.ComponentModel.Container components = null;
  24. public Form1()
  25. {
  26. //
  27. // Windows 窗体设计器支持所必需的
  28. //
  29. InitializeComponent();
  30. //
  31. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  32. //
  33. }
  34. /// <summary>
  35. /// 清理所有正在使用的资源。
  36. /// </summary>
  37. protected override void Dispose( bool disposing )
  38. {
  39. if( disposing )
  40. {
  41. if (components != null) 
  42. {
  43. components.Dispose();
  44. }
  45. }
  46. base.Dispose( disposing );
  47. }
  48. #region Windows Form Designer generated code
  49. /// <summary>
  50. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  51. /// 此方法的内容。
  52. /// </summary>
  53. private void InitializeComponent()
  54. {
  55. this.label1 = new System.Windows.Forms.Label();
  56. this.label2 = new System.Windows.Forms.Label();
  57. this.textBox1 = new System.Windows.Forms.TextBox();
  58. this.textBox2 = new System.Windows.Forms.TextBox();
  59. this.button1 = new System.Windows.Forms.Button();
  60. this.SuspendLayout();
  61. // 
  62. // label1
  63. // 
  64. this.label1.Location = new System.Drawing.Point(32, 48);
  65. this.label1.Name = "label1";
  66. this.label1.TabIndex = 0;
  67. this.label1.Text = "用户名";
  68. // 
  69. // label2
  70. // 
  71. this.label2.Location = new System.Drawing.Point(32, 96);
  72. this.label2.Name = "label2";
  73. this.label2.TabIndex = 1;
  74. this.label2.Text = "密码";
  75. // 
  76. // textBox1
  77. // 
  78. this.textBox1.Location = new System.Drawing.Point(160, 48);
  79. this.textBox1.Name = "textBox1";
  80. this.textBox1.TabIndex = 2;
  81. this.textBox1.Text = "";
  82. // 
  83. // textBox2
  84. // 
  85. this.textBox2.Location = new System.Drawing.Point(160, 96);
  86. this.textBox2.Name = "textBox2";
  87. this.textBox2.PasswordChar = '*';
  88. this.textBox2.TabIndex = 3;
  89. this.textBox2.Text = "";
  90. // 
  91. // button1
  92. // 
  93. this.button1.Location = new System.Drawing.Point(184, 152);
  94. this.button1.Name = "button1";
  95. this.button1.TabIndex = 4;
  96. this.button1.Text = "确定";
  97. this.button1.Click += new System.EventHandler(this.button1_Click);
  98. // 
  99. // Form1
  100. // 
  101. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  102. this.ClientSize = new System.Drawing.Size(292, 213);
  103. this.Controls.AddRange(new System.Windows.Forms.Control[] {
  104.   this.button1,
  105.   this.textBox2,
  106.   this.textBox1,
  107.   this.label2,
  108.   this.label1});
  109. this.Name = "Form1";
  110. this.Text = "使用SOAP标头的用户验证";
  111. this.ResumeLayout(false);
  112. }
  113. #endregion
  114. /// <summary>
  115. /// 应用程序的主入口点。
  116. /// </summary>
  117. [STAThread]
  118. static void Main() 
  119. {
  120. Application.Run(new Form1());
  121. }
  122. private void button1_Click(object sender, System.EventArgs e)
  123. {
  124. //获取用户名和密码
  125. string userName=this.textBox1.Text;
  126. string passWord=this.textBox2.Text;
  127. //创建一个验证类的对象
  128. Authentication valid=new Authentication();
  129. valid.Username=userName;
  130. valid.Password=passWord;
  131. //新建一个Web服务实例
  132. Service1 validService=new Service1();   
  133. //设置Web服务验证类的值
  134.         validService.AuthenticationValue=valid;
  135. //调用Web 服务方法
  136. string result=validService.ValidateUser();
  137. //显示结果
  138.     MessageBox.Show(result,"提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
  139. }
  140. }
  141. }