Esempio n. 1
0
 static string MakeArrangementLocationNodeName(string strLocationName)
 {
     /*
      * if (String.IsNullOrEmpty(strLocationName) == true)
      *  return "<空>";
      *
      * return strLocationName;
      * */
     return(ArrangementLocationDialog.GetDisplayString(strLocationName));
 }
Esempio n. 2
0
        private void toolStripButton_arrangement_modify_Click(object sender, EventArgs e)
        {
            string strError = "";
            int nRet = 0;

            // 当前节点
            TreeNode current_treenode = this.treeView_arrangement.SelectedNode;

            if (current_treenode == null)
            {
                MessageBox.Show(this, "尚未选定要修改的节点");
                return;
            }

            if (current_treenode.ImageIndex == TYPE_ARRANGEMENT_GROUP)
            {
                // 组节点
                string strXml = (string)current_treenode.Tag;
                if (String.IsNullOrEmpty(strXml) == true)
                {
                    strError = "节点 " + current_treenode.Text + " 没有Tag定义";
                    goto ERROR1;
                }

                XmlDocument dom = new XmlDocument();
                try
                {
                    dom.LoadXml(strXml);
                }
                catch (Exception ex)
                {
                    strError = "<group>节点的XML装入DOM时出错: " + ex.Message;
                    goto ERROR1;
                }

                string strArrangementName = DomUtil.GetAttr(dom.DocumentElement,
                    "name");
                string strClassType = DomUtil.GetAttr(dom.DocumentElement,
                    "classType");
                string strQufenhaoType = DomUtil.GetAttr(dom.DocumentElement,
                    "qufenhaoType");
                string strZhongcihaoDbName = DomUtil.GetAttr(dom.DocumentElement,
                    "zhongcihaodb");
                string strCallNumberStyle = DomUtil.GetAttr(dom.DocumentElement,
    "callNumberStyle");

                List<string> used_dbnames = GetArrangementAllUsedZhongcihaoDbName(current_treenode);

                ArrangementGroupDialog dlg = new ArrangementGroupDialog();
                MainForm.SetControlFont(dlg, this.Font, false);

                dlg.Text = "修改排架体系特性";
                dlg.ArrangementName = strArrangementName;
                dlg.ClassType = strClassType;
                dlg.QufenhaoType = strQufenhaoType;
                dlg.ZhongcihaoDbName = strZhongcihaoDbName;
                dlg.CallNumberStyle = strCallNumberStyle;
                dlg.AllZhongcihaoDatabaseInfoXml = GetAllZhongcihaoDbInfoXml();
                dlg.ExcludingDbNames = used_dbnames;
                dlg.StartPosition = FormStartPosition.CenterScreen;
            REDO_INPUT:
                dlg.ShowDialog(this);

                if (dlg.DialogResult != DialogResult.OK)
                    return;

                // 检查排架体系节点名是否重复
                nRet = CheckArrangementNameDup(dlg.ArrangementName,
                    current_treenode,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;
                if (nRet == 1)
                {
                    MessageBox.Show(this, "排架体系名 '" + dlg.ArrangementName + "' 已经存在,无法重复创建,请修改");
                    goto REDO_INPUT;
                }

                DomUtil.SetAttr(dom.DocumentElement, "name", dlg.ArrangementName);
                DomUtil.SetAttr(dom.DocumentElement, "classType", dlg.ClassType);
                DomUtil.SetAttr(dom.DocumentElement, "qufenhaoType", dlg.QufenhaoType);
                DomUtil.SetAttr(dom.DocumentElement, "zhongcihaodb", dlg.ZhongcihaoDbName);
                DomUtil.SetAttr(dom.DocumentElement, "callNumberStyle", dlg.CallNumberStyle);

                current_treenode.Text = MakeArrangementGroupNodeName(
                    dlg.ArrangementName,
                    dlg.ClassType,
                    dlg.QufenhaoType,
                    dlg.ZhongcihaoDbName,
                    dlg.CallNumberStyle);
                current_treenode.Tag = dom.DocumentElement.OuterXml;

                // 确保展开
                // current_treenode.Parent.Expand();

                this.ArrangementChanged = true;

            }
            else if (current_treenode.ImageIndex == TYPE_ARRANGEMENT_LOCATION)
            {
                // 馆藏地点节点
                string strXml = (string)current_treenode.Tag;

                if (String.IsNullOrEmpty(strXml) == true)
                {
                    strError = "节点 " + current_treenode.Text + " 没有Tag定义";
                    goto ERROR1;
                }

                XmlDocument dom = new XmlDocument();
                try
                {
                    dom.LoadXml(strXml);
                }
                catch (Exception ex)
                {
                    strError = "<location>节点的XML装入DOM时出错: " + ex.Message;
                    goto ERROR1;
                }

                string strLocationName = DomUtil.GetAttr(dom.DocumentElement,
                    "name");

                List<string> used_locationnames = this.GetArrangementAllUsedLocationName(current_treenode);

                ArrangementLocationDialog dlg = new ArrangementLocationDialog();
                MainForm.SetControlFont(dlg, this.Font, false);

                dlg.Text = "修改馆藏地点名";
                if (this.Channel != null)
                    dlg.LibraryCodeList = this.Channel.LibraryCodeList;
                dlg.LocationString = strLocationName;
                dlg.ExcludingLocationNames = used_locationnames;
                dlg.StartPosition = FormStartPosition.CenterScreen;

                dlg.GetValueTable -= new GetValueTableEventHandler(dlg_GetValueTable);
                dlg.GetValueTable += new GetValueTableEventHandler(dlg_GetValueTable);

                dlg.ShowDialog(this);

                if (dlg.DialogResult != DialogResult.OK)
                    return;

                /*
                // 检查对话框中得到的书目库名,是不是被别处用过的书目库名?
                if (used_locationnames.IndexOf(dlg.SelectedDatabaseName) != -1)
                {
                    strError = "您所指定的书目库 '" + dlg.SelectedDatabaseName + "' 已经被其他数据库节点使用过了。放弃本次修改数据库节点操作。";
                    goto ERROR1;
                }*/

                DomUtil.SetAttr(dom.DocumentElement, "name", dlg.LocationString);

                string strDisplayText = MakeArrangementLocationNodeName(dlg.LocationString);

                current_treenode.Text = strDisplayText;
                current_treenode.Tag = dom.DocumentElement.OuterXml;

                // 确保展开
                current_treenode.Parent.Expand();

                this.ArrangementChanged = true;
            }
            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
Esempio n. 3
0
        private void toolStripMenuItem_arrangement_insert_location_Click(object sender, EventArgs e)
        {
            string strError = "";
            // int nRet = 0;

            // 当前节点
            TreeNode current_treenode = this.treeView_arrangement.SelectedNode;

            if (current_treenode == null)
            {
                strError = "尚未选定排架体系节点,因此无法插入新的馆藏地点名节点";
                goto ERROR1;
            }

            int index = -1;

            Debug.Assert(current_treenode != null, "");

            // 如果是第一级的节点,则理解为插入到它的儿子的尾部
            if (current_treenode.Parent == null)
            {
                Debug.Assert(current_treenode != null, "");

                index = current_treenode.Nodes.Count;
            }
            else
            {
                index = current_treenode.Parent.Nodes.IndexOf(current_treenode);

                Debug.Assert(index != -1, "");

                index++;

                current_treenode = current_treenode.Parent;
            }

            // 至此,current_treenode为<group>类型的节点了

            List<string> used_locationnames = GetArrangementAllUsedLocationName(null);

            // 新的馆藏地名
            ArrangementLocationDialog dlg = new ArrangementLocationDialog();
            MainForm.SetControlFont(dlg, this.Font, false);

            dlg.Text = "请指定馆藏地点";
            if (this.Channel != null)
                dlg.LibraryCodeList = this.Channel.LibraryCodeList;
            dlg.ExcludingLocationNames = used_locationnames;
            dlg.StartPosition = FormStartPosition.CenterScreen;

            dlg.GetValueTable -= new GetValueTableEventHandler(dlg_GetValueTable);
            dlg.GetValueTable += new GetValueTableEventHandler(dlg_GetValueTable);

            dlg.ShowDialog(this);

            if (dlg.DialogResult != DialogResult.OK)
                return;

            /*
            // 检查对话框中得到的书目库名,是不是被别处用过的书目库名?
            if (used_locationnames.IndexOf(dlg.SelectedDatabaseName) != -1)
            {
                strError = "您所指定的书目库 '" + dlg.SelectedDatabaseName + "' 已经被其他数据库节点使用过了。放弃本次创建数据库节点操作。";
                goto ERROR1;
            }*/

            XmlDocument dom = new XmlDocument();
            dom.LoadXml("<location />");

            DomUtil.SetAttr(dom.DocumentElement, "name", dlg.LocationString);

            string strLocationCaption = MakeArrangementLocationNodeName(dlg.LocationString);

            TreeNode new_treenode = new TreeNode(strLocationCaption,
                TYPE_ARRANGEMENT_LOCATION, TYPE_ARRANGEMENT_LOCATION);
            new_treenode.Tag = dom.DocumentElement.OuterXml;

            current_treenode.Nodes.Insert(index, new_treenode);

            this.treeView_arrangement.SelectedNode = new_treenode;

            this.ArrangementChanged = true;

            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }