textBox1.Text = lc_yhbm;
}
}
单击按钮事件中有关用户修改并存入XML文件代码:
private void button7_Click(object sender, EventArgs e)
{
XElement yhFile = XElement.Load(@"ftp://100.100.0.1/yhcd1/XMLYhsj.xml");
string lc_yhbm = textBox1.Text.Trim();
string lc_yhxm = textBox2.Text.Trim();
string lc_dwmc = textBox3.Text.Trim();
string lc_jsmc = textBox4.Text.Trim();
string lc_yhmm1 = textBox5.Text.Trim();
string lc_yhmm2 = textBox10.Text.Trim();
string lc_scmm = oper.mmjmsc(lc_yhmm1); //调用密码加密输出方法
try
{
foreach (var cl in yhFile.Elements("yhbm"))
{
if (cl.Value.ToString() == lc_yhbm)
{
cl.SetAttributeValue("yhxm", lc_yhxm); //修改元素属性
cl.SetAttributeValue("dwbm", lc_dwbm); //lc_dwbm下拉列表框赋值
cl.SetAttributeValue("dwmc", lc_dwmc);
cl.SetAttributeValue("jsbm", lc_jsbm); //lc_jsbm下拉列表框赋值
cl.SetAttributeValue("jsmc", lc_jsmc);
cl.SetAttributeValue("yhmm", lc_scmm);
}
}
|