Example #1
0
        // DOM中的<readerTypes>和<bookTypes>部分 --> types编辑界面
        LibraryCodeInfo GetLibraryCodeInfo(XmlDocument dom,
                                           string strLibraryCode)
        {
            LibraryCodeInfo info = new LibraryCodeInfo();

            info.LibraryCode = strLibraryCode;

            string  strFilter = "";
            XmlNode root      = dom.DocumentElement;

            if (string.IsNullOrEmpty(strLibraryCode) == false)
            {
                XmlNode temp = root.SelectSingleNode("//library[@code='" + strLibraryCode + "']");
                if (temp == null)
                {
                    return(info);
                }
                root = temp;
            }
            else
            {
                strFilter = "[count(ancestor::library) = 0]";
            }


            // readertypes

            {
                XmlNodeList nodes   = root.SelectNodes("descendant::readerTypes/item" + strFilter);
                string      strText = "";
                for (int i = 0; i < nodes.Count; i++)
                {
                    if (String.IsNullOrEmpty(strText) == false)
                    {
                        strText += "\r\n";
                    }
                    strText += nodes[i].InnerText;
                }

                info.ReaderTypeList = strText;
            }

            // booktypes
            {
                XmlNodeList nodes   = root.SelectNodes("descendant::bookTypes/item" + strFilter);
                string      strText = "";
                for (int i = 0; i < nodes.Count; i++)
                {
                    if (String.IsNullOrEmpty(strText) == false)
                    {
                        strText += "\r\n";
                    }
                    strText += nodes[i].InnerText;
                }

                info.BookTypeList = strText;
            }

            return(info);
        }
Example #2
0
        /*public*/ void FinishLibraryCodeTextbox()
        {
                            // 把当前textbox中的收尾
                if (m_currentLibraryCodeItem != null)
                {
                    LibraryCodeInfo info = (LibraryCodeInfo)m_currentLibraryCodeItem.Tag;
                    if (info == null)
                    {
                        info = new LibraryCodeInfo();
                        m_currentLibraryCodeItem.Tag = info;
                    }

                    if (info.BookTypeList != this.textBox_loanPolicy_bookTypes.Text)
                    {
                        info.BookTypeList = this.textBox_loanPolicy_bookTypes.Text;
                        info.Changed = true;
                    }
                    if (info.ReaderTypeList != this.textBox_loanPolicy_readerTypes.Text)
                    {
                        info.ReaderTypeList = this.textBox_loanPolicy_readerTypes.Text;
                        info.Changed = true;
                    }
                }

        }
Example #3
0
        // 在listview中列出馆代码
        void ListLibraryCodes(XmlDocument dom)
        {
            List <string> librarycodes = new List <string>();
            XmlNodeList   nodes        = dom.DocumentElement.SelectNodes("library");

            foreach (XmlNode node in nodes)
            {
                string strCode = DomUtil.GetAttr(node, "code");
                librarycodes.Add(strCode);
            }

            // 看看是否还有不属于任何<library>元素的
            nodes = dom.DocumentElement.SelectNodes("//param[count(ancestor::library) = 0]");
            if (nodes.Count > 0)
            {
                if (librarycodes.IndexOf("") == -1)
                {
                    librarycodes.Insert(0, "");
                }
            }

            //
            this.m_currentLibraryCodeItem = null;
            this.listView_loanPolicy_libraryCodes.Items.Clear();
            foreach (string strLibraryCode in librarycodes)
            {
                ListViewItem    item = new ListViewItem(string.IsNullOrEmpty(strLibraryCode) == true ? "<缺省>" : strLibraryCode);
                LibraryCodeInfo info = GetLibraryCodeInfo(dom,
                                                          strLibraryCode);
                item.Tag = info;

                this.listView_loanPolicy_libraryCodes.Items.Add(item);
            }

            this.textBox_loanPolicy_readerTypes.Text = "";
            this.textBox_loanPolicy_bookTypes.Text   = "";

            // 选定第一行
            if (this.listView_loanPolicy_libraryCodes.Items.Count > 0)
            {
                this.listView_loanPolicy_libraryCodes.Items[0].Selected = true;
            }
        }
