public int Initial(ManagerForm managerform,
            bool bCreateMode,
            string strXml,
            out string strError)
        {
            strError = "";

            this.ManagerForm = managerform;
            this.CreateMode = bCreateMode;

            this.Xml = strXml;

            // 填充窗口内容
            if (String.IsNullOrEmpty(strXml) == false)
            {
                XmlDocument dom = new XmlDocument();
                try
                {
                    dom.LoadXml(strXml);
                }
                catch (Exception ex)
                {
                    strError = "XML装载到DOM时出错: " + ex.Message;
                    return -1;
                }

                // 虚拟库名captions
                XmlNodeList nodes = dom.DocumentElement.SelectNodes("caption");
                string strCaptionsXml = "";
                for (int i = 0; i < nodes.Count; i++)
                {
                    strCaptionsXml += nodes[i].OuterXml;
                }

                if (String.IsNullOrEmpty(strCaptionsXml) == false)
                    this.captionEditControl_virtualDatabaseName.Xml = strCaptionsXml;

                // 成员库
                nodes = dom.DocumentElement.SelectNodes("database");
                string strMemberDatabaseNames = "";
                for (int i = 0; i < nodes.Count; i++)
                {
                    strMemberDatabaseNames += DomUtil.GetAttr(nodes[i], "name") + "\r\n";
                }
                this.textBox_memberDatabases.Text = strMemberDatabaseNames;

                // froms定义
                nodes = dom.DocumentElement.SelectNodes("from");
                string strFromsXml = "";
                for (int i = 0; i < nodes.Count; i++)
                {
                    strFromsXml += nodes[i].OuterXml;
                }
                if (String.IsNullOrEmpty(strFromsXml) == false)
                    this.fromEditControl1.Xml = strFromsXml;
            }

            return 0;
        }
Example #2
0
        public int Initial(ManagerForm managerform,
                           bool bCreateMode,
                           string strXml,
                           out string strError)
        {
            strError = "";

            this.ManagerForm = managerform;
            this.CreateMode  = bCreateMode;

            this.Xml = strXml;

            // 填充窗口内容
            if (String.IsNullOrEmpty(strXml) == false)
            {
                XmlDocument dom = new XmlDocument();
                try
                {
                    dom.LoadXml(strXml);
                }
                catch (Exception ex)
                {
                    strError = "XML装载到DOM时出错: " + ex.Message;
                    return(-1);
                }

                // 虚拟库名captions
                XmlNodeList nodes          = dom.DocumentElement.SelectNodes("caption");
                string      strCaptionsXml = "";
                for (int i = 0; i < nodes.Count; i++)
                {
                    strCaptionsXml += nodes[i].OuterXml;
                }

                if (String.IsNullOrEmpty(strCaptionsXml) == false)
                {
                    this.captionEditControl_virtualDatabaseName.Xml = strCaptionsXml;
                }

                // 成员库
                nodes = dom.DocumentElement.SelectNodes("database");
                string strMemberDatabaseNames = "";
                for (int i = 0; i < nodes.Count; i++)
                {
                    strMemberDatabaseNames += DomUtil.GetAttr(nodes[i], "name") + "\r\n";
                }
                this.textBox_memberDatabases.Text = strMemberDatabaseNames;

                // froms定义
                nodes = dom.DocumentElement.SelectNodes("from");
                string strFromsXml = "";
                for (int i = 0; i < nodes.Count; i++)
                {
                    strFromsXml += nodes[i].OuterXml;
                }
                if (String.IsNullOrEmpty(strFromsXml) == false)
                {
                    this.fromEditControl1.Xml = strFromsXml;
                }
            }

            return(0);
        }
