| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 463 人关注过本帖
标题:谁能帮我看看下面的哪里错了!注册发信
只看楼主 加入收藏
d778
Rank: 1
等 级:新手上路
帖 子:257
专家分:0
注 册:2006-1-10
收藏
 问题点数:0 回复次数:0 
谁能帮我看看下面的哪里错了!注册发信
源程序如下!是一个注册程序!但是要求 注册完后可以发信给注册人
红色部分 为我加的发信代码
xxxxxxx  为我个人隐藏!

using System;
using System.Collections;
using
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using
using


namespace onlineHotel.user
{
    /// <summary>
    /// Register 的摘要说明。
    /// </summary>
    public class Register : BasePage
    {
        protected System.Web.UI.WebControls.TextBox txtUserName;
        protected System.Web.UI.WebControls.TextBox txtPassword;
        protected System.Web.UI.WebControls.TextBox txtRePassword;
        protected System.Web.UI.WebControls.TextBox txtEmail;
        protected System.Web.UI.WebControls.TextBox txtTel;
        protected System.Web.UI.WebControls.Button btnAffirm;
    
        private void Page_Load(object sender, System.EventArgs e)
        {
            // 在此处放置用户代码以初始化页面
            if(! IsPostBack)
            {
                btnAffirm.Attributes.Add("onClick","javascript:return post_go();");
                
            }
        }

        #region Web 窗体设计器生成的代码
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: 该调用是 Web 窗体设计器所必需的。
            //
            InitializeComponent();
            base.OnInit(e);
        }
        
        /// <summary>
        /// 设计器支持所需的方法 - 不要使用代码编辑器修改
        /// 此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {   
            this.btnAffirm.Click += new System.EventHandler(this.btnAffirm_Click);
            this.Load += new System.EventHandler(this.Page_Load);

        }
        #endregion

        private void btnAffirm_Click(object sender, System.EventArgs e)
        {
           
            if(txtUserName.Text.Trim() == "")
            {
                ToolHelper.Alert("请输入登录名",this.Page);
                return;
            }
            if(txtPassword.Text.Trim() == "")
            {
                ToolHelper.Alert("请输入密码",this.Page);
                return;
            }
            Config cg = new Config();
            DataTable dt = cg.GetTable("select [ID] from t_member_member where [UserName]='"+txtUserName.Text.Trim()+"'");
            if(dt.Rows.Count > 0)
            {
                ToolHelper.Alert("此登录名已存在!请选择其它的名字.",this.Page);
                return;
            }
            SqlParameter[] sp = new SqlParameter[]
                                  {
                                      new SqlParameter("@UserName",SqlDbType.NVarChar),
                                      new SqlParameter("@Password",SqlDbType.NVarChar),
                                      new SqlParameter("@Email",SqlDbType.NVarChar),
                                      new SqlParameter("@Tel",SqlDbType.NVarChar),
                                      new SqlParameter("@RegistDate",SqlDbType.DateTime)                                    
                                  };
            sp[0].Value = ToolHelper.StringReplace(txtUserName.Text.Trim(),1);
            sp[1].Value = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(ToolHelper.StringReplace(txtPassword.Text.Trim(),1),"MD5");
            sp[2].Value = ToolHelper.StringReplace(txtEmail.Text.Trim());
            sp[3].Value = ToolHelper.StringReplace(txtTel.Text.Trim(),1);
            sp[4].Value = System.DateTime.Now;
            
            string strSql = "insert into t_member_member([UserName],[PassWord],[Email],[Tel],[RegistDate]) values(@UserName,@Password,@Email,@Tel,@RegistDate)";
            Config.ExecuteNonQuery(Config.CONN_STRING,CommandType.Text,strSql,sp);
            
            Session["id"]= cg.GetMaxId("ID","t_member_member") - 1;
            Session["name"] = txtUserName.Text.Trim();
            
             bool bTF = false;
        if (dal.ExecuteSql(sb.ToString()))
        {
            bTF = true;
        }
        return bTF;
    }

    public bool SendEmail(string UserName, string Password, string Email)
    {
        string form = "xxxxxxxxxxx";
        string FromName = "xxxxxxxxxxxxx";
        string to = Email;
        MailMessage mail = new MailMessage(form, to);
        mail.IsBodyHtml = true;

        mail.Subject = "xxxxxxx!";
        StringBuilder sb = new StringBuilder();
        sb.Append("xxxxx:<br>");
        sb.Append("  xx:<br>");
        sb.Append("  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <br>");
        sb.Append("  &raquo;&nbsp;&nbsp;&nbsp;会员号: " + UserName + " <br>");
        sb.Append("  &raquo;&nbsp;&nbsp;&nbsp;密 码: " + Password + " <br>");
        sb.Append("  xxxxxxxxxxxxxxxx  <br>");
        sb.Append("  xxxxxxx  <br><br>");
        sb.Append("    xxxxxx <br>");
        sb.Append("     xxxxxxxxx  <br><br><br><br>");
        sb.Append("                   xxxxxx  <br>");
        sb.Append("                  xxxxxx <br>");
        mail.Body = sb.ToString();

        SmtpClient smtp = new SmtpClient();

        bool bTF = true;
        try
        {
            smtp.Send(mail);
        }
        catch
        {
            bTF = false;
        }
        return bTF;

    }
}
}
搜索更多相关主题的帖子: 注册 
2008-05-04 16:18
快速回复:谁能帮我看看下面的哪里错了!注册发信
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014603 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved