示例#1
0
        private ArrayList myGetPrintPage(string sql)
        {
            if (this.ExecQuery(sql) == -1)
            {
                return(null);
            }
            ArrayList al = new ArrayList();

            while (this.Reader.Read())
            {
                Neusoft.HISFC.Models.EPR.EPRPrintPage printPage = new Neusoft.HISFC.Models.EPR.EPRPrintPage();
                printPage.ID   = this.Reader[0].ToString();
                printPage.Page = int.Parse(this.Reader[1].ToString());
                printPage.Name = this.Reader[2].ToString();
                printPage.Memo = this.Reader[3].ToString();
                Neusoft.FrameWork.Xml.XML xml = new Neusoft.FrameWork.Xml.XML();
                System.Xml.XmlDocument    doc = new XmlDocument();
                printPage.SortedControlsXml = this.Reader[4].ToString();
                printPage.BeginDate         = DateTime.Parse(this.Reader[5].ToString());
                printPage.EndDate           = DateTime.Parse(this.Reader[6].ToString());
                printPage.StartRow          = int.Parse(this.Reader[7].ToString());
                al.Add(printPage);
            }
            this.Reader.Close();
            return(al);
        }
示例#2
0
        /// <summary>
        /// 保存查询条件
        /// </summary>
        private void SaveQueryCondition()
        {
            Neusoft.FrameWork.Xml.XML xml = new Neusoft.FrameWork.Xml.XML();
            XmlDocument doc  = new XmlDocument();
            XmlElement  root = xml.CreateRootElement(doc, "SETTING", "1.0");

            for (int i = 0; i < this._CurConditionCount; i++)
            {
                //添加查询条件节点
                ucCondition condition    = (ucCondition)this.pnlConditionGroup.Controls[i];
                XmlElement  xmlCondition = xml.AddXmlNode(doc, root, "Condition", "");
                xml.AddNodeAttibute(xmlCondition, "Tree", condition.Field);
                xml.AddNodeAttibute(xmlCondition, "CompareOperator", condition.CompareOperator);
                xml.AddNodeAttibute(xmlCondition, "CompareContext1", condition.CompareContext1);
                xml.AddNodeAttibute(xmlCondition, "RelationOperator", condition.RelationOperator);
                xml.AddNodeAttibute(xmlCondition, "CompareContext2", condition.CompareContext2);
            }
            if (Neusoft.HISFC.BizProcess.Factory.Function.IntegrateManager.SetQueryCondition(this.FindForm().Name, doc.OuterXml, false) == -1)
            {
                MessageBox.Show(Neusoft.HISFC.BizProcess.Factory.Function.IntegrateManager.Err);
            }
//			else
//			{
//				MessageBox.Show("条件模板保存成功!");
//			}
//
//			doc.Save(Application.StartupPath + "\\" + this._QueryConditionFileName);
        }
