Esempio n. 1
0
        /// <summary>
        /// 根据用户池公司联系人信息集合FOR XML AUTO, ROOT('root')后的字符串获取联系人信息集合
        /// </summary>
        /// <param name="s">FOR XML AUTO后的字符串</param>
        /// <returns></returns>
        private IList <EyouSoft.Model.PoolStructure.ContacterInfo> GetContactersByXml(string s)
        {
            IList <EyouSoft.Model.PoolStructure.ContacterInfo> contacters = new List <EyouSoft.Model.PoolStructure.ContacterInfo>();

            if (string.IsNullOrEmpty(s))
            {
                return(contacters);
            }

            System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
            xd.LoadXml(s);

            System.Xml.XmlNodeList xnl = xd.GetElementsByTagName("tbl_CompanyContacter");

            if (xnl != null)
            {
                foreach (System.Xml.XmlNode xn in xnl)
                {
                    EyouSoft.Model.PoolStructure.ContacterInfo contacter = new EyouSoft.Model.PoolStructure.ContacterInfo();

                    contacter.ContacterId = int.Parse(xn.Attributes["ContactId"].Value);
                    contacter.Fullname    = xn.Attributes["Fullname"] != null ? xn.Attributes["Fullname"].Value : string.Empty;
                    contacter.JobTitle    = xn.Attributes["JobTitle"] != null ? xn.Attributes["JobTitle"].Value : string.Empty;
                    contacter.Mobile      = xn.Attributes["Mobile"] != null ? xn.Attributes["Mobile"].Value : string.Empty;
                    if (xn.Attributes["Birthday"] != null)
                    {
                        contacter.Birthday = Convert.ToDateTime(xn.Attributes["Birthday"].Value);
                    }

                    contacters.Add(contacter);
                }
            }

            return(contacters);
        }
Esempio n. 2
0
        /// <summary>
        /// 获取用户池公司信息业务实体
        /// </summary>
        /// <param name="companyId">公司编号</param>
        /// <returns></returns>
        public virtual EyouSoft.Model.PoolStructure.CompanyInfo GetCompanyInfo(string companyId)
        {
            EyouSoft.Model.PoolStructure.CompanyInfo info = null;
            DbCommand cmd = this._db.GetSqlStringCommand(SQL_SELECT_GetCompanyInfo);

            this._db.AddInParameter(cmd, "CompanyId", DbType.AnsiStringFixedLength, companyId);

            using (IDataReader rdr = DbHelper.ExecuteReader(cmd, this._db))
            {
                #region 公司信息
                if (rdr.Read())
                {
                    info             = new EyouSoft.Model.PoolStructure.CompanyInfo();
                    info.Address     = rdr["Address"].ToString();
                    info.CityId      = rdr.GetInt32(rdr.GetOrdinal("CityId"));
                    info.CompanyId   = rdr.GetString(rdr.GetOrdinal("CompanyId"));
                    info.CompanyName = rdr["CompanyName"].ToString();
                    //info.Contacters = null;
                    info.CountyId   = rdr.GetInt32(rdr.GetOrdinal("CountyId"));
                    info.CreateTime = rdr.GetDateTime(rdr.GetOrdinal("CreateTime"));
                    //info.CustomerTypeConfig = null;
                    info.ProvinceId = rdr.GetInt32(rdr.GetOrdinal("ProvinceId"));
                    info.Remark     = rdr["Remark"].ToString();
                    info.Star       = rdr["Star"].ToString();
                    //info.SuitProductConfig = null;
                }

                if (info == null)
                {
                    return(null);
                }
                #endregion

                #region 联系人
                rdr.NextResult();
                info.Contacters = new List <EyouSoft.Model.PoolStructure.ContacterInfo>();
                while (rdr.Read())
                {
                    var contacter = new EyouSoft.Model.PoolStructure.ContacterInfo();

                    contacter.Character   = rdr["Character"].ToString();
                    contacter.CompanyId   = rdr.GetString(rdr.GetOrdinal("CompanyId"));
                    contacter.ContacterId = rdr.GetInt32(rdr.GetOrdinal("ContactId"));
                    contacter.CreateTime  = rdr.GetDateTime(rdr.GetOrdinal("CreateTime"));
                    contacter.Email       = rdr["Email"].ToString();
                    contacter.Fullname    = rdr["Fullname"].ToString();
                    contacter.Interest    = rdr["Interest"].ToString();
                    contacter.JobTitle    = rdr["JobTitle"].ToString();
                    contacter.Mobile      = rdr["Mobile"].ToString();
                    contacter.QQ          = rdr["QQ"].ToString();
                    contacter.Remark      = rdr["Remark"].ToString();

                    if (!rdr.IsDBNull(rdr.GetOrdinal("Birthday")))
                    {
                        contacter.Birthday = rdr.GetDateTime(rdr.GetOrdinal("Birthday"));
                    }

                    if (!rdr.IsDBNull(rdr.GetOrdinal("RememberDay")))
                    {
                        contacter.RememberDay = rdr.GetDateTime(rdr.GetOrdinal("RememberDay"));
                    }

                    info.Contacters.Add(contacter);
                }
                #endregion

                #region  公司类型
                rdr.NextResult();
                info.CustomerTypeConfig = new List <EyouSoft.Model.PoolStructure.CustomerTypeInfo>();
                while (rdr.Read())
                {
                    info.CustomerTypeConfig.Add(new EyouSoft.Model.PoolStructure.CustomerTypeInfo()
                    {
                        TypeId = rdr.GetInt32(rdr.GetOrdinal("TypeId"))
                    });
                }
                #endregion

                #region 适用产品
                rdr.NextResult();
                info.SuitProductConfig = new List <EyouSoft.Model.PoolStructure.SuitProductInfo>();
                while (rdr.Read())
                {
                    info.SuitProductConfig.Add(new EyouSoft.Model.PoolStructure.SuitProductInfo()
                    {
                        ProuctId = rdr.GetInt32(rdr.GetOrdinal("SuitProductId"))
                    });
                }
                #endregion
            }

            return(info);
        }
