예제 #1
0
        private void entityEditControl_editing_ContentChanged(object sender, ContentChangedEventArgs e)
        {
            // this.button_OK.Enabled = e.CurrentChanged;
            SetOkButtonState();

            if (string.IsNullOrEmpty(Program.MainForm.RfidCenterUrl) == false)
            {
                try
                {
                    BookItem item = this.Item.Clone();
                    item.RecordDom = this._editing.DataDom;
                    this.chipEditor_editing.LogicChipItem = BuildChip(item);
                }
                catch (Exception ex)
                {
                    SetMessage(ex.Message);
                }
#if NO
                int nRet = this.Restore(true, out string strError);
                if (nRet != -1)
                {
                    try
                    {
                        this.chipEditor_editing.LogicChipItem = BuildChip(this.Item);
                    }
                    catch (Exception ex)
                    {
                        SetMessage(ex.Message);
                    }
                }
#endif
            }
        }
예제 #2
0
        /// <summary>
        /// 根据当前对象克隆出一个新对象
        /// </summary>
        /// <returns>新对象</returns>
        public BookItem Clone()
        {
            BookItem item = new BookItem();

            this.CopyTo(item);
            return(item);
        }
예제 #3
0
파일: BookItem.cs 프로젝트: zszqwe/dp2
        // 2008/11/4
        /// <summary>
        /// 选定(加亮)匹配指定批次号的那些行
        /// </summary>
        /// <param name="strBatchNo">批次号</param>
        /// <param name="bClearOthersHilight">同时清除其它事项的加亮状态</param>
        public void SelectItemsByBatchNo(string strBatchNo,
            bool bClearOthersHilight)
        {
            if (this.Count == 0)
                return;

            ListView list = this[0].ListViewItem.ListView;
            int first_hilight_item_index = -1;
            for (int i = 0; i < list.Items.Count; i++)
            {
                ListViewItem listview_item = list.Items[i];

                BookItem book_item = (BookItem)listview_item.Tag;

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

                if (book_item.BatchNo == strBatchNo)
                {
                    listview_item.Selected = true;
                    if (first_hilight_item_index == -1)
                        first_hilight_item_index = i;
                }
                else
                {
                    if (bClearOthersHilight == true)
                        listview_item.Selected = false;
                }
            }

            // 滚入视野范围
            if (first_hilight_item_index != -1)
                list.EnsureVisible(first_hilight_item_index);
        }
예제 #4
0
        bool EnsureCreateAccessNo(BookItem book_item)
        {
            if (book_item.AccessNo.StartsWith("@"))
            {
                button_getAccessNo_Click(this.entityEditControl_editing.GetAccessNoButton, new EventArgs());
                return(true);
            }

            return(false);
        }
예제 #5
0
        private void listView_tags_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.listView_tags.SelectedItems.Count == 1)
            {
                ItemInfo item_info = (ItemInfo)this.listView_tags.SelectedItems[0].Tag;
                OneTag   tag       = item_info.OneTag;
                // var tag_info = tag.TagInfo;

                this.SelectedTag       = tag;
                this.button_OK.Enabled = true;

                this.chipEditor1.LogicChipItem = item_info.LogicChipItem;

                if (string.IsNullOrEmpty(item_info.Xml) == false)
                {
                    BookItem book_item = new BookItem();
                    int      nRet      = book_item.SetData("",
                                                           item_info.Xml,
                                                           null,
                                                           out string strError);
                    if (nRet == -1)
                    {
                        // 如何报错?
                    }
                    else
                    {
                        this.propertyGrid_record.SelectedObject = book_item;
                    }
                }
                else
                {
                    this.propertyGrid_record.SelectedObject = null;
                }
            }
            else
            {
                this.chipEditor1.LogicChipItem          = null;
                this.propertyGrid_record.SelectedObject = null;

                this.SelectedTag       = null;
                this.button_OK.Enabled = false;
            }
        }
