public string Select(string id,string ps)
{
//File.WriteAllText("D:/users/anmj/documents/visual studio 2010/Projects/Bill/Bill/123.xml", Encryption.Encrypt(str));
string strpath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\XmlData\\UserXml.xml";
XmlDocument doc = new XmlDocument();
#region 验证
try
{
if (!File.Exists(strpath))
{
XmlDeclaration xmldeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8","yes");
doc.AppendChild(xmldeclaration);
XmlElement xmlelement = doc.CreateElement("Users");
doc.AppendChild(xmlelement);
doc.Save(strpath);
}
doc.Load(strpath);
XmlNodeList node = doc.DocumentElement.SelectNodes("User[@ID=\"" + id + "\"]");
if (node.Count > 0)
{
foreach (XmlNode item in node)
{
if ((item as XmlElement).GetAttribute("Password") == Encryption.Encrypt(ps))
{
Application["User_id"] = (item as XmlElement).GetAttribute("ID");
return "Home.aspx";
}
}
return "#";
}
else
return "#";
}
catch
{
return "#";
}
#endregion
}
{
//File.WriteAllText("D:/users/anmj/documents/visual studio 2010/Projects/Bill/Bill/123.xml", Encryption.Encrypt(str));
string strpath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\XmlData\\UserXml.xml";
XmlDocument doc = new XmlDocument();
#region 验证
try
{
if (!File.Exists(strpath))
{
XmlDeclaration xmldeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8","yes");
doc.AppendChild(xmldeclaration);
XmlElement xmlelement = doc.CreateElement("Users");
doc.AppendChild(xmlelement);
doc.Save(strpath);
}
doc.Load(strpath);
XmlNodeList node = doc.DocumentElement.SelectNodes("User[@ID=\"" + id + "\"]");
if (node.Count > 0)
{
foreach (XmlNode item in node)
{
if ((item as XmlElement).GetAttribute("Password") == Encryption.Encrypt(ps))
{
Application["User_id"] = (item as XmlElement).GetAttribute("ID");
return "Home.aspx";
}
}
return "#";
}
else
return "#";
}
catch
{
return "#";
}
#endregion
}