Example #4
0
        /*public*/ void FinishLibraryCodeTextbox()
        {
            // 把当前textbox中的收尾
            if (m_currentLibraryCodeItem != null)
            {
                LibraryCodeInfo info = (LibraryCodeInfo)m_currentLibraryCodeItem.Tag;
                if (info == null)
                {
                    info = new LibraryCodeInfo();
                    m_currentLibraryCodeItem.Tag = info;
                }

                if (info.BookTypeList != this.textBox_loanPolicy_bookTypes.Text)
                {
                    info.BookTypeList = this.textBox_loanPolicy_bookTypes.Text;
                    info.Changed      = true;
                }
                if (info.ReaderTypeList != this.textBox_loanPolicy_readerTypes.Text)
                {
                    info.ReaderTypeList = this.textBox_loanPolicy_readerTypes.Text;
                    info.Changed        = true;
                }
            }
        }
Example #5
0
        // types编辑界面 --> DOM中的<readerTypes>和<bookTypes>部分
        // 调用前dom中应当已经装入了权限XML代码
        bool TypesToRightsXml(ref XmlDocument dom)
        {
            // 结束一下当前textbox
            FinishLibraryCodeTextbox();

            bool bChanged = false;

            XmlNode root = dom.DocumentElement;

            // 对每个馆代码循环
            foreach (ListViewItem item in this.listView_loanPolicy_libraryCodes.Items)
            {
                // string strLibraryCode = item.Text;
                LibraryCodeInfo info = (LibraryCodeInfo)item.Tag;

                /*
                 * if (info.Changed == false)
                 *  continue;
                 * */
                string strLibraryCode    = info.LibraryCode;
                string strReaderTypesXml = BuildTypesXml(info.ReaderTypeList);
                string strBookTypesXml   = BuildTypesXml(info.BookTypeList);

                string strFilter = "";
                if (string.IsNullOrEmpty(strLibraryCode) == false)
                {
                    XmlNode temp = root.SelectSingleNode("//library[@code='" + strLibraryCode + "']");
                    if (temp == null)
                    {
                        temp = dom.CreateElement("library");
                        root.AppendChild(temp);
                        DomUtil.SetAttr(temp, "code", strLibraryCode);
                    }
                    root = temp;
                }
                else
                {
                    strFilter = "[count(ancestor::library) = 0]";
                }

                {
                    XmlNode nodeReaderTypes = root.SelectSingleNode("descendant::readerTypes" + strFilter);

                    if (nodeReaderTypes == null)
                    {
                        nodeReaderTypes = dom.CreateElement("readerTypes");
                        root.AppendChild(nodeReaderTypes);
                    }

                    nodeReaderTypes.InnerXml = strReaderTypesXml;
                }

                {
                    XmlNode nodeBookTypes = root.SelectSingleNode("descendant::bookTypes" + strFilter);


                    if (nodeBookTypes == null)
                    {
                        nodeBookTypes = dom.CreateElement("bookTypes");
                        root.AppendChild(nodeBookTypes);
                    }

                    nodeBookTypes.InnerXml = strBookTypesXml;
                }

                if (info.Changed == true)
                {
                    bChanged = true;
                }

                info.Changed = false;
            }

            return(bChanged);
        }
Example #6
0
        // DOM中的<readerTypes>和<bookTypes>部分 --> types编辑界面
        LibraryCodeInfo GetLibraryCodeInfo(XmlDocument dom,
            string strLibraryCode)
        {
            LibraryCodeInfo info = new LibraryCodeInfo();

            info.LibraryCode = strLibraryCode;

            string strFilter = "";
            XmlNode root = dom.DocumentElement;
            if (string.IsNullOrEmpty(strLibraryCode) == false)
            {
                XmlNode temp = root.SelectSingleNode("//library[@code='" + strLibraryCode + "']");
                if (temp == null)
                    return info;
                root = temp;
            }
            else
            {
                strFilter = "[count(ancestor::library) = 0]";
            }


            // readertypes

            {
                XmlNodeList nodes = root.SelectNodes("descendant::readerTypes/item" + strFilter);
                string strText = "";
                for (int i = 0; i < nodes.Count; i++)
                {
                    if (String.IsNullOrEmpty(strText) == false)
                        strText += "\r\n";
                    strText += nodes[i].InnerText;
                }

                info.ReaderTypeList = strText;
            }

            // booktypes
            {
                XmlNodeList nodes = root.SelectNodes("descendant::bookTypes/item" + strFilter);
                string strText = "";
                for (int i = 0; i < nodes.Count; i++)
                {
                    if (String.IsNullOrEmpty(strText) == false)
                        strText += "\r\n";
                    strText += nodes[i].InnerText;
                }

                info.BookTypeList = strText;
            }

            return info;
        }