Esempio n. 1
0
        /// <summary>
        /// 插入一条记录到表CGQuotedPrice,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="cGQuotedPrice">待插入的实体对象</param>
        public int AddCGQuotedPrice(CGQuotedPriceEntity entity)
        {
            string    sql = @"insert into CGQuotedPrice( [InquiryOrderCode],[InquiryProductId],[CGMemId],[CGPrice],[Price],[InquiryProductType],[InquiryProductDes],[Remark],[HasSelected],[QuotedTime],[CheckMemId],[CheckTime])VALUES
			            ( @InquiryOrderCode,@InquiryProductId,@CGMemId,@CGPrice,@Price,@InquiryProductType,@InquiryProductDes,@Remark,@HasSelected,@QuotedTime,@CheckMemId,@CheckTime);
			SELECT SCOPE_IDENTITY();"            ;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@InquiryOrderCode", DbType.String, entity.InquiryOrderCode);
            db.AddInParameter(cmd, "@InquiryProductId", DbType.Int32, entity.InquiryProductId);
            db.AddInParameter(cmd, "@CGMemId", DbType.Int32, entity.CGMemId);
            db.AddInParameter(cmd, "@CGPrice", DbType.Decimal, entity.CGPrice);
            db.AddInParameter(cmd, "@Price", DbType.Decimal, entity.Price);
            db.AddInParameter(cmd, "@InquiryProductType", DbType.Int32, entity.InquiryProductType);
            db.AddInParameter(cmd, "@InquiryProductDes", DbType.String, entity.InquiryProductDes);
            db.AddInParameter(cmd, "@Remark", DbType.String, entity.Remark);
            db.AddInParameter(cmd, "@HasSelected", DbType.Int32, entity.HasSelected);
            db.AddInParameter(cmd, "@QuotedTime", DbType.DateTime, entity.QuotedTime);
            db.AddInParameter(cmd, "@CheckMemId", DbType.Int32, entity.CheckMemId);
            db.AddInParameter(cmd, "@CheckTime", DbType.String, entity.CheckTime);
            object identity = db.ExecuteScalar(cmd);

            if (identity == null || identity == DBNull.Value)
            {
                return(0);
            }
            return(Convert.ToInt32(identity));
        }
Esempio n. 2
0
        /// <summary>
        /// 判断当前节点是否已存在相同的
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int  ExistNum(CGQuotedPriceEntity entity)
        {
            ///id=0,判断总数,ID>0判断除自己之外的总数
            string sql = @"Select count(1) from dbo.[CGQuotedPrice] WITH(NOLOCK) ";

            string where = "where ";
            if (entity.Id == 0)
            {
            }
            else
            {
            }
            sql = sql + where;
            DbCommand cmd = db.GetSqlStringCommand(sql);

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

            if (identity == null || identity == DBNull.Value)
            {
                return(0);
            }
            return(Convert.ToInt32(identity));
        }
Esempio n. 3
0
        /// <summary>
        /// 根据主键值读取记录。如果数据库不存在这条数据将返回null
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public CGQuotedPriceEntity GetCGQuotedPrice(int id)
        {
            string    sql = @"SELECT  [Id],[InquiryOrderCode],[InquiryProductId],[CGMemId],[CGPrice],[Price],[InquiryProductType],[InquiryProductDes],[Remark],[HasSelected],[QuotedTime],[CheckMemId],[CheckTime]
							FROM
							dbo.[CGQuotedPrice] WITH(NOLOCK)	
							WHERE [Id]=@id"                            ;
            DbCommand cmd = db.GetSqlStringCommand(sql);

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

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                if (reader.Read())
                {
                    entity.Id = StringUtils.GetDbInt(reader["Id"]);
                    entity.InquiryOrderCode   = StringUtils.GetDbString(reader["InquiryOrderCode"]);
                    entity.InquiryProductId   = StringUtils.GetDbInt(reader["InquiryProductId"]);
                    entity.CGMemId            = StringUtils.GetDbInt(reader["CGMemId"]);
                    entity.CGPrice            = StringUtils.GetDbDecimal(reader["CGPrice"]);
                    entity.Price              = StringUtils.GetDbDecimal(reader["Price"]);
                    entity.InquiryProductType = StringUtils.GetDbInt(reader["InquiryProductType"]);
                    entity.InquiryProductDes  = StringUtils.GetDbString(reader["InquiryProductDes"]);
                    entity.Remark             = StringUtils.GetDbString(reader["Remark"]);
                    entity.HasSelected        = StringUtils.GetDbInt(reader["HasSelected"]);
                    entity.QuotedTime         = StringUtils.GetDbDateTime(reader["QuotedTime"]);
                    entity.CheckMemId         = StringUtils.GetDbInt(reader["CheckMemId"]);
                    entity.CheckTime          = StringUtils.GetDbString(reader["CheckTime"]);
                }
            }
            return(entity);
        }
