62,074
社区成员
发帖
与我相关
我的任务
分享
protected void Button1_Click(object sender, EventArgs e)
{
staffModel staff = new staffModel();
staff.Staffpwd = this.pwd.Text.ToString().Trim();
string type = this.regtype.SelectedValue.ToString();
//判断选择类型
switch (type)
{
case "1":
staff.Stafftype = "员工注册";
break;
case "2":
staff.Stafftype = "教师注册";
break;
case "3":
staff.Stafftype = "学生注册";
break;
case "4":
staff.Stafftype = "家长注册";
break;
case "5":
staff.Stafftype = "渠道注册";
break;
}
staff.Staffname = this.people.Text.ToString().Trim();
staff.Staffsex = int.Parse(this.sex.SelectedValue.ToString());
staff.Staffinc = this.inc.Text.ToString().Trim();
staff.Staffbonken = this.bonken.Text.ToString().Trim();
staff.Staffphone = this.phone.Text.ToString().Trim();
staff.Stafftel = this.tel.Text.ToString().Trim();
staff.Staffmail = this.mail.Text.ToString().Trim();
staff.Staffqq = this.qq.Text.ToString().Trim();
staff.Staffaddress = this.address.Text.ToString().Trim();
staff.Staffzipcode = this.zipcode.Text.ToString().Trim();
staff.Staffnote = this.node.Text.ToString().Trim();
staff.Staffdate = System.DateTime.Now;
string year = System.DateTime.Now.ToString("yy");//截取时间年份
//查询最大流水号
DataSet ds = bll.Getmaxstaffcodeid();
string id = ds.Tables[0].Rows[0][0].ToString();
string newid;
if (id == "" && id == null)
{
newid = "00000";
}
else
{
newid = Convert.ToString(Convert.ToInt32(id) + 1).PadLeft(5, '0');
}
staff.Staffcode = type + year + newid;//生成流水号
if (this.yzm.Text.ToString().ToUpper() == this.IMGCODE1.Text)
{
if (eastelite.DIP.BLL.staffBll.addregister(staff))
{
Session["reg"] = staff;//存入session
MailMessage mail = new MailMessage();
staffModel s = Session["reg"] as staffModel;//接收session
string mailfrom = System.Configuration.ConfigurationManager.AppSettings["servermailname"].ToString();
string mailto = this.mail.Text.ToString().Trim();
string mailpwd = System.Configuration.ConfigurationManager.AppSettings["servermailpwd"].ToString();
mail.BodyFormat = System.Web.Mail.MailFormat.Html;
mail.To = this.mail.Text; //接受人的邮箱
mail.From = mailfrom; //你自己的邮箱(注意qq邮箱不行)
mail.Subject = this.people.Text.ToString() + ",您好,感谢您注册****公司系统帐户"; //邮箱标题
mail.Body = "尊敬的" + this.people.Text + ":<br>感谢您对于本系统的支持与关注!<br>您的注册信息如下:<br>系统帐号:<font color='red'>" + s.Staffcode + "</font><br>系统密码:<font color='red'>"
+ this.pwd.Text + "</font><br>用户名:<font color='red'>" + this.people.Text + "</font><br>安全邮箱:<font color='red'>" + this.mail.Text
+ "</font><br>帐号或其他相关问题请登录我们的官网咨询或留言.<br>谢谢您的关注!(请勿回复系统邮件)";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", "2");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //stmp验证
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", mailfrom);
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", mailpwd);
SmtpMail.SmtpServer = "smtp.ym.163.com"; //企业代理邮件服务器
SmtpMail.Send(mail);
cleartext();//清空文本
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "str", "<script>window.open('regdetatile.aspx',target='_self');</script>");//弹出信息显示页面
}
else
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "str", "<script>alert('抱歉。注册提交失败。请刷新后重新尝试!')</script>");
}
}
else
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "str", "<script>alert('验证码错误。请重新填写!')</script>");
}
}