WebForm1.aspx.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11. namespace MWSeviceDemo
  12. {
  13. /// <summary>
  14. /// WebForm1 的摘要说明。
  15. /// </summary>
  16. public class WebForm1 : System.Web.UI.Page
  17. {
  18. MWSeviceDemo.MW.wmgw ws;
  19. protected System.Web.UI.WebControls.TextBox TextBox1;
  20. protected System.Web.UI.WebControls.Label Label1;
  21. protected System.Web.UI.WebControls.Label Label2;
  22. protected System.Web.UI.WebControls.TextBox TextBox2;
  23. protected System.Web.UI.WebControls.Button Button1;
  24. protected System.Web.UI.WebControls.Label Label3;
  25. protected System.Web.UI.WebControls.Label Label4;
  26. protected System.Web.UI.WebControls.Label Label5;
  27. protected System.Web.UI.WebControls.TextBox TextBox3;
  28. protected System.Web.UI.WebControls.TextBox TextBox4;
  29. protected System.Web.UI.WebControls.TextBox TextBox5;
  30. protected System.Web.UI.WebControls.ListBox ListBox1;
  31. protected System.Web.UI.WebControls.Button Button2;
  32. protected System.Web.UI.WebControls.Button Button3;
  33. protected System.Web.UI.WebControls.Button Button5;
  34. protected System.Web.UI.WebControls.Label Label6;
  35. protected System.Web.UI.WebControls.TextBox TextBox6;
  36. protected System.Web.UI.WebControls.Label Label7;
  37. protected System.Web.UI.WebControls.Button Button4;
  38. private void Page_Load(object sender, System.EventArgs e)
  39. {
  40. // 在此处放置用户代码以初始化页面
  41. ws = new MWSeviceDemo.MW.wmgw();
  42. }
  43. #region Web 窗体设计器生成的代码
  44. override protected void OnInit(EventArgs e)
  45. {
  46. //
  47. // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
  48. //
  49. InitializeComponent();
  50. base.OnInit(e);
  51. }
  52. /// <summary>
  53. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  54. /// 此方法的内容。
  55. /// </summary>
  56. private void InitializeComponent()
  57. {
  58. this.Button1.Click += new System.EventHandler(this.Button1_Click);
  59. this.Button2.Click += new System.EventHandler(this.Button2_Click);
  60. this.Button3.Click += new System.EventHandler(this.Button3_Click);
  61. this.Button4.Click += new System.EventHandler(this.Button4_Click);
  62. this.Button5.Click += new System.EventHandler(this.Button5_Click);
  63. this.Load += new System.EventHandler(this.Page_Load);
  64. }
  65. #endregion
  66. private void Button1_Click(object sender, System.EventArgs e)
  67. {
  68. //单发
  69. int result;
  70. result=ws.MongateSendSms(TextBox1.Text,TextBox2.Text,TextBox4.Text,TextBox3.Text);
  71. if(result > 0)
  72. ListBox1.Items.Insert(0,"发送信息成功!");
  73. else
  74. ListBox1.Items.Insert(0,"发送信息失败!返回:"+result.ToString());
  75. }
  76. private void Button2_Click(object sender, System.EventArgs e)
  77. {
  78. int bal=ws.MongateQueryBalance(TextBox1.Text,TextBox2.Text);
  79. int use=ws.MongateQueryUsed(TextBox1.Text,TextBox2.Text);
  80. if(bal>=0 && use >=0){ListBox1.Items.Insert(0,"帐户余额:"+bal.ToString()+";帐户已用:"+use.ToString());}
  81. else{ListBox1.Items.Insert(0,"返回:" + bal.ToString()+","+use.ToString());}
  82. }
  83. private void Button3_Click(object sender, System.EventArgs e)
  84. {
  85. string []result = ws.MongateCsGetSmsExEx(TextBox1.Text,TextBox2.Text);
  86. if(result==null){ListBox1.Items.Insert(0,"无信息");}
  87. else
  88. foreach (string s in result)
  89. {
  90. ListBox1.Items.Insert(0,new ListItem(s,""));
  91. }
  92. }
  93. private void Button4_Click(object sender, System.EventArgs e)
  94. {
  95. string []result = ws.MongateCsGetStatusReportExEx(TextBox1.Text,TextBox2.Text);
  96. if(result==null){ListBox1.Items.Insert(0,"无状态报告");}
  97. else
  98. foreach (string s in result)
  99. {
  100. ListBox1.Items.Insert(0,new ListItem(s,""));
  101. }
  102. }
  103. private void Button5_Click(object sender, System.EventArgs e)
  104. {
  105. string []ret=null;
  106. //子端口发送
  107. ret = ws.MongateCsSPSendSmsExEx(TextBox1.Text,TextBox2.Text,TextBox4.Text,TextBox3.Text,this.TextBox6.Text);
  108. if(ret[0] == null)
  109. {
  110. ListBox1.Items.Insert(0,"发送信息成功!信息编号:"+ret[1]);
  111. ListBox1.Items.Insert(0,"正确号码:"+ret[2]);
  112. ListBox1.Items.Insert(0,"错误号码:"+ret[3]);
  113. }
  114. else
  115. {
  116. ListBox1.Items.Insert(0,"发送失败:" + ret[0] + "错误号码:"+ret[2]);
  117. }
  118. }
  119. }
  120. }