NewAccount.cs
资源名称:yjal.rar [点击查看]
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:11k
源码类别:
Email客户端
开发平台:
Visual C++
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using MailManageSystem.RegisterAccount ;
- namespace MailManageSystem
- {
- /// <summary>
- /// NewAccount 的摘要说明。
- /// </summary>
- public class NewAccount : System.Windows.Forms.Form
- {
- private System.Windows.Forms.PictureBox pictureBox1;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.Label label7;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.Label label8;
- private System.Windows.Forms.Button btnNext;
- private System.Windows.Forms.Button btnCancle;
- private System.Windows.Forms.TextBox txtUserName;
- private System.Windows.Forms.TextBox txtPassWord;
- private System.Windows.Forms.TextBox txtAccountName;
- private System.Windows.Forms.TextBox txtMailAddress;
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
- private System.Windows.Forms.LinkLabel linkLabel1;
- AccountOperate acOperate=new AccountOperate();
- public NewAccount()
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- InitializeComponent();
- //
- // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
- //
- }
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(NewAccount));
- this.pictureBox1 = new System.Windows.Forms.PictureBox();
- this.label1 = new System.Windows.Forms.Label();
- this.txtUserName = new System.Windows.Forms.TextBox();
- this.label6 = new System.Windows.Forms.Label();
- this.txtPassWord = new System.Windows.Forms.TextBox();
- this.label7 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.txtAccountName = new System.Windows.Forms.TextBox();
- this.label5 = new System.Windows.Forms.Label();
- this.btnNext = new System.Windows.Forms.Button();
- this.label8 = new System.Windows.Forms.Label();
- this.txtMailAddress = new System.Windows.Forms.TextBox();
- this.btnCancle = new System.Windows.Forms.Button();
- this.linkLabel1 = new System.Windows.Forms.LinkLabel();
- this.SuspendLayout();
- //
- // pictureBox1
- //
- this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
- this.pictureBox1.Location = new System.Drawing.Point(8, 8);
- this.pictureBox1.Name = "pictureBox1";
- this.pictureBox1.Size = new System.Drawing.Size(152, 272);
- this.pictureBox1.TabIndex = 0;
- this.pictureBox1.TabStop = false;
- //
- // label1
- //
- this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
- this.label1.Location = new System.Drawing.Point(192, 16);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(128, 24);
- this.label1.TabIndex = 0;
- this.label1.Text = "建立新的用户帐户:";
- this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // txtUserName
- //
- this.txtUserName.Location = new System.Drawing.Point(304, 88);
- this.txtUserName.Name = "txtUserName";
- this.txtUserName.Size = new System.Drawing.Size(144, 21);
- this.txtUserName.TabIndex = 2;
- this.txtUserName.Text = "";
- //
- // label6
- //
- this.label6.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.label6.Location = new System.Drawing.Point(240, 120);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(40, 23);
- this.label6.TabIndex = 0;
- this.label6.Text = "密码:";
- //
- // txtPassWord
- //
- this.txtPassWord.Location = new System.Drawing.Point(304, 120);
- this.txtPassWord.Name = "txtPassWord";
- this.txtPassWord.PasswordChar = '*';
- this.txtPassWord.Size = new System.Drawing.Size(144, 21);
- this.txtPassWord.TabIndex = 3;
- this.txtPassWord.Text = "531115";
- //
- // label7
- //
- this.label7.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.label7.Location = new System.Drawing.Point(232, 88);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(56, 23);
- this.label7.TabIndex = 0;
- this.label7.Text = "用户名:";
- //
- // label4
- //
- this.label4.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.label4.ForeColor = System.Drawing.Color.Red;
- this.label4.Location = new System.Drawing.Point(184, 200);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(112, 16);
- this.label4.TabIndex = 0;
- this.label4.Text = "[必填]帐户名称:";
- //
- // txtAccountName
- //
- this.txtAccountName.Location = new System.Drawing.Point(304, 200);
- this.txtAccountName.Name = "txtAccountName";
- this.txtAccountName.Size = new System.Drawing.Size(144, 21);
- this.txtAccountName.TabIndex = 4;
- this.txtAccountName.Text = "";
- //
- // label5
- //
- this.label5.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.label5.Location = new System.Drawing.Point(184, 160);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(256, 24);
- this.label5.TabIndex = 0;
- this.label5.Text = ""帐户名称"是在本软件中要显示的名称";
- this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // btnNext
- //
- this.btnNext.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.btnNext.Location = new System.Drawing.Point(200, 272);
- this.btnNext.Name = "btnNext";
- this.btnNext.TabIndex = 5;
- this.btnNext.Text = "下一步";
- this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
- //
- // label8
- //
- this.label8.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.label8.ForeColor = System.Drawing.Color.Red;
- this.label8.Location = new System.Drawing.Point(168, 56);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(128, 23);
- this.label8.TabIndex = 0;
- this.label8.Text = "[必填]电子邮件地址:";
- //
- // txtMailAddress
- //
- this.txtMailAddress.Location = new System.Drawing.Point(304, 56);
- this.txtMailAddress.Name = "txtMailAddress";
- this.txtMailAddress.Size = new System.Drawing.Size(144, 21);
- this.txtMailAddress.TabIndex = 1;
- this.txtMailAddress.Text = "xuelinbo1115@163.com";
- this.txtMailAddress.Leave += new System.EventHandler(this.txtMailAddress_Leave);
- //
- // btnCancle
- //
- this.btnCancle.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.btnCancle.Location = new System.Drawing.Point(384, 272);
- this.btnCancle.Name = "btnCancle";
- this.btnCancle.TabIndex = 0;
- this.btnCancle.Text = "取消";
- this.btnCancle.Click += new System.EventHandler(this.btnCancle_Click);
- //
- // linkLabel1
- //
- this.linkLabel1.Location = new System.Drawing.Point(376, 232);
- this.linkLabel1.Name = "linkLabel1";
- this.linkLabel1.Size = new System.Drawing.Size(80, 16);
- this.linkLabel1.TabIndex = 6;
- this.linkLabel1.TabStop = true;
- this.linkLabel1.Text = "检测帐户名";
- this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
- //
- // NewAccount
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(472, 318);
- this.Controls.Add(this.linkLabel1);
- this.Controls.Add(this.btnCancle);
- this.Controls.Add(this.label8);
- this.Controls.Add(this.txtMailAddress);
- this.Controls.Add(this.btnNext);
- this.Controls.Add(this.label5);
- this.Controls.Add(this.txtAccountName);
- this.Controls.Add(this.label4);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.pictureBox1);
- this.Controls.Add(this.txtPassWord);
- this.Controls.Add(this.label7);
- this.Controls.Add(this.label6);
- this.Controls.Add(this.txtUserName);
- this.Name = "NewAccount";
- this.Text = "NewAccount";
- this.ResumeLayout(false);
- }
- #endregion
- private void btnNext_Click(object sender, System.EventArgs e)
- {
- SystemManage.UserName =this.txtUserName .Text ;
- SystemManage.PassWd =this.txtPassWord .Text ;
- SystemManage.AccountName =this.txtAccountName .Text ;
- if(this.txtMailAddress .Text =="")
- {
- MessageBox.Show ("请检查邮件地址");
- return;
- }
- if(this.txtUserName .Text =="")
- {
- MessageBox.Show ("请检查用户名");
- return;
- }
- if(this.txtPassWord.Text =="")
- {
- MessageBox.Show ("密码不能为空");
- return;
- }
- if(this.txtAccountName.Text =="")
- {
- MessageBox.Show ("帐户名不可为空");
- return;
- }
- if(returnState())
- {
- MessageBox.Show ("请更改注册名!");
- }
- else
- {
- SmtpPop smtpop=new SmtpPop ();
- smtpop.Show ();
- this.Close();
- }
- }
- private void btnCancle_Click(object sender, System.EventArgs e)
- {
- this.Close ();
- }
- private void txtMailAddress_Leave(object sender, System.EventArgs e)
- {
- int i=this.txtMailAddress .Text .IndexOf ("@");
- if(i==-1)
- {
- MessageBox.Show ("请输入正确的邮件格式!","请检查");
- return;
- }
- else
- {
- this.txtAccountName .Text =this.txtMailAddress .Text .Substring (0,i);
- this.txtUserName.Text =this.txtAccountName .Text ;
- SystemManage.MailAddress =this.txtMailAddress .Text ;
- SystemManage.AccountName =this.txtAccountName .Text ;
- }
- }
- //调用Accountoperate类的检查帐户是否被占用的函数,并返回一个标志位
- private bool returnState()
- {
- bool state=false;
- state=acOperate.CheckAccount("select AccountName from Users where AccountName='"+this.txtAccountName .Text +"'",this.txtAccountName .Text );
- return state;
- }
- private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
- {
- if(returnState())
- {
- MessageBox.Show ("这个帐户已经被人注册","很遗憾!",MessageBoxButtons.OK,MessageBoxIcon.Warning);
- this.txtAccountName .Clear ();
- }
- else
- {
- MessageBox.Show ("这个注册名还没有人使用,您可以放心使用了","恭喜!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
- }
- }
- }
- }