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的更多相关文章

  1. struts2 在 Action 或 Interceptor 中获取 web.xml 中配置的 <context-param> 参数 (这是我的第一篇博文,哈哈。)

    最近为了改一个问题,想加一个控制开关,就在web.xml 中配置了一个 <context-param> 参数,并在 Action 或 Interceptor 中获取参数值. 1.在 web ...

  2. xml获取配置DataTable

    在CSDN写博客时,经常遇到需要绑定数据源的时候,可是自己从数据库获取数据的函数都是已经封装好了的,这样别人复制你的代码,要想看到结果,还得修改修改,很是麻烦,博客实例,数据源简单点就好,这样别人写你 ...

  3. 应用SharedPreference保存程序的配置信息

    SharedPreference: 1.用来保存应用程序的配置信息的XML文件,内部的数据形式为键值对 2.一般存在于/data/data/<包名>shared_prefs目录下 3.该对 ...

  4. 玩转Spring Boot 自定义配置、导入XML配置与外部化配置

    玩转Spring Boot 自定义配置.导入XML配置与外部化配置       在这里我会全面介绍在Spring Boot里面如何自定义配置,更改Spring Boot默认的配置,以及介绍各配置的优先 ...

  5. SpringBoot Logback无法获取配置中心属性

    SpringBoot Logback无法获取配置中心属性 前言 最近在做项目中,需要把项目中的日志信息通过RabbitMQ将规定格式的消息发送到消息队列中,然后ELK系统通过消息队列拿日志并且保存起来 ...

  6. 在web.config配置中添加xml内容

    在web.config 中添加需要的内容时, 就是在<configuration>节点内添加一个新的<configSections>元素, 在configSections元素中 ...

  7. (转)maven配置之pom.xml配置

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  8. ubuntu 开机显示错误:无法应用原保存的显示器配置

    无法应用原保存的显示器配置CRTC 63:尝试 800x600@60Hz 模式输出在 1366x768@60Hz (通过 0)CRTC 63:尝试 2560x1600@60Hz 模式输出在 1366x ...

  9. JavaWeb学习之Servlet(四)----ServletConfig获取配置信息、ServletContext的应用

    [声明] 欢迎转载,但请保留文章原始出处→_→ 文章来源:http://www.cnblogs.com/smyhvae/p/4140877.html [正文] 一.ServletConfig:代表当前 ...

随机推荐

  1. jmeter 使用问题

    问题1:导入脚本失败,提示 解决:没有安装JMemter plugins manager插件,具体安装参考http://www.cnblogs.com/cxx1/p/7883820.html,第二步.

  2. Go语言基础之流程控制

    Go语言基础之流程控制 流程控制是每种编程语言控制逻辑走向和执行次序的重要部分,流程控制可以说是一门语言的“经脉”. Go语言中最常用额流程控制有if和for,而switch和goto主要是为了简化代 ...

  3. Solve Error: node postinstall sh: node: command not found

    When install the yeoman using the following command: npm install -g yo You might have the following ...

  4. laravel之模型操作

    首先在App下创建模型,一个模型对应着一个表: 2.创建好模型之后,使用控制器来操作模型 先使用模型 创建方法来使用模型(记得要添加路由)

  5. 在循环中如何取input的值和增加点击事件

    {volist name="dianpu" id="dianpu"} <input style="border: none;" rea ...

  6. sqlserver 表循环-游标、表变量、临时表

    SQL Server遍历表的几种方法 阅读目录 使用游标 使用表变量 使用临时表 在数据库开发过程中,我们经常会碰到要遍历数据表的情形,一提到遍历表,我们第一印象可能就想到使用游标,使用游标虽然直观易 ...

  7. 使用sessionStorage进行数据存值

    <!DOCTYPE html> <head> <meta charset="UTF-8" /> <meta name="view ...

  8. 精心调制的Bash主题分享

    第一个是米色背景, 一样遵守蓝色为目录的习惯, 字体为浅灰色,代码和终端看起来相对比较清晰 第二个则是 深海蓝的背景风格,字体都选择饱和度较高的颜色,如下图 终端 配置方法,这里以 mintty 也就 ...

  9. 常用的 jQuery 事件

    $(document).ready(): $(document).ready() 方法允许我们在文档完全加载完后执行函数. click(): click() 方法是当按钮点击事件被触发时会调用一个函数 ...

  10. 转载,matla滤波函数

    转载地址http://blog.sina.com.cn/s/blog_6163bdeb0102e1dj.html 滤波器设计是一个创建满足指定滤波要求的滤波器参数的过程.滤波器的实现包括滤波器结构的选 ...