예제 #6
0
파일: BookItem.cs 프로젝트: renyh1013/dp2
        // parameters:
        //      refid_change_table  修改过的refid。key为旧值,value为新值
        /// <summary>
        /// 根据一个 XML 字符串内容,构建出集合内的若干事项
        /// </summary>
        /// <param name="nodeItemCollection">XmlNode对象,本方法将使用其下属的 dprms:item 元素来构造事项</param>
        /// <param name="list">ListView 对象。构造好的事项会显示到其中</param>
        /// <param name="bRefreshRefID">构造事项的过程中,是否要刷新每个事项的 RefID 成员值</param>
        /// <param name="refid_change_table">返回修改过的refid。key为旧值,value为新值</param>
        /// <param name="strError">返回出错信息</param>
        /// <returns>-1: 出错。错误信息在 strError 中; 0: 成功</returns>
        public int ImportFromXml(XmlNode nodeItemCollection,
            ListView list,
            bool bRefreshRefID,
            out Hashtable refid_change_table,
            out string strError)
        {
            strError = "";
            refid_change_table = new Hashtable();
            int nRet = 0;

            if (nodeItemCollection == null)
                return 0;

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
            nsmgr.AddNamespace("dprms", DpNs.dprms);

            XmlNodeList nodes = nodeItemCollection.SelectNodes("dprms:item", nsmgr);
            for (int i = 0; i < nodes.Count; i++)
            {
                XmlNode node = nodes[i];

                BookItem book_item = new BookItem();
                nRet = book_item.SetData("",
                    node.OuterXml,
                    null,
                    out strError);
                if (nRet == -1)
                    return -1;

                if (bRefreshRefID == true)
                {
                    string strOldRefID = book_item.RefID;
                    book_item.RefID = Guid.NewGuid().ToString();
                    if (String.IsNullOrEmpty(strOldRefID) == false)
                    {
                        refid_change_table[strOldRefID] = book_item.RefID;
                    }
                }

                this.Add(book_item);
                book_item.ItemDisplayState = ItemDisplayState.New;
                book_item.AddToListView(list);

                book_item.Changed = true;
            }

            // 更换<binding>元素内<item>元素的refID属性值
            if (bRefreshRefID == true
                && refid_change_table.Count > 0)
            {
                foreach (BookItem item in this)
                {
                    nRet = item.ReplaceBindingItemRefID(refid_change_table,
                        out strError);
                    if (nRet == -1)
                        return -1;
                }
            }

            return 0;
        }
예제 #7
0
파일: BookItem.cs 프로젝트: renyh1013/dp2
 /// <summary>
 /// 根据当前对象克隆出一个新对象
 /// </summary>
 /// <returns>新对象</returns>
 public BookItem Clone()
 {
     BookItem item = new BookItem();
     this.CopyTo(item);
     return item;
 }