Esempio n. 3
0
        /// <summary>
        /// 获取公司信息集合,列表以公司联系人信息为行集
        /// </summary>
        /// <param name="pageSize">每页记录数</param>
        /// <param name="pageIndex">当前页索引</param>
        /// <param name="recordCount">总记录数</param>
        /// <param name="searchInfo">查询信息</param>
        /// <returns></returns>
        public virtual IList <EyouSoft.Model.PoolStructure.ContacterInfo> GetCompanysItemByContacter(int pageSize, int pageIndex, ref int recordCount, EyouSoft.Model.PoolStructure.CompanySearchInfo searchInfo)
        {
            IList <EyouSoft.Model.PoolStructure.ContacterInfo> contacters = new List <EyouSoft.Model.PoolStructure.ContacterInfo>();
            StringBuilder cmdText       = new StringBuilder();
            string        tableName     = "view_Company_ItemsByContacter";
            string        primaryKey    = "ContactId";
            string        orderByString = "CreateTime DESC";
            string        fields        = "ContactId,CompanyId,CompanyName,Fullname,Mobile,JobTitle,Birthday";

            #region 拼接查询
            cmdText.Append(" 1=1 ");

            if (searchInfo.CityId.HasValue)
            {
                cmdText.AppendFormat(" AND CityId={0} ", searchInfo.CityId.Value);
            }

            if (!string.IsNullOrEmpty(searchInfo.CompanyName))
            {
                cmdText.AppendFormat(" AND CompanyName LIKE '%{0}%' ", searchInfo.CompanyName);
            }

            if (searchInfo.CountyId.HasValue)
            {
                cmdText.AppendFormat(" AND CountyId={0} ", searchInfo.CountyId.Value);
            }

            if (searchInfo.ProvinceId.HasValue)
            {
                cmdText.AppendFormat(" AND ProvinceId={0} ", searchInfo.ProvinceId.Value);
            }

            if (!string.IsNullOrEmpty(searchInfo.ContacterFullname))
            {
                cmdText.AppendFormat(" AND Fullname LIKE '%{0}%' ", searchInfo.ContacterFullname);
            }

            if (!string.IsNullOrEmpty(searchInfo.ContacterMobile))
            {
                cmdText.AppendFormat(" AND Mobile='{0}' ", searchInfo.ContacterMobile);
            }

            if (searchInfo.CustomerTypeId.HasValue)
            {
                cmdText.AppendFormat(" AND EXISTS(SELECT 1 FROM tbl_CompanyCustomerTypeConfig WHERE CompanyId=view_Company_ItemsByContacter.CompanyId AND TypeId={0}) ", searchInfo.CustomerTypeId.Value);
            }

            if (searchInfo.SuitProductId.HasValue)
            {
                cmdText.AppendFormat(" AND EXISTS(SELECT 1 FROM tbl_CompanySuitProductConfig WHERE CompanyId=view_Company_ItemsByContacter.CompanyId AND SuitProductId={0}) ", searchInfo.SuitProductId.Value);
            }

            if (searchInfo.UserCitys != null && searchInfo.UserCitys.Length > 0)
            {
                cmdText.Append(" AND CityId IN( ");
                cmdText.Append(searchInfo.UserCitys[0].ToString());

                for (int i = 1; i < searchInfo.UserCitys.Length; i++)
                {
                    cmdText.AppendFormat(",{0}", searchInfo.UserCitys[i].ToString());
                }

                cmdText.Append(" ) ");
            }

            if (searchInfo.UserCustomerTypes != null && searchInfo.UserCustomerTypes.Count > 0)
            {
                cmdText.Append(" AND EXISTS(SELECT 1 FROM tbl_CompanyCustomerTypeConfig WHERE CompanyId=view_Company_ItemsByContacter.CompanyId AND TypeId IN( ");
                cmdText.Append(searchInfo.UserCustomerTypes[0].ToString());

                for (int i = 1; i < searchInfo.UserCustomerTypes.Count; i++)
                {
                    cmdText.AppendFormat(",{0}", searchInfo.UserCustomerTypes[i].ToString());
                }

                cmdText.Append(" )) ");
            }
            #endregion

            using (IDataReader rdr = DbHelper.ExecuteReader(this._db, pageSize, pageIndex, ref recordCount, tableName, primaryKey, fields, cmdText.ToString(), orderByString))
            {
                while (rdr.Read())
                {
                    EyouSoft.Model.PoolStructure.ContacterInfo contacter = new EyouSoft.Model.PoolStructure.ContacterInfo();

                    contacter.CompanyId   = rdr.GetString(rdr.GetOrdinal("CompanyId"));
                    contacter.CompanyName = rdr["CompanyName"].ToString();
                    contacter.ContacterId = rdr.GetInt32(rdr.GetOrdinal("ContactId"));
                    contacter.Fullname    = rdr["Fullname"].ToString();
                    contacter.Mobile      = rdr["Mobile"].ToString();
                    contacter.JobTitle    = rdr["JobTitle"].ToString();

                    if (!rdr.IsDBNull(rdr.GetOrdinal("Birthday")))
                    {
                        contacter.Birthday = rdr.GetDateTime(rdr.GetOrdinal("Birthday"));
                    }

                    contacters.Add(contacter);
                }
            }

            return(contacters);
        }