保存配置,获取配置,XML
private void SaveSOConfig()
{
//保存配置
Dictionary<string, string> PrintConfigDIC = new Dictionary<string, string>();
PrintConfigDIC.Add("TIME1", dtTime1.Text);
PrintConfigDIC.Add("TIME2", dtTime2.Text);
PrintConfigDIC.Add("STARTUP1", ConvertUtility.ObjectToString(chkStartUp1.Checked));
PrintConfigDIC.Add("STARTUP2", ConvertUtility.ObjectToString(chkStartUp2.Checked));
try
{
string path = @"C:\LayoutStyle\StandingOrderConfig.xml";
if (File.Exists(path))
{
File.Delete(path);
}
XmlDocument xml = new XmlDocument();//创建根节点 config
xml.AppendChild(xml.CreateXmlDeclaration("1.0", "utf-8", ""));
XmlElement one = xml.CreateElement("StandingOrderConfig");//把根节点加到xml文档中
foreach (var pc in PrintConfigDIC)
{
one.SetAttribute(pc.Key, pc.Value);
}
xml.AppendChild(one);
xml.Save(path);
MessageBox.Show("配置保存成功", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
LoadGridView();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
}
private void LoadSOConfig()
{
//获取配置
string path = @"C:\LayoutStyle\StandingOrderConfig.xml";
if (File.Exists(path))
{
XmlDocument doc = new XmlDocument();
doc.Load(path);
XmlNodeList nodeList = doc.SelectNodes("/StandingOrderConfig");
if (nodeList != null)
{
foreach (XmlNode node in nodeList)
{
dtTime1.EditValue = node.Attributes["TIME1"].Value;
dtTime2.EditValue = node.Attributes["TIME2"].Value;
chkStartUp1.Checked = ConvertUtility.ObjectTobool(node.Attributes["STARTUP1"].Value);
chkStartUp2.Checked = ConvertUtility.ObjectTobool(node.Attributes["STARTUP2"].Value);
DDDs.Clear();
if (chkStartUp1.Checked)
{
DDDs.Add(new DDD() { DateTimeOfExecOnce = node.Attributes["TIME1"].Value, difftime = "24H", IsRunning = "正在执行...", jobname = "长期医嘱更新" });
}
if (chkStartUp2.Checked)
{
DDDs.Add(new DDD() { DateTimeOfExecOnce = node.Attributes["TIME2"].Value, difftime = "24H", IsRunning = "正在执行...", jobname = "长期医嘱床位费更新" });
}
break;
}
}
}
}
保存配置,获取配置,XML的更多相关文章
- struts2 在 Action 或 Interceptor 中获取 web.xml 中配置的 <context-param> 参数 (这是我的第一篇博文,哈哈。)
最近为了改一个问题,想加一个控制开关,就在web.xml 中配置了一个 <context-param> 参数,并在 Action 或 Interceptor 中获取参数值. 1.在 web ...
- xml获取配置DataTable
在CSDN写博客时,经常遇到需要绑定数据源的时候,可是自己从数据库获取数据的函数都是已经封装好了的,这样别人复制你的代码,要想看到结果,还得修改修改,很是麻烦,博客实例,数据源简单点就好,这样别人写你 ...
- 应用SharedPreference保存程序的配置信息
SharedPreference: 1.用来保存应用程序的配置信息的XML文件,内部的数据形式为键值对 2.一般存在于/data/data/<包名>shared_prefs目录下 3.该对 ...
- 玩转Spring Boot 自定义配置、导入XML配置与外部化配置
玩转Spring Boot 自定义配置.导入XML配置与外部化配置 在这里我会全面介绍在Spring Boot里面如何自定义配置,更改Spring Boot默认的配置,以及介绍各配置的优先 ...
- SpringBoot Logback无法获取配置中心属性
SpringBoot Logback无法获取配置中心属性 前言 最近在做项目中,需要把项目中的日志信息通过RabbitMQ将规定格式的消息发送到消息队列中,然后ELK系统通过消息队列拿日志并且保存起来 ...
- 在web.config配置中添加xml内容
在web.config 中添加需要的内容时, 就是在<configuration>节点内添加一个新的<configSections>元素, 在configSections元素中 ...
- (转)maven配置之pom.xml配置
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- ubuntu 开机显示错误:无法应用原保存的显示器配置
无法应用原保存的显示器配置CRTC 63:尝试 800x600@60Hz 模式输出在 1366x768@60Hz (通过 0)CRTC 63:尝试 2560x1600@60Hz 模式输出在 1366x ...
- JavaWeb学习之Servlet(四)----ServletConfig获取配置信息、ServletContext的应用
[声明] 欢迎转载,但请保留文章原始出处→_→ 文章来源:http://www.cnblogs.com/smyhvae/p/4140877.html [正文] 一.ServletConfig:代表当前 ...
随机推荐
- 社团的CTF逆向题WriteUp
最近社团弄了CTF比赛,然后我就帮忙写了逆向的题目,这里写一下WriteUp,题目和源码在附件中给出 一个简单的逆向:one_jmp_to_flag.exe 这题算是签到题,直接OD智能搜索就完事了, ...
- linux用户添加组
usermod -G groupname username (这种会把用户从其他组中去掉,只属于该组)如:usermod -G git git (git只属于git组) usermod -a -G g ...
- PHP算法学习(4) 随机算法
svn地址:svn://gitee.com/zxadmin/live_z <?php /* * 随机数算法 * 伪随机数 根据分布概率 */ final class Random { /* * ...
- Python Learning - Two
1. Built-in Modules and Functions 1) Function def greeting(name): print("Hello,", name) g ...
- js 重写alert 兼容iphone使得alert 不带src
<script> window.alert = function(name){ var iframe = document.createElement("IFRAME" ...
- Python 学习笔记6 变量-字典
字典是python中一个十分重要的变量,他是一个可变的容器对象.通过一组key(键)和value(值)对组成一个元素. 组成形式为{'key':'value', 'key':'value'}.整个字典 ...
- 【TensorFlow使用教程】1 环境搭建
一.TensorFlow主要依赖包——Protocol Buffer & Bazel 1. Protocol Buffer 首先要弄清三个概念: 结构化数据:指拥有多种属性的数据,例如用户信息 ...
- in与exists和not in 与 not exists的区别
1.in 与 exists: 外表大,用IN:内表大,用EXISTS: 原理: 用in:外表使用了索引,直接作hash连接: 用exists:内表使用了索引,外表作loop循环再进行匹配: 2.not ...
- 学习Makefile
1> 编译一个文件2> 编译多个文件3> 编译多个目录下的文件4> inclue makefile5> 使用规则1>target:depend[tab]cmddep ...
- win7 64位系统下安装autoitlibrary库遇到问题解决
转载来自http://blog.sina.com.cn/s/blog_53f023270101skyq.html 今天需要在win7 64位系统下安装autoitlibrary库,起初安装好了robo ...