예제 #1
0
        /// <summary>
        /// 删除路线时使用
        /// </summary>
        /// <param name="id"></param>
        /// <param name="usermapEntity"></param>
        public void GenerateCallDayPlanning_RouteDelete(Guid id, RouteUserMappingEntity usermapEntity)
        {
            //RouteUserMappingEntity usermapEntity = new RouteBLL(CurrentUserInfo).GetRouteUser(id);
            IDbTransaction tran = new TransactionHelper(this.CurrentUserInfo).CreateTransaction();

            using (tran.Connection)
            {
                try
                {
                    if (usermapEntity.ClientUserID.HasValue)
                    {
                        this._currentDAO.GenerateCallDayPlanning(id, usermapEntity.ClientUserID.Value.ToString(), tran);
                    }
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
            }
        }
예제 #2
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Update(RouteUserMappingEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Update(pEntity, pTran);
 }
예제 #3
0
        public void EditRoute(RouteEntity entity, string CycleDetailIDS, int ClientUserID)
        {
            Guid?routeID         = entity.RouteID;
            Guid generateRouteID = new Guid();                  //用于调用生成calldayplanning函数

            RouteCycleMappingEntity[] oldcyclemapEntity = null; //数据库的route cycle 信息
            RouteUserMappingEntity    oldusermapEntity  = null; //数据库的 route user 信息
            RouteEntity oldentity = this._currentDAO.GetByID(entity.RouteID);

            if (routeID != null)
            {
                oldcyclemapEntity = this.GetRouteCycle(routeID.Value);
                oldusermapEntity  = this.GetRouteUser(routeID.Value);
            }

            bool isUpdate = false;

            isUpdate = (routeID != null && !string.IsNullOrEmpty(routeID.ToString()));

            IDbTransaction tran = new TransactionHelper(this.CurrentUserInfo).CreateTransaction();

            using (tran.Connection)
            {
                try
                {
                    /*
                     * 编辑路线信息   路线周期关联信息   路线人员关联信息
                     */

                    #region 路线信息
                    if (isUpdate)
                    {
                        this._currentDAO.Update(entity, tran);
                        generateRouteID = entity.RouteID.Value;
                    }
                    else
                    {
                        this._currentDAO.Create(entity, tran);
                        generateRouteID = entity.RouteID.Value;
                    }
                    #endregion

                    #region 路线信息-周期

                    //前台选择的id
                    Guid[] frontSelectedIDS = Array.ConvertAll <string, Guid>(CycleDetailIDS.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                                                                              , x => Guid.Parse(x)
                                                                              );
                    if (isUpdate)
                    {
                        //数据库已有id
                        IEnumerable <Guid> selectedIDS = oldcyclemapEntity.Select(x => x.CycleDetailID.Value);

                        //需要新增、删除的id
                        IEnumerable <Guid> deletedList = selectedIDS.Except(frontSelectedIDS);
                        IEnumerable <Guid> createList  = frontSelectedIDS.Except(selectedIDS);

                        //删除
                        foreach (Guid id in deletedList)
                        {
                            Guid mappingID = oldcyclemapEntity.Where(x => x.CycleDetailID == id).Select(x => x.MappingID.Value).ToList()[0];
                            new RouteCycleMappingBLL(CurrentUserInfo).Delete(mappingID, tran);
                        }

                        //新增
                        foreach (Guid id in createList)
                        {
                            RouteCycleMappingEntity cyclemapEntity = new RouteCycleMappingEntity();
                            cyclemapEntity.RouteID             = entity.RouteID;
                            cyclemapEntity.CycleDetailID       = id;
                            cyclemapEntity.ClientID            = Convert.ToInt32(CurrentUserInfo.ClientID);
                            cyclemapEntity.ClientDistributorID = Convert.ToInt32(CurrentUserInfo.ClientDistributorID);
                            new RouteCycleMappingBLL(CurrentUserInfo).Create(cyclemapEntity, tran);
                        }
                    }
                    else
                    {
                        //新增
                        foreach (Guid id in frontSelectedIDS)
                        {
                            RouteCycleMappingEntity cyclemapEntity = new RouteCycleMappingEntity();
                            cyclemapEntity.RouteID             = entity.RouteID;
                            cyclemapEntity.CycleDetailID       = id;
                            cyclemapEntity.ClientID            = Convert.ToInt32(CurrentUserInfo.ClientID);
                            cyclemapEntity.ClientDistributorID = Convert.ToInt32(CurrentUserInfo.ClientDistributorID);
                            new RouteCycleMappingBLL(CurrentUserInfo).Create(cyclemapEntity, tran);
                        }
                    }
                    #endregion

                    #region 路线信息-人员
                    if (isUpdate)
                    {
                        if (oldcyclemapEntity != null && oldusermapEntity != null)
                        {
                            int olduserid = oldusermapEntity.ClientUserID.Value;

                            oldusermapEntity.RouteID             = entity.RouteID;
                            oldusermapEntity.ClientUserID        = ClientUserID;
                            oldusermapEntity.ClientID            = Convert.ToInt32(CurrentUserInfo.ClientID);
                            oldusermapEntity.ClientDistributorID = Convert.ToInt32(CurrentUserInfo.ClientDistributorID);
                            new RouteUserMappingBLL(CurrentUserInfo).Update(oldusermapEntity, tran);

                            //删除路线终端信息(如果人员变化 或者 终端类型变化 就清空终端信息)
                            if (olduserid != ClientUserID || oldentity.POPType != entity.POPType)
                            {
                                new RoutePOPMappingDAO(CurrentUserInfo).DeleteRoutePOPMappingByRouteID(routeID.Value, tran);
                            }
                        }
                        else
                        {
                            tran.Rollback();
                            throw new Exception("数据问题,无路线周期、路线人员 关系数据");
                        }
                    }
                    else
                    {
                        RouteUserMappingEntity usermapEntity = new RouteUserMappingEntity();
                        usermapEntity.RouteID             = entity.RouteID;
                        usermapEntity.ClientUserID        = ClientUserID;
                        usermapEntity.ClientID            = Convert.ToInt32(CurrentUserInfo.ClientID);
                        usermapEntity.ClientDistributorID = Convert.ToInt32(CurrentUserInfo.ClientDistributorID);
                        new RouteUserMappingBLL(CurrentUserInfo).Create(usermapEntity, tran);
                    }
                    #endregion

                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
            }

            #region 生成calldayplanning
            if (isUpdate)
            {//修改时调用生成计划
                this.GenerateCallDayPlanning(generateRouteID);
            }
            #endregion
        }
예제 #4
0
 /// <summary>
 /// 创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Create(RouteUserMappingEntity pEntity)
 {
     _currentDAO.Create(pEntity);
 }
예제 #5
0
 /// <summary>
 /// 分页根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public PagedQueryResult <RouteUserMappingEntity> PagedQueryByEntity(RouteUserMappingEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex)
 {
     return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex));
 }
예제 #6
0
 /// <summary>
 /// 根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public RouteUserMappingEntity[] QueryByEntity(RouteUserMappingEntity pQueryEntity, OrderBy[] pOrderBys)
 {
     return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys));
 }
예제 #7
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="pEntity"></param>
 public void Delete(RouteUserMappingEntity pEntity)
 {
     _currentDAO.Delete(pEntity);
 }
예제 #8
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Update(RouteUserMappingEntity pEntity)
 {
     _currentDAO.Update(pEntity);
 }