Esempio n. 4
0
        /// <summary>
        /// 读取记录列表。
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public IList <CGQuotedPriceEntity> GetCGQuotedPriceAll(string ordercode, int cgmemid, bool hascgprice, bool hasprice, bool hasselect)
        {
            string where = " where 1=1 ";
            if (!string.IsNullOrEmpty(ordercode))
            {
                where += " and InquiryOrderCode=@InquiryOrderCode ";
            }
            if (cgmemid != -1)
            {
                where += " and CGMemId=@CGMemId ";
            }
            if (hascgprice)
            {
                where += " and CGPrice>0 ";
            }
            if (hasprice)
            {
                where += " and Price>0 ";
            }
            if (hasselect)
            {
                where += " and HasSelected=1 ";
            }
            string sql = @"SELECT    [Id],[InquiryOrderCode],[InquiryProductId],[InquiryProductSubId],[CGMemId],[CGPrice],[Price],[InquiryProductType],[InquiryProductDes],[Remark],[HasSelected],[QuotedTime],[CheckMemId],
[CheckTime] from dbo.[CGQuotedPrice] WITH(NOLOCK)       " + where;
            IList <CGQuotedPriceEntity> entityList = new List <CGQuotedPriceEntity>();
            DbCommand cmd = db.GetSqlStringCommand(sql);

            if (!string.IsNullOrEmpty(ordercode))
            {
                db.AddInParameter(cmd, "@InquiryOrderCode", DbType.String, ordercode);
            }
            if (cgmemid != -1)
            {
                db.AddInParameter(cmd, "@CGMemId", DbType.Int32, cgmemid);
            }
            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    CGQuotedPriceEntity entity = new CGQuotedPriceEntity();
                    entity.Id = StringUtils.GetDbInt(reader["Id"]);
                    entity.InquiryOrderCode    = StringUtils.GetDbString(reader["InquiryOrderCode"]);
                    entity.InquiryProductId    = StringUtils.GetDbInt(reader["InquiryProductId"]);
                    entity.InquiryProductSubId = StringUtils.GetDbInt(reader["InquiryProductSubId"]);
                    entity.CGMemId             = StringUtils.GetDbInt(reader["CGMemId"]);
                    entity.CGPrice             = StringUtils.GetDbDecimal(reader["CGPrice"]);
                    entity.Price = StringUtils.GetDbDecimal(reader["Price"]);
                    entity.InquiryProductType = StringUtils.GetDbInt(reader["InquiryProductType"]);
                    entity.InquiryProductDes  = StringUtils.GetDbString(reader["InquiryProductDes"]);
                    entity.Remark             = StringUtils.GetDbString(reader["Remark"]);
                    entity.HasSelected        = StringUtils.GetDbInt(reader["HasSelected"]);
                    entity.QuotedTime         = StringUtils.GetDbDateTime(reader["QuotedTime"]);
                    entity.CheckMemId         = StringUtils.GetDbInt(reader["CheckMemId"]);
                    entity.CheckTime          = StringUtils.GetDbString(reader["CheckTime"]);
                    entityList.Add(entity);
                }
            }
            return(entityList);
        }
