using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;
using DSWeb.EntityDA;
using DSWeb.Models;
using System.IO;
using System.Xml;
using JsonHelper;
namespace DSWeb.Accounts
{
public partial class ForgetPassWord : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
var desp = tbDESCRIPTION.Text.Trim();
if (desp.Length == 0)
{
Response.Write("");
return;
}
T_ALL_DA T_ALL_DA = new T_ALL_DA();
UserDA UserDA = new UserDA();
DataSet ds = T_ALL_DA.GetAllSQL("select * from [info_client] where 1=1 and DESCRIPTION='" + desp + "' and ISSTOP=0");
if (ds != null)
{
if (ds.Tables[0].Rows[0]["LOGINNAME"].ToString().Trim().Equals(""))
{
Response.Write("");//用户名不存在
return;
}
else
{
DataSet ds1 = UserDA.GetExcuteSql("select * from info_client where GID='" + ds.Tables[0].Rows[0]["GID"].ToString().Trim() + "' and ISSTOP=0");
if (ds1 == null)
{
Response.Write("");
return;
}
else
{
try
{
getXML(ds.Tables[0].Rows[0]["corpid"].ToString().Trim());
//
//收件人地址
//发件人地址
//邮件正文
//邮件的主题
//发件人密码
//邮箱服务器地址
string sto = ds.Tables[0].Rows[0]["EMAIL"].ToString().Trim();
string sBody = "客户登陆名称:" + ds.Tables[0].Rows[0]["LOGINNAME"].ToString().Trim() + ",密码:" + ds.Tables[0].Rows[0]["LOGINPASSWORD"].ToString().Trim();
SendMail SendMail = new SendMail(sto, this.hdSender.Value.Trim(), sBody, this.hdTitle.Value.Trim(), this.hdPassWord.Value.Trim(), this.hdMailServe.Value.Trim());
SendMail.Send();
}
catch (Exception)
{
}
}
}
}
else
{
Response.Write("");
return;
}
}
protected void getXML(string strCompanyID)
{
string OppPath = "xml";
string xmlPath = Server.MapPath(OppPath);
string xmlName = "SendMail.xml";
//
if (File.Exists(xmlPath + "//" + xmlName)) //判断文件是否寸在
{
//存在的情况下
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(xmlPath + "//" + xmlName);
//更新文件
XmlNode roots = xmldoc.SelectSingleNode("Data");//获取History节点的所有子节点
foreach (XmlNode root in roots)//遍历所有子节点
{
XmlElement xe = (XmlElement)root;//将子节点类型转换为XmlElement类型
if (xe.GetAttribute("companyid").ToString().Trim() == strCompanyID.Trim())//如果id属性值为“strCompanyID”
{
XmlNodeList bakss = xe.ChildNodes;//继续获取xe子节点的所有子节点
foreach (XmlNode baks in bakss)//遍历
{
XmlElement bak = (XmlElement)baks;//转换类型
if (bak.Name == "MAILSERVE")//如果找到
{
this.hdMailServe.Value = bak.InnerText.Trim();//发件人邮箱服务器地址
}
else if (bak.Name == "SENDER")//如果找到
{
this.hdSender.Value = bak.InnerText.Trim();//发件人地址
}
else if (bak.Name == "PASSWORD")//发件人密码
{
this.hdPassWord.Value = bak.InnerText.Trim();
}
else if (bak.Name == "TITLE")//邮件的主题
{
this.hdTitle.Value = bak.InnerText.Trim();
}
else if (bak.Name == "REMARK")//备注信息
{
lbREMARK.Text = bak.InnerText.Trim();
}
}
break;
}
//
}
}
}
//---
}
}