コード例 #1
0
ファイル: InitialService.cs プロジェクト: radtek/crm
        /// <summary>
        /// 根据客户号与门店号获取终端初始信息
        /// </summary>
        /// <param name="customer_code"></param>
        /// <param name="unit_code"></param>
        /// <returns></returns>
        public InitialInfo GetPCInitialInfo(string customer_code, string unit_code)
        {
            InitialInfo initialInfo = new InitialInfo();
            //获取客户信息
            CustomerInfo customerInfo = new CustomerInfo();

            customerInfo = GetCustomerInfoByCustomerCode(customer_code);
            if (customerInfo == null || customerInfo.ID.Equals(""))
            {
                throw new Exception("客户不存在");
            }
            //获取登录数据库
            cPos.Model.LoggingSessionInfo loggingSessionInfo = new LoggingSessionInfo();

            //获取门店
            UnitInfo unitInfo = new UnitInfo();

            if (!customerInfo.ID.Equals(""))
            {
                loggingSessionInfo = GetLoggingSessionInfoByCustomerId(customerInfo.ID);
                unitInfo           = new UnitService().GetUnitInfoByCode(loggingSessionInfo, customerInfo.ID, unit_code);
            }
            else
            {
                throw new Exception("门店不存在");
            }
            //获取仓库
            IList <cPos.Model.Pos.WarehouseInfo> warehouseInfoList = new List <Model.Pos.WarehouseInfo>();
            //获取终端号码
            IList <cPos.Model.Pos.PosUnitInfo> posUnitInfoList = new List <cPos.Model.Pos.PosUnitInfo>();
            //获取用户集合
            IList <cPos.Model.User.UserInfo> userInfoList = new List <cPos.Model.User.UserInfo>();

            if (!unitInfo.Id.Equals(""))
            {
                warehouseInfoList = new cPos.Service.PosService().GetWarehouseByUnitID(loggingSessionInfo, unitInfo.Id);
                Hashtable _ht = new Hashtable();
                _ht.Add("UnitID", unitInfo.Id);
                posUnitInfoList = new cPos.Service.PosService().SelectPosUnitList(loggingSessionInfo, _ht);

                cUserService userService = new cUserService();
                userInfoList = userService.GetUserListByUnitId(loggingSessionInfo, unitInfo.Id);
            }


            initialInfo.customerInfo = customerInfo;
            initialInfo.unitInfo     = unitInfo;
            if (warehouseInfoList.Count > 0)
            {
                initialInfo.warehouseInfo = warehouseInfoList[0];
            }
            else
            {
                throw new Exception("仓库不存在");
            }
            if (posUnitInfoList.Count > 0)
            {
                initialInfo.posUnitInfo = posUnitInfoList[0];
            }
            else
            {
                throw new Exception("终端不存在");
            }
            if (userInfoList.Count > 0)
            {
                initialInfo.userInfo = userInfoList[0];
            }
            else
            {
                throw new Exception("用户不存在");
            }
            return(initialInfo);
        }