Ejemplo n.º 1
0
        public PageResultEntity GetStorePageData(HttpContext pContext)
        {
            CallDayPlanningBLL_Store b   = new CallDayPlanningBLL_Store(CurrentUserInfo, "Store");
            string pSearch               = pContext.Request["pSearch"];
            List <DefindControlEntity> l = new List <DefindControlEntity>();

            if (!string.IsNullOrEmpty(pSearch))
            {
                l = pSearch.DeserializeJSONTo <List <DefindControlEntity> >();
            }

            int?pPageIndex = null;
            int?pPageSize  = null;

            if (!string.IsNullOrEmpty(pContext.Request["pPageIndex"]))
            {
                pPageIndex = Convert.ToInt32(pContext.Request["pPageIndex"]);
            }
            if (!string.IsNullOrEmpty(pContext.Request["pPageSize"]))
            {
                pPageSize = Convert.ToInt32(pContext.Request["pPageSize"]);
            }
            CallDayPlanningViewEntity_POP entity = new CallDayPlanningViewEntity_POP();

            entity.ClientUserID = pContext.Request["CorrelationValue"].Split('|')[0].ToInt();
            entity.CallDate     = pContext.Request["CorrelationValue"].Split('|')[1].ToDateTime();
            return(b.GetUserCDPStoreList(l, pPageSize, pPageIndex, entity));
        }
