Exemplo n.º 1
0
        /*
        void entityControl1_GenerateAccessNo(object sender, GenerateDataEventArgs e)
        {
            CreateCallNumber(sender, e);
        }*/

        void issueControl1_GenerateEntity(object sender, GenerateEntityEventArgs e)
        {
            orderControl1_GenerateEntity(sender, e);
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
        // parameters:
        //      deleted_ids 已经成功删除的id
        int DeleteItemRecords(List<string> ids,
            out List<string> deleted_ids,
            out string strError)
        {
            strError = "";
            deleted_ids = new List<string>();

            Debug.Assert(this.GenerateEntity != null, "");

            GenerateEntityEventArgs data_container = new GenerateEntityEventArgs();
            // data_container.InputItemBarcode = this.InputItemsBarcode;
            data_container.SeriesMode = true;

            for (int i = 0; i < ids.Count; i++)
            {
                GenerateEntityData e = new GenerateEntityData();

                e.Action = "delete";
                e.RefID = ids[i];
                e.Xml = "";

                data_container.DataList.Add(e);
            }

            if (data_container.DataList != null
    && data_container.DataList.Count > 0)
            {
                // 调用外部挂接的事件
                this.GenerateEntity(this, data_container);
                string strErrorText = "";

                if (String.IsNullOrEmpty(data_container.ErrorInfo) == false)
                {
                    strError = data_container.ErrorInfo;
                    return -1;
                }

                for (int i = 0; i < data_container.DataList.Count; i++)
                {
                    GenerateEntityData data = data_container.DataList[i];
                    if (String.IsNullOrEmpty(data.ErrorInfo) == false)
                    {
                        strErrorText += data.ErrorInfo;
                    }
                    else
                        deleted_ids.Add(data.RefID);
                }

                if (String.IsNullOrEmpty(strErrorText) == false)
                {
                    strError = strErrorText;
                    return -1;
                }
            }

            return 0;
        }