首页 > 代码库 > XML
XML
public int num = 0; /// <summary> /// 关闭背光 /// </summary> public void CloseOtherBackLight() { string path = GFun.GetDataDir() + "CloseOtherBackLight.xml"; bool isok = true; if (File.Exists(path)) isok = true; else isok = false; if (num == 0) { isok = false; } if (isok == false) { FHost.CloseBackLight(0xFF, false); XmlDocument CloseBackLight = new XmlDocument(); XmlNode node = CloseBackLight.CreateElement("CloseOtherBackLight"); CloseBackLight.AppendChild(node); List<int> other = new List<int>(); string cmdStr = "Select EtnCode from Patient"; using (SqlCeCommand cmd = new SqlCeCommand(cmdStr, DbOprt.Conn)) { using (SqlCeDataReader dr = cmd.ExecuteReader()) { string txt = string.Empty; while (dr.Read()) { string BedNo = Convert.ToString(dr["EtnCode"]); try { other.Add(Convert.ToInt16(BedNo)); } catch (System.Exception ex) { Excp.WriteExcp(ex); } } } } for (int i = 0; i < other.Count; i++) { XmlNode bedno = CloseBackLight.CreateNode(XmlNodeType.Element, "BedNo", null); bedno.InnerText = other[i].ToString(); node.AppendChild(bedno); } CloseBackLight.Save(path); foreach (int item in other) { FHost.OpenBackLight((short)item); } } else { XmlDocument BedNo = new XmlDocument(); BedNo.Load(path); XmlNode root = BedNo.DocumentElement; List<int> XMLBedNo = new List<int>(); foreach (XmlNode xmlNode in root.ChildNodes) { XMLBedNo.Add(Convert.ToInt16(xmlNode.InnerText)); } List<int> SQLBedNo = new List<int>(); string cmdStr = "Select EtnCode from Patient"; using (SqlCeCommand cmd = new SqlCeCommand(cmdStr, DbOprt.Conn)) { using (SqlCeDataReader dr = cmd.ExecuteReader()) { string txt = string.Empty; while (dr.Read()) { string BedID = Convert.ToString(dr["EtnCode"]); try { SQLBedNo.Add(Convert.ToInt16(BedID)); } catch (System.Exception ex) { Excp.WriteExcp(ex); } } } } List<int> Open = new List<int>(); List<int> Close = new List<int>(); for (int i = 0; i < XMLBedNo.Count; i++) { if (!SQLBedNo.Contains(XMLBedNo[i])) { Close.Add(XMLBedNo[i]); } } for (int i = 0; i < SQLBedNo.Count; i++) { if (!XMLBedNo.Contains(SQLBedNo[i])) { Open.Add(SQLBedNo[i]); } } foreach (var item in Open) { FHost.OpenBackLight((short)item); } foreach (var item in Close) { FHost.CloseBackLight((short)item, false); } File.Delete(path); XmlDocument CloseBackLight = new XmlDocument(); XmlNode node = CloseBackLight.CreateElement("CloseOtherBackLight"); CloseBackLight.AppendChild(node); for (int i = 0; i < SQLBedNo.Count; i++) { XmlNode bedno = CloseBackLight.CreateNode(XmlNodeType.Element, "BedNo", null); bedno.InnerText = SQLBedNo[i].ToString(); node.AppendChild(bedno); } CloseBackLight.Save(path); } num++; }
XML
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。