Exemple #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);

            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);
        }
Exemple #2
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);
        }