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. 小甲鱼Python第十七讲课后习题

    笔记: 1.分清楚形参和实参 2.函数文档:是函数的一部分,于解释不同,使用help(函数名)或者 函数名__doc__可以查看到 3.关键字参数(在一个函数的参数较多的时候作用比较明显): 给参数的 ...

  2. webpack3_脚手架

    webpack    记得 --save-dev 装入开发依赖 更新迭代快,需要有根据报错解决问题的能力,来融会贯通这个工具 这里的是 webpack3,其实已经到了 webpack4 了 采用了 w ...

  3. Python练手例子(7)

    37.对10个数进行排序. 程序分析:可以利用选择法,即从后9个比较过程中,选择一个最小的与第一个元素交换,下次类推,即用第二个元素与后8个进行比较,并进行交换. #python 3.7 if __n ...

  4. linux for循环 fork() 产生子进程

    #include <sys/types.h> #include <unistd.h> #include<stdio.h> int main() { for(int ...

  5. Android自定义控件之日历控件

      标签: android 控件 日历 应用 需求 2015年09月26日 22:21:54 25062人阅读 评论(109) 收藏 举报 分类: Android自定义控件系列(7) 版权声明:转载注 ...

  6. 壁虎书6 Decision Trees

    Decision Trees are versatile Machine Learning algorithms that can perform both classification and re ...

  7. MTQQ 物联网

    这个是学校的SRP项目.去年12月做了大概3周. 直接摘个人总结报告如下: 在本次“学生研究计划”项目,研究课题是“基于JAVA的智能家居公众号”.根据课题要求之一:以微信作为媒介,实现智能设备的远程 ...

  8. Python 笔记 v1 - json和字符串互转

    字符串转为json对象并取值 >>> 使用了Json包中的loads()方法和dumps()方法 string =" { "status": " ...

  9. 2019-04-25t16:19:49 转成正常的年月日

    1.首先得到的值时2019-04-25t16:19:49 2.想转成2019-04-25 3. var d = new Date(2019-04-25t16:19:49); var yy = d.ge ...

  10. Linux - ansible 安装

    # 安装依赖 yum install rpm-build python2-devel sshpass PyYAML python-jinja2 python-paramiko python-six p ...