You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
209 lines
9.4 KiB
C#
209 lines
9.4 KiB
C#
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;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
|
|
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)
|
|
{
|
|
if(tbDESCRIPTION.Text.Trim()=="")
|
|
{
|
|
Response.Write("<script>alert('请输入公司全称!');history.back();</script>");
|
|
return;
|
|
}
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
//var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
var cmdClient =
|
|
db.GetSqlStringCommand(
|
|
@"select * from [info_client] where 1=1 and DESCRIPTION=@DESCRIPTION and ISSTOP=0");
|
|
cmdClient.Parameters.Clear();
|
|
db.AddInParameter(cmdClient, "@DESCRIPTION", DbType.String, tbDESCRIPTION.Text.Trim());
|
|
DataSet ds = db.ExecuteDataSet(cmdClient);
|
|
if (ds != null)
|
|
{
|
|
if (ds.Tables[0].Rows[0]["LOGINNAME"].ToString().Trim().Equals(""))
|
|
{
|
|
Response.Write("<script>alert('此用户无登陆系统的账号,请联系管理员!');history.back();</script>");//用户名不存在
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
|
|
var cmdClient2 =
|
|
db.GetSqlStringCommand(
|
|
@"select * from [info_client] where 1=1 and GID=@GID and ISSTOP=0");
|
|
cmdClient2.Parameters.Clear();
|
|
db.AddInParameter(cmdClient2, "@GID", DbType.String, ds.Tables[0].Rows[0]["GID"].ToString().Trim());
|
|
DataSet ds1 = db.ExecuteDataSet(cmdClient);
|
|
if (ds1 == null)
|
|
{
|
|
Response.Write("<script>alert('此用户无登陆系统的权限,请联系管理员!');history.back();</script>");
|
|
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("<script>alert('账号不存在,请重新注册!');history.back();</script>");
|
|
return;
|
|
}
|
|
|
|
|
|
//tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
//tran.Rollback();
|
|
Response.Write("<script>alert('账号不存在,请重新注册!');history.back();</script>");
|
|
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='" + tbDESCRIPTION.Text.Trim() + "' and ISSTOP=0");
|
|
//if (ds != null)
|
|
//{
|
|
// if (ds.Tables[0].Rows[0]["LOGINNAME"].ToString().Trim().Equals(""))
|
|
// {
|
|
// Response.Write("<script>alert('此用户无登陆系统的账号,请联系管理员!');history.back();</script>");//用户名不存在
|
|
// 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("<script>alert('此用户无登陆系统的权限,请联系管理员!');history.back();</script>");
|
|
// return;
|
|
// }
|
|
// else
|
|
// {
|
|
// try
|
|
// {
|
|
// getXML(ds.Tables[0].Rows[0]["corpid"].ToString().Trim());
|
|
// //
|
|
// //<param name="To">收件人地址</param>
|
|
// //<param name="From">发件人地址</param>
|
|
// //<param name="Body">邮件正文</param>
|
|
// //<param name="Title">邮件的主题</param>
|
|
// //<param name="Password">发件人密码</param>
|
|
// //<param name="Password">邮箱服务器地址</param>
|
|
// 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("<script>alert('账号不存在,请重新注册!');history.back();</script>");
|
|
// 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;
|
|
}
|
|
//
|
|
}
|
|
}
|
|
}
|
|
//---
|
|
}
|
|
}
|