NewAccount.cs
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:11k
源码类别:

Email客户端

开发平台:

Visual C++

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using MailManageSystem.RegisterAccount ;
  7. namespace MailManageSystem
  8. {
  9. /// <summary>
  10. /// NewAccount 的摘要说明。
  11. /// </summary>
  12. public class NewAccount : System.Windows.Forms.Form
  13. {
  14. private System.Windows.Forms.PictureBox pictureBox1;
  15. private System.Windows.Forms.Label label1;
  16. private System.Windows.Forms.Label label6;
  17. private System.Windows.Forms.Label label7;
  18. private System.Windows.Forms.Label label4;
  19. private System.Windows.Forms.Label label5;
  20. private System.Windows.Forms.Label label8;
  21. private System.Windows.Forms.Button btnNext;
  22. private System.Windows.Forms.Button btnCancle;
  23. private System.Windows.Forms.TextBox txtUserName;
  24. private System.Windows.Forms.TextBox txtPassWord;
  25. private System.Windows.Forms.TextBox txtAccountName;
  26. private System.Windows.Forms.TextBox txtMailAddress;
  27. /// <summary>
  28. /// 必需的设计器变量。
  29. /// </summary>
  30. private System.ComponentModel.Container components = null;
  31. private System.Windows.Forms.LinkLabel linkLabel1;
  32. AccountOperate acOperate=new AccountOperate();
  33. public NewAccount()
  34. {
  35. //
  36. // Windows 窗体设计器支持所必需的
  37. //
  38. InitializeComponent();
  39. //
  40. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  41. //
  42. }
  43. /// <summary>
  44. /// 清理所有正在使用的资源。
  45. /// </summary>
  46. protected override void Dispose( bool disposing )
  47. {
  48. if( disposing )
  49. {
  50. if(components != null)
  51. {
  52. components.Dispose();
  53. }
  54. }
  55. base.Dispose( disposing );
  56. }
  57. #region Windows 窗体设计器生成的代码
  58. /// <summary>
  59. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  60. /// 此方法的内容。
  61. /// </summary>
  62. private void InitializeComponent()
  63. {
  64. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(NewAccount));
  65. this.pictureBox1 = new System.Windows.Forms.PictureBox();
  66. this.label1 = new System.Windows.Forms.Label();
  67. this.txtUserName = new System.Windows.Forms.TextBox();
  68. this.label6 = new System.Windows.Forms.Label();
  69. this.txtPassWord = new System.Windows.Forms.TextBox();
  70. this.label7 = new System.Windows.Forms.Label();
  71. this.label4 = new System.Windows.Forms.Label();
  72. this.txtAccountName = new System.Windows.Forms.TextBox();
  73. this.label5 = new System.Windows.Forms.Label();
  74. this.btnNext = new System.Windows.Forms.Button();
  75. this.label8 = new System.Windows.Forms.Label();
  76. this.txtMailAddress = new System.Windows.Forms.TextBox();
  77. this.btnCancle = new System.Windows.Forms.Button();
  78. this.linkLabel1 = new System.Windows.Forms.LinkLabel();
  79. this.SuspendLayout();
  80. // 
  81. // pictureBox1
  82. // 
  83. this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
  84. this.pictureBox1.Location = new System.Drawing.Point(8, 8);
  85. this.pictureBox1.Name = "pictureBox1";
  86. this.pictureBox1.Size = new System.Drawing.Size(152, 272);
  87. this.pictureBox1.TabIndex = 0;
  88. this.pictureBox1.TabStop = false;
  89. // 
  90. // label1
  91. // 
  92. this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System;
  93. this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
  94. this.label1.Location = new System.Drawing.Point(192, 16);
  95. this.label1.Name = "label1";
  96. this.label1.Size = new System.Drawing.Size(128, 24);
  97. this.label1.TabIndex = 0;
  98. this.label1.Text = "建立新的用户帐户:";
  99. this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
  100. // 
  101. // txtUserName
  102. // 
  103. this.txtUserName.Location = new System.Drawing.Point(304, 88);
  104. this.txtUserName.Name = "txtUserName";
  105. this.txtUserName.Size = new System.Drawing.Size(144, 21);
  106. this.txtUserName.TabIndex = 2;
  107. this.txtUserName.Text = "";
  108. // 
  109. // label6
  110. // 
  111. this.label6.FlatStyle = System.Windows.Forms.FlatStyle.System;
  112. this.label6.Location = new System.Drawing.Point(240, 120);
  113. this.label6.Name = "label6";
  114. this.label6.Size = new System.Drawing.Size(40, 23);
  115. this.label6.TabIndex = 0;
  116. this.label6.Text = "密码:";
  117. // 
  118. // txtPassWord
  119. // 
  120. this.txtPassWord.Location = new System.Drawing.Point(304, 120);
  121. this.txtPassWord.Name = "txtPassWord";
  122. this.txtPassWord.PasswordChar = '*';
  123. this.txtPassWord.Size = new System.Drawing.Size(144, 21);
  124. this.txtPassWord.TabIndex = 3;
  125. this.txtPassWord.Text = "531115";
  126. // 
  127. // label7
  128. // 
  129. this.label7.FlatStyle = System.Windows.Forms.FlatStyle.System;
  130. this.label7.Location = new System.Drawing.Point(232, 88);
  131. this.label7.Name = "label7";
  132. this.label7.Size = new System.Drawing.Size(56, 23);
  133. this.label7.TabIndex = 0;
  134. this.label7.Text = "用户名:";
  135. // 
  136. // label4
  137. // 
  138. this.label4.FlatStyle = System.Windows.Forms.FlatStyle.System;
  139. this.label4.ForeColor = System.Drawing.Color.Red;
  140. this.label4.Location = new System.Drawing.Point(184, 200);
  141. this.label4.Name = "label4";
  142. this.label4.Size = new System.Drawing.Size(112, 16);
  143. this.label4.TabIndex = 0;
  144. this.label4.Text = "[必填]帐户名称:";
  145. // 
  146. // txtAccountName
  147. // 
  148. this.txtAccountName.Location = new System.Drawing.Point(304, 200);
  149. this.txtAccountName.Name = "txtAccountName";
  150. this.txtAccountName.Size = new System.Drawing.Size(144, 21);
  151. this.txtAccountName.TabIndex = 4;
  152. this.txtAccountName.Text = "";
  153. // 
  154. // label5
  155. // 
  156. this.label5.FlatStyle = System.Windows.Forms.FlatStyle.System;
  157. this.label5.Location = new System.Drawing.Point(184, 160);
  158. this.label5.Name = "label5";
  159. this.label5.Size = new System.Drawing.Size(256, 24);
  160. this.label5.TabIndex = 0;
  161. this.label5.Text = ""帐户名称"是在本软件中要显示的名称";
  162. this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
  163. // 
  164. // btnNext
  165. // 
  166. this.btnNext.FlatStyle = System.Windows.Forms.FlatStyle.System;
  167. this.btnNext.Location = new System.Drawing.Point(200, 272);
  168. this.btnNext.Name = "btnNext";
  169. this.btnNext.TabIndex = 5;
  170. this.btnNext.Text = "下一步";
  171. this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
  172. // 
  173. // label8
  174. // 
  175. this.label8.FlatStyle = System.Windows.Forms.FlatStyle.System;
  176. this.label8.ForeColor = System.Drawing.Color.Red;
  177. this.label8.Location = new System.Drawing.Point(168, 56);
  178. this.label8.Name = "label8";
  179. this.label8.Size = new System.Drawing.Size(128, 23);
  180. this.label8.TabIndex = 0;
  181. this.label8.Text = "[必填]电子邮件地址:";
  182. // 
  183. // txtMailAddress
  184. // 
  185. this.txtMailAddress.Location = new System.Drawing.Point(304, 56);
  186. this.txtMailAddress.Name = "txtMailAddress";
  187. this.txtMailAddress.Size = new System.Drawing.Size(144, 21);
  188. this.txtMailAddress.TabIndex = 1;
  189. this.txtMailAddress.Text = "xuelinbo1115@163.com";
  190. this.txtMailAddress.Leave += new System.EventHandler(this.txtMailAddress_Leave);
  191. // 
  192. // btnCancle
  193. // 
  194. this.btnCancle.FlatStyle = System.Windows.Forms.FlatStyle.System;
  195. this.btnCancle.Location = new System.Drawing.Point(384, 272);
  196. this.btnCancle.Name = "btnCancle";
  197. this.btnCancle.TabIndex = 0;
  198. this.btnCancle.Text = "取消";
  199. this.btnCancle.Click += new System.EventHandler(this.btnCancle_Click);
  200. // 
  201. // linkLabel1
  202. // 
  203. this.linkLabel1.Location = new System.Drawing.Point(376, 232);
  204. this.linkLabel1.Name = "linkLabel1";
  205. this.linkLabel1.Size = new System.Drawing.Size(80, 16);
  206. this.linkLabel1.TabIndex = 6;
  207. this.linkLabel1.TabStop = true;
  208. this.linkLabel1.Text = "检测帐户名";
  209. this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
  210. // 
  211. // NewAccount
  212. // 
  213. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  214. this.ClientSize = new System.Drawing.Size(472, 318);
  215. this.Controls.Add(this.linkLabel1);
  216. this.Controls.Add(this.btnCancle);
  217. this.Controls.Add(this.label8);
  218. this.Controls.Add(this.txtMailAddress);
  219. this.Controls.Add(this.btnNext);
  220. this.Controls.Add(this.label5);
  221. this.Controls.Add(this.txtAccountName);
  222. this.Controls.Add(this.label4);
  223. this.Controls.Add(this.label1);
  224. this.Controls.Add(this.pictureBox1);
  225. this.Controls.Add(this.txtPassWord);
  226. this.Controls.Add(this.label7);
  227. this.Controls.Add(this.label6);
  228. this.Controls.Add(this.txtUserName);
  229. this.Name = "NewAccount";
  230. this.Text = "NewAccount";
  231. this.ResumeLayout(false);
  232. }
  233. #endregion
  234. private void btnNext_Click(object sender, System.EventArgs e)
  235. {
  236. SystemManage.UserName =this.txtUserName .Text ;
  237. SystemManage.PassWd =this.txtPassWord .Text ;
  238. SystemManage.AccountName =this.txtAccountName .Text ;
  239. if(this.txtMailAddress .Text =="")
  240. {
  241. MessageBox.Show ("请检查邮件地址");
  242. return;
  243. }
  244. if(this.txtUserName .Text =="")
  245. {
  246. MessageBox.Show ("请检查用户名");
  247. return;
  248. }
  249. if(this.txtPassWord.Text =="")
  250. {
  251. MessageBox.Show ("密码不能为空");
  252. return;
  253. }
  254. if(this.txtAccountName.Text =="")
  255. {
  256. MessageBox.Show ("帐户名不可为空");
  257. return;
  258. }
  259. if(returnState())
  260. {
  261. MessageBox.Show ("请更改注册名!");
  262. }
  263. else
  264. {
  265. SmtpPop smtpop=new SmtpPop ();
  266. smtpop.Show ();
  267. this.Close();
  268. }
  269. }
  270. private void btnCancle_Click(object sender, System.EventArgs e)
  271. {
  272. this.Close ();
  273. }
  274. private void txtMailAddress_Leave(object sender, System.EventArgs e)
  275. {
  276. int i=this.txtMailAddress .Text .IndexOf ("@");
  277. if(i==-1)
  278. {
  279. MessageBox.Show ("请输入正确的邮件格式!","请检查");
  280. return;
  281. }
  282. else
  283. {
  284. this.txtAccountName .Text =this.txtMailAddress .Text .Substring (0,i);
  285. this.txtUserName.Text  =this.txtAccountName .Text ;
  286. SystemManage.MailAddress =this.txtMailAddress .Text ;
  287. SystemManage.AccountName =this.txtAccountName .Text ;
  288. }
  289. }
  290. //调用Accountoperate类的检查帐户是否被占用的函数,并返回一个标志位
  291. private bool returnState()
  292. {
  293. bool state=false;
  294. state=acOperate.CheckAccount("select AccountName from Users where AccountName='"+this.txtAccountName .Text +"'",this.txtAccountName .Text );
  295. return state;
  296. }
  297. private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
  298. {
  299. if(returnState())
  300. {
  301. MessageBox.Show ("这个帐户已经被人注册","很遗憾!",MessageBoxButtons.OK,MessageBoxIcon.Warning);
  302. this.txtAccountName .Clear ();
  303. }
  304. else
  305. {
  306. MessageBox.Show ("这个注册名还没有人使用,您可以放心使用了","恭喜!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
  307. }
  308. }
  309. }
  310. }