示例#3
0
        public static void SaveColumnProperty(FarPoint.Win.Spread.SheetView fv, string FileName)
        {
            string path;

            try
            {
                path = FileName.Substring(0, FileName.LastIndexOf(@"\"));
                if (System.IO.Directory.Exists(path) == false)
                {
                    System.IO.Directory.CreateDirectory(path);
                }
            }
            catch { }

            Neusoft.FrameWork.Xml.XML myXml = new Neusoft.FrameWork.Xml.XML();
            XmlDocument doc = new XmlDocument();
            XmlElement  root;

            root = myXml.CreateRootElement(doc, "Setting", "1.0");
            for (int i = 0; i < fv.Columns.Count; i++)
            {
                XmlElement e = myXml.AddXmlNode(doc, root, "Column", "");
                myXml.AddNodeAttibute(e, "displayname", fv.Columns[i].Label);
                myXml.AddNodeAttibute(e, "width", fv.Columns[i].Width.ToString());
                myXml.AddNodeAttibute(e, "visible", fv.Columns[i].Visible.ToString());

                if (fv.Columns[i].Locked)
                {
                    myXml.AddNodeAttibute(e, "enable", "false");
                }
                else
                {
                    myXml.AddNodeAttibute(e, "enable", "true");
                }
                if (fv.Columns[i].CellType != null)
                {
                    myXml.AddNodeAttibute(e, "type", fv.Columns[i].CellType.ToString());
                }
                else
                {
                    myXml.AddNodeAttibute(e, "type", "");
                }
                myXml.AddNodeAttibute(e, "sort", fv.Columns[i].AllowAutoSort.ToString());
                try
                {
                    myXml.AddNodeAttibute(e, "tag", fv.Columns[i].Tag.ToString());
                }
                catch { }
            }
            try
            {
                StreamWriter sr        = new StreamWriter(FileName, false, System.Text.Encoding.Default);
                string       cleandown = doc.OuterXml;
                sr.Write(cleandown);
                sr.Close();
                //doc.Save(FileName);
            }
            catch (Exception ex) { System.Windows.Forms.MessageBox.Show("无法保存!" + ex.Message); }
        }
        /// <summary>
        /// 创建和更新配置文件
        /// </summary>
        /// <param name="filePath">配置文件路径</param>
        /// <returns>false创建失败 true创建成功</returns>
        public bool CreateXml(string filePath)
        {
            Neusoft.FrameWork.Xml.XML myXml = new Neusoft.FrameWork.Xml.XML();
            XmlDocument doc = new XmlDocument();
            XmlElement  root;

            root = myXml.CreateRootElement(doc, "Setting", "1.0");
            string     tempWindowName = this.fpSpead1_Sheet1.Cells[0, 5].Text;
            string     currWindowName = string.Empty;
            XmlElement secondNode     = null;

            for (int i = 0; i < this.fpSpead1_Sheet1.RowCount; i++)
            {
                currWindowName = this.fpSpead1_Sheet1.Cells[i, 5].Text;
                if (i == 0)
                {
                    secondNode = myXml.AddXmlNode(doc, root, tempWindowName, string.Empty);
                }
                else if (tempWindowName != currWindowName)
                {
                    secondNode = myXml.AddXmlNode(doc, root, currWindowName, string.Empty);
                }

                XmlElement e = myXml.AddXmlNode(doc, secondNode, "Column", string.Empty);
                myXml.AddNodeAttibute(e, "opCode", this.fpSpead1_Sheet1.Cells[i, 0].Text);
                myXml.AddNodeAttibute(e, "opName", this.fpSpead1_Sheet1.Cells[i, 1].Text);
                myXml.AddNodeAttibute(e, "opKey", this.fpSpead1_Sheet1.Cells[i, 2].Text);
                string opKeyHash = string.Empty, cuKeyHash = string.Empty;
                if (this.fpSpead1_Sheet1.Cells[i, 2].Text != string.Empty)
                {
                    opKeyHash = this.fpSpead1_Sheet1.Cells[i, 2].Tag.ToString();
                }
                myXml.AddNodeAttibute(e, "opKeyHash", opKeyHash);
                myXml.AddNodeAttibute(e, "cuKey", this.fpSpead1_Sheet1.Cells[i, 3].Text);
                if (this.fpSpead1_Sheet1.Cells[i, 3].Text != string.Empty)
                {
                    cuKeyHash = this.fpSpead1_Sheet1.Cells[i, 3].Tag.ToString();
                }
                myXml.AddNodeAttibute(e, "cuKeyHash", cuKeyHash);
                myXml.AddNodeAttibute(e, "hash", this.fpSpead1_Sheet1.Cells[i, 4].Text);

                tempWindowName = currWindowName;
            }
            try
            {
                StreamWriter sr        = new StreamWriter(filePath, false, System.Text.Encoding.Default);
                string       cleandown = doc.OuterXml;
                sr.Write(cleandown);
                sr.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("无法保存!" + ex.Message);
            }

            return(true);
        }
示例#5
0
        /// <summary>
        /// 获得配置
        /// </summary>
        /// <param name="FileName">HisProfile.xml文件名</param>
        /// <returns>0正确 -1错误</returns>
        public int GetSetting(string FileName)
        {
            XmlDocument doc;

            Neusoft.FrameWork.Xml.XML manageXml = new Neusoft.FrameWork.Xml.XML();
            doc = manageXml.LoadXml(FileName);
            if (doc == null)
            {
                this.Err     = "无法打开文件!" + manageXml.Err;
                this.ErrCode = "-1";
                return(-1);
            }
            XmlNodeList nodes;
            XmlNode     node;

            try
            {
                //数据库设置
                node = doc.SelectSingleNode(@"/设置/数据库设置");
                this.objSetting.ConnectionString = node.Attributes[0].Value;
                //ftp设置
                node = doc.SelectSingleNode(@"/设置/设置");
                objSetting.SQLByXMl = Neusoft.FrameWork.Function.NConvert.ToBoolean(node.Attributes["sql开关"].Value);

                //web service设置
                nodes = doc.SelectNodes(@"/设置/WebService设置");
                foreach (XmlNode mynode in nodes)
                {
                    Neusoft.FrameWork.Models.NeuObject obj = new Neusoft.FrameWork.Models.NeuObject();
                    obj.ID   = mynode.Attributes[0].Value;
                    obj.Name = mynode.Attributes[1].Value;
                    try
                    {
                        obj.Memo = node.Attributes[2].Value;
                    }
                    catch {}
                    this.objSetting.alWebservice.Add(obj);
                }
            }
            catch
            {
                return(-1);
            }
            return(0);
        }
示例#6
0
        protected string _SaveCondition()
        {
            Neusoft.FrameWork.Xml.XML myXml = new Neusoft.FrameWork.Xml.XML();
            XmlDocument doc   = new XmlDocument();
            XmlElement  eRoot = myXml.CreateRootElement(doc, "setting");

            for (int i = 0; i < 20; i++)
            {
                XmlElement eRow = null;
                eRow = myXml.AddXmlNode(doc, eRoot, "row", "");
                for (int j = 0; j < 4; j++)
                {
                    Control c = this.getControl(j, i) as Control;
                    if (c == null)
                    {
                        break;
                    }
                    myXml.AddXmlNode(doc, eRow, "column", c.Text);
                }
            }
            return(doc.OuterXml);
        }
示例#7
0
        /// <summary>
        /// 加载xml配置文件
        /// </summary>
        /// <returns></returns>
        private int LoadXml()
        {
            Neusoft.FrameWork.Xml.XML xml = new Neusoft.FrameWork.Xml.XML();

            System.Xml.XmlDocument doc = null;
            try
            {
                doc = xml.LoadXml(this.strFileName);
            }
            catch
            {
                return(-1);
            }
            if (doc == null)
            {
                return(-1);
            }
            System.Xml.XmlNodeList nodes = doc.SelectNodes("/Setting/Panel");
            System.Xml.XmlNodeList ControlNodes;
            foreach (System.Xml.XmlNode node in nodes)
            {
                this.AddSplitButton();
                ControlNodes = node.SelectNodes("Control");
                foreach (System.Xml.XmlNode ControlNode in ControlNodes)
                {
                    try
                    {
                        this.AddButton(ControlNode.Attributes["Text"].Value, int.Parse(ControlNode.Attributes["Special"].Value), ControlNode.Attributes["Tag"].Value);
                    }
                    catch {}
                }
                this.AddSplitButton();
            }
            this.btnLastButton.Dock = DockStyle.Bottom;
            return(0);
        }
示例#8
0
        /// <summary>
        /// 判断程序版本是否为最新版本
        /// </summary>
        /// <returns>新版本返回1 旧版本返回-1</returns>
        public static int JudgeVersionNumber()
        {
            Neusoft.FrameWork.Xml.XML xmlManager = new Neusoft.FrameWork.Xml.XML();
            System.Xml.XmlDocument    doc        = new System.Xml.XmlDocument();
            System.Xml.XmlNode        root;

            #region 获取本地配置文件内HIS系统版本

            string hosVersionNumber = "";
            //string hosFilePath = Application.StartupPath + "\\HIS.config";
            //if (System.IO.File.Exists(hosFilePath))			//存在配置文件
            //{
            //doc.Load(hosFilePath);
            //root = doc.SelectSingleNode("//VersionNumber");
            hosVersionNumber = System.Configuration.ConfigurationManager.AppSettings["VersionNumber"];

            if (string.IsNullOrEmpty(hosVersionNumber))
            {
                MessageBox.Show("读取本地XML配置文件时 未找到版本号结点");
                return(-1);
            }
            //hosVersionNumber = obj.ToString(); //root.Attributes[0].Value.ToString();
            //}
            //else
            //{
            //    #region 自动建立

            //    System.Xml.XmlDocument newDoc = new System.Xml.XmlDocument();
            //    System.Xml.XmlDeclaration declarationNode = newDoc.CreateXmlDeclaration("1.0", "GB2312", null);
            //    newDoc.AppendChild(declarationNode);

            //    System.Xml.XmlElement configNode = newDoc.CreateElement("Config");
            //    configNode.SetAttribute("Version", "4.5");
            //    newDoc.AppendChild(configNode);

            //    System.Xml.XmlElement versionNumNode = newDoc.CreateElement("VersionNumber");
            //    versionNumNode.SetAttribute("Number", "20070101");
            //    configNode.AppendChild(versionNumNode);

            //    newDoc.Save(Application.StartupPath + "\\HIS.config");

            //    #endregion

            //    return 1;
            //}
            Function.VersionNumber = hosVersionNumber;
            #endregion

            //读取控制参数 如果未找到对应控制参数或参数为0 不进行版本校验
            Neusoft.HISFC.BizLogic.Manager.Controler controlerManagment = new Neusoft.HISFC.BizLogic.Manager.Controler();
            string control = controlerManagment.QueryControlerInfo(Neusoft.HISFC.BizProcess.Integrate.SysConst.Use_Judge_VersionNum);
            if (control == null || control == "0" || control == "-1")
            {
                return(1);
            }

            #region 获取服务器版本号

            string serverVersionNumber = "";
            Neusoft.FrameWork.Management.DataBaseManger dataBase = new Neusoft.FrameWork.Management.DataBaseManger();
            dataBase.ExecQuery(Function.versionSelect);
            try
            {
                if (dataBase.Reader.Read())
                {
                    serverVersionNumber = dataBase.Reader[0].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                dataBase.Reader.Close();
            }
            #endregion

            if (hosVersionNumber != serverVersionNumber)
            {
                MessageBox.Show(Neusoft.FrameWork.Management.Language.Msg("您当前所用的信息管理系统非最新版本 请重启系统进行升级或与信息科联系"));
                return(-1);
            }

            return(1);
        }
示例#9
0
        /// <summary>
        /// 获得连接串
        /// </summary>
        /// <returns></returns>
        public string GetConnectString()
        {
            string dbInstance   = "";
            string DataBaseName = "";
            string userName     = "";
            string password     = "";
            string connString   = "";

            if (!System.IO.File.Exists(profileName))
            {
                Neusoft.FrameWork.Xml.XML myXml = new Neusoft.FrameWork.Xml.XML();
                XmlDocument doc = new XmlDocument();
                XmlElement  root;
                root = myXml.CreateRootElement(doc, "SqlServerConnectForHis4.0", "1.0");

                XmlElement dbName = myXml.AddXmlNode(doc, root, "设置", "");

                myXml.AddNodeAttibute(dbName, "数据库实例名", "");
                myXml.AddNodeAttibute(dbName, "数据库名", "");
                myXml.AddNodeAttibute(dbName, "用户名", "");
                myXml.AddNodeAttibute(dbName, "密码", "");

                try
                {
                    StreamWriter sr        = new StreamWriter(profileName, false, System.Text.Encoding.Default);
                    string       cleandown = doc.OuterXml;
                    sr.Write(cleandown);
                    sr.Close();
                }
                catch (Exception ex)
                {
                    this.Err     = "创建医保连接服务配置出错!" + ex.Message;
                    this.ErrCode = "-1";
                    this.WriteErr();
                    return("");
                }

                return("");
            }
            else
            {
                XmlDocument doc = new XmlDocument();

                try
                {
                    StreamReader sr        = new StreamReader(profileName, System.Text.Encoding.Default);
                    string       cleandown = sr.ReadToEnd();
                    doc.LoadXml(cleandown);
                    sr.Close();
                }
                catch { return(""); }

                XmlNode node = doc.SelectSingleNode("//设置");

                try
                {
                    dbInstance   = node.Attributes["数据库实例名"].Value.ToString();
                    DataBaseName = node.Attributes["数据库名"].Value.ToString();
                    userName     = node.Attributes["用户名"].Value.ToString();
                    password     = node.Attributes["密码"].Value.ToString();
                }
                catch { return(""); }

                connString = "packet size=4096;user id=" + userName + ";data source=" + dbInstance + ";pers" +
                             "ist security info=True;initial catalog=" + DataBaseName + ";password=" + password;
            }

            return(connString);
        }
示例#10
0
        /// <summary>
        /// 读取xml接口文件
        /// <br>读取配置文件 HIS_SETTING.XML,LIS_SETTING.XML,PACS_SETTING.XML</br>
        /// </summary>
        /// <param name="xmlFileName"></param>
        /// <returns></returns>
        public int ReadXML(string xmlFileName)
        {
            //显示进度
            this.ProgressBarValue = 0;
            this.ProgressBarText  = "读取设置信息...";

            System.Xml.XmlDocument           doc;
            System.Xml.XmlNodeList           nodes;
            Neusoft.FrameWork.Models.NeuInfo info = new Neusoft.FrameWork.Models.NeuInfo();

            Neusoft.FrameWork.Xml.XML manageXml = new Neusoft.FrameWork.Xml.XML();
            doc = manageXml.LoadXml(xmlFileName);
            if (doc == null)
            {
                this.Err     = "无法打开文件!" + xmlFileName + manageXml.Err;
                this.ErrCode = "-1";
                this.WriteErr();
                return(-1);
            }
            nodes = doc.SelectNodes("设置/变量");
            try
            {
                foreach (System.Xml.XmlNode node in nodes)
                {
                    this.ProgressBarValue = this.ProgressBarValue + (100 / nodes.Count);

                    info      = new Neusoft.FrameWork.Models.NeuInfo();
                    info.Name = node.Attributes["显示名称"].Value;
                    info.ID   = node.Attributes["变量名"].Value;
                    switch (node.Attributes["类型"].Value.ToString())
                    {
                    case "参数":
                        info.type = Neusoft.FrameWork.Models.NeuInfo.infoType.Param;
                        break;

                    case "全局变量":
                        info.type = Neusoft.FrameWork.Models.NeuInfo.infoType.Global;
                        break;

                    case "临时变量":
                        info.type = Neusoft.FrameWork.Models.NeuInfo.infoType.Temp;
                        break;

                    case "常量":
                        info.type = Neusoft.FrameWork.Models.NeuInfo.infoType.Const;
                        break;

                    case "患者列表":
                        info.type = Neusoft.FrameWork.Models.NeuInfo.infoType.PatientList;
                        break;

                    case "科室列表":
                        info.type = Neusoft.FrameWork.Models.NeuInfo.infoType.inDeptList;
                        break;

                    case "关联变量":
                        info.type = Neusoft.FrameWork.Models.NeuInfo.infoType.Associate;
                        break;

                    case "事件":
                        info.type = Neusoft.FrameWork.Models.NeuInfo.infoType.Event;
                        break;

                    case "其它列表":
                        info.type = Neusoft.FrameWork.Models.NeuInfo.infoType.List;
                        break;

                    default:
                        info.type = (Neusoft.FrameWork.Models.NeuInfo.infoType) int.Parse(node.Attributes["类型"].Value.ToString());
                        break;
                    }
                    info.Sql = node.ChildNodes[0].InnerText;
                    try
                    {
                        info.showType = node.ChildNodes[2].InnerText;
                    }
                    catch {}
                    try
                    {
                        info.UpdateSql = node.ChildNodes[1].InnerText;
                    }
                    catch {}
                    info.Memo = info.Sql;                    //存储以前的sql

                    alInfo.Add(info);
                }
                this.ProgressBarValue = 100;
                return(0);
            }
            catch (Exception ex) {
                this.ProgressBarValue = 0;
                Err = ex.Message;
                return(-1);
            }
        }
示例#11
0
        /// <summary>
        /// 从对象生成Xml
        /// </summary>
        /// <param name="setting"></param>
        public string GetXmlFromNurseSheetSetting(Neusoft.HISFC.Models.EPR.NurseSheetSetting setting)
        {
            System.Xml.XmlDocument    doc = new System.Xml.XmlDocument();
            Neusoft.FrameWork.Xml.XML xml = new Neusoft.FrameWork.Xml.XML();
            XmlElement root = xml.CreateRootElement(doc, "Setting");

            ////Help
            //XmlElement elmHelp = xml.AddXmlNode(doc, root, "Help", "");
            //xml.AddNodeAttibute(elmHelp, "IsUseHelp", setting.IsUseHelp.ToString());
            //if (setting.Help != null && setting.Help.Length > 0)
            //{
            //    xml.AddNodeAttibute(elmHelp, "Text", string.Join("\n", setting.Help));
            //}

            //Print
            System.Xml.XmlElement elmPrint = xml.AddXmlNode(doc, root, "Print", "");
            //xml.AddNodeAttibute(elmPrint, "PrintType", setting.PrintType.ToString());
            //xml.AddNodeAttibute(elmPrint, "Page", setting.Page);
            //xml.AddNodeAttibute(elmPrint, "LandScape", setting.LandSacpe.ToString());
            //xml.AddNodeAttibute(elmPrint, "StartX", setting.StartX.ToString());
            //xml.AddNodeAttibute(elmPrint, "StartY", setting.StartY.ToString());
            //xml.AddNodeAttibute(elmPrint, "RowHeight", setting.RowHeight.ToString());
            //xml.AddNodeAttibute(elmPrint, "RowCount1", setting.RowCount1.ToString());
            //xml.AddNodeAttibute(elmPrint, "RowCount2", setting.RowCount2.ToString());
            //xml.AddNodeAttibute(elmPrint, "CaptionRowCount", setting.CaptionRowCount.ToString());
            //if (setting.BackImage != null)
            //{
            //    string fileName = Neusoft.NFC.Interface.Classes.Function.GetTempFileName() + ".bmp";
            //    setting.BackImage.Save(fileName);
            //    System.IO.FileStream stream = new System.IO.FileStream(fileName, System.IO.FileMode.Open);
            //    byte[] byteimg = new byte[stream.Length];

            //    stream.Read(byteimg, 0, (int)stream.Length);
            //    stream.Close();
            //    System.Text.UnicodeEncoding encoding = new UnicodeEncoding();
            //    string strImg = Convert.ToBase64String(byteimg); // encoding.GetString(byteimg);
            //    xml.AddXmlCDataNode(doc, elmPrint, "BackGroundImage", strImg);
            //}
            System.Xml.XmlElement elmColumns = xml.AddXmlNode(doc, root, "Columns", "");
            //Columns
            if (setting.Columns != null && setting.Columns.Length > 0)
            {
                for (int i = 0; i < setting.Columns.Length; i++)
                {
                    System.Xml.XmlElement elmColumn = xml.AddXmlNode(doc, elmColumns, "Column", "");
                    xml.AddNodeAttibute(elmColumn, "Caption", setting.Columns[i].Caption);
                    xml.AddNodeAttibute(elmColumn, "Style", setting.Columns[i].Style.ToString());
                    //xml.AddNodeAttibute(elmColumn, "WordCount", setting.Columns[i].WordCount.ToString());
                    xml.AddNodeAttibute(elmColumn, "IsDescription", setting.Columns[i].IsDescription.ToString());
                    xml.AddNodeAttibute(elmColumn, "IsUseHelp", setting.Columns[i].IsUseHelp.ToString());
                    if (setting.Columns[i].Help != null)
                    {
                        xml.AddNodeAttibute(elmColumn, "Help", string.Join("\n", setting.Columns[i].Help));
                    }
                    xml.AddNodeAttibute(elmColumn, "Width", setting.Columns[i].Width.ToString());
                    xml.AddNodeAttibute(elmColumn, "Left", setting.Columns[i].Left.ToString());

                    if (setting.Columns[i].Items != null && setting.Columns[i].Items.Length > 0)
                    {
                        for (int j = 0; j < setting.Columns[i].Items.Length; j++)
                        {
                            System.Xml.XmlElement elemItem = xml.AddXmlNode(doc, elmColumn, "Item", setting.Columns[i].Items[j]);
                        }
                    }
                }
            }
            return(doc.OuterXml);
        }
示例#12
0
        /// <summary>
        /// 保存操作员最后一次选择的操作类型、目标单位写入配置文件
        /// </summary>
        /// <returns>成功返回1 失败返回-1</returns>
        public int SavePriv()
        {
            try
            {
                if (this.filePath == "")
                {
                    return(1);
                }

                Neusoft.FrameWork.Xml.XML myXml = new Neusoft.FrameWork.Xml.XML();
                System.Xml.XmlDocument    doc   = new System.Xml.XmlDocument();
                System.Xml.XmlElement     root;
                if (System.IO.File.Exists(Application.StartupPath + this.filePath))
                {               //文件已存在
                    doc.Load(Application.StartupPath + this.filePath);
                    root = (System.Xml.XmlElement)doc.SelectSingleNode("Setting");
                }
                else
                {                                                                                       //文件不存在
                    //设置根结点
                    root = myXml.CreateRootElement(doc, "Setting", "1.0");
                }

                System.Xml.XmlNode deptNode = doc.SelectSingleNode("/Setting/DeptInfo[@DeptID = '" + this.deptInfo.ID + "']");
                if (deptNode != null)           //存在科室节点
                {
                    System.Xml.XmlNode operNode = doc.SelectSingleNode("/Setting/DeptInfo[@DeptID = '" + this.deptInfo.ID + "']/OperInfo[@OperID = '" + this.operInfo.ID + "']");
                    if (operNode != null)       //存在操作员节点
                    {
                        //保存入库类型
                        operNode.ChildNodes[0].Attributes["ID"].Value   = this.PrivType.ID;
                        operNode.ChildNodes[0].Attributes["Name"].Value = this.privType.Name;
                        //保存目标科室
                        operNode.ChildNodes[1].Attributes["ID"].Value   = this.targetDept.ID;
                        operNode.ChildNodes[1].Attributes["Name"].Value = this.targetDept.Name;
                        //保存领送人
                        operNode.ChildNodes[2].Attributes["ID"].Value   = this.targetPerson.ID;
                        operNode.ChildNodes[2].Attributes["Name"].Value = this.targetPerson.Name;
                    }
                    else                       //不存在操作员节点
                    {
                        #region 添加操作员节点

                        //在该科室内未找到该操作员历史信息 添加该操作员信息
                        System.Xml.XmlElement xmlNewOper = doc.CreateElement("OperInfo");
                        xmlNewOper.SetAttribute("OperID", this.operInfo.ID);
                        //添加入库类型子节点 并赋值
                        System.Xml.XmlElement xmlPriv = doc.CreateElement("PrivType");
                        xmlPriv.SetAttribute("ID", this.privType.ID);
                        xmlPriv.SetAttribute("Name", this.privType.Name);
                        xmlNewOper.AppendChild(xmlPriv);
                        //添加供货单位子节点 并赋值
                        System.Xml.XmlElement xmlOffer = doc.CreateElement("TargetDept");
                        xmlOffer.SetAttribute("ID", this.targetDept.ID);
                        xmlOffer.SetAttribute("Name", this.targetDept.Name);
                        xmlNewOper.AppendChild(xmlOffer);
                        //添加领送人子节点 并赋值
                        System.Xml.XmlElement xmlPerson = doc.CreateElement("TargetPerson");
                        xmlPerson.SetAttribute("ID", this.targetPerson.ID);
                        xmlPerson.SetAttribute("Name", this.targetPerson.Name);
                        xmlNewOper.AppendChild(xmlPerson);

                        //设置关联
                        ((System.Xml.XmlElement)deptNode).AppendChild(xmlNewOper);

                        #endregion
                    }
                }
                else
                {
                    #region 添加科室节点

                    //该科室未找到 添加该科室、该操作员的配置信息 本次入库类型 供货单位
                    System.Xml.XmlElement xmlNewDept = doc.CreateElement("DeptInfo");
                    xmlNewDept.SetAttribute("DeptID", this.deptInfo.ID);

                    //添加该操作员信息
                    System.Xml.XmlElement xmlNewOper1 = doc.CreateElement("OperInfo");
                    xmlNewOper1.SetAttribute("OperID", this.operInfo.ID);
                    //添加入库类型子节点 并赋值
                    System.Xml.XmlElement xmlPriv1 = doc.CreateElement("PrivType");
                    xmlPriv1.SetAttribute("ID", this.privType.ID);
                    xmlPriv1.SetAttribute("Name", this.privType.Name);
                    //添加供货单位子节点 并赋值
                    System.Xml.XmlElement xmlOffer1 = doc.CreateElement("TargetDept");
                    xmlOffer1.SetAttribute("ID", this.targetDept.ID);
                    xmlOffer1.SetAttribute("Name", this.targetDept.Name);
                    //添加领送人子节点 并赋值
                    System.Xml.XmlElement xmlPerson = doc.CreateElement("TargetPerson");
                    xmlPerson.SetAttribute("ID", this.targetPerson.ID);
                    xmlPerson.SetAttribute("Name", this.targetPerson.Name);

                    xmlNewOper1.AppendChild(xmlPriv1);
                    xmlNewOper1.AppendChild(xmlOffer1);
                    xmlNewOper1.AppendChild(xmlPerson);

                    xmlNewDept.AppendChild(xmlNewOper1);

                    root.AppendChild(xmlNewDept);

                    #endregion
                }

                doc.Save(Application.StartupPath + this.filePath);

                return(1);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(-1);
            }
        }