Ejemplo n.º 1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(tbxName.Text))
     {
         XmlNodeList nodelist = configele.SelectNodes(string.Format("Item[@Name='{0}']", ReplaceName));
         if (nodelist.Count > 0)
         {
             MessageBox.Show(string.Format("已存在名称为({0})的明细", ReplaceName));
         }
         else
         {
             //保存XML
             XmlElement ele = oper.Doc.CreateElement("Item");
             ele.SetAttribute("Name", ReplaceName);
             ele.SetAttribute("Type", cbbConfigType.Text);
             ele.SetAttribute("DataBase", cbbDataBase.Text);
             ele.SetAttribute("Path", tbxPath.Text);
             oper.AddEle(ele, configele);
             //保存文件
             FileStreamHelper.SaveText(string.Format("{0}{1}{2}", Application.StartupPath, configDataPath, configItemName), ReplaceName, Content);
             RefreshList();
         }
     }
     else
     {
         MessageBox.Show("名称不能为空");
     }
 }
Ejemplo n.º 2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(DataName.Text))
     {
         if (oper.Exist(string.Format("/Base/DataConnections/Connection[@Name='{0}']", ConnectName)))
         {
             MessageBox.Show(string.Format("已存在名称为({0})的数据源", ConnectName));
         }
         else
         {
             XmlElement ele = oper.Doc.CreateElement("Connection");
             ele.SetAttribute("Name", ConnectName);
             ele.SetAttribute("Type", ConnectType);
             ele.InnerText = ConnectString;
             oper.AddEle(ele, "/Base/DataConnections");
             RefreshList();
         }
     }
     else
     {
         MessageBox.Show("名称不能为空");
     }
 }