/// <summary>
        /// 流程完成时的操作。
        /// </summary>
        /// <returns></returns>
        public int Complete(Guid id)
        {
            RoadFlow.Data.Model.BuildingsModel model = Get(id.ToString());
            #region 去除流程关联字段
            model.State      = null;
            model.CreateTime = null;
            model.UpdateTime = null;
            #endregion
            BuildingsDataBLL buildingsDataBLL = new BuildingsDataBLL();
            if (buildingsDataBLL.Get(id) != null)  //楼栋已存在,更新楼栋信息
            {
                model.ID         = null;
                model.UpdateTime = DateTime.Now;
                buildingsDataBLL.Update(model, id);
            }
            else
            {
                buildingsDataBLL.Add(model);
            }
            //更新合成表
            BuildingsAndBuildingMonthInfoBLL buildingsAndBuildingMonthInfoBLL = new BuildingsAndBuildingMonthInfoBLL();
            if (buildingsAndBuildingMonthInfoBLL.Get(id) != null)
            {
                model.ID         = null;
                model.UpdateTime = DateTime.Now;
                buildingsAndBuildingMonthInfoBLL.Update(model, id);
            }
            else
            {
                buildingsAndBuildingMonthInfoBLL.Add(model);
            }

            return(1);
        }
        public int ManageDelete(Guid id)
        {
            using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
            {
                try
                {
                    BuildingsBLL                buildingsBLL                = new BuildingsBLL();
                    BuildingsDataBLL            buildingsDataBLL            = new BuildingsDataBLL();
                    BuildingMonthModifyCountBLL buildingMonthModifyCountBLL = new BuildingMonthModifyCountBLL();
                    BuildingMonthInfoDataBLL    buildingMonthInfoDataBLL    = new BuildingMonthInfoDataBLL();
                    BuildingMonthInfoBLL        buildingMonthInfoBLL        = new BuildingMonthInfoBLL();

                    buildingMonthModifyCountBLL.ManageDeleteByBuildingID(id);
                    buildingMonthInfoDataBLL.ManageDeleteByBuildingID(id);
                    buildingMonthInfoBLL.ManageDeleteByBuildingID(id);

                    buildingsBLL.ManageDelete(id);
                    buildingsDataBLL.ManageDelete(id);
                    BaseDb.Delete(id);
                    scope.Complete();
                    return(1);
                }
                catch (Exception ex)
                {
                    return(0);
                }
            }
        }
 /// <summary>
 /// 绑定楼盘
 /// </summary>
 /// <returns></returns>
 public int ManageBindHouseID(Guid houseID, Guid id)
 {
     RoadFlow.Data.Model.BuildingsAndBuildingMonthInfoModel model = new Data.Model.BuildingsAndBuildingMonthInfoModel();
     model.HouseID = houseID;
     using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
     {
         try
         {
             BuildingsBLL     buildingsBLL     = new BuildingsBLL();
             BuildingsDataBLL buildingsDataBLL = new BuildingsDataBLL();
             buildingsBLL.MangeUpdate(model, id);
             buildingsDataBLL.ManageUpdate(model, id);
             BaseDb.Update(model, new KeyValuePair <string, object>("ID", id));
             scope.Complete();
             return(1);
         }
         catch (Exception ex)
         {
             return(0);
         }
     }
 }
        /// <summary>
        /// 管理员编辑(除了BuildingsAndBuildingMonthInfo外,需要更新BuildingMonthInfoDataBLL,BuildingMonthInfoBLL,BuildingsBLL,BuildingsDataBLL)
        /// </summary>
        /// <param name="model"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public int ManageUpdate(RoadFlow.Data.Model.BuildingsModel building, RoadFlow.Data.Model.BuildingMonthInfoModel monthInfo, Guid buildingID)
        {
            using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
            {
                bool isUpdate = Update <RoadFlow.Data.Model.BuildingsModel>(building, buildingID) > 0 && Update <RoadFlow.Data.Model.BuildingMonthInfoModel>(monthInfo, buildingID) > 0;//更新组合表
                if (isUpdate)
                {
                    #region BuildingMonthInfo
                    BuildingMonthInfoDataBLL buildingMonthInfoDataBLL = new BuildingMonthInfoDataBLL();
                    var monthDataList = buildingMonthInfoDataBLL.GetListByBuildingID(buildingID);
                    var monthDataLast = monthDataList.OrderByDescending(i => i.TimeArea).FirstOrDefault();
                    if (monthDataLast != null)
                    {//有最新每月信息则更新每月信息
                        BuildingMonthInfoBLL buildingMonthInfoBLL = new BuildingMonthInfoBLL();
                        isUpdate = buildingMonthInfoDataBLL.ManageUpdate(monthInfo, monthDataLast.ID.Value) > 0 && buildingMonthInfoBLL.ManageUpdate(monthInfo, monthDataLast.BuildingMonthInfoID.Value) > 0;
                    }

                    #endregion
                    if (isUpdate)
                    {//更新楼栋基本信息
                        #region Building
                        BuildingsBLL     buildingsBLL     = new BuildingsBLL();
                        BuildingsDataBLL buildingsDataBLL = new BuildingsDataBLL();
                        building.ID = null;
                        isUpdate    = buildingsBLL.ManageUpdate(building, buildingID) > 0 && buildingsDataBLL.ManageUpdate(building, buildingID) > 0;
                        #endregion
                        if (isUpdate)
                        {
                            scope.Complete();
                            return(1);
                        }
                    }
                }
            }
            return(0);
        }