Пример #1
0
        // (复制)另存书目记录为。注:包括下属的册、订购、期、评注记录和对象资源
        private void toolStripButton1_marcEditor_saveTo_Click(object sender, EventArgs e)
        {
            string strError = "";
            int nRet = 0;

            if (StringUtil.CompareVersion(this.MainForm.ServerVersion, "2.39") < 0)
            {
                strError = "本功能需要配合 dp2library 2.39 或以上版本才能使用";
                goto ERROR1;
            }

            string strTargetRecPath = this.m_marcEditor.Record.Fields.GetFirstSubfield("998", "t");
            if (string.IsNullOrEmpty(strTargetRecPath) == false)
            {
                DialogResult result = MessageBox.Show(this,
    "当前窗口内的记录原本是从 '" + strTargetRecPath + "' 复制过来的。是否要复制回原有位置?\r\n\r\nYes: 是; No: 否,继续进行普通复制操作; Cancel: 放弃本次操作",
    "EntityForm",
    MessageBoxButtons.YesNoCancel,
    MessageBoxIcon.Question,
    MessageBoxDefaultButton.Button1);
                if (result == System.Windows.Forms.DialogResult.Cancel)
                    return;
                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    // strTargetRecPath会发生作用
                }

                if (result == System.Windows.Forms.DialogResult.No)
                {
                    strTargetRecPath = "";
                }
            }


            bool bSaveAs = false;   // 源记录ID就是'?',追加方式。这意味着数据库中没有源记录

            // 源记录就是 ?
            if (Global.IsAppendRecPath(this.BiblioRecPath) == true)
            {
                bSaveAs = true;
            }

            MergeStyle merge_style = MergeStyle.CombinSubrecord | MergeStyle.ReserveSourceBiblio;

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

            dlg.MainForm = this.MainForm;
            // dlg.RecPath = this.BiblioRecPath;
            if (string.IsNullOrEmpty(strTargetRecPath) == false)
                dlg.RecPath = strTargetRecPath;
            else
            {
                dlg.RecPath = this.MainForm.AppInfo.GetString(
                    "entity_form",
                    "save_to_used_path",
                    this.BiblioRecPath);
                dlg.RecID = "?";
            }

            if (bSaveAs == false)
                dlg.MessageText = "(注:本功能*可选择*是否复制书目记录下属的册、期、订购、实体记录和对象资源)\r\n\r\n将当前窗口中的书目记录 " + this.BiblioRecPath + " 复制到:";
            else
            {
                dlg.Text = "保存新书目记录到特定位置";
                dlg.MessageText = "注:\r\n1) 当前执行的是保存而不是复制操作(因为数据库里面还没有这条记录);\r\n2) 书目记录下属的册、期、订购、实体记录和对象资源会被一并保存";
                dlg.EnableCopyChildRecords = false;
            }

            if (string.IsNullOrEmpty(strTargetRecPath) == false)
                dlg.BuildLink = false;
            else
            {
                if (bSaveAs == false)
                    dlg.BuildLink = this.MainForm.AppInfo.GetBoolean(
                        "entity_form",
                        "when_save_to_build_link",
                        true);
                else
                    dlg.BuildLink = false;
            }

            if (bSaveAs == false)
                dlg.CopyChildRecords = this.MainForm.AppInfo.GetBoolean(
                    "entity_form",
                    "when_save_to_copy_child_records",
                    false);
            else
                dlg.CopyChildRecords = true;

            {
                string strMarcSyntax = this.GetCurrentMarcSyntax();
                if (string.IsNullOrEmpty(strMarcSyntax) == true)
                    strMarcSyntax = this.MarcSyntax;    // 外来数据的 MARC 格式

                dlg.MarcSyntax = strMarcSyntax;
            }

            dlg.CurrentBiblioRecPath = this.BiblioRecPath;
            this.MainForm.AppInfo.LinkFormState(dlg, "entityform_BiblioSaveToDlg_state");
            dlg.ShowDialog(this);
            // this.MainForm.AppInfo.UnlinkFormState(dlg);

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

            if (this.BiblioRecPath == dlg.RecPath)
            {
                strError = "要保存到的位置 '" + dlg.RecPath + "' 和当前记录本来的位置 '" + this.BiblioRecPath + "' 相同,复制操作被拒绝。若确实要这样保存记录,请直接使用保存功能。";
                goto ERROR1;
            }

            if (bSaveAs == false)
            {
                this.MainForm.AppInfo.SetBoolean(
                    "entity_form",
                    "when_save_to_build_link",
                    dlg.BuildLink);
                this.MainForm.AppInfo.SetBoolean(
                    "entity_form",
                    "when_save_to_copy_child_records",
                    dlg.CopyChildRecords);
            }
            this.MainForm.AppInfo.SetString(
    "entity_form",
    "save_to_used_path",
    dlg.RecPath);

            // 源记录就是 ?
            if (bSaveAs == true)
            {
                this.BiblioRecPath = dlg.RecPath;

                // 提交所有保存请求
                // return:
                //      -1  有错。此时不排除有些信息保存成功。
                //      0   成功。
                nRet = DoSaveAll();
                if (nRet == -1)
                {
                    strError = "保存操作出错";
                    goto ERROR1;
                }

                return;
            }

            // if (dlg.CopyChildRecords == true)
            {
                // 如果当前记录没有保存,则先保存
                if (this.EntitiesChanged == true
        || this.IssuesChanged == true
        || this.BiblioChanged == true
        || this.ObjectChanged == true
        || this.OrdersChanged == true
        || this.CommentsChanged == true)
                {
                    // 警告尚未保存
                    DialogResult result = MessageBox.Show(this,
                        "当前窗口内有 " + GetCurrentChangedPartName() + " 被修改后尚未保存。复制操作前必须先保存当前记录。\r\n\r\n请问要立即保存么?",
                        "EntityForm",
                        MessageBoxButtons.OKCancel,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button2);
                    if (result == DialogResult.OK)
                    {
                        // 提交所有保存请求
                        // return:
                        //      -1  有错。此时不排除有些信息保存成功。
                        //      0   成功。
                        nRet = DoSaveAll();
                        if (nRet == -1)
                        {
                            strError = "因为保存操作出错,所以后续的复制操作被放弃";
                            goto ERROR1;
                        }
                    }
                    else
                    {
                        strError = "复制操作被放弃";
                        goto ERROR1;
                    }
                }
            }

            // 看看要另存的位置,记录是否已经存在?
            // TODO: 需要改造为合并,或者覆盖。覆盖是先删除目标位置的记录。
            if (dlg.RecID != "?")
            {
                byte[] timestamp = null;

                // 检测特定位置书目记录是否已经存在
                // parameters:
                // return:
                //      -1  error
                //      0   not found
                //      1   found
                nRet = DetectBiblioRecord(dlg.RecPath,
                    out timestamp,
                    out strError);
                if (nRet == 1)
                {
                    if (dlg.RecPath != strTargetRecPath)
                    {
#if NO
                        // 提醒覆盖?
                        DialogResult result = MessageBox.Show(this,
                            "书目记录 " + dlg.RecPath + " 已经存在。\r\n\r\n要用当前窗口中的书目记录覆盖此记录么? ",
                            "EntityForm",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button2);
                        if (result != DialogResult.Yes)
                            return;
#endif
                        GetMergeStyleDialog merge_dlg = new GetMergeStyleDialog();
                        MainForm.SetControlFont(merge_dlg, this.Font, false);
                        merge_dlg.SourceRecPath = this.BiblioRecPath;
                        merge_dlg.TargetRecPath = dlg.RecPath;
                        merge_dlg.MessageText = "目标书目记录 " + dlg.RecPath + " 已经存在。\r\n\r\n请指定当前窗口中的书目记录(源)和此目标记录合并的方法";

                        merge_dlg.UiState = this.MainForm.AppInfo.GetString(
        "entity_form",
        "GetMergeStyleDialog_copy_uiState",
        "");
                        merge_dlg.EnableSubRecord = dlg.CopyChildRecords;

                        this.MainForm.AppInfo.LinkFormState(merge_dlg, "entityform_GetMergeStyleDialog_copy_state");
                        merge_dlg.ShowDialog(this);
                        this.MainForm.AppInfo.UnlinkFormState(merge_dlg);
                        this.MainForm.AppInfo.SetString(
"entity_form",
"GetMergeStyleDialog_copy_uiState",
merge_dlg.UiState);

                        if (merge_dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                            return;

                        merge_style = merge_dlg.GetMergeStyle();

                    }

                    // this.BiblioTimestamp = timestamp;   // 为了顺利覆盖

                    // TODO: 预先检查操作者权限,确保删除书目记录和下级记录都能成功,否则就警告

#if NO
                    // 删除目标位置的书目记录,但保留其下属的实体等记录
                    nRet = DeleteBiblioRecordFromDatabase(dlg.RecPath,
                        "onlydeletebiblio",
                        timestamp,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;
#endif
                    if ((merge_style & MergeStyle.OverwriteSubrecord) != 0)
                    {
                        // 删除目标记录整个,或者删除目标位置的下级记录
                        // TODO: 测试的时候,注意不用下述调用而测试保留目标书目记录中对象的可能性
                        nRet = DeleteBiblioRecordFromDatabase(dlg.RecPath,
                            (merge_style & MergeStyle.ReserveSourceBiblio) != 0 ? "delete" : "onlydeletesubrecord",
                            timestamp,
                            out strError);
                        if (nRet == -1)
                        {
                            if ((merge_style & MergeStyle.ReserveSourceBiblio) != 0)
                                strError = "删除目标位置的书目记录 '" + dlg.RecPath + "' 时出错: " + strError;
                            else
                                strError = "删除目标位置的书目记录 '" + dlg.RecPath + "' 的全部子记录时出错: " + strError;
                            goto ERROR1;
                        }
                    }

                }
            }

            string strOutputBiblioRecPath = "";
            byte[] baOutputTimestamp = null;
            string strXml = "";

            string strOldBiblioRecPath = this.BiblioRecPath;
            string strOldMarc = this.GetMarc();    //  this.m_marcEditor.Marc;
            bool bOldChanged = this.GetMarcChanged();   //  this.m_marcEditor.Changed;

            try
            {

                // 保存原来的记录路径
                bool bOldReadOnly = this.m_marcEditor.ReadOnly;
                Field old_998 = null;
                // bool bOldChanged = this.BiblioChanged;

                if (dlg.BuildLink == true)
                {
                    nRet = this.MainForm.CheckBuildLinkCondition(
                        dlg.RecPath,    // 即将创建/保存的记录
                        strOldBiblioRecPath,    // 保存前的记录
                        false,
                        out strError);
                    if (nRet == -1 || nRet == 0)
                    {
                        // 
                        strError = "无法为记录 '" + this.BiblioRecPath + "' 建立指向 '" + strOldBiblioRecPath + "' 的目标关系:" + strError;
                        MessageBox.Show(this, strError);
                    }
                    else
                    {
                        // 保存当前记录的998字段
                        old_998 = this.m_marcEditor.Record.Fields.GetOneField("998", 0);

                        this.m_marcEditor.Record.Fields.SetFirstSubfield("998", "t", strOldBiblioRecPath);
                        /*
                        if (bOldReadOnly == false)
                            this.MarcEditor.ReadOnly = true;
                        */
                    }
                }
                else
                {
                    // 保存当前记录的998字段
                    old_998 = this.m_marcEditor.Record.Fields.GetOneField("998", 0);

                    // 清除可能存在的998$t
                    if (old_998 != null)
                    {
                        SubfieldCollection subfields = old_998.Subfields;
                        Subfield old_t = subfields["t"];
                        if (old_t != null)
                        {
                            old_998.Subfields = subfields.Remove(old_t);
                            // 如果998内一个子字段也没有了,是否这个字段要删除?
                        }
                        else
                            old_998 = null; // 表示(既然没有删除$t,就)不用恢复
                    }
                }

                string strMergeStyle = "";
                if ((merge_style & MergeStyle.ReserveSourceBiblio) != 0)
                    strMergeStyle = "reserve_source";
                else
                    strMergeStyle = "reserve_target";

                if ((merge_style & MergeStyle.MissingSourceSubrecord) != 0)
                    strMergeStyle += ",missing_source_subrecord";
                else if ((merge_style & MergeStyle.OverwriteSubrecord) != 0)
                {
                    // dp2library 尚未实现这个功能,不过本函数前面已经用 SetBiblioInfo() API 主动删除了目标位置下属的子记录,效果是一样的。(当然,这样实现起来原子性不是那么好)
                    // strMergeStyle += ",overwrite_target_subrecord";
                }

                if (dlg.CopyChildRecords == false)
                {
                    nRet = CopyBiblio(
        "onlycopybiblio",
        dlg.RecPath,
        strMergeStyle,
        out strXml,
        out strOutputBiblioRecPath,
        out baOutputTimestamp,
        out strError);
                    if (nRet == -1)
                        MessageBox.Show(this, strError);
                }
                else
                {
                    nRet = CopyBiblio(
                        "copy",
                        dlg.RecPath,
                        strMergeStyle,
                        out strXml,
                        out strOutputBiblioRecPath,
                        out baOutputTimestamp,
                        out strError);
                    if (nRet == -1)
                        MessageBox.Show(this, strError);
                }

            }
            finally
            {
#if NO
                // 复原当前窗口的记录
                if (this.m_marcEditor.Marc != strOldMarc)
                    this.m_marcEditor.Marc = strOldMarc;
                if (this.m_marcEditor.Changed != bOldChanged)
                    this.m_marcEditor.Changed = bOldChanged;
#endif
                if (this.GetMarc() /*this.m_marcEditor.Marc*/ != strOldMarc)
                {
                    // this.m_marcEditor.Marc = strOldMarc;
                    this.SetMarc(strOldMarc);
                }
                if (this.GetMarcChanged() /*this.m_marcEditor.Changed*/ != bOldChanged)
                {
                    // this.m_marcEditor.Changed = bOldChanged;
                    this.SetMarcChanged(bOldChanged);
                }
            }

            if (nRet == -1)
            {
                this.BiblioRecPath = strOldBiblioRecPath;

#if NO
                if (old_998 != null)
                {
                    // 恢复先前的998字段内容
                    for (int i = 0; i < this.MarcEditor.Record.Fields.Count; i++)
                    {
                        Field temp = this.MarcEditor.Record.Fields[i];
                        if (temp.Name == "998")
                        {
                            this.MarcEditor.Record.Fields.RemoveAt(i);
                            i--;
                        }
                    }
                    if (old_998 != null)
                    {
                        this.MarcEditor.Record.Fields.Insert(this.MarcEditor.Record.Fields.Count,
                            old_998.Name,
                            old_998.Indicator,
                            old_998.Value);
                    }
                    // 恢复操作前的ReadOnly
                    if (this.MarcEditor.ReadOnly != bOldReadOnly)
                        this.MarcEditor.ReadOnly = bOldReadOnly;

                    if (this.BiblioChanged != bOldChanged)
                        this.BiblioChanged = bOldChanged;
                }
#endif
                return;
            }

            // TODO: 询问是否要立即装载目标记录到当前窗口,还是装入新的一个种册窗,还是不装入?
            {
                DialogResult result = MessageBox.Show(this,
        "复制操作已经成功。\r\n\r\n请问是否立即将目标记录 '" + strOutputBiblioRecPath + "' 装入一个新的种册窗以便进行观察? \r\n\r\n是(Yes): 装入一个新的种册窗;\r\n否(No): 装入当前窗口;\r\n取消(Cancel): 不装入目标记录到任何窗口",
        "EntityForm",
        MessageBoxButtons.YesNoCancel,
        MessageBoxIcon.Question,
        MessageBoxDefaultButton.Button1);
                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    EntityForm form = new EntityForm();
                    form.MdiParent = this.MainForm;
                    form.MainForm = this.MainForm;
                    form.Show();
                    Debug.Assert(form != null, "");

                    form.LoadRecordOld(strOutputBiblioRecPath, "", true);
                    return;
                }
                if (result == System.Windows.Forms.DialogResult.Cancel)
                    return;
            }

            // 将目标记录装入当前窗口
            this.LoadRecordOld(strOutputBiblioRecPath, "", false);
#if NO
            // 将目标记录装入当前窗口
            this.BiblioTimestamp = baOutputTimestamp;
            this.BiblioRecPath = strOutputBiblioRecPath;


            string strBiblioDbName = Global.GetDbName(this.BiblioRecPath);

            // bool bError = false;

            // 装载新记录的entities部分

            // 接着装入相关的所有册
            string strItemDbName = this.MainForm.GetItemDbName(strBiblioDbName);
            if (String.IsNullOrEmpty(strItemDbName) == false) // 仅在当前书目库有对应的实体库时,才装入册记录
            {
                this.EnableItemsPage(true);

                nRet = this.entityControl1.LoadEntityRecords(this.BiblioRecPath,
                    out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                    // bError = true;
                }
            }
            else
            {
                this.EnableItemsPage(false);
                this.entityControl1.ClearEntities();
            }

            // 接着装入相关的所有期
            string strIssueDbName = this.MainForm.GetIssueDbName(strBiblioDbName);
            if (String.IsNullOrEmpty(strIssueDbName) == false) // 仅在当前书目库有对应的期库时,才装入期记录
            {
                this.EnableIssuesPage(true);
                nRet = this.issueControl1.LoadIssueRecords(this.BiblioRecPath,
                    out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                    // bError = true;
                }
            }
            else
            {
                this.EnableIssuesPage(false);
                this.issueControl1.ClearIssues();
            }
            // 接着装入相关的所有订购信息
            string strOrderDbName = this.MainForm.GetOrderDbName(strBiblioDbName);
            if (String.IsNullOrEmpty(strOrderDbName) == false) // 仅在当前书目库有对应的采购库时,才装入采购记录
            {
                if (String.IsNullOrEmpty(strIssueDbName) == false)
                    this.orderControl1.SeriesMode = true;
                else
                    this.orderControl1.SeriesMode = false;

                this.EnableOrdersPage(true);
                nRet = this.orderControl1.LoadOrderRecords(this.BiblioRecPath,
                    out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                    // bError = true;
                }
            }
            else
            {
                this.EnableOrdersPage(false);
                this.orderControl1.ClearOrders();
            }

            // 接着装入相关的所有评注信息
            string strCommentDbName = this.MainForm.GetCommentDbName(strBiblioDbName);
            if (String.IsNullOrEmpty(strCommentDbName) == false) // 仅在当前书目库有对应的评注库时,才装入评注记录
            {
                this.EnableCommentsPage(true);
                nRet = this.commentControl1.LoadCommentRecords(this.BiblioRecPath,
                    out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                    // bError = true;
                }
            }
            else
            {
                this.EnableCommentsPage(false);
                this.commentControl1.ClearComments();
            }

            // 接着装入对象资源
            if (dlg.CopyChildRecords == true)
            {
                nRet = this.binaryResControl1.LoadObject(this.BiblioRecPath,    // 2008/11/2 changed
                    strXml,
                    out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                    // bError = true;
                    // return -1;
                }
            }

            // 装载书目和<dprms:file>以外的其它XML片断
            {
                nRet = LoadXmlFragment(strXml,
                    out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                }
            }

            /*
            // 没有对象资源
            if (this.binaryResControl1 != null)
            {
                this.binaryResControl1.Clear();
            }
             * */

            // TODO: 装载HTML?
            Global.SetHtmlString(this.webBrowser_biblioRecord, "(空白)");   // 暂时刷新为空白
#endif

            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
Пример #2
0
        void orderControl1_OpenTargetRecord(object sender, OpenTargetRecordEventArgs e)
        {
            // 新打开一个EntityForm
            EntityForm form = null;
            int nRet = 0;

            if (e.TargetRecPath == this.BiblioRecPath)
            {
                // 如果涉及当前记录,不必新开EntityForm窗口了,仅仅激活items page就可以了
                form = this;
                Global.Activate(form);
            }
            else
            {
                form = new EntityForm();
                form.MdiParent = this.MdiParent;
                form.MainForm = this.MainForm;
                form.Show();

                nRet = form.LoadRecordOld(e.TargetRecPath,
                    "",
                    false);
                if (nRet != 1)
                {
                    e.ErrorInfo = "目标书目记录 " + e.TargetRecPath + " 装载失败";
                    return;
                }

            }

            form.ActivateItemsPage();
            form.SelectItemsByBatchNo(e.BatchNo, true);
        }
Пример #3
0
        // 验收的时候自动创建实体记录
        void orderControl1_GenerateEntity(object sender,
            GenerateEntityEventArgs e)
        {
            string strError = "";
            int nRet = 0;

            string strTargetRecPath = "";
            if (sender is OrderControl)
            {
                Debug.Assert(e.SeriesMode == false, "");
                strTargetRecPath = this.orderControl1.TargetRecPath;
            }
            else if (sender is IssueControl)
            {
                Debug.Assert(e.SeriesMode == true, "");
                strTargetRecPath = this.issueControl1.TargetRecPath;
            }
            else if (sender is IssueManageControl)
            {
                Debug.Assert(e.SeriesMode == true, "");
                strTargetRecPath = this.issueControl1.TargetRecPath;
            }
            else
            {
                Debug.Assert(false, "");
                strTargetRecPath = this.orderControl1.TargetRecPath;
            }


            EntityForm form = null;

            // 4) 这里的路径为空,表示需要通过菜单选择目标库,然后处理方法同3)
            if (String.IsNullOrEmpty(strTargetRecPath) == true)
            {
                string strBiblioRecPath = "";

                if (e.SeriesMode == false)
                {
                    // 图书。

                    // TODO: 如果为工作库,当对话框打开后,缺省选定源库名? 这样会方便了脱离验收窗的实体窗独立验收操作

                    // 根据书目库名获得MARC格式语法名
                    // return:
                    //      null    没有找到指定的书目库名
                    string strCurSyntax = MainForm.GetBiblioSyntax(this.BiblioDbName);
                    if (strCurSyntax == null)
                    {
                        e.ErrorInfo = "书目库名 '" + this.BiblioDbName + "' 居然没有找到";
                        return;
                    }

                    // TODO: 如果可选列表为一个库名,那就最好不必让用户选了?

                    // 获得一个目标库名
                    GetAcceptTargetDbNameDlg dlg = new GetAcceptTargetDbNameDlg();
                    MainForm.SetControlFont(dlg, this.Font, false);
                    dlg.AutoFinish = true;
                    dlg.SeriesMode = e.SeriesMode;
                    dlg.MainForm = this.MainForm;
                    dlg.DbName = this.BiblioDbName;
                    // 根据当前所在的库的marc syntax限制一下目标库的范围
                    dlg.MarcSyntax = strCurSyntax;

                    dlg.ShowDialog(this);

                    if (dlg.DialogResult != DialogResult.OK)
                    {
                        e.ErrorInfo = "放弃创建实体记录";
                        return;
                    }

                    // 如果目标库名和当前窗口的书目记录路径中的库名相同,则意味着目标记录就是当前记录,而不必新建记录
                    if (dlg.DbName == this.BiblioDbName)
                    {
                        strBiblioRecPath = this.BiblioRecPath;
                    }
                    else
                    {
                        strBiblioRecPath = dlg.DbName + "/?";
                    }
                }
                else
                {
                    // 2009/11/9 
                    // 期刊。禁止验收到其他记录的能力。直接验收到源记录。
                    strBiblioRecPath = this.BiblioRecPath;
                }

                // 新打开一个EntityForm
                if (strBiblioRecPath == this.BiblioRecPath)
                {
                    // 如果涉及当前记录,不必新开EntityForm窗口了
                    form = this;
                }
                else
                {
                    form = new EntityForm();
                    form.MdiParent = this.MdiParent;
                    form.MainForm = this.MainForm;
                    form.Show();

                    // 设置MARC记录
                    // ??? e.BiblioRecord 
                    form.m_marcEditor.Marc = this.GetMarc();    //  this.m_marcEditor.Marc;

                    form.BiblioRecPath = strBiblioRecPath;
                }

                form.EnableItemsPage(true);

                // TODO: 在创建实体记录过程中,是否允许立即输入册条码号?
                // 输入册条码号的同时,要醒目显示条码所对应的馆藏地点,以便工作人员分类摆放图书
                // 也建议dp2Circulation提供一个通过扫册条码快速观察馆藏地点的功能窗口

                goto CREATE_ENTITY;
            }

            // 3) 这里的路径仅有库名部分,表示种记录不存在,需要根据当前记录的MARC来创建;
            /*
            string strID = Global.GetID(this.TargetRecPath);
            if (String.IsNullOrEmpty(strID) == true
                || strID == "?")
             * */
            if (Global.IsAppendRecPath(this.TargetRecPath) == true)   // 2008/12/3 
            {
                string strDbName = Global.GetDbName(strTargetRecPath);

                // 路径全为空的情况已经走到前面的分支内了,不会走到这里
                Debug.Assert(String.IsNullOrEmpty(strDbName) == false, "路径全为空的情况已经走到前面的分支内了,不会走到这里");

                // TODO: 需要检查一下strDbName中的数据库名是否确实为目标库

                string strBiblioRecPath = "";

                // 如果目标库名和当前窗口的书目记录路径中的库名相同,则意味着目标记录就是当前记录,而不必新建记录
                if (strDbName == this.BiblioDbName)
                {
                    strBiblioRecPath = this.BiblioRecPath;
                }
                else
                {
                    strBiblioRecPath = strDbName + "/?";
                }

                // 新打开一个EntityForm
                if (strBiblioRecPath == this.BiblioRecPath)
                {
                    // 如果涉及当前记录,不必新开EntityForm窗口了
                    form = this;
                }
                else
                {
                    form = new EntityForm();
                    form.MdiParent = this.MdiParent;
                    form.MainForm = this.MainForm;
                    form.Show();
                }

                // 设置MARC记录
                form.m_marcEditor.Marc = this.GetMarc();    //  this.m_marcEditor.Marc;
                form.BiblioRecPath = strBiblioRecPath;
                form.EnableItemsPage(true);


                goto CREATE_ENTITY;
            }

            // 1)这里的路径和当前记录路径一致,表明实体记录就创建在当前记录下;
            if (this.entityControl1.BiblioRecPath == strTargetRecPath)
            {

                // 不要求保存
                form = this;
                goto CREATE_ENTITY;
            }


            // 2) 目标记录路径和当前记录路径不一致,不过目标种记录已经存在,需要在它下面创建实体记录;

            {
                Debug.Assert(strTargetRecPath != this.BiblioRecPath, "新开窗口,必须不涉及当前书目记录");

                Debug.Assert(form == null, "");

                // 新打开一个EntityForm
                form = new EntityForm();
                form.MdiParent = this.MdiParent;
                form.MainForm = this.MainForm;
                form.Show();

                nRet = form.LoadRecordOld(strTargetRecPath,
                    "",
                    false);
                if (nRet != 1)
                {
                    e.ErrorInfo = "目标书目记录 " + strTargetRecPath + " 装载失败";
                    return;
                }

                // items page自然会被显示出来

                goto CREATE_ENTITY;
            }

        CREATE_ENTITY:

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

            List<InputBookItem> bookitems = new List<InputBookItem>();

            LibraryChannel channel = this.GetChannel();
            try
            {
                // 创建实体记录
                for (int i = 0; i < e.DataList.Count; i++)
                {
                    GenerateEntityData data = e.DataList[i];

                    BookItem bookitem = null;
                    // 外部调用,设置一个实体记录。
                    // 具体动作有:new change delete
                    nRet = form.entityControl1.DoSetEntity(
                        channel,
                        false,
                        data.Action,
                        data.RefID,
                        data.Xml,
                        out bookitem,
                        out strError);
                    if (nRet == -1 || nRet == 1)
                    {
                        Debug.Assert(nRet != 1, "");
                        data.ErrorInfo = strError;
                    }

                    if (data.Action == "new")
                    {
                        InputBookItem input_bookitem = new InputBookItem();
                        input_bookitem.Sequence = data.Sequence;
                        input_bookitem.OtherPrices = data.OtherPrices;
                        input_bookitem.BookItem = bookitem;
                        bookitems.Add(input_bookitem);
                    }
                }

                if (bookitems.Count > 0
                    && e.InputItemBarcode == true)  // 2009/1/15 
                {
                    // 要求输入若干条码
                    InputItemBarcodeDialog item_barcode_dlg = new InputItemBarcodeDialog();
                    MainForm.SetControlFont(item_barcode_dlg, this.Font, false);

                    item_barcode_dlg.AppInfo = this.MainForm.AppInfo;
                    item_barcode_dlg.SeriesMode = e.SeriesMode; // 2008/12/27 

                    item_barcode_dlg.DetectBarcodeDup -= new DetectBarcodeDupHandler(item_barcode_dlg_DetectBarcodeDup);
                    item_barcode_dlg.DetectBarcodeDup += new DetectBarcodeDupHandler(item_barcode_dlg_DetectBarcodeDup);

                    item_barcode_dlg.VerifyBarcode -= new VerifyBarcodeHandler(item_barcode_dlg_VerifyBarcode);
                    item_barcode_dlg.VerifyBarcode += new VerifyBarcodeHandler(item_barcode_dlg_VerifyBarcode);

                    item_barcode_dlg.EntityControl = form.entityControl1;
                    item_barcode_dlg.BookItems = bookitems;

                    this.MainForm.AppInfo.LinkFormState(item_barcode_dlg, "entityform_inputitembarcodedlg_state");
                    item_barcode_dlg.ShowDialog(this);
                    this.MainForm.AppInfo.UnlinkFormState(item_barcode_dlg);

                    if (item_barcode_dlg.DialogResult != DialogResult.OK)
                    {
                    }
                }

                // ??
                // 将最终保存后获得的书目记录路径记载到TargetRecPath中
                strTargetRecPath = form.BiblioRecPath;
                if (sender is OrderControl)
                    this.orderControl1.TargetRecPath = strTargetRecPath;
                else if (sender is IssueControl)
                    this.issueControl1.TargetRecPath = strTargetRecPath;
                else if (sender is IssueManageControl)
                    this.issueControl1.TargetRecPath = strTargetRecPath;

                // 设置MARC记录
                if (String.IsNullOrEmpty(e.BiblioRecord) == false)
                {
                    Debug.Assert(e.BiblioSyntax == "unimarc"
                        || e.BiblioSyntax == "usmarc"
                        || e.BiblioSyntax == "marc"
                        || e.BiblioSyntax == "xml",
                        "");
                    nRet = form.ImportRecordString(e.BiblioSyntax,
                        e.BiblioRecord,
                        out strError);
                    if (nRet == -1)
                    {
                        e.ErrorInfo = strError;
                        return;
                    }
                }

                // 为新的册记录创建索取号
                if (e.CreateCallNumber == true && bookitems.Count > 0)
                {
                    // 选定新的册记录事项
                    List<BookItem> items = new List<BookItem>();
                    foreach (InputBookItem input_item in bookitems)
                    {
                        items.Add(input_item.BookItem);
                    }
                    // 在listview中选定指定的事项
                    nRet = form.EntityControl.SelectItems(
                       true,
                       items);
                    if (nRet < items.Count)
                    {
                        e.ErrorInfo = "SetlectItems()未能选定要求的全部事项";
                        form.ActivateItemsPage();
                        return;
                    }

                    // 为当前选定的事项创建索取号
                    // return:
                    //      -1  出错
                    //      0   放弃处理
                    //      1   已经处理
                    nRet = form.EntityControl.CreateCallNumber(
                        false,
                        out strError);
                    if (nRet == -1)
                    {
                        /*
                        e.ErrorInfo = "创建索取号时发生错误: " + strError;
                        form.ActivateItemsPage();
                        return;
                         * */
                        // 警告性质
                        // 2012/9/1
                        this.ActivateItemsPage();
                        MessageBox.Show(this, "警告:创建索取号时发生错误: " + strError);
                    }
                }


                // 保存整个记录?
                if (this != form)
                {
                    // 提交所有保存请求
                    // return:
                    //      -1  有错。此时不排除有些信息保存成功。
                    //      0   成功。
                    nRet = form.DoSaveAll();
                    e.TargetRecPath = form.BiblioRecPath;

                    if (form.HasCommentPage == true && form.CommentControl != null
                        && this.HasCommentPage == true && this.CommentControl != null
                        && this.CommentControl.Items.Count > 0)
                    {
                        // 移动、归并评注记录
                        // 改变归属
                        // 即修改实体信息的<parent>元素内容,使指向另外一条书目记录
                        // parameters:
                        //      items   要改变归属的事项集合。如果为 null,表示全部改变归属
                        nRet = this.CommentControl.ChangeParent(null,
                            form.BiblioRecPath,
                            out strError);
                        if (nRet == -1)
                            MessageBox.Show(this, "警告:移动评注记录(" + this.BiblioRecPath + " --> " + form.BiblioRecPath + ")时发生错误: " + strError);

                        // 重新装载评注属性页
                        nRet = form.CommentControl.LoadItemRecords(
                            channel,
                            form.BiblioRecPath,
                            null,
                            "",
                            out strError);
                        if (nRet == -1)
                            MessageBox.Show(this, "警告:重新装载书目记录 " + form.BiblioRecPath + " 的下属评注记录时发生错误: " + strError);

                    }
                }
                else
                {
                    e.TargetRecPath = form.BiblioRecPath;
                }

                // 触发提示通知推荐过的读者
                if (form.HostObject != null)
                {
                    AfterCreateItemsArgs e1 = new AfterCreateItemsArgs();
                    e1.Case = "accept";
                    // form.HostObject.AfterCreateItems(this, e1);
                    form.HostObject.Invoke("AfterCreateItems", this, e1);
                    if (string.IsNullOrEmpty(e.ErrorInfo) == false)
                    {
                        MessageBox.Show(this, "验收中创建册记录的延续工作(AfterCreateItems)失败: " + strError + "\r\n\r\n但保存操作已经成功");
                    }
                }

                // 2013/12/2 移动到这里
                if (this != form)
                {
                    form.Close();
                }
            }
            finally
            {
                this.ReturnChannel(channel);
            }
            return;
        }
Пример #4
0
        // 装入种册窗/实体窗,用册条码号/记录路径
        // parameters:
        //      strTargetFormType   目标窗口类型 "EntityForm" "ItemInfoForm"
        //      strIdType   标识类型 "barcode" "recpath"
        //      strOpenType 打开窗口的方式 "new" "exist"
        void LoadRecord(string strTargetFormType,
            string strIdType,
            string strOpenType)
        {
            string strTargetFormName = "种册窗";
            if (strTargetFormType == "ItemInfoForm")
                strTargetFormName = "实体窗";

            if (this.listView_number.SelectedItems.Count == 0)
            {
                MessageBox.Show(this, "尚未在列表中选定要装入" + strTargetFormName + "的行");
                return;
            }

            string strBarcodeOrRecPath = "";

            if (strIdType == "barcode")
            {
                // barcode
                strBarcodeOrRecPath = ListViewUtil.GetItemText(this.listView_number.SelectedItems[0], 1);
            }
            else
            {
                Debug.Assert(strIdType == "recpath", "");
                // recpath
                strBarcodeOrRecPath = ListViewUtil.GetItemText(this.listView_number.SelectedItems[0], 0);
            }

            if (strTargetFormType == "EntityForm")
            {
                EntityForm form = null;

                if (strOpenType == "exist")
                {
                    form = MainForm.GetTopChildWindow<EntityForm>();
                    if (form != null)
                        Global.Activate(form);
                }
                else
                {
                    Debug.Assert(strOpenType == "new", "");
                }

                if (form == null)
                {
                    form = new EntityForm();

                    form.MdiParent = this.MainForm;

                    form.MainForm = this.MainForm;
                    form.Show();
                }

                if (strIdType == "barcode")
                {
                    // 装载一个册,连带装入种
                    // parameters:
                    //      bAutoSavePrev   是否自动提交保存先前发生过的修改?如果==true,是;如果==false,则要出现MessageBox提示
                    // return:
                    //      -1  error
                    //      0   not found
                    //      1   found
                    form.LoadItemByBarcode(strBarcodeOrRecPath, false);
                }
                else
                {
                    Debug.Assert(strIdType == "recpath", "");

                    // parameters:
                    //      bAutoSavePrev   是否自动提交保存先前发生过的修改?如果==true,是;如果==false,则要出现MessageBox提示
                    // return:
                    //      -1  error
                    //      0   not found
                    //      1   found
                    form.LoadItemByRecPath(strBarcodeOrRecPath, false);
                }
            }
            else
            {
                Debug.Assert(strTargetFormType == "ItemInfoForm", "");

                ItemInfoForm form = null;

                if (strOpenType == "exist")
                {
                    form = MainForm.GetTopChildWindow<ItemInfoForm>();
                    if (form != null)
                        Global.Activate(form);
                }
                else
                {
                    Debug.Assert(strOpenType == "new", "");
                }

                if (form == null)
                {
                    form = new ItemInfoForm();

                    form.MdiParent = this.MainForm;

                    form.MainForm = this.MainForm;
                    form.Show();
                }

                if (strIdType == "barcode")
                {
                    form.LoadRecord(strBarcodeOrRecPath);
                }
                else
                {
                    Debug.Assert(strIdType == "recpath", "");

                    form.LoadRecordByRecPath(strBarcodeOrRecPath, "");
                }
            }
        }
Пример #5
0
        void menu_loadToNewDetailWindow_Click(object sender, EventArgs e)
        {
            if (this.listView_browse.SelectedItems.Count == 0)
            {
                MessageBox.Show(this, "尚未选定要装入种册窗的事项");
                return;
            }
            string strPath = this.listView_browse.SelectedItems[0].SubItems[0].Text;

            EntityForm form = new EntityForm();

            form.MdiParent = this.MainForm;
            form.MainForm = this.MainForm;
            form.Show();
            form.LoadRecordOld(strPath, "", true);
        }
Пример #6
0
        void LoadToEntityForm(ListView list)
        {
            if (list.SelectedItems.Count == 0)
            {
                MessageBox.Show(this, "尚未选定要装载的事项");
                return;
            }

            string strBarcode = list.SelectedItems[0].Text;
            string strRecPath = ListViewUtil.GetItemText(list.SelectedItems[0], COLUMN_RECPATH);

            EntityForm form = new EntityForm();

            form.MainForm = this.MainForm;
            form.MdiParent = this.MainForm;
            form.Show();

            if (String.IsNullOrEmpty(strBarcode) == false)
                form.LoadItemByBarcode(strBarcode, false);
            else
                form.LoadItemByRecPath(strRecPath, false);
        }
Пример #7
0
        // 双击:将书目记录装入详细窗
        private void listView_number_DoubleClick(object sender, EventArgs e)
        {
            if (this.listView_number.SelectedItems.Count == 0)
            {
                MessageBox.Show(this, "尚未选定要装入详细窗的事项");
                return;
            }
            string strPath = this.listView_number.SelectedItems[0].SubItems[0].Text;

            EntityForm form = new EntityForm();

            form.MdiParent = this.MainForm;

            form.MainForm = this.MainForm;
            form.Show();
            form.LoadRecordOld(strPath, "", true);

        }
Пример #8
0
        void menu_loadToNewEntityForm_Click(object sender, EventArgs e)
        {
            if (this.listView_records.SelectedItems.Count == 0)
            {
                MessageBox.Show(this, "尚未选定要装入实体窗口的事项");
                return;
            }
            string strPath = this.listView_records.SelectedItems[0].SubItems[0].Text;

            EntityForm form = null;

            if (form == null)
            {
                form = new EntityForm();

                form.MdiParent = this.MainForm;
                form.MainForm = this.MainForm;
                form.Show();
            }

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

            form.LoadRecordOld(strPath, "", true);
        }
Пример #9
0
        private void listView_records_DoubleClick(object sender, EventArgs e)
        {
            string strError = "";

            if (this.listView_records.SelectedItems.Count == 0)
            {
                strError = "尚未选定要装入种册窗的事项";
                goto ERROR1;
            }

            string strPath = this.listView_records.SelectedItems[0].SubItems[0].Text;

            if (String.IsNullOrEmpty(strPath) == false)
            {
                EntityForm form = null;

                if (this.LoadToExistDetailWindow == true)
                {
                    form = MainForm.GetTopChildWindow<EntityForm>();
                    if (form != null)
                        Global.Activate(form);

                }

                if (form == null)
                {
                    form = new EntityForm();

                    form.MdiParent = this.MainForm;

                    form.MainForm = this.MainForm;
                    form.Show();
                }

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

                if (strPath.IndexOf("@") == -1)
                    form.LoadRecordOld(strPath, "", true);
                else
                {
                    // TODO: 可以允许在 BiblioSearchForm 中被修改过、尚未保存的书目记录装入种册窗进行继续修改
                    if (this.m_biblioTable == null)
                    {
                        strError = "m_biblioTable == null";
                        goto ERROR1;
                    }

                    BiblioInfo info = this.m_biblioTable[strPath] as BiblioInfo;
                    if (info == null)
                    {
                        strError = "m_biblioTable 中不存在 key 为 " + strPath + " 的 BiblioInfo 事项";
                        goto ERROR1;
                    }

                    int nRet = form.LoadRecord(info,
                        true,
                        out strError);
                    if (nRet != 1)
                        goto ERROR1;

                }

            }
            else
            {
                ItemQueryParam query = (ItemQueryParam)this.listView_records.SelectedItems[0].Tag;
                Debug.Assert(query != null, "");

                this.textBox_queryWord.Text = ListViewUtil.GetItemText(this.listView_records.SelectedItems[0], 1);
                if (query != null)
                {
                    this.checkedComboBox_biblioDbNames.Text = query.DbNames;
                    this.comboBox_from.Text = query.From;
                }

                if (this.textBox_queryWord.Text == "")
                    this.comboBox_matchStyle.Text = "空值";
                else
                    this.comboBox_matchStyle.Text = "精确一致";

                DoSearch(false, false, null);
            }
            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
Пример #10
0
        void menu_createCallNumber_Click(object sender, EventArgs e)
        {
            string strError = "";
            int nRet = 0;

            Debug.Assert(this.DbType == "item", "");

            if (this.listView_records.SelectedItems.Count == 0)
            {
                strError = "尚未选定要进行批处理的事项";
                goto ERROR1;
            }

            if (stop != null && stop.State == 0)    // 0 表示正在处理
            {
                strError = "目前有长操作正在进行,无法进行创建索取号的操作";
                goto ERROR1;
            }

            bool bOverwrite = false;
            {
                DialogResult result = MessageBox.Show(this,
    "在后面即将进行的处理过程中,对已经存在索取号的册记录,是否要重新创建索取号?\r\n\r\n(Yes: 要重新创建;No: 不重新创建,即:跳过;Cancel: 现在就放弃本次批处理)",
    this.DbType + "SearchForm",
    MessageBoxButtons.YesNoCancel,
    MessageBoxIcon.Question,
    MessageBoxDefaultButton.Button2);
                if (result == System.Windows.Forms.DialogResult.Yes)
                    bOverwrite = true;
                else if (result == System.Windows.Forms.DialogResult.No)
                    bOverwrite = false;
                else
                    return;

            }

            int nCount = 0;

            stop.Style = StopStyle.EnableHalfStop;
            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在创建索取号 ...");
            stop.BeginLoop();

            this.EnableControls(false);
            try
            {

                // 打开一个新的种册窗
                EntityForm form = null;

                form = new EntityForm();

                form.MdiParent = this.MainForm;

                form.MainForm = this.MainForm;
                form.Show();

                stop.SetProgressRange(0, this.listView_records.SelectedItems.Count);

                ItemSearchForm itemsearchform = null;
                bool bHideMessageBox = false;

                int i = 0;
                foreach (ListViewItem item in this.listView_records.SelectedItems)
                {
                    Application.DoEvents();	// 出让界面控制权

                    if (stop != null)
                    {
                        if (stop.State != 0)
                        {
                            MessageBox.Show(this, "用户中断");
                            return;
                        }
                    }

                    string strRecPath = ListViewUtil.GetItemText(item, 0);

                    // parameters:
                    //      bAutoSavePrev   是否自动提交保存先前发生过的修改?如果==true,是;如果==false,则要出现MessageBox提示
                    // return:
                    //      -1  error
                    //      0   not found
                    //      1   found
                    form.LoadItemByRecPath(strRecPath, true);

                    // 为当前选定的事项创建索取号
                    // return:
                    //      -1  出错
                    //      0   放弃处理
                    //      1   已经处理
                    nRet = form.EntityControl.CreateCallNumber(bOverwrite, out strError);
                    if (nRet == -1)
                        goto ERROR;

                    if (nRet == 1)
                    {
                        nCount++;
                        // form.DoSaveAll();
                        nRet = form.EntityControl.SaveItems(
                            this.Channel,
                            out strError);
                        if (nRet == -1)
                            goto ERROR;

                        nRet = RefreshBrowseLine(item,
    out strError);
                        if (nRet == -1)
                        {
                            strError = "刷新浏览内容时出错: " + strError;
                            goto ERROR;
#if NO
                            DialogResult result = MessageBox.Show(this,
                                "刷新浏览内容时出错: " + strError + "。\r\n\r\n是否继续刷新? (OK 刷新;Cancel 放弃刷新)",
                                this.DbType + "SearchForm",
                                MessageBoxButtons.OKCancel,
                                MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button1);
                            if (result == System.Windows.Forms.DialogResult.Cancel)
                                break;
#endif
                        }
                    }

                ERROR:
                    if (nRet == -1)
                    {
                        if (itemsearchform == null)
                        {
                            Form active_mdi = this.MainForm.ActiveMdiChild;

                            itemsearchform = new ItemSearchForm();
                            itemsearchform.MdiParent = this.MainForm;
                            itemsearchform.MainForm = this.MainForm;
                            itemsearchform.Show();
                            itemsearchform.QueryWordString = "创建索取号过程中出错的册记录";

                            active_mdi.Activate();
                        }

                        ListViewItem new_item = itemsearchform.AddLineToBrowseList(Global.BuildLine(item));
                        ListViewUtil.ChangeItemText(new_item, 1, strError);

                        this.OutputText(strRecPath + " : " + strError, 2);

                        strError = "在为册记录 " + strRecPath + " 创建索取号时出错: " + strError;

                        if (bHideMessageBox == false)
                        {
                            DialogResult result = MessageDialog.Show(this,
                                strError + "。\r\n\r\n是否继续处理后面的记录? (继续: 继续;停止: 停止整个批处理)",
            MessageBoxButtons.OKCancel,
            MessageBoxDefaultButton.Button1,
            "不再出现此对话框",
            ref bHideMessageBox,
            new string[] { "继续", "停止" });
                            if (result == System.Windows.Forms.DialogResult.Cancel)
                                goto ERROR1;
                        }
                        form.EntitiesChanged = false;
                    }

                    stop.SetProgressValue(++i);
                }

                // form.DoSaveAll();
                form.Close();
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");
                stop.HideProgress();
                stop.Style = StopStyle.None;

                this.EnableControls(true);
            }

            MessageBox.Show(this, "共处理 " + nCount.ToString() + " 个册记录");
            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
Пример #11
0
        // 装入种册窗/实体窗,用册条码号/记录路径
        // parameters:
        //      strTargetFormType   目标窗口类型 "EntityForm" "ItemInfoForm"
        //      strIdType   标识类型 "barcode" "recpath"
        //      strOpenType 打开窗口的方式 "new" "exist"
        void LoadRecord(string strTargetFormType,
            string strIdType,
            string strOpenType)
        {
            string strTargetFormName = "种册窗";

            if (strTargetFormType == "ItemInfoForm")
                strTargetFormName = "实体窗";

            if (this.listView_records.SelectedItems.Count == 0)
            {
                MessageBox.Show(this, "尚未在列表中选定要装入" + strTargetFormName + "的行");
                return;
            }

            string strBarcodeOrRecPath = "";

            if (strIdType == "barcode")
            {
                // barcode
                // strBarcodeOrRecPath = ListViewUtil.GetItemText(this.listView_records.SelectedItems[0], 1);
                string strError = "";
                // 根据 ListViewItem 对象,获得册条码号列的内容
                int nRet = GetItemBarcodeOrRefID(
                    this.listView_records.SelectedItems[0],
                    true,
                    out strBarcodeOrRecPath,
                    out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                    return;
                }
            }
            else
            {
                Debug.Assert(strIdType == "recpath", "");
                // recpath
                strBarcodeOrRecPath = ListViewUtil.GetItemText(this.listView_records.SelectedItems[0], 0);
            }

            if (strTargetFormType == "EntityForm")
            {
                EntityForm form = null;

                if (strOpenType == "exist")
                {
                    form = MainForm.GetTopChildWindow<EntityForm>();
                    if (form != null)
                        Global.Activate(form);
                }
                else
                {
                    Debug.Assert(strOpenType == "new", "");
                }

                if (form == null)
                {
                    form = new EntityForm();

                    form.MdiParent = this.MainForm;

                    form.MainForm = this.MainForm;
                    form.Show();
                }

                if (strIdType == "barcode")
                {
                    // 装载一个册,连带装入种
                    // parameters:
                    //      bAutoSavePrev   是否自动提交保存先前发生过的修改?如果==true,是;如果==false,则要出现MessageBox提示
                    // return:
                    //      -1  error
                    //      0   not found
                    //      1   found
                    form.LoadItemByBarcode(strBarcodeOrRecPath, false);
                }
                else
                {
                    Debug.Assert(strIdType == "recpath", "");

                    if (this.DbType == "item")
                    {
                        // parameters:
                        //      bAutoSavePrev   是否自动提交保存先前发生过的修改?如果==true,是;如果==false,则要出现MessageBox提示
                        // return:
                        //      -1  error
                        //      0   not found
                        //      1   found
                        form.LoadItemByRecPath(strBarcodeOrRecPath, false);
                    }
                    else if (this.DbType == "comment")
                        form.LoadCommentByRecPath(strBarcodeOrRecPath, false);
                    else if (this.DbType == "order")
                        form.LoadOrderByRecPath(strBarcodeOrRecPath, false);
                    else if (this.DbType == "issue")
                        form.LoadIssueByRecPath(strBarcodeOrRecPath, false);
                    else
                        throw new Exception("未知的DbType '" + this.DbType + "'");
                }
            }
            else
            {
                Debug.Assert(strTargetFormType == "ItemInfoForm", "");

                ItemInfoForm form = null;

                if (strOpenType == "exist")
                {
                    form = MainForm.GetTopChildWindow<ItemInfoForm>();
                    if (form != null)
                        Global.Activate(form);
                }
                else
                {
                    Debug.Assert(strOpenType == "new", "");
                }

                if (form == null)
                {
                    form = new ItemInfoForm();

                    form.MdiParent = this.MainForm;

                    form.MainForm = this.MainForm;
                    form.Show();
                }

                if (this.DbType == "arrive")
                    form.DbType = "item";
                else
                    form.DbType = this.DbType;

                if (strIdType == "barcode")
                {
                    Debug.Assert(this.DbType == "item" || this.DbType == "arrive", "");
                    form.LoadRecord(strBarcodeOrRecPath);
                }
                else
                {
                    Debug.Assert(strIdType == "recpath", "");

                    // TODO: 需要改造为适应多种记录
                    form.LoadRecordByRecPath(strBarcodeOrRecPath, "");
                }
            }
        }
Пример #12
0
        // 装入种册窗,用册条码号
        void menu_loadToEntityFormByBarcode_Click(object sender, EventArgs e)
        {
            if (this.listView_records.SelectedItems.Count == 0)
            {
                MessageBox.Show(this, "尚未在列表中选定要装入种册窗的册事项");
                return;
            }

            string strBarcode = ListViewUtil.GetItemText(this.listView_records.SelectedItems[0], 1);

            EntityForm form = null;

            if (this.LoadToExistDetailWindow == true)
            {
                form = MainForm.TopEntityForm;
                if (form != null)
                    form.Activate();
            }

            if (form == null)
            {
                form = new EntityForm();

                form.MdiParent = this.MainForm;

                form.MainForm = this.MainForm;
                form.Show();
            }

            // 装载一个册,连带装入种
            // parameters:
            //      bAutoSavePrev   是否自动提交保存先前发生过的修改?如果==true,是;如果==false,则要出现MessageBox提示
            // return:
            //      -1  error
            //      0   not found
            //      1   found
            form.LoadItem(strBarcode, false);
        }