コード例 #1
0
        /// <summary>
        /// 判断当前节点是否已存在相同的
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int  ExistNum(InquiryOrderMemberEntity entity)
        {
            ///id=0,判断总数,ID>0判断除自己之外的总数
            string sql = @"Select count(1) from dbo.[InquiryOrderMember] WITH(NOLOCK) ";

            string where = "where ";
            if (entity.Id == 0)
            {
                where = where + "  (MemName=@MemName) ";
                where = where + "  (CompanyName=@CompanyName) ";
            }
            else
            {
                where = where + " id<>@Id and  (MemName=@MemName) ";
                where = where + " id<>@Id and  (CompanyName=@CompanyName) ";
            }
            sql = sql + where;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            if (entity.Id > 0)
            {
                db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id);
            }

            db.AddInParameter(cmd, "@MemName", DbType.String, entity.MemName);

            db.AddInParameter(cmd, "@CompanyName", DbType.String, entity.CompanyName);
            object identity = db.ExecuteScalar(cmd);

            if (identity == null || identity == DBNull.Value)
            {
                return(0);
            }
            return(Convert.ToInt32(identity));
        }
コード例 #2
0
        /// <summary>
        /// 根据主键值读取记录。如果数据库不存在这条数据将返回null
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public InquiryOrderMemberEntity GetInquiryOrderMember(int id)
        {
            string    sql = @"SELECT  [Id],[InquiryOrderCode],[MemId],[MemName],[MemPhone],[CompanyAddress],[CompanyName]
							FROM
							dbo.[InquiryOrderMember] WITH(NOLOCK)	
							WHERE [Id]=@id"                            ;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@Id", DbType.Int32, id);
            InquiryOrderMemberEntity entity = new InquiryOrderMemberEntity();

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                if (reader.Read())
                {
                    entity.Id = StringUtils.GetDbInt(reader["Id"]);
                    entity.InquiryOrderCode = StringUtils.GetDbString(reader["InquiryOrderCode"]);
                    entity.MemId            = StringUtils.GetDbInt(reader["MemId"]);
                    entity.MemName          = StringUtils.GetDbString(reader["MemName"]);
                    entity.MemPhone         = StringUtils.GetDbString(reader["MemPhone"]);
                    entity.CompanyAddress   = StringUtils.GetDbString(reader["CompanyAddress"]);
                    entity.CompanyName      = StringUtils.GetDbString(reader["CompanyName"]);
                }
            }
            return(entity);
        }
コード例 #3
0
        public string InquiryOrderEdit1(InquiryOrderEntity order)
        {
            bool needmember = false;

            if (string.IsNullOrEmpty(order.Code))
            {
                Random rd = new Random();
                order.Code = XTCodeBLL.Instance.GetCodeFromProc(XTCodeType.OrderDayNo) + rd.Next(100, 999).ToString();
                needmember = true;
            }
            order.Code = InquiryOrderDA.Instance.InquiryOrderEdit1(order);
            if (needmember)
            {
                MemStoreEntity           stor  = StoreBLL.Instance.GetStoreByMemId(order.MemId);
                InquiryOrderMemberEntity memen = new InquiryOrderMemberEntity();
                memen.MemId            = order.MemId;
                memen.InquiryOrderCode = order.Code;
                memen.MemName          = stor.ContactsManName;
                memen.MemPhone         = stor.MobilePhone;
                memen.CompanyName      = stor.CompanyName;
                memen.CompanyAddress   = stor.Address;
                InquiryOrderMemberBLL.Instance.AddInquiryOrderMember(memen);
            }
            return(order.Code);
        }
コード例 #4
0
        /// <summary>
        /// 根据主键值更新记录的全部字段(注意:该方法不会对自增字段、timestamp类型字段以及主键字段更新!如果要更新主键字段,请使用Update方法)。
        /// 如果数据库有数据被更新了则返回True,否则返回False
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="inquiryOrderMember">待更新的实体对象</param>
        public int UpdateInquiryOrderMember(InquiryOrderMemberEntity entity)
        {
            string    sql = @" UPDATE dbo.[InquiryOrderMember] SET
                       [InquiryOrderCode]=@InquiryOrderCode,[MemId]=@MemId,[MemName]=@MemName,[MemPhone]=@MemPhone,[CompanyAddress]=@CompanyAddress,[CompanyName]=@CompanyName
                       WHERE [Id]=@id";
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id);
            db.AddInParameter(cmd, "@InquiryOrderCode", DbType.String, entity.InquiryOrderCode);
            db.AddInParameter(cmd, "@MemId", DbType.Int32, entity.MemId);
            db.AddInParameter(cmd, "@MemName", DbType.String, entity.MemName);
            db.AddInParameter(cmd, "@MemPhone", DbType.String, entity.MemPhone);
            db.AddInParameter(cmd, "@CompanyAddress", DbType.String, entity.CompanyAddress);
            db.AddInParameter(cmd, "@CompanyName", DbType.String, entity.CompanyName);
            return(db.ExecuteNonQuery(cmd));
        }