Ejemplo n.º 2
0
        public void EditCDP(CallDayPlanningEntity entity, string poplist)
        {
            CallDayPlanningViewEntity_POP searchEntity = new CallDayPlanningViewEntity_POP();

            searchEntity.ClientUserID = entity.ClientUserID;
            searchEntity.CallDate     = entity.CallDate;
            CallDayPlanningEntity[] oldEntity = this._currentDAO.GetCallDayPlanning(searchEntity);

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

            using (tran.Connection)
            {
                try
                {
                    foreach (string popid in poplist.Split(','))
                    {
                        if (!string.IsNullOrEmpty(popid) &&
                            oldEntity.Where(m => m.POPID == popid).ToArray().Length == 0)
                        {
                            entity.PlanningID = null;
                            entity.POPID      = popid;
                            this._currentDAO.Create(entity, tran);
                        }
                    }

                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
            }
        }
        /// <summary>
        /// 路线地图选择终端
        /// </summary>
        /// <param name="routeid"></param>
        /// <param name="mappingEntity"></param>
        /// <param name="deletelist">删除的ID集合(不要含用户后来又选择的)</param>
        public void EditUserCDPPOPMap_Store(CallDayPlanningViewEntity_POP infoEntity, List <DefindControlEntity> pSearch, CallDayPlanningViewEntity_POP[] mappingEntity, string deletelist)
        {
            IDbTransaction tran = new TransactionHelper(this.CurrentUserInfo).CreateTransaction();

            using (tran.Connection)
            {
                try
                {
                    List <CallDayPlanningEntity> oldList = this._currentDAO.GetCallDayPlanning(infoEntity).ToList();

                    for (int i = 0; i < mappingEntity.Length; i++)
                    {
                        CallDayPlanningViewEntity_POP entity = mappingEntity[i];

                        if (entity.MappingID != null && !string.IsNullOrEmpty(entity.MappingID.ToString()))
                        {
                            //修改
                            CallDayPlanningEntity uEntity = oldList.Where(m => m.PlanningID == entity.MappingID).ToArray()[0];
                            uEntity.Sequence = (i + 1);
                            this._currentDAO.Update(uEntity, tran);
                        }
                        else
                        {
                            //新增
                            CallDayPlanningEntity uEntity = new CallDayPlanningEntity();

                            uEntity.CallDate     = infoEntity.CallDate;
                            uEntity.POPID        = entity.StoreID.ToString().ToLower();
                            uEntity.POPType      = 1;
                            uEntity.ClientUserID = infoEntity.ClientUserID;
                            uEntity.Sequence     = (i + 1);
                            uEntity.PlanningType = 2;

                            uEntity.ClientID            = Convert.ToInt32(CurrentUserInfo.ClientID);
                            uEntity.ClientDistributorID = Convert.ToInt32(CurrentUserInfo.ClientDistributorID);
                            this._currentDAO.Create(uEntity, tran);
                        }
                    }
                    //删除
                    if (deletelist != null && !string.IsNullOrEmpty(deletelist))
                    {
                        foreach (string mapid in deletelist.Split(','))
                        {
                            if (!string.IsNullOrEmpty(mapid))
                            {
                                this._currentDAO.Delete(Guid.Parse(mapid), tran);
                            }
                        }
                    }

                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
            }
        }
        /// <summary>
        /// 拜访计划终端选择
        /// </summary>
        /// <param name="infoEntity">clientuserid,calldate 必传</param>
        /// <param name="pSearch"></param>
        /// <param name="mappingEntity"></param>
        public void EditUserCDPPOPList_Store(
            CallDayPlanningViewEntity_POP infoEntity,
            List <DefindControlEntity> pSearch,
            CallDayPlanningViewEntity_POP[] mappingEntity)
        {
            IDbTransaction tran = new TransactionHelper(this.CurrentUserInfo).CreateTransaction();

            using (tran.Connection)
            {
                try
                {
                    List <CallDayPlanningEntity> oldList = this._currentDAO.GetCallDayPlanning(infoEntity).ToList();

                    foreach (CallDayPlanningViewEntity_POP entity in mappingEntity)
                    {
                        if (entity.MappingID != null && !string.IsNullOrEmpty(entity.MappingID.ToString()))
                        {
                            if (entity.IsDelete == 1)
                            {
                                //删除
                                this._currentDAO.Delete(entity.MappingID, tran);
                            }
                            else
                            {
                                //修改
                                CallDayPlanningEntity uEntity = oldList.Where(m => m.PlanningID == entity.MappingID).ToArray()[0];
                                uEntity.Sequence = entity.Sequence;
                                this._currentDAO.Update(uEntity, tran);
                            }
                        }
                        else
                        {
                            //新增
                            CallDayPlanningEntity uEntity = new CallDayPlanningEntity();

                            uEntity.CallDate     = infoEntity.CallDate;
                            uEntity.POPID        = entity.StoreID.ToString().ToLower();
                            uEntity.POPType      = 1;
                            uEntity.ClientUserID = infoEntity.ClientUserID;
                            uEntity.Sequence     = entity.Sequence;
                            uEntity.PlanningType = 2;

                            uEntity.ClientID            = Convert.ToInt32(CurrentUserInfo.ClientID);
                            uEntity.ClientDistributorID = Convert.ToInt32(CurrentUserInfo.ClientDistributorID);
                            this._currentDAO.Create(uEntity, tran);
                        }
                    }

                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
            }
        }
Ejemplo n.º 5
0
        private string EditRoutePOPList_Store(HttpContext pContext)
        {
            string pSearch = pContext.Request["pSearch"];
            List <DefindControlEntity> l = new List <DefindControlEntity>();

            if (!string.IsNullOrEmpty(pSearch))
            {
                l = pSearch.DeserializeJSONTo <List <DefindControlEntity> >();
            }
            CallDayPlanningViewEntity_POP infoEntity = new CallDayPlanningViewEntity_POP();

            infoEntity.ClientUserID = pContext.Request["id"].Split('|')[0].ToInt();
            infoEntity.CallDate     = pContext.Request["id"].Split('|')[1].ToDateTime();

            CallDayPlanningViewEntity_POP[] entity = pContext.Request["form"].DeserializeJSONTo <CallDayPlanningViewEntity_POP[]>();

            new CallDayPlanningBLL_Store(CurrentUserInfo, "Store").EditUserCDPPOPList_Store(infoEntity, l, entity);
            return("{success:true}");
        }
        public PageResultEntity GetUserCDPStoreList(List <DefindControlEntity> pSearch, int?pPageSize, int?pPageIndex, CallDayPlanningViewEntity_POP entity)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append(base.GetTempSql());                                                        //需要生成的临时表
            sql.AppendLine("select ");
            sql.Append(new StoreDefindModuleBLL(CurrentUserInfo, "Store").GetStoreGridFildSQL()); //获取字SQL

            //new
            sql.AppendFormat(" CPOPM.PlanningID as MappingID,cast('{0}' as int) as ClientUserID,CPOPM.POPID,CPOPM.Sequence, ", entity.ClientUserID);

            sql.AppendLine("ROW_NUMBER() OVER( order by case when CPOPM.PlanningID is null then 1 else 0 end asc,CPOPM.Sequence asc,CPOPM.CreateTime asc) ROW_NUMBER,");
            sql.AppendLine("main.StoreID into #outTemp");
            sql.AppendLine("from Store main");
            sql.Append(new StoreDefindModuleBLL(CurrentUserInfo, "Store").GetStoreLeftGridJoinSQL());      //获取联接SQL
            sql.AppendLine("");
            sql.Append(new StoreDefindModuleBLL(CurrentUserInfo, "Store").GetStoreSearchJoinSQL(pSearch)); //获取条件联接SQL

            //new
            sql.AppendLine(string.Format(" inner join (select distinct StoreID from dbo.fnGetStoreByUserID('{0}',1)) fn_sad on  CONVERT(nvarchar(100),main.StoreID) = CONVERT(nvarchar(100),fn_sad.StoreID) ", entity.ClientUserID));

            sql.AppendFormat(@" left join CallDayPlanning CPOPM 
                                on CPOPM.POPType=1 and cast(main.StoreID as nvarchar(200))=CPOPM.POPID 
                                and CPOPM.isdelete=0 and CONVERT(date,CPOPM.CallDate,23)='{0}' and CPOPM.ClientUserID={1} 
                                and CPOPM.ClientID={2} and CPOPM.ClientDistributorID={3}",
                             entity.CallDate.Value.ToShortDateString(),
                             entity.ClientUserID,
                             CurrentUserInfo.ClientID,
                             CurrentUserInfo.ClientDistributorID);

            sql.AppendLine(string.Format("Where main.IsDelete=0 and main.ClientID={0}",
                                         base._pUserInfo.ClientID));

            sql.Append(new StoreDefindModuleBLL(CurrentUserInfo, "").GetStroeGridSearchSQL(pSearch)); //获取条件
            sql.Append(base.GetPubPageSQL(pPageSize, pPageIndex));
            sql.Append(base.GetDropTempSql());                                                        //需要删除的临时表
            return(base.GetPageData(sql.ToString()));
        }