예제 #8
0
        // 写入右侧的信息到标签
        private void toolStripButton_saveRfid_Click(object sender, EventArgs e)
        {
            {
                BookItem item = this.Item.Clone();
                item.RecordDom = this._editing.DataDom;
                EnsureCreateAccessNo(item);
            }

            // 写入以前,装载标签内容到左侧,然后调整右侧(中间可能会警告)。然后再保存
            string strError = "";

            // string pii = this.chipEditor_editing.LogicChipItem.FindElement(ElementOID.PII).Text;
            string pii = GetPII(this.Item.OldRecord);   // 从修改前的册记录中获得册条码号

            // 看左侧是否装载过。如果没有装载过则自动装载
            if (_leftLoaded == false)
            {
                // return:
                //      -1  出错
                //      0   放弃装载
                //      1   成功装载
                int nRet = LoadOldChip(pii,
                                       "adjust_right,saving",
                                       // false, true,
                                       out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }
                if (nRet == 0)
                {
                    strError = "已放弃保存 RFID 标签内容";
                    goto ERROR1;
                }
            }

            // 然后保存
            {
                int nRet = SaveNewChip(out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }
            }

            // TODO: 改成类似 ShowMessage() 效果
            MessageBox.Show(this, "保存成功");

            // 刷新左侧显示
            {
                Debug.Assert(_tagExisting != null, "");

                Debug.WriteLine("222 " + (_tagExisting.TagInfo != null ? "!=null" : "==null"));

                Debug.Assert(_tagExisting.TagInfo != null, "");
                // 2019/9/30
                Debug.Assert(_tagExisting.AntennaID == _tagExisting.TagInfo.AntennaID, $"1 _tagExisting.AntennaID({_tagExisting.AntennaID}) 应该 == _tagExisting.TagInfo.AntennaID({_tagExisting.TagInfo.AntennaID})");

                // 用保存后的确定了的 UID 重新装载
                int nRet = LoadChipByUID(
                    _tagExisting.ReaderName,
                    _tagExisting.TagInfo.UID,
                    _tagExisting.AntennaID,
                    out TagInfo tag_info,
                    out strError);
                if (nRet == -1)
                {
                    _leftLoaded = false;
                    strError    = "保存 RFID 标签内容已经成功。但刷新左侧显示时候出错: " + strError;
                    goto ERROR1;
                }

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

                _tagExisting.TagInfo   = tag_info;
                _tagExisting.AntennaID = tag_info.AntennaID;    // 2019/9/30

                Debug.WriteLine("set taginfo");
                var chip = LogicChipItem.FromTagInfo(tag_info);
                this.chipEditor_existing.LogicChipItem = chip;

#if NO
                string new_pii = this.chipEditor_editing.LogicChipItem.FindElement(ElementOID.PII)?.Text;

                // return:
                //      -1  出错
                //      0   放弃装载
                //      1   成功装载
                int nRet = LoadOldChip(new_pii,
                                       "auto_close_dialog",
                                       // true, false,
                                       out strError);
                if (nRet != 1)
                {
                    // this.chipEditor_existing.LogicChipItem = null;
                    _leftLoaded = false;
                    strError    = "保存 RFID 标签内容已经成功。但刷新左侧显示时候出错: " + strError;
                    goto ERROR1;
                }
#endif
            }
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
예제 #9
0
        // 根据 BookItem 对象构造一个 LogicChipItem 对象
        public static LogicChipItem BuildChip(BookItem book_item)
        {
            if (StringUtil.CompareVersion(Program.MainForm.ServerVersion, "3.11") < 0)
            {
                throw new Exception("当前连接的 dp2library 必须为 3.11 或以上版本,才能使用 RFID 有关功能");
            }

            LogicChipItem result = new LogicChipItem();

            result.AFI   = LogicChipItem.DefaultBookAFI;
            result.DSFID = LogicChipItem.DefaultDSFID;
            result.EAS   = LogicChipItem.DefaultBookEAS;

            // barcode --> PII
            result.NewElement(ElementOID.PII, book_item.Barcode);

            // location --> OwnerInstitution 要配置映射关系
            // 定义一系列前缀对应的 ISIL 编码。如果 location 和前缀前方一致比对成功,则得到 ISIL 编码
            MainForm.GetOwnerInstitution(
                Program.MainForm.RfidCfgDom,
                StringUtil.GetPureLocation(book_item.Location),
                out string isil,
                out string alternative);
            if (string.IsNullOrEmpty(isil) == false)
            {
                result.NewElement(ElementOID.OwnerInstitution, isil);
            }
            else if (string.IsNullOrEmpty(alternative) == false)
            {
                result.NewElement(ElementOID.AlternativeOwnerInstitution, alternative);
            }

            // SetInformation?
            // 可以考虑用 volume 元素映射过来。假设 volume 元素内容符合 (xx,xx) 格式
            string value = MainForm.GetSetInformation(book_item.Volume);

            if (value != null)
            {
                result.NewElement(ElementOID.SetInformation, value);
            }

            // TypeOfUsage?
            // (十六进制两位数字)
            // 10 一般流通馆藏
            // 20 非流通馆藏。保存本库? 加工中?
            // 70 被剔旧的馆藏。和 state 元素应该有某种对应关系,比如“注销”
            {
                string typeOfUsage = "";
                if (StringUtil.IsInList("注销", book_item.State) == true ||
                    StringUtil.IsInList("丢失", book_item.State) == true)
                {
                    typeOfUsage = "70";
                }
                else if (string.IsNullOrEmpty(book_item.State) == false &&
                         StringUtil.IsInList("加工中", book_item.State) == true)
                {
                    typeOfUsage = "20";
                }
                else
                {
                    typeOfUsage = "10";
                }

                result.NewElement(ElementOID.TypeOfUsage, typeOfUsage);
            }

            // AccessNo --> ShelfLocation
            // 注意去掉 {ns} 部分
            result.NewElement(ElementOID.ShelfLocation,
                              StringUtil.GetPlainTextCallNumber(book_item.AccessNo)
                              );

            return(result);
        }
예제 #10
0
        // entityeditcontrol的某个输入域触发了按键
        private void entityEditControl_editing_ControlKeyDown(object sender,
                                                              ControlKeyEventArgs e)
        {
            string strAction = "copy";

            bool bUp = false;

            Debug.WriteLine("keycode=" + e.e.KeyCode.ToString());

            if (e.e.KeyCode == Keys.A && e.e.Control == true)
            {
                if (this.GenerateData != null)
                {
                    GenerateDataEventArgs e1 = new GenerateDataEventArgs();
                    e1.FocusedControl = sender; // sender为 EntityEditControl
                    this.GenerateData(this, e1);
                }
                e.e.SuppressKeyPress = true;    // 2015/5/28
                return;
            }
            else if (e.e.KeyCode == Keys.PageDown && e.e.Control == true)
            {
                // this.button_editing_nextRecord_Click(null, null);
                this.toolStripButton_next_Click(null, null);
                return;
            }
            else if (e.e.KeyCode == Keys.PageUp && e.e.Control == true)
            {
                // this.button_editing_prevRecord_Click(null, null);
                this.toolStripButton_prev_Click(null, null);
                return;
            }
            else if (e.e.KeyCode == Keys.OemOpenBrackets && e.e.Control == true)
            {
                bUp = true; // 从上面拷贝
            }
            else if (e.e.KeyCode == Keys.OemCloseBrackets && e.e.Control == true)
            {
                bUp = false;    // 从下面拷贝
            }
            else if (e.e.KeyCode == Keys.OemMinus && e.e.Control == true)
            {
                bUp       = true; // 从上面减量
                strAction = "minus";
            }
            else if (e.e.KeyCode == Keys.Oemplus && e.e.Control == true)
            {
                bUp       = true; // 从上面增量
                strAction = "plus";
            }
            else if (e.e.KeyCode == Keys.D0 && e.e.Control == true)
            {
                bUp       = false; // 从下面减量
                strAction = "minus";
            }
            else if (e.e.KeyCode == Keys.D9 && e.e.Control == true)
            {
                bUp       = false; // 从下面增量
                strAction = "plus";
            }
            else
            {
                return;
            }

            string   strError = "";
            BookItem bookitem = GetPrevOrNextItem(bUp, out strError);

            if (bookitem == null)
            {
                return;
            }
            switch (e.Name)
            {
            case "PublishTime":
                this.entityEditControl_editing.PublishTime =
                    DoAction(strAction, bookitem.PublishTime);
                break;

            case "Seller":
                this.entityEditControl_editing.Seller =
                    DoAction(strAction, bookitem.Seller);
                break;

            case "Source":
                this.entityEditControl_editing.Source =
                    DoAction(strAction, bookitem.Source);
                break;

            case "Intact":
                this.entityEditControl_editing.Intact =
                    DoAction(strAction, bookitem.Intact);
                break;

            case "Binding":
                this.entityEditControl_editing.Binding =
                    DoAction(strAction, bookitem.Binding);
                break;

            case "Operations":
                this.entityEditControl_editing.Operations =
                    DoAction(strAction, bookitem.Operations);
                break;

            case "Price":
                this.entityEditControl_editing.Price =
                    DoAction(strAction, bookitem.Price);
                break;

            case "Barcode":
                this.entityEditControl_editing.Barcode =
                    DoAction(strAction, bookitem.Barcode);
                break;

            case "State":
                this.entityEditControl_editing.State =
                    DoAction(strAction, bookitem.State);
                break;

            case "Location":
                this.entityEditControl_editing.LocationString =
                    DoAction(strAction, bookitem.Location);
                break;

            case "Comment":
                this.entityEditControl_editing.Comment =
                    DoAction(strAction, bookitem.Comment);
                break;

            case "Borrower":
                Console.Beep();
                //this.entityEditControl_editing.Borrower = bookitem.Borrower;
                break;

            case "BorrowDate":
                Console.Beep();
                //this.entityEditControl_editing.BorrowDate = bookitem.BorrowDate;
                break;

            case "BorrowPeriod":
                Console.Beep();
                //this.entityEditControl_editing.BorrowPeriod = bookitem.BorrowPeriod;
                break;

            case "RecPath":
                Console.Beep();
                //this.entityEditControl_editing.RecPath = bookitem.RecPath;
                break;

            case "BookType":
                this.entityEditControl_editing.BookType =
                    DoAction(strAction, bookitem.BookType);
                break;

            case "RegisterNo":
                this.entityEditControl_editing.RegisterNo =
                    DoAction(strAction, bookitem.RegisterNo);
                break;

            case "MergeComment":
                this.entityEditControl_editing.MergeComment =
                    DoAction(strAction, bookitem.MergeComment);
                break;

            case "BatchNo":
                this.entityEditControl_editing.BatchNo =
                    DoAction(strAction, bookitem.BatchNo);
                break;

            case "Volume":
                this.entityEditControl_editing.Volume =
                    DoAction(strAction, bookitem.Volume);
                break;

            case "AccessNo":
                this.entityEditControl_editing.AccessNo =
                    DoAction(strAction, bookitem.AccessNo);
                break;

            case "RefID":
                Console.Beep();
                // this.entityEditControl_editing.RefID = bookitem.RefID;  // 2009/6/2
                break;

            default:
                Debug.Assert(false, "未知的栏目名称 '" + e.Name + "'");
                return;
            }
        }
예제 #11
0
        // parameters:
        //      refid_change_table  修改过的refid。key为旧值,value为新值
        /// <summary>
        /// 根据一个 XML 字符串内容,构建出集合内的若干事项
        /// </summary>
        /// <param name="nodeItemCollection">XmlNode对象,本方法将使用其下属的 dprms:item 元素来构造事项</param>
        /// <param name="list">ListView 对象。构造好的事项会显示到其中</param>
        /// <param name="bRefreshRefID">构造事项的过程中,是否要刷新每个事项的 RefID 成员值</param>
        /// <param name="refid_change_table">返回修改过的refid。key为旧值,value为新值</param>
        /// <param name="strError">返回出错信息</param>
        /// <returns>-1: 出错。错误信息在 strError 中; 0: 成功</returns>
        public int ImportFromXml(XmlNode nodeItemCollection,
                                 ListView list,
                                 bool bRefreshRefID,
                                 out Hashtable refid_change_table,
                                 out string strError)
        {
            strError           = "";
            refid_change_table = new Hashtable();
            int nRet = 0;

            if (nodeItemCollection == null)
            {
                return(0);
            }

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());

            nsmgr.AddNamespace("dprms", DpNs.dprms);

            XmlNodeList nodes = nodeItemCollection.SelectNodes("dprms:item", nsmgr);

            for (int i = 0; i < nodes.Count; i++)
            {
                XmlNode node = nodes[i];

                BookItem book_item = new BookItem();
                nRet = book_item.SetData("",
                                         node.OuterXml,
                                         null,
                                         out strError);
                if (nRet == -1)
                {
                    return(-1);
                }

                if (bRefreshRefID == true)
                {
                    string strOldRefID = book_item.RefID;
                    book_item.RefID = Guid.NewGuid().ToString();
                    if (String.IsNullOrEmpty(strOldRefID) == false)
                    {
                        refid_change_table[strOldRefID] = book_item.RefID;
                    }
                }

                this.Add(book_item);
                book_item.ItemDisplayState = ItemDisplayState.New;
                book_item.AddToListView(list);

                book_item.Changed = true;
            }

            // 更换<binding>元素内<item>元素的refID属性值
            if (bRefreshRefID == true &&
                refid_change_table.Count > 0)
            {
                foreach (BookItem item in this)
                {
                    nRet = item.ReplaceBindingItemRefID(refid_change_table,
                                                        out strError);
                    if (nRet == -1)
                    {
                        return(-1);
                    }
                }
            }

            return(0);
        }