/// <summary>
 /// Deprecated Method for adding a new object to the OldHouseSet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOldHouseSet(OldHouse oldHouse)
 {
     base.AddObject("OldHouseSet", oldHouse);
 }
        public OrderFlow CreateOrderFromPreorder(IEnumerable<PreprocessOrder> preorders)
        {
            OrderFlow order = InnerCreateOrder();

            foreach (PreprocessOrder pre in preorders)
            {
                //------------------------------
                OldHouse house = new OldHouse();

                foreach (PreprocessConsumer cur in pre.PreprocessConsumer)
                {
                    Consumer consumer = null;
                    foreach (Consumer rep in order.Consumer)
                    {
                        //注意,不能改变cur。
                        string sname, sid;
                        sname = cur.Name;
                        sid = cur.IdentityCardNo;
                        if (rep.Name == sname.Trim() &&
                            rep.IdentityType == cur.IdentityType &&
                            rep.IdentityCardNo == sid.Trim())
                        {
                            consumer = rep;
                            break;
                        }
                    }

                    if (consumer == null)
                    {
                        string sname, sid;
                        sname = cur.Name;
                        sid = cur.IdentityCardNo;

                        consumer = new Consumer();
                        consumer.Name = sname.Trim();
                        consumer.IdentityType = cur.IdentityType;
                        consumer.IdentityCardNo = sid.Trim();
                        consumer.Memo = cur.Memo;
                        order.Consumer.Add(consumer);
                    }
                    else if (string.IsNullOrEmpty(consumer.Memo))
                    {
                        consumer.Memo = cur.Memo;
                    }

                    HouseOwner owner = new HouseOwner();

                    owner.IsCertificateOwner = false;
                    owner.Consumer = consumer;

                    house.HouseOwner.Add(owner);
                }
                //------------------------------
                house.RegionType = pre.RegionType;
                house.OwnershipType = pre.OwnershipType;
                house.Organization = pre.Organization;
                house.CertificateType = pre.CertificateType;
                house.CertificateNo = pre.CertificateNo;
                house.Address = pre.Address;
                house.PropertyArea = pre.PropertyArea;
                house.MeasureArea = pre.MeasureArea;
                house.EvaluationTotalPrice = pre.EvaluationTotalPrice;
                house.Memo = pre.Memo;

                order.OldHouse.Add(house);

                //------------------------------
                order.QueueNo = pre.QueueNo;

            }

            this.OrderFlows.Add(order);

            //从服务器更新用户名和时间
            order.UpdateCreator();

            //这样更新,居然解决了!!!因为实际上传递的参数是0
            foreach (PreprocessOrder pre in preorders)
            {
                pre.UpdateAssociatedOrderFlow(order.OrderFlowId);
            }

            OrderFlowLog(order, Operate_Enum.Order_Create_Pre);

            return order;
        }
 /// <summary>
 /// Create a new OldHouse object.
 /// </summary>
 /// <param name="oldHouseId">Initial value of the OldHouseId property.</param>
 /// <param name="regionType">Initial value of the RegionType property.</param>
 /// <param name="ownershipType">Initial value of the OwnershipType property.</param>
 /// <param name="certificateType">Initial value of the CertificateType property.</param>
 /// <param name="address">Initial value of the Address property.</param>
 /// <param name="orderFlowId">Initial value of the OrderFlowId property.</param>
 public static OldHouse CreateOldHouse(global::System.Int32 oldHouseId, global::System.Int32 regionType, global::System.Int32 ownershipType, global::System.Int32 certificateType, global::System.String address, global::System.Int32 orderFlowId)
 {
     OldHouse oldHouse = new OldHouse();
     oldHouse.OldHouseId = oldHouseId;
     oldHouse.RegionType = regionType;
     oldHouse.OwnershipType = ownershipType;
     oldHouse.CertificateType = certificateType;
     oldHouse.Address = address;
     oldHouse.OrderFlowId = orderFlowId;
     return oldHouse;
 }
        public OrderFlow CreateOrderFromError(ErrorFlow error)
        {
            OrderFlow order = InnerCreateOrder();

            foreach (OrderFlow o in error.OrderFlow)
            {
                foreach (Apartment apt in o.Apartment)
                {
                    apt.SellStateEnum = SellState_Enum.Locked;
                    apt.OrderFlow = order;
                }

                foreach (PreprocessOrder pre in o.PreprocessOrder)
                {
                    pre.IsProcessed = true;
                    pre.OrderFlow = order;
                }
                //不检查重复性
                foreach (OldHouse house in o.OldHouse)
                {
                    OldHouse newh = new OldHouse();
                    newh.RegionType = house.RegionType;
                    newh.OwnershipType = house.OwnershipType;
                    newh.Organization = house.Organization;
                    newh.CertificateType = house.CertificateType;
                    newh.CertificateNo = house.CertificateNo;
                    newh.Address = house.Address;
                    newh.PropertyArea = house.PropertyArea;
                    newh.MeasureArea = house.MeasureArea;
                    newh.EvaluationTotalPrice = house.EvaluationTotalPrice;
                    newh.Memo = house.Memo;

                    order.OldHouse.Add(newh);
                }
                //不检查重复性
                foreach (Consumer user in o.Consumer)
                {
                    Consumer con = new Consumer();
                    con.Name = user.Name;
                    con.IdentityType = user.IdentityType;
                    con.IdentityCardNo = user.IdentityCardNo;
                    con.Memo = user.Memo;

                    order.Consumer.Add(con);
                }
                //不添加HouseOwener

                order.QueueNo = o.QueueNo;
            }
            //新单设置成错误状态,以免其他人删除,处理完成后设置成其他状态
            order.OrderState = (int)OrderState_Enum.Error;

            order.ErrorOrderType = (int)ErrorOrderType_Enum.CreateOrder;
            order.ErrorFlow = error;

            this.OrderFlows.Add(order);

            //从服务器更新用户名和时间
            order.UpdateCreator();

            OrderFlowLog(order, Operate_Enum.Order_Create_Error);

            return order;
        }