Пример #1
0
        public OrderItem Clone()
        {
            OrderItem newObject = new OrderItem();

            newObject.ItemDisplayState = this.ItemDisplayState;

            newObject.RecPath = this.RecPath;
            newObject.m_bChanged = this.m_bChanged;
            newObject.OldRecord = this.OldRecord;


            // 放入最新鲜的内容
            newObject.CurrentRecord = this.RecordDom.OuterXml;


            newObject.RecordDom = new XmlDocument();
            newObject.RecordDom.LoadXml(this.RecordDom.OuterXml);

            newObject.Timestamp = ByteArray.GetCopy(this.Timestamp);
            newObject.ListViewItem = null;  // this.ListViewItem;
            newObject.Error = null; // this.Error;

            return newObject;
        }
Пример #2
0
        // parameters:
        //       changed_refids  累加修改过的 refid 对照表。 原来的 --> 新的
        /// <summary>
        /// 根据一个 XML 字符串内容,构建出集合内的若干事项
        /// </summary>
        /// <param name="nodeOrderCollection">XmlNode对象,本方法将使用其下属的 dprms:order 元素来构造事项</param>
        /// <param name="list">ListView 对象。构造好的事项会显示到其中</param>
        /// <param name="bRefreshRefID">构造事项的过程中,是否要刷新每个事项的 RefID 成员值</param>
        /// <param name="changed_refids">累加修改过的 refid 对照表。 原来的 --> 新的</param>
        /// <param name="strError">返回出错信息</param>
        /// <returns>-1: 出错。错误信息在 strError 中; 0: 成功</returns>
        public int ImportFromXml(XmlNode nodeOrderCollection,
            ListView list,
            bool bRefreshRefID,
            ref Hashtable changed_refids,
            out string strError)
        {
            strError = "";
            int nRet = 0;

            if (nodeOrderCollection == null)
                return 0;

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

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

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

                if (bRefreshRefID == true)
                {
                    string strOldRefID = order_item.RefID;
                    order_item.RefID = Guid.NewGuid().ToString();

                    changed_refids[strOldRefID] = order_item.RefID;
                }

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

                order_item.Changed = true;
            }

            return 0;
        }
Пример #3
0
        // Undo标记删除
        // return:
        //      false   没有必要Undo
        //      true    已经Undo
        public bool UndoMaskDeleteItem(OrderItem orderitem)
        {
            if (orderitem.ItemDisplayState != ItemDisplayState.Deleted)
                return false;   // 要Undo的事项根本就不是Deleted状态,所以谈不上Undo

            // 因为不知道上次标记删除前数据是否改过,因此全当改过
            orderitem.ItemDisplayState = ItemDisplayState.Changed;
            orderitem.Changed = true;

            // 刷新
            orderitem.RefreshListView();
            return true;
        }
Пример #4
0
        // 从集合中和视觉上同时删除
        public void PhysicalDeleteItem(
            OrderItem orderitem)
        {
            // 从listview中消失
            orderitem.DeleteFromListView();

            this.Remove(orderitem);
        }
Пример #5
0
        // 标记删除
        public void MaskDeleteItem(
            bool bRemoveFromList,
            OrderItem orderitem)
        {
            if (orderitem.ItemDisplayState == ItemDisplayState.New)
            {
                PhysicalDeleteItem(orderitem);
                return;
            }


            orderitem.ItemDisplayState = ItemDisplayState.Deleted;
            orderitem.Changed = true;

            // 从listview中消失?
            if (bRemoveFromList == true)
                orderitem.DeleteFromListView();
            else
            {
                orderitem.RefreshListView();
            }
        }