十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
代码如下:
成都创新互联公司是一家集网站建设,莱山企业网站建设,莱山品牌网站建设,网站定制,莱山网站建设报价,网络营销,网络优化,莱山网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。
/// summary
/// 连接到窗体:通过密码保护信息找回密码!
/// /summary
/// param name="sender"/param
/// param name="e"/param
private void lbl_mibao_Click(object sender, EventArgs e)
{
Getbackpwd getbackpwd = new Getbackpwd();
getbackpwd.Show();
}
/// summary
/// 当该窗体加载时从xml文件中读取用户信息并加载到combox的Items中
/// /summary
/// param name="sender"/param
/// param name="e"/param
private void Addresslist_Load(object sender, EventArgs e)
{
XmlTextReader reader = new XmlTextReader(@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");
while (reader.Read())
{
//if (reader.LocalName.Equals("Name") || reader.LocalName.Equals("Number"))
if (reader.LocalName.Equals("username"))
{
this.cmbUserName.Items.Add(reader.ReadString());
}
//if (reader.LocalName.Equals("Number"))
//{
// this.label2.Text += reader.ReadString() + "\n";\
//}
}
reader.Close();
}
/// summary
/// 保存用户名到user.xml
/// /summary
//在listcontol上更改SelectedValue时执行从数据库读取密码的事件
private void cmbUserName_SelectedValueChanged(object sender, EventArgs e)
{
string username = cmbUserName.Text.Trim();
string sql = string.Format("select pwd from Admin where Username='{0}'", username);
try
{
SqlCommand command = new SqlCommand(sql, DBHelper.connection);
DBHelper.connection.Open();
SqlDataReader dataReader = command.ExecuteReader();
while (dataReader.Read())
{
txtpwd.Text = (string)dataReader["pwd"];
checkBoxpwd.Checked = true;
}
}
catch
{
MessageBox.Show("数据库操作出错!");
}
finally
{
DBHelper.connection.Close();
}
}
/// summary
/// 记住密码操作
/// /summary
/// param name="sender"/param
/// param name="e"/param
private void checkBoxpwd_Enter(object sender, EventArgs e)
{
bool check = true;
check = checkinput(cmbUserName.Text.Trim());
if ((string)cmbUserName.Text.Trim() == "")
{
MessageBox.Show("请输入用户名", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
cmbUserName.Focus();
}
else
{
if (txtpwd.Text.Trim() == "")
{
MessageBox.Show("请输入密码", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
txtpwd.Focus();
}
else
{
bool isValidUser = false; // 标识是否为合法用户
string message = ""; // 如果登录失败,显示的消息提示
// 如果验证通过,就显示相应的用户窗体,并将当前窗体设为不可见
if (ValidateInput())
{
// 调用用户验证方法
isValidUser = ValidateUser(cmbUserName.Text, txtpwd.Text, ref message);
// 如果是合法用户,显示相应的窗体
if (isValidUser)
{
if (check == true)
{
XmlDocument doc = new XmlDocument();
doc.Load(@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");//(@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");
XmlElement node = doc.CreateElement("user");
XmlNode xnode = (XmlNode)doc.CreateElement("username");
xnode.InnerText = cmbUserName.Text.Trim();
node.AppendChild(xnode);
doc.DocumentElement.InsertAfter(node, doc.DocumentElement.LastChild);
doc.Save(@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");
//doc.Load (@"E:\面向对象--C#练习\通讯录\address list\address list\user.xml");
}
}
// 如果登录失败,显示相应的消息
else
{
MessageBox.Show(message, "记住密码失败!", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
}
/// summary
/// 验证当前combox中内容是否已经存在于xml文件中
/// /summary
/// param name="text"/param
/// returns/returns
private bool checkinput(string text)
{
int count;
bool c = true;
for (count = 0; count cmbUserName.Items.Count;count ++ )
{
if (text ==(string )cmbUserName .Items [count])
{
c=false;
}
}
return c;
}
xml文件内容如下:?xml version="1.0" encoding="utf-8"?
person
user
'加入一个命令按钮,两个文本框,第一个用来输入账号,第二个用来输入密码
Private
Sub
Command1_Click()
Dim
vDoc,
vTag
Dim
i
As
Integer
Set
vDoc
=
WebBrowser1.Document
For
i
=
To
vDoc.All.length
-
1
'检测所有标签
If
UCase(vDoc.All(i).tagName)
=
"INPUT"
Then
'找到input标签
Set
vTag
=
vDoc.All(i)
If
vTag.Type
=
"text"
Then
'看看是不是我们需要的
If
vTag.Name
=
"username"
Then
vTag.Value
=
Text1.Text
'这里是要搜索的内容
End
If
End
If
Next
i
For
i
=
To
vDoc.All.length
-
1
'检测所有标签
If
UCase(vDoc.All(i).tagName)
=
"INPUT"
Then
'找到input标签
Set
vTag
=
vDoc.All(i)
If
vTag.Type
=
"password"
Then
vTag.Value
=
Text2.Text
'看看是不是我们需要的
If
vTag.Value
=
"登陆"
Then
vTag.Select
'也可以没有这个
vTag.Click
'点击提交了,一切都OK了
End
If
Next
i
End
Sub
Private
Sub
Form_Load()
WebBrowser1.Navigate
";tpl=mn"
End
Sub
Private
Sub
Form_Resize()
WebBrowser1.Width
=
Form1.Width
-
500
WebBrowser1.Height
=
Form1.Height
-
1200
End
Sub
,不会的可以HI我,这是我现在用的。保证没问题。,复制代码即可。
添加一个webbrowser控件,然后在它的complete事件里添加代码:
Dim d As Object, o As Object, pc As String
On Error Resume Next
Set d = web.Document
If d Is Nothing Then Exit Sub
Set o = d.getElementById("username")
o.Value = "admin"
Set o = d.getElementById("pwd_")
o.Value = "123456"
web.Navigate "javascript:checkLogin();void 0"