www.pudn.com > FORU(SMS).rar > SMS_addAdmin.cs


using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Text; 
using System.Windows.Forms; 
using System.Data.SqlClient; 
 
namespace FORU_SMS_ 
{ 
    public partial class SMS_addAdmin : Form 
    { 
        public SMS_addAdmin() 
        { 
            InitializeComponent(); 
        } 
        BaseClass.DataConn Dconn = new FORU_SMS_.BaseClass.DataConn(); 
        BaseClass.DataClass Dclass = new FORU_SMS_.BaseClass.DataClass(); 
        BaseClass.UserData Udata = new FORU_SMS_.BaseClass.UserData(); 
 
        private void SMS_addAdmin_Load(object sender, EventArgs e) 
        { 
            this.txtName.Focus(); 
        } 
 
        private void button1_Click(object sender, EventArgs e) 
        { 
            if (this.txtName.Text.Trim() == "") 
            { 
                MessageBox.Show("账号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); 
                this.txtName.Focus(); 
            } 
            else if (this.txtPass.Text.Trim() == "") 
            { 
                MessageBox.Show("密码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); 
                this.txtPass.Focus(); 
            } 
            else if (this.conftxtPass.Text.Trim() == "") 
            { 
                MessageBox.Show("确认密码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); 
                this.conftxtPass.Focus(); 
            } 
            else if (this.txtPass.Text.Trim() != this.conftxtPass.Text.Trim()) 
            { 
                MessageBox.Show("密码不一致!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); 
            } 
            else 
            { 
                try 
                { 
                    SqlDataReader sqlRead = Dclass.GetRead("select * from SMS_User where UserName='" + this.txtName.Text.Trim() + "'"); 
                    if (sqlRead.Read()) 
                    { 
                        MessageBox.Show("该账号已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); 
                    } 
                    else 
                    { 
                        Udata._Name = this.txtName.Text.Trim(); 
                        Udata._Pass = this.txtPass.Text.Trim(); 
                        Udata._confPass = this.conftxtPass.Text.Trim(); 
                        Udata.addAdmin(); 
                        MessageBox.Show("提交成功!"); 
                        this.txtName.Text = ""; 
                        this.txtPass.Text = ""; 
                        this.conftxtPass.Text = ""; 
                    } 
                } 
                catch (Exception ex) 
                { 
                    MessageBox.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 
                } 
            } 
        } 
 
    } 
}