コード例 #5
0
        /// <summary>
        /// 读取记录列表。
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public IList <InquiryOrderMemberEntity> GetInquiryOrderMemberList(int pagesize, int pageindex, ref int recordCount)
        {
            string sql = @"SELECT   [Id],[InquiryOrderCode],[MemId],[MemName],[MemPhone],[CompanyAddress],[CompanyName]
						FROM
						(SELECT ROW_NUMBER() OVER (ORDER BY Id desc) AS ROWNUMBER,
						 [Id],[InquiryOrderCode],[MemId],[MemName],[MemPhone],[CompanyAddress],[CompanyName] from dbo.[InquiryOrderMember] WITH(NOLOCK)	
						WHERE  1=1 ) as temp 
						where rownumber BETWEEN ((@PageIndex - 1) * @PageSize + 1) AND @PageIndex * @PageSize"                        ;

            string sql2 = @"Select count(1) from dbo.[InquiryOrderMember] with (nolock) ";
            IList <InquiryOrderMemberEntity> entityList = new List <InquiryOrderMemberEntity>();
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageindex);
            db.AddInParameter(cmd, "@PageSize", DbType.Int32, pagesize);

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    InquiryOrderMemberEntity entity = new InquiryOrderMemberEntity();
                    entity.Id = StringUtils.GetDbInt(reader["Id"]);
                    entity.InquiryOrderCode = StringUtils.GetDbString(reader["InquiryOrderCode"]);
                    entity.MemId            = StringUtils.GetDbInt(reader["MemId"]);
                    entity.MemName          = StringUtils.GetDbString(reader["MemName"]);
                    entity.MemPhone         = StringUtils.GetDbString(reader["MemPhone"]);
                    entity.CompanyAddress   = StringUtils.GetDbString(reader["CompanyAddress"]);
                    entity.CompanyName      = StringUtils.GetDbString(reader["CompanyName"]);
                    entityList.Add(entity);
                }
            }
            cmd = db.GetSqlStringCommand(sql2);
            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                if (reader.Read())
                {
                    recordCount = StringUtils.GetDbInt(reader[0]);
                }
                else
                {
                    recordCount = 0;
                }
            }
            return(entityList);
        }
コード例 #6
0
        /// <summary>
        /// 插入一条记录到表InquiryOrderMember,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="inquiryOrderMember">待插入的实体对象</param>
        public int AddInquiryOrderMember(InquiryOrderMemberEntity entity)
        {
            string    sql = @"insert into InquiryOrderMember( [InquiryOrderCode],[MemId],[MemName],[MemPhone],[CompanyAddress],[CompanyName])VALUES
			            ( @InquiryOrderCode,@MemId,@MemName,@MemPhone,@CompanyAddress,@CompanyName);
			SELECT SCOPE_IDENTITY();"            ;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@InquiryOrderCode", DbType.String, entity.InquiryOrderCode);
            db.AddInParameter(cmd, "@MemId", DbType.Int32, entity.MemId);
            db.AddInParameter(cmd, "@MemName", DbType.String, entity.MemName);
            db.AddInParameter(cmd, "@MemPhone", DbType.String, entity.MemPhone);
            db.AddInParameter(cmd, "@CompanyAddress", DbType.String, entity.CompanyAddress);
            db.AddInParameter(cmd, "@CompanyName", DbType.String, entity.CompanyName);
            object identity = db.ExecuteScalar(cmd);

            if (identity == null || identity == DBNull.Value)
            {
                return(0);
            }
            return(Convert.ToInt32(identity));
        }
コード例 #7
0
        /// <summary>
        /// 读取记录列表。
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public IList <InquiryOrderMemberEntity> GetInquiryOrderMemberAll()
        {
            string sql = @"SELECT    [Id],[InquiryOrderCode],[MemId],[MemName],[MemPhone],[CompanyAddress],[CompanyName] from dbo.[InquiryOrderMember] WITH(NOLOCK)	";
            IList <InquiryOrderMemberEntity> entityList = new List <InquiryOrderMemberEntity>();
            DbCommand cmd = db.GetSqlStringCommand(sql);

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    InquiryOrderMemberEntity entity = new InquiryOrderMemberEntity();
                    entity.Id = StringUtils.GetDbInt(reader["Id"]);
                    entity.InquiryOrderCode = StringUtils.GetDbString(reader["InquiryOrderCode"]);
                    entity.MemId            = StringUtils.GetDbInt(reader["MemId"]);
                    entity.MemName          = StringUtils.GetDbString(reader["MemName"]);
                    entity.MemPhone         = StringUtils.GetDbString(reader["MemPhone"]);
                    entity.CompanyAddress   = StringUtils.GetDbString(reader["CompanyAddress"]);
                    entity.CompanyName      = StringUtils.GetDbString(reader["CompanyName"]);
                    entityList.Add(entity);
                }
            }
            return(entityList);
        }
コード例 #8
0
 /// <summary>
 /// 更新一条InquiryOrderMember记录。
 /// 该方法提供给界面等UI层调用
 /// </summary>
 /// <param name="inquiryOrderMember">待更新的实体对象</param>
 /// <param name="columns">要更新的列名,不提供任何列名时默认将更新主键之外的所有列</param>
 public int UpdateInquiryOrderMember(InquiryOrderMemberEntity inquiryOrderMember)
 {
     return(InquiryOrderMemberDA.Instance.UpdateInquiryOrderMember(inquiryOrderMember));
 }
コード例 #9
0
 /// <summary>
 /// 插入一条记录到表InquiryOrderMember,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0。
 /// 该方法提供给界面等UI层调用
 /// </summary>
 /// <param name="inquiryOrderMember">要添加的InquiryOrderMember数据实体对象</param>
 public int AddInquiryOrderMember(InquiryOrderMemberEntity inquiryOrderMember)
 {
     return(InquiryOrderMemberDA.Instance.AddInquiryOrderMember(inquiryOrderMember));
 }
コード例 #10
0
 /// <summary>
 /// 判断对象是否存在
 /// </summary>
 /// <param name="dicEnum"></param>
 /// <returns></returns>
 public bool IsExist(InquiryOrderMemberEntity inquiryOrderMember)
 {
     return(InquiryOrderMemberDA.Instance.ExistNum(inquiryOrderMember) > 0);
 }