Example #3
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="managerform">系统管理窗</param>
        /// <param name="dbnames">数据库名集合</param>
        /// <param name="strError">返回出错信息</param>
        /// <returns>-1: 出错  0: 正常</returns>
        public int Initial(ManagerForm managerform,
                           List <string> dbnames,
                           out string strError)
        {
            strError = "";

            this.ManagerForm = managerform;
            this.m_dbnames   = dbnames;

            // 合并后的结果
            XmlDocument dom_total = new XmlDocument();

            dom_total.LoadXml("<root />");

            // 获得全部数据库定义
            for (int i = 0; i < this.m_dbnames.Count; i++)
            {
                string strDbName = this.m_dbnames[i];

                string strOutputInfo = "";
                // 获得普通数据库定义
                int nRet = this.ManagerForm.GetDatabaseInfo(
                    strDbName,
                    out strOutputInfo,
                    out strError);
                if (nRet == -1)
                {
                    return(-1);
                }
                if (nRet == 0)
                {
                    strError = "数据库 '" + strDbName + "' 不存在";
                    return(-1);
                }

                XmlDocument dom = new XmlDocument();
                try
                {
                    dom.LoadXml(strOutputInfo);
                }
                catch (Exception ex)
                {
                    strError = "XML装入DOM时出错: " + ex.Message;
                    return(-1);
                }

                XmlNodeList nodes = dom.DocumentElement.SelectNodes("from");
                for (int j = 0; j < nodes.Count; j++)
                {
                    XmlNode node         = nodes[j];
                    string  strFromStyle = DomUtil.GetAttr(node, "style");

                    // 跳过没有style属性的<from>
                    if (String.IsNullOrEmpty(strFromStyle) == true)
                    {
                        continue;
                    }

                    // 跳过“记录索引号”style。因为这个<from>元素下没有<caption>元素,会引起麻烦
                    if (strFromStyle == "recid")
                    {
                        continue;
                    }

                    XmlNode nodeExist = dom_total.DocumentElement.SelectSingleNode("from[@style='" + strFromStyle + "']");
                    if (nodeExist != null)
                    {
                        // style已经存在,对captions进行合并增补
                        MergeCaptions(nodeExist,
                                      node);
                        continue;
                    }

                    // 新增
                    XmlNode new_node = dom_total.CreateElement("from");
                    dom_total.DocumentElement.AppendChild(new_node);
                    DomUtil.SetAttr(new_node, "style", strFromStyle);
                    new_node.InnerXml = node.InnerXml;
                }
            }

            this.m_strFromsXml = dom_total.DocumentElement.InnerXml;

            return(0);
        }
Example #4
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="managerform">系统管理窗</param>
        /// <param name="dbnames">数据库名集合</param>
        /// <param name="strError">返回出错信息</param>
        /// <returns>-1: 出错  0: 正常</returns>
        public int Initial(ManagerForm managerform,
            List<string> dbnames,
            out string strError)
        {
            strError = "";

            this.ManagerForm = managerform;
            this.m_dbnames = dbnames;

            // 合并后的结果
            XmlDocument dom_total = new XmlDocument();
            dom_total.LoadXml("<root />");

            // 获得全部数据库定义
            for (int i = 0; i < this.m_dbnames.Count; i++)
            {
                string strDbName = this.m_dbnames[i];

                string strOutputInfo = "";
                // 获得普通数据库定义
                int nRet = this.ManagerForm.GetDatabaseInfo(
                    strDbName,
                    out strOutputInfo,
                    out strError);
                if (nRet == -1)
                    return -1;
                if (nRet == 0)
                {
                    strError = "数据库 '" + strDbName + "' 不存在";
                    return -1;
                }

                XmlDocument dom = new XmlDocument();
                try
                {
                    dom.LoadXml(strOutputInfo);
                }
                catch (Exception ex)
                {
                    strError = "XML装入DOM时出错: " + ex.Message;
                    return -1;
                }

                XmlNodeList nodes = dom.DocumentElement.SelectNodes("from");
                for (int j = 0; j < nodes.Count; j++)
                {
                    XmlNode node = nodes[j];
                    string strFromStyle = DomUtil.GetAttr(node, "style");

                    // 跳过没有style属性的<from>
                    if (String.IsNullOrEmpty(strFromStyle) == true)
                        continue;

                    // 跳过“记录索引号”style。因为这个<from>元素下没有<caption>元素,会引起麻烦
                    if (strFromStyle == "recid")
                        continue;

                    XmlNode nodeExist = dom_total.DocumentElement.SelectSingleNode("from[@style='" + strFromStyle + "']");
                    if (nodeExist != null)
                    {
                        // style已经存在,对captions进行合并增补
                        MergeCaptions(nodeExist,
                            node);
                        continue;
                    }

                    // 新增
                    XmlNode new_node = dom_total.CreateElement("from");
                    dom_total.DocumentElement.AppendChild(new_node);
                    DomUtil.SetAttr(new_node, "style", strFromStyle);
                    new_node.InnerXml = node.InnerXml;
                }
            }

            this.m_strFromsXml = dom_total.DocumentElement.InnerXml;

            return 0;
        }