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;
}
}
}
}