zoukankan      html  css  js  c++  java
  • 保存配置,获取配置,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:LayoutStyleStandingOrderConfig.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:LayoutStyleStandingOrderConfig.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;
    }
    }
    }
    }

  • 相关阅读:
    GDC快讯,腾讯CMatrix布局云游戏B端领域
    如何测试小程序? 腾讯智慧零售保障优衣库小程序体验优化
    一分钟读懂兼容报告:测试过程视频复现,问题定位很轻松
    一到秒杀就瘫痪?压测大师保你后台稳健
    how2j-springcloud-摘抄
    问题1
    springcloud---how2java--记录零碎的信息
    how2java-springcloud-demo
    oracle 查两个日期之间数据有多少条
    非官网渠道下单导致的错误
  • 原文地址:https://www.cnblogs.com/mapstar/p/10774581.html
Copyright © 2011-2022 走看看