Ejemplo n.º 1
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);
            string strRefID = ListViewUtil.GetItemText(list.SelectedItems[0], COLUMN_REFID);

            EntityForm form = new EntityForm();

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

            if (String.IsNullOrEmpty(strBarcode) == false)
                form.LoadItemByBarcode(strBarcode, false);
            else if (String.IsNullOrEmpty(strRecPath) == false)
                form.LoadItemByRecPath(strRecPath, false);
            else if (String.IsNullOrEmpty(strRefID) == false)
                form.LoadItemByRefID(strRefID, false);
            else
            {
                form.Close();
                MessageBox.Show(this, "所选定行的条码号、记录路径、参考ID全都为空,无法定位记录");
            }
        }
Ejemplo 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;
        }
Ejemplo n.º 3
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);
        }