private void AddApartment(Apartment apt)
        {
            this.ShowOrdersView();

            IRegion ordersRegion = _regionManager.Regions[RegionNames.OrdersRegion];

            var orderCompositeViewModel = ServiceLocator.Current.GetInstance<OrderCompositeViewModel>();

            orderCompositeViewModel.CurApartment = apt;

            ordersRegion.Add(orderCompositeViewModel);
            OrderModels.Add(orderCompositeViewModel);

            ordersRegion.Activate(orderCompositeViewModel);
        }
 public void OnoperCompleted(Apartment apartment)
 {
     //NitpickHouseDomainContext nitpick = apartmentDomainDataSource.DomainContext as NitpickHouseDomainContext;
     //if (nitpick != null)
     //{
     //    nitpick.Apartments.Detach(apartment);
     //}
 }
 /// <summary>
 /// Create a new Apartment object.
 /// </summary>
 /// <param name="apartmentId">Initial value of the ApartmentId property.</param>
 /// <param name="residentialId">Initial value of the ResidentialId property.</param>
 /// <param name="roomType">Initial value of the RoomType property.</param>
 /// <param name="area">Initial value of the Area property.</param>
 public static Apartment CreateApartment(global::System.Int32 apartmentId, global::System.Int32 residentialId, global::System.String roomType, global::System.Double area)
 {
     Apartment apartment = new Apartment();
     apartment.ApartmentId = apartmentId;
     apartment.ResidentialId = residentialId;
     apartment.RoomType = roomType;
     apartment.Area = area;
     return apartment;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Apartments EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToApartments(Apartment apartment)
 {
     base.AddObject("Apartments", apartment);
 }
 private void RepareOperation(Apartment cur)
 {
     cur.CurState = ApartmentRuntimeState.Busing;
     _apartmentBusingList.Add(cur);
 }
 //初始化已经Attach 到DomainContent的数据,主要确保存在Consumer
 private void InitialAttachedData(Apartment apt)
 {
     //以下部分需要仔细考虑
     if (apt.Consumer == null)
     {
         byte selltype = 0;
         if (apt.CanMarketSell)
         {
             selltype = 1;
         }
         //注意:特地不设置OperateUser、OperateTime
         //可以用这两个字段来区分是新增记录还是修改记录
         apt.Consumer = new Consumer
         {
             Apartment = apt,
             ApartmentId = apt.ApartmentId,
             SellType = selltype
         };
     }
 }
 private string GetOperationResult(Apartment cur)
 {
     string info;
     //期房
     if (cur.Area == 1.0)
     {
         info = String.Format("序号:   \t{0}\n编号:   \t{1}\n户型:   \t{2}\n面积:   \t{3}\n套内:   \t{4}\n公摊:   \t{5}\n",
             cur.ApartmentId,
             cur.Builing,
             cur.RoomType,
             cur.Uint,
             cur.Floor,
             cur.Number);
     }
     else//现房
     {
         info = String.Format("序号:   \t{0}\n编号:   \t{1}\n位置:   \t{2}{3}楼{4}号\n户型:   \t{5}\n面积:   \t{6:F2}\n套内:   \t{7:F2}\n公摊:   \t{8:F2}\n",
             cur.ApartmentId,
             cur.Builing,
             cur.Uint,
             cur.Floor,
             cur.Number,
             cur.RoomType,
             cur.Area,
             cur.ActualArea,
             cur.ShareArea);
     }
     string comsterinfo;
     if (cur.Consumer != null)
     {
         string tmp;
         switch(cur.Consumer.RegionType)
         {
             case 1:
                 tmp = "一街坊";
                 break;
             case 2:
                 tmp = "二街坊";
                 break;
             case 3:
                 tmp = "整合区域";
                 break;
             default:
                 tmp = "未知";
                 break;
         }
         comsterinfo = String.Format("销售类型:\t{0}\n购买者:  \t{1}\n身份证:  \t{2}\n房产证:  \t{3}\n所属区段:\t{4}\n拆迁面积:\t{5:F2}\n原地址:  \t{6}\n操作人员:\t{7}\n",
             cur.Consumer.SellType == 0 ? "拆迁":"市场",
             cur.Consumer.Name,
             cur.Consumer.IdCard,
             cur.Consumer.RealEstateId,
             tmp,
             cur.Consumer.OriginArea,
             cur.Consumer.OriginAddress,
             cur.Consumer.OperateUser);
         info += comsterinfo;
     }
     string lockinfo;
     if (cur.LockStatu != null)
     {
         lockinfo = String.Format("锁定人员:\t{0}\n", cur.LockStatu.OperateUser);
         info += lockinfo;
     }
     return info;
 }
        public void ApartmentDelete(Apartment cur)
        {
            #region Check

            if (MessageBox.Show(ApartmentServiceError.DelException_Warnning, "警告", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
            {
                return;
            }

            if (cur.CanDelSold == false)
            {
                cur.ValidationErrors.Add(new ValidationResult(ApartmentServiceError.DelException_AuthLimit, null));
                MessageBox.Show(ApartmentServiceError.DelException_AuthLimit);
                return;
            }
            if (cur.Consumer == null || cur.LockStatu == null)
            {
                throw new InvalidOperationException(ApartmentServiceError.SystemException_CheckState);
            }
             //为空,则表示正在删除未售记录
            if (String.IsNullOrEmpty(cur.Consumer.OperateUser))
            {
                throw new InvalidOperationException(ApartmentServiceError.SystemException_DeleteUnSell);
            }
               #endregion

            #region pepare
            RepareOperation(cur);
            #endregion

            #region initial content

            Apartment commitApartment = new Apartment
            {
                ApartmentId = cur.ApartmentId,
                RoomType = cur.RoomType,
                Area = cur.Area,
                Builing = cur.Builing,
                Uint = cur.Uint,
                Floor = cur.Floor,
                Number = cur.Number,
                ActualArea = cur.ActualArea,
                ShareArea = cur.ShareArea,
                ShareFactor = cur.ShareFactor,
                ResidentialId = cur.ResidentialId,
                Residential = null,
                Consumer = null,
                LockStatu = null
            };

            commitApartment.Consumer = new Consumer()
            {
                Apartment = commitApartment,
                ApartmentId = cur.Consumer.ApartmentId,
                SellType = cur.Consumer.SellType,
                RegionType = cur.Consumer.RegionType,
                Name = cur.Consumer.Name,
                IdCard = cur.Consumer.IdCard,
                RealEstateId = cur.Consumer.RealEstateId,
                OriginArea = cur.Consumer.OriginArea,
                OriginAddress = cur.Consumer.OriginAddress,
                OperateTime = cur.Consumer.OperateTime,
                OperateUser = cur.Consumer.OperateUser
            };
            commitApartment.LockStatu = new LockStatu()
            {
                Apartment = commitApartment,
                ApartmentId = cur.ApartmentId,
                OperateUser = cur.LockStatu.OperateUser,
                OperateTime = cur.LockStatu.OperateTime
            };

            #endregion

            #region submit

            NitpickHouseDomainContext submitContext = new NitpickHouseDomainContext();

            //use attach to set apartment to unchange state
            submitContext.Apartments.Attach(commitApartment);

            commitApartment.LockStatu = null;

            commitApartment.Consumer = null;

            // submit the new context
            SubmitOperation submitOp = submitContext.SubmitChanges();
            submitOp.Completed += (send, args) =>
            {
                CompleteOperation(submitOp, cur);
            };
            #endregion
        }
        private void CompleteOperation(SubmitOperation submitOp, Apartment cur)
        {
            //---------------------------
            //如果当前正在加载,则查询结果可能不正确,需要cancel一次
            MakeSureLoadCorret();

            //---------------------------

            if (submitOp.HasError)
            {
                cur.ValidationErrors.Add(new ValidationResult(submitOp.Error.Message, null));
                submitOp.MarkErrorAsHandled();
                MessageBox.Show(ApartmentServiceError.ServerOperationException + "\n\n" + submitOp.Error.Message);
            }
            else
            {
                string info = GetOperationResult(cur);
                MessageBox.Show(ApartmentServiceError.ServerOperationSuccessed + "\n\n" + info);
                if (_apartemntLocked.Contains(cur))
                {
                    _apartemntLocked.Remove(cur);
                }
            }
            //---------------------------

            //取出busing列表
            if (_apartmentBusingList.Contains(cur))
            {
                _apartmentBusingList.Remove(cur);
            }

            cur.CurState = ApartmentRuntimeState.Deleted;

            _domainContext.Apartments.Detach(cur);
        }
示例#10
0
        public void ApartmentSell(Apartment cur)
        {
            #region Check

            if (cur.CanSell == false && cur.CanMarketSell == false)
            {
                cur.ValidationErrors.Add(new ValidationResult(ApartmentServiceError.SellException_AuthLimit, null));
                MessageBox.Show(ApartmentServiceError.SellException_AuthLimit);
                return;
            }
            if (cur.Consumer == null || cur.LockStatu == null)
            {
                throw new InvalidOperationException(ApartmentServiceError.SystemException_CheckState);
            }
            //不为空,则表示已售记录,再次销售
            if (!String.IsNullOrEmpty(cur.Consumer.OperateUser))
            {
                throw new InvalidOperationException(ApartmentServiceError.SystemException_SellSold);
            }
            if (!CheckComsterInfo(cur.Consumer))
            {
                MessageBox.Show(ApartmentServiceError.SellException_NeedInformation);
                return;
            }
            #endregion

            #region pepare
            RepareOperation(cur);
            #endregion

            #region initial content

            Apartment commitApartment = new Apartment
            {
                ApartmentId = cur.ApartmentId,
                RoomType = cur.RoomType,
                Area = cur.Area,
                Builing = cur.Builing,
                Uint = cur.Uint,
                Floor = cur.Floor,
                Number = cur.Number,
                ActualArea = cur.ActualArea,
                ShareArea = cur.ShareArea,
                ShareFactor = cur.ShareFactor,
                ResidentialId = cur.ResidentialId,
                Residential = null,
                Consumer = null,
                LockStatu = null
            };

            commitApartment.LockStatu = new LockStatu()
            {
                Apartment = commitApartment,
                ApartmentId = cur.ApartmentId,
                OperateUser = cur.LockStatu.OperateUser,
                OperateTime = cur.LockStatu.OperateTime
            };

            #endregion

            #region submit
            NitpickHouseDomainContext submitContext = new NitpickHouseDomainContext();

            //use attach to set apartment to unchange state
            submitContext.Apartments.Attach(commitApartment);

            commitApartment.LockStatu = null;

            commitApartment.Consumer = new Consumer()
            {
                Apartment = commitApartment,
                ApartmentId = cur.Consumer.ApartmentId,
                SellType = cur.Consumer.SellType,
                RegionType = cur.Consumer.RegionType,
                Name = cur.Consumer.Name,
                IdCard = cur.Consumer.IdCard,
                RealEstateId = cur.Consumer.RealEstateId,
                OriginArea = cur.Consumer.OriginArea,
                OriginAddress = cur.Consumer.OriginAddress,
                OperateUser = WebContext.Current.User.Name,
                OperateTime = DateTime.Now
            };

            // submit the new context
            SubmitOperation submitOp = submitContext.SubmitChanges();
            submitOp.Completed += (send, args) =>
            {
                CompleteOperation(submitOp, cur);
            };
            #endregion
        }
示例#11
0
        /// <summary>
        /// 锁定Apartment函数,被browser调用
        /// </summary>
        /// <param name="cur"></param>
        /// <param name="callback"></param>
        public void ApartmentLock(Apartment cur)
        {
            #region Check
            if (cur.CanLock == false)
            {
                cur.CurState = ApartmentRuntimeState.Deleted;
                cur.ValidationErrors.Add(new ValidationResult(ApartmentServiceError.LockException_AuthLimit, null));
                MessageBox.Show(ApartmentServiceError.LockException_AuthLimit);
                return;
            }
            if (cur.LockStatu != null)
            {
                cur.CurState = ApartmentRuntimeState.Deleted;
                cur.ValidationErrors.Add(new ValidationResult(ApartmentServiceError.LockException_LockForLocked, null));
                MessageBox.Show(ApartmentServiceError.LockException_LockForLocked);
                return;
            }

            if (cur.HasChanges)
            {
                cur.CurState = ApartmentRuntimeState.Deleted;
                cur.ValidationErrors.Add(new ValidationResult(ApartmentServiceError.LockException_RecordModified, null));
                MessageBox.Show(ApartmentServiceError.LockException_RecordModified);
                return;
            }
            #endregion

            #region set origin state

            cur.CurState = ApartmentRuntimeState.Busing;

            #endregion

            #region initial content

            Apartment commitApartment = new Apartment{
                ApartmentId = cur.ApartmentId,
                RoomType = cur.RoomType,
                Area = cur.Area,
                Builing = cur.Builing,
                Uint = cur.Uint,
                Floor = cur.Floor,
                Number = cur.Number,
                ActualArea = cur.ActualArea,
                ShareArea = cur.ShareArea,
                ShareFactor = cur.ShareFactor,
                ResidentialId = cur.ResidentialId,
                Residential = null,
                Consumer = null,
                LockStatu = null
            };

            if (cur.Consumer != null)
            {
                commitApartment.Consumer = new Consumer()
                {
                    Apartment = commitApartment,
                    ApartmentId = cur.Consumer.ApartmentId,
                    SellType = cur.Consumer.SellType,
                    RegionType = cur.Consumer.RegionType,
                    Name = cur.Consumer.Name,
                    IdCard = cur.Consumer.IdCard,
                    RealEstateId = cur.Consumer.RealEstateId,
                    OriginArea = cur.Consumer.OriginArea,
                    OriginAddress = cur.Consumer.OriginAddress,
                    OperateTime = cur.Consumer.OperateTime,
                    OperateUser = cur.Consumer.OperateUser
                };
            }

            #endregion

            #region submit

            NitpickHouseDomainContext submitContext = new NitpickHouseDomainContext();

            //use attach to set apartment to unchange state
            submitContext.Apartments.Attach(commitApartment);

            commitApartment.LockStatu = new LockStatu()
            {
                Apartment = commitApartment,
                ApartmentId = cur.ApartmentId,
                OperateUser = WebContext.Current.User.Name,
                OperateTime = DateTime.Now
            };

            // submit the new context
            var submitOp = submitContext.SubmitChanges();
            submitOp.Completed += (send, args) =>
            {
                if (submitOp.HasError)
                {
                    cur.CurState = ApartmentRuntimeState.Deleted;
                    cur.ValidationErrors.Add(new ValidationResult(submitOp.Error.Message, null));
                    submitOp.MarkErrorAsHandled();
                    MessageBox.Show(ApartmentServiceError.ServerOperationException);
                }
                else
                {
                    //---------------------------
                    //如果当前正在加载,则查询结果可能不正确,需要cancel一次
                    MakeSureLoadCorret();
                    //---------------------------

                    Apartment submittedApartments = (Apartment)submitOp.ChangeSet.ModifiedEntities[0];
                    submitContext.Apartments.Detach(submittedApartments);

                    //刷新状态
                    submittedApartments.CurState = ApartmentRuntimeState.Normal;
                    submittedApartments.RefreshAuthenticate(true);

                    _domainContext.Apartments.Attach(submittedApartments);

                    InitialAttachedData(submittedApartments);

                    //-----------------------
                    //add 到视图,及时显示出来
                    //因为前面清除了当前查询,所以不会出现马上清除的情况。
                    _apartemntLocked.Add(submittedApartments);
                }
            };

            #endregion
        }
示例#12
0
 private void RemoveApartment(Apartment apt)
 {
     IRegion ordersRegion = _regionManager.Regions[RegionNames.OrdersRegion];
     foreach (OrderCompositeViewModel v in OrderModels)
     {
         if (v.CurApartment == apt)
         {
             OrderModels.Remove(v);
             ordersRegion.Remove(v);
             if (ordersRegion.Views.Count() == 0)
             {
                 this.RemoveOrdersView();
             }
             break;
         }
     }
 }