Esempio n. 5
0
        /// <summary>
        /// 读取记录列表。
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public IList <CGQuotedPriceEntity> GetCGQuotedPriceList(int pagesize, int pageindex, ref int recordCount)
        {
            string sql = @"SELECT   [Id],[InquiryOrderCode],[InquiryProductId],[CGMemId],[CGPrice],[Price],[InquiryProductType],[InquiryProductDes],[Remark],[HasSelected],[QuotedTime],[CheckMemId],[CheckTime]
						FROM
						(SELECT ROW_NUMBER() OVER (ORDER BY Id desc) AS ROWNUMBER,
						 [Id],[InquiryOrderCode],[InquiryProductId],[CGMemId],[CGPrice],[Price],[InquiryProductType],[InquiryProductDes],[Remark],[HasSelected],[QuotedTime],[CheckMemId],[CheckTime] from dbo.[CGQuotedPrice] WITH(NOLOCK)	
						WHERE  1=1 ) as temp 
						where rownumber BETWEEN ((@PageIndex - 1) * @PageSize + 1) AND @PageIndex * @PageSize"                        ;

            string sql2 = @"Select count(1) from dbo.[CGQuotedPrice] with (nolock) ";
            IList <CGQuotedPriceEntity> entityList = new List <CGQuotedPriceEntity>();
            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())
                {
                    CGQuotedPriceEntity entity = new CGQuotedPriceEntity();
                    entity.Id = StringUtils.GetDbInt(reader["Id"]);
                    entity.InquiryOrderCode   = StringUtils.GetDbString(reader["InquiryOrderCode"]);
                    entity.InquiryProductId   = StringUtils.GetDbInt(reader["InquiryProductId"]);
                    entity.CGMemId            = StringUtils.GetDbInt(reader["CGMemId"]);
                    entity.CGPrice            = StringUtils.GetDbDecimal(reader["CGPrice"]);
                    entity.Price              = StringUtils.GetDbDecimal(reader["Price"]);
                    entity.InquiryProductType = StringUtils.GetDbInt(reader["InquiryProductType"]);
                    entity.InquiryProductDes  = StringUtils.GetDbString(reader["InquiryProductDes"]);
                    entity.Remark             = StringUtils.GetDbString(reader["Remark"]);
                    entity.HasSelected        = StringUtils.GetDbInt(reader["HasSelected"]);
                    entity.QuotedTime         = StringUtils.GetDbDateTime(reader["QuotedTime"]);
                    entity.CheckMemId         = StringUtils.GetDbInt(reader["CheckMemId"]);
                    entity.CheckTime          = StringUtils.GetDbString(reader["CheckTime"]);
                    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);
        }
        /// <summary>
        /// 插入一条记录到表CGQuotedPrice,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0。
        /// 该方法提供给界面等UI层调用
        /// </summary>
        /// <param name="cGQuotedPrice">要添加的CGQuotedPrice数据实体对象</param>
        public int AddCGQuotedPrice(CGQuotedPriceEntity cGQuotedPrice)
        {
            if (cGQuotedPrice.Id > 0)
            {
                return(UpdateCGQuotedPrice(cGQuotedPrice));
            }

            else if (CGQuotedPriceBLL.Instance.IsExist(cGQuotedPrice))
            {
                return((int)CommonStatus.ADD_Fail_Exist);
            }
            else
            {
                return(CGQuotedPriceDA.Instance.AddCGQuotedPrice(cGQuotedPrice));
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 根据主键值更新记录的全部字段(注意:该方法不会对自增字段、timestamp类型字段以及主键字段更新!如果要更新主键字段,请使用Update方法)。
        /// 如果数据库有数据被更新了则返回True,否则返回False
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="cGQuotedPrice">待更新的实体对象</param>
        public int UpdateCGQuotedPrice(CGQuotedPriceEntity entity)
        {
            string    sql = @" UPDATE dbo.[CGQuotedPrice] SET
                       [InquiryOrderCode]=@InquiryOrderCode,[InquiryProductId]=@InquiryProductId,[CGMemId]=@CGMemId,[CGPrice]=@CGPrice,[Price]=@Price,[InquiryProductType]=@InquiryProductType,[InquiryProductDes]=@InquiryProductDes,[Remark]=@Remark,[HasSelected]=@HasSelected,[QuotedTime]=@QuotedTime,[CheckMemId]=@CheckMemId,[CheckTime]=@CheckTime
                       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, "@InquiryProductId", DbType.Int32, entity.InquiryProductId);
            db.AddInParameter(cmd, "@CGMemId", DbType.Int32, entity.CGMemId);
            db.AddInParameter(cmd, "@CGPrice", DbType.Decimal, entity.CGPrice);
            db.AddInParameter(cmd, "@Price", DbType.Decimal, entity.Price);
            db.AddInParameter(cmd, "@InquiryProductType", DbType.Int32, entity.InquiryProductType);
            db.AddInParameter(cmd, "@InquiryProductDes", DbType.String, entity.InquiryProductDes);
            db.AddInParameter(cmd, "@Remark", DbType.String, entity.Remark);
            db.AddInParameter(cmd, "@HasSelected", DbType.Int32, entity.HasSelected);
            db.AddInParameter(cmd, "@QuotedTime", DbType.DateTime, entity.QuotedTime);
            db.AddInParameter(cmd, "@CheckMemId", DbType.Int32, entity.CheckMemId);
            db.AddInParameter(cmd, "@CheckTime", DbType.String, entity.CheckTime);
            return(db.ExecuteNonQuery(cmd));
        }
 /// <summary>
 /// 更新一条CGQuotedPrice记录。
 /// 该方法提供给界面等UI层调用
 /// </summary>
 /// <param name="cGQuotedPrice">待更新的实体对象</param>
 /// <param name="columns">要更新的列名,不提供任何列名时默认将更新主键之外的所有列</param>
 public int UpdateCGQuotedPrice(CGQuotedPriceEntity cGQuotedPrice)
 {
     return(CGQuotedPriceDA.Instance.UpdateCGQuotedPrice(cGQuotedPrice));
 }
 /// <summary>
 /// 判断对象是否存在
 /// </summary>
 /// <param name="dicEnum"></param>
 /// <returns></returns>
 public bool IsExist(CGQuotedPriceEntity cGQuotedPrice)
 {
     return(CGQuotedPriceDA.Instance.ExistNum(cGQuotedPrice) > 0);
 }