コード例 #1
0
ファイル: InventoryForm.cs プロジェクト: renyh1013/dp2
        public InventoryForm()
        {
            InitializeComponent();

            this.DbType = "inventory";

            _chargingForm = new QuickChargingForm();
            this.tabPage_scan.Padding = new Padding(4, 4, 4, 4);
            this.tabPage_scan.Controls.Add(_chargingForm.MainPanel);
            _chargingForm.MainPanel.Dock = DockStyle.Fill;

            {
                ListViewProperty prop = new ListViewProperty();
                this.listView_inventoryList_records.Tag = prop;
                // 第一列特殊,记录路径
                prop.SetSortStyle(0, ColumnSortStyle.RecPath);
                prop.GetColumnTitles -= new GetColumnTitlesEventHandler(prop_GetColumnTitles);
                prop.GetColumnTitles += new GetColumnTitlesEventHandler(prop_GetColumnTitles);

                prop.CompareColumn -= new CompareEventHandler(prop_CompareColumn);
                prop.CompareColumn += new CompareEventHandler(prop_CompareColumn);
            }

            {
                ListViewProperty prop = new ListViewProperty();
                this.listView_baseList_records.Tag = prop;
                // 第一列特殊,记录路径
                prop.SetSortStyle(0, ColumnSortStyle.RecPath);
                prop.GetColumnTitles -= new GetColumnTitlesEventHandler(prop_GetBaseListColumnTitles);
                prop.GetColumnTitles += new GetColumnTitlesEventHandler(prop_GetBaseListColumnTitles);

                prop.CompareColumn -= new CompareEventHandler(prop_CompareColumn2);
                prop.CompareColumn += new CompareEventHandler(prop_CompareColumn2);
            }

        }
コード例 #2
0
        void _scanBarcodeForm_BarcodeScaned(object sender, ScanedEventArgs e)
        {
            string strError = "";
            int    nRet     = 0;

            if (string.IsNullOrEmpty(e.Barcode) == true)
            {
                Console.Beep();
                return;
            }

            // 自动切换到 登记 属性页,避免操作者看不到扫入了什么内容
            if (this.tabControl_main.SelectedTab != this.tabPage_register)
            {
                this.tabControl_main.SelectedTab = this.tabPage_register;
            }

            // 清除浮动的错误信息
            this._floatingMessage.Text = "";

            // 把册条码号直接加入行中,然后等待专门的线程来装载刷新
            // 要查重
#if NO
            ListViewItem dup = ListViewUtil.FindItem(this.listView_in, e.Barcode, COLUMN_BARCODE);
            if (dup != null)
            {
                Console.Beep();
                ListViewUtil.SelectLine(dup, true);
                MessageBox.Show(this, "您扫入的册条码号 ‘" + e.Barcode + "’ 在列表中已经存在了,请注意不要重复扫入");
                this._scanBarcodeForm.Activate();
                return;
            }

            ListViewItem item = new ListViewItem();
            ListViewUtil.ChangeItemText(item, COLUMN_BARCODE, e.Barcode);
            this.listView_in.Items.Add(item);
            ListViewUtil.SelectLine(item, true);
            item.EnsureVisible();
#endif
            string strText = e.Barcode;

            // 如果是 ISBN,则新装入一个书目记录
            // TODO: 装入前需要对整个 list 进行查重,如果前面已经有同样 ISBN 的书目,要提醒
            if (QuickChargingForm.IsISBN(ref strText) == true)
            {
#if NO
                RegisterLine line = new RegisterLine(this.entityRegisterControl1);
                line.BiblioBarcode = strText;

                this.entityRegisterControl1.InsertNewLine(0, line, true);
                line.label_color.Focus();

                this.entityRegisterControl1.SetColorList();

                this.entityRegisterControl1.AddTask(line, "search_biblio");

                // 选定刚新增的事项
                this.entityRegisterControl1.SelectItem(line, true);
                // 确保事项可见
                this.entityRegisterControl1.EnsureVisible(line);
#endif
                this.entityRegisterControl1.AddNewBiblio(strText);
            }
            else
            {
                // 当作册条码号进入
                nRet = this.entityRegisterControl1.AddNewEntity(strText,
                                                                out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }
            }

            // this.entityRegisterControl1.ActivateThread();
            return;

ERROR1:
            MessageBox.Show(this, strError);
            this._scanBarcodeForm.Focus();
        }
コード例 #3
0
ファイル: KeyboardForm.cs プロジェクト: zszqwe/dp2
        private void button_scan_Click(object sender, EventArgs e)
        {
            string strError = "";
            int    nRet     = 0;

            this.textBox_input.SelectAll();
            this.textBox_input.Focus();

            if (this._step == Step.PrepareSearchBiblio)
            {
                this.BaseForm.QueryWord = this.textBox_input.Text;
                this._lastISBN          = this.textBox_input.Text;
                // 显示“正在检索”
                this.SetStep(Step.SearchingBiblio);
                this.BaseForm.DoSearch(this.textBox_input.Text, "ISBN", false);
                this.SetStep(Step.SearchBiblioCompleted);
                // 如果检索命中,要选择后,切换到下一页。选择方面,可以提示输入 1 2 3 4 等用以选择
                // 如果检索没有命中,提示再次扫入相同的 ISBN,可以直接进入创建新记录流程
                if (this.BaseForm.SearchResultErrorCount > 0)
                {
                    this.SetStep(Step.SearchBiblioError);
                }
                else if (this.BaseForm.SearchResultCount > 0)
                {
                    if (this.BaseForm.SearchResultCount == 1)
                    {
                        // 命中唯一的一条
                        this.EditSelectedBrowseLine();
                        // 观察书目记录包含多少册记录。
                        this.SetStep(Step.EditEntity);
                        return;
                    }
                    this.textBox_input.Text = "1";
                    this.SetStep(Step.SelectSearchResult);
                }
                else
                {
                    Debug.Assert(this.BaseForm.SearchResultCount == 0, "");

                    // 没有命中。当再次输入同样的 ISBN, 表示创建新书目记录
                    this.SetStep(Step.SearchBiblioNotFound);
                }
                return;
            }

            if (this._step == Step.SelectSearchResult)
            {
                int index = 0;

                // 如果输入刚才用过的 ISBN ,表示选择第一个记录
                if (this.textBox_input.Text == this._lastISBN && string.IsNullOrEmpty(this._lastISBN) == false)
                {
                    index = 1;
                }
                else
                {
                    // 根据输入的数字挑选命中记录
                    if (StringUtil.IsPureNumber(this.textBox_input.Text) == false)
                    {
                        strError = "请输入一个数字";
                        goto ERROR1;
                    }

                    if (int.TryParse(this.textBox_input.Text, out index) == false)
                    {
                        strError = "输入的应该是一个数字";
                        goto ERROR1;
                    }

                    // TODO: 可以根据检索命中列表中事项的最大个数,探测 input 中输入达到这么多个字符后不需要按回车键就可以开始后续处理

                    if (index - 1 >= this.BaseForm.ResultListCount)
                    {
                        strError = "请输入一个 1-" + (this.BaseForm.ResultListCount + 1).ToString() + " 之间的数字";
                        goto ERROR1;
                    }
                }
                this.BaseForm.SelectBrowseLine(true, index - 1);
                this.EditSelectedBrowseLine();
                // 观察书目记录包含多少册记录。
                this.SetStep(Step.EditEntity);
                return;
            }

            if (this._step == Step.SearchBiblioNotFound)
            {
                // 如果输入刚才用过的 ISBN ,表示创建新书目记录
                if (this.textBox_input.Text == this._lastISBN && string.IsNullOrEmpty(this._lastISBN) == false)
                {
                    nRet = this.BaseForm.NewBiblio(false);
                    if (nRet == -1)
                    {
                        this.DisplayError("操作出错");
                        return;
                    }
                    this.SetStep(Step.EditBiblio);
                    return;
                }
                else
                {
                    string strText = this.textBox_input.Text;
                    this.SetStep(Step.PrepareSearchBiblio);
                    this.textBox_input.Text = strText;
                    this.BeginInvoke(new Action <object, EventArgs>(button_scan_Click), this, new EventArgs());
                    return;
                }
                //return;
            }

            if (this._step == Step.EditBiblio)
            {
                // 观察输入的字符串,如果和检索使用过的 ISBN 一致,则增加一个册(册条码号为空);
                // 如果是其他 ISBN,则回到检索画面自动启动检索书目;
                // 如果不是 ISBN,则当作为当前书目字段输入内容

                string strText = this.textBox_input.Text;

                if (strText == this._lastISBN && string.IsNullOrEmpty(this._lastISBN) == false)
                {
                    // 将上一个 EntityEditControl 中的蓝色行标记清除
                    if (this._currentEntityControl != null)
                    {
                        this.BaseForm.DisableWizardControl();
                        this._currentEntityControl.ClearActiveState();
                        this.BaseForm.EnableWizardControl();
                    }
                    this._currentEntityControl = this.BaseForm.AddNewEntity("", false);
                    this._currentEntityLine    = null;
#if NO
                    // 越过第一个字段
                    this._currentEntityLine = GetNextEntityLine(this._currentEntityLine);
#endif
                    return;
                }

                if (QuickChargingForm.IsISBN(ref strText) == true)
                {
                    this.SetStep(Step.PrepareSearchBiblio);
                    this.textBox_input.Text = strText;
                    this.BeginInvoke(new Action <object, EventArgs>(button_scan_Click), this, new EventArgs());
                    return;
                }
                else
                {
                    // 为当前子字段添加内容,顺次进入下一子字段。等所有字段都输入完以后,自动进入 EditEntity 状态
                    if (this._currenBiblioLine != null)
                    {
                        if (string.IsNullOrEmpty(this.textBox_input.Text) == true)
                        {
                            List <EasyLine> selected_lines = new List <EasyLine>();
                            selected_lines.Add(this._currenBiblioLine);
                            EasyMarcControl container = this._currenBiblioLine.Container;
                            // 删除前要先找到上一个行。否则删除后查找将无法继续
                            this._currenBiblioLine = GetPrevBiblioLine(this._currenBiblioLine);
                            // 删除
                            container.DeleteElements(selected_lines);
                        }
                        else
                        {
                            this._currenBiblioLine.Content = this.textBox_input.Text;
                            this.textBox_input.Text        = "";
                        }
                        SetStep(Step.EditBiblio);
                    }
                    else
                    {
                        this.textBox_input.Text = "";
                        SetStep(Step.EditEntity);
                    }
                    return;
                }
            }

            if (this._step == Step.EditEntity)
            {
                // 观察输入的字符串,如果和检索使用过的 ISBN 一致,则增加一个册(册条码号为空);
                // 如果是其他 ISBN,则回到检索画面自动启动检索书目;
                // 如果不是 ISBN,则当作册条码号增加一个册

                string strText = this.textBox_input.Text;

                if (strText == this._lastISBN && string.IsNullOrEmpty(this._lastISBN) == false)
                {
                    // 将上一个 EntityEditControl 中的蓝色行标记清除
                    if (this._currentEntityControl != null)
                    {
                        this.BaseForm.DisableWizardControl();
                        this._currentEntityControl.ClearActiveState();
                        this.BaseForm.EnableWizardControl();
                    }

                    this._currentEntityControl = this.BaseForm.AddNewEntity("", false);
                    this._currentEntityLine    = null;
#if NO
                    // 越过第一个字段
                    this._currentEntityLine = GetNextEntityLine(this._currentEntityLine);
#endif
                    this.BeginInvoke(new Func <Step, string, bool>(SetStep), Step.EditEntity, "");
                    return;
                }

                if (QuickChargingForm.IsISBN(ref strText) == true)
                {
                    // TODO: 连带引起保存书目和册记录可能会失败哟
                    if (this.SetStep(Step.PrepareSearchBiblio) == false)
                    {
                        return;
                    }
                    this.textBox_input.Text = strText;
                    this.BeginInvoke(new Action <object, EventArgs>(button_scan_Click), this, new EventArgs());
                    return;
                }
                else
                {
                    // 首次输入册条码号。还没有关联的 EntityEditControl
                    if (this._currentEntityControl == null)
                    {
                        this._currentEntityControl = this.BaseForm.AddNewEntity(strText, false);
                        this._currentEntityLine    = null;
                        // 越过第一个字段
                        this._currentEntityLine = GetNextEntityLine(this._currentEntityLine);

                        this.BeginInvoke(new Func <Step, string, bool>(SetStep), Step.EditEntity, "");
                        return;
                    }
                    // 为册编辑器当前行输入内容,顺次进入下一行。等所有字段都输入完以后,自动进入 EditEntity 等待输入册条码号的状态
                    if (this._currentEntityLine != null)
                    {
                        this._currentEntityLine.Content = this.textBox_input.Text;
                        this.textBox_input.Text         = "";

                        SetStep(Step.EditEntity);
                    }
                    else
                    {
                        // 进入首次等待输入册条码号的状态
                        this._currentEntityControl = null;
                        this._currentEntityLine    = null;
                        this.textBox_input.Text    = "";
                        SetStep(Step.EditEntity);
                    }
                    return;
                }
            }
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
コード例 #4
0
ファイル: ItemHandoverForm.cs プロジェクト: renyh1013/dp2
        // 进行还书操作
        // return:
        //      -1  出错
        //      其他  处理的事项数
        int DoReturn(List<ListViewItem> items,
            out string strError)
        {
            strError = "";
            //int nRet = 0;

            if (items.Count == 0)
            {
                strError = "尚未给出要还书的事项";
                return -1;
            }

            if (stop != null && stop.State == 0)    // 0 表示正在处理
            {
                strError = "目前有长操作正在进行,无法进行还书的操作";
                return -1;
            }

            string strOperName = "还书";

            int nCount = 0;
            List<ListViewItem> oper_items = new List<ListViewItem>();

            stop.Style = StopStyle.EnableHalfStop;
            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在进行" + strOperName + "操作 ...");
            stop.BeginLoop();

            this.EnableControls(false);
            try
            {
                // 打开一个新的快捷出纳窗
                QuickChargingForm form = new QuickChargingForm();
                form.MdiParent = this.MainForm;
                form.MainForm = this.MainForm;
                form.BorrowComplete -= new BorrowCompleteEventHandler(form_BorrowComplete);
                form.BorrowComplete += new BorrowCompleteEventHandler(form_BorrowComplete);
                form.Show();

                form.SmartFuncState = FuncState.Return;

                stop.SetProgressRange(0, items.Count);

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

                    if (stop != null && stop.State != 0)
                    {
                        strError = "用户中断";
                        return -1;
                    }

                    string strBorrower = ListViewUtil.GetItemText(item, COLUMN_BORROWER);
                    if (string.IsNullOrEmpty(strBorrower) == true)
                        continue;

                    string strItemBarcode = ListViewUtil.GetItemText(item, COLUMN_BARCODE);

                    if (String.IsNullOrEmpty(strItemBarcode) == true)
                        continue;

                    form.AsyncDoAction(form.SmartFuncState, strItemBarcode);

                    stop.SetProgressValue(++i);

                    nCount++;
                    oper_items.Add(item);
                }

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

                this.EnableControls(true);
            }

            // 注:由于不知道还书操作最终什么时候完成,所以此处无法刷新 items 的显示
            return nCount;
        }
コード例 #5
0
ファイル: ItemSearchForm.cs プロジェクト: renyh1013/dp2
        // 进行流通操作
        int DoCirculation(string strAction,
            out string strError)
        {
            strError = "";
            int nRet = 0;

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

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

            if (stop != null && stop.State == 0)    // 0 表示正在处理
            {
                strError = "目前有长操作正在进行,无法进行借书或者还书的操作";
                return -1;
            }

            string strOperName = "";
            if (strAction == "borrow")
                strOperName = "借书";
            else if (strAction == "return")
                strOperName = "还书";
            else if (strAction == "inventory")
                strOperName = "盘点";
            else
            {
                strError = "未知的 strAction 值 '" + strAction + "'";
                return -1;
            }

            int nCount = 0;

            stop.Style = StopStyle.EnableHalfStop;
            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在进行" + strOperName + "操作 ...");
            stop.BeginLoop();

            this.EnableControls(false);
            try
            {

                // 如果必要,促使登录一次,以便观察当前用户的权限
                if (string.IsNullOrEmpty(this.Channel.Rights) == true)
                {
                    string strValue = "";
                    long lRet = Channel.GetSystemParameter(stop,
                        "library",
                        "name",
                        out strValue,
                        out strError);
                }

                // 检查前端权限
                if (StringUtil.IsInList("client_simulateborrow", this.Channel.Rights) == false)
                {
                    strError = "当前用户不具备 client_simulateborrow 权限,无法进行模拟" + strOperName + "的操作";
                    return -1;
                }

                // 打开一个新的快捷出纳窗
                QuickChargingForm form = new QuickChargingForm();
                form.MdiParent = this.MainForm;
                form.MainForm = this.MainForm;
                form.Show();

                string strReaderBarcode = "";

                if (strAction == "borrow")
                {
                    strReaderBarcode = InputDlg.GetInput(
         this,
         "批处理" + strOperName,
         "请输入读者证条码号:",
         "",
         this.MainForm.DefaultFont);
                    if (strReaderBarcode == null)
                    {
                        form.Close();
                        strError = "用户放弃操作";
                        return -1;
                    }

                    form.SmartFuncState = FuncState.Borrow;
                    string strID = Guid.NewGuid().ToString();
                    form.AsyncDoAction(FuncState.Borrow, strReaderBarcode, strID);
                    DateTime start = DateTime.Now;
                    // 等待任务完成
                    while (true)
                    {
                        Application.DoEvents();	// 出让界面控制权

                        if (stop != null && stop.State != 0)
                        {
                            strError = "用户中断";
                            return -1;
                        }

                        string strState = form.GetTaskState(strID);
                        if (strState != null)
                        {
                            if (strState == "error")
                            {
                                strError = "输入读者证条码号的过程有误";
                                return -1;
                            }

                            if (strState == "finish" || strState == "error")
                                break;
                        }
                        Thread.Sleep(1000);
                        TimeSpan delta = DateTime.Now - start;
                        if (delta.TotalSeconds > 30)
                        {
                            strError = "任务长时间没有反应,后继操作被放弃";
                            return -1;
                        }
                    }
                }
                else if (strAction == "return")
                {
                    form.SmartFuncState = FuncState.Return;
                }
                else if (strAction == "inventory")
                {
                    form.SmartFuncState = FuncState.InventoryBook;
                    string strBatchNo = InputDlg.GetInput(
this,
"批处理" + strOperName,
"请输入批次号:",
"",
this.MainForm.DefaultFont);
                    if (strBatchNo == null)
                    {
                        form.Close();
                        strError = "用户放弃操作";
                        return -1;
                    }
                    form.BatchNo = strBatchNo;
                }

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

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

                    if (stop != null && stop.State != 0)
                    {
                        strError = "用户中断";
                        return -1;
                    }

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

                    string strItemBarcode = "";
                    // 根据 ListViewItem 对象,获得册条码号列的内容
                    nRet = GetItemBarcodeOrRefID(
                        item,
                        true,
                        out strItemBarcode,
                        out strError);
                    if (nRet == -1)
                        return -1;

                    if (String.IsNullOrEmpty(strItemBarcode) == true)
                        continue;

                    form.AsyncDoAction(form.SmartFuncState, strItemBarcode);

                    stop.SetProgressValue(++i);

                    nCount++;
                }

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

                this.EnableControls(true);
            }
        }