public IList <VWCGMemQuotedEntity> GetVWCGMemQuotedAllByCode(string ordercode) { string sql = @" SELECT [Id],[InquiryOrderCode],[CGMemId],[CreateTime],[SendWeChatTime], [ReadTime],[QuoteTime],[FromClass],[SendWeChatStatus],HasChecked,HasInStock,RemarkByCGMem from dbo.[CGMemQuoted] WITH(NOLOCK) WHERE InquiryOrderCode=@InquiryOrderCode order by CGMemId desc "; IList <VWCGMemQuotedEntity> entityList = new List <VWCGMemQuotedEntity>(); DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@InquiryOrderCode", DbType.String, ordercode); using (IDataReader reader = db.ExecuteReader(cmd)) { while (reader.Read()) { VWCGMemQuotedEntity entity = new VWCGMemQuotedEntity(); entity.Id = StringUtils.GetDbInt(reader["Id"]); entity.InquiryOrderCode = StringUtils.GetDbString(reader["InquiryOrderCode"]); entity.CGMemId = StringUtils.GetDbInt(reader["CGMemId"]); entity.CreateTime = StringUtils.GetDbDateTime(reader["CreateTime"]); entity.SendWeChatTime = StringUtils.GetDbDateTime(reader["SendWeChatTime"]); entity.ReadTime = StringUtils.GetDbDateTime(reader["ReadTime"]); entity.QuoteTime = StringUtils.GetDbDateTime(reader["QuoteTime"]); entity.FromClass = StringUtils.GetDbInt(reader["FromClass"]); entity.SendWeChatStatus = StringUtils.GetDbInt(reader["SendWeChatStatus"]); entity.HasChecked = StringUtils.GetDbInt(reader["HasChecked"]); entity.HasInStock = StringUtils.GetDbInt(reader["HasInStock"]); entity.RemarkByCGMem = StringUtils.GetDbString(reader["RemarkByCGMem"]); entityList.Add(entity); } } return(entityList); }
public IList <VWCGMemQuotedEntity> GetInquiryCGMemQuotedList(int pagesize, int pageindex, ref int recordCount, string ordercode, int hasread, int hasquote, int status, int cgmemid) { string where = " where 1=1 "; if (!string.IsNullOrEmpty(ordercode)) { where += " and InquiryOrderCode=@InquiryOrderCode "; } if (hasread != -1) { where += " and HasRead=@HasRead "; } if (hasquote != -1) { where += " and HasQuote=@HasQuote "; } if (cgmemid > 0) { where += " and CGMemId=@CGMemId "; } if (status > 0) { where += " and SendWeChatStatus=@SendWeChatStatus "; } string sql = @"SELECT [Id],[InquiryOrderCode],[CGMemId],HasSend,HasRead,HasQuote,[CreateTime],[SendWeChatTime],[ReadTime],[QuoteTime],[FromClass],[SendWeChatStatus] FROM (SELECT ROW_NUMBER() OVER (ORDER BY Id desc) AS ROWNUMBER, [Id],[InquiryOrderCode],[CGMemId],HasSend,HasRead,HasQuote,[CreateTime],[SendWeChatTime],[ReadTime],[QuoteTime],[FromClass],[SendWeChatStatus] from dbo.[CGMemQuoted] WITH(NOLOCK) " + where + @") as temp where rownumber BETWEEN ((@PageIndex - 1) * @PageSize + 1) AND @PageIndex * @PageSize" ; string sql2 = @"Select count(1) from dbo.[CGMemQuoted] with (nolock) " + where; IList <VWCGMemQuotedEntity> entityList = new List <VWCGMemQuotedEntity>(); DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageindex); db.AddInParameter(cmd, "@PageSize", DbType.Int32, pagesize); if (!string.IsNullOrEmpty(ordercode)) { db.AddInParameter(cmd, "@InquiryOrderCode", DbType.String, ordercode); } if (hasread != -1) { db.AddInParameter(cmd, "@HasRead", DbType.Int32, hasread); } if (hasquote != -1) { db.AddInParameter(cmd, "@HasQuote", DbType.Int32, hasquote); } if (cgmemid > 0) { db.AddInParameter(cmd, "@CGMemId", DbType.Int32, cgmemid); } if (status > 0) { db.AddInParameter(cmd, "@SendWeChatStatus", DbType.Int32, status); } using (IDataReader reader = db.ExecuteReader(cmd)) { while (reader.Read()) { VWCGMemQuotedEntity entity = new VWCGMemQuotedEntity(); entity.Id = StringUtils.GetDbInt(reader["Id"]); entity.InquiryOrderCode = StringUtils.GetDbString(reader["InquiryOrderCode"]); entity.CGMemId = StringUtils.GetDbInt(reader["CGMemId"]); entity.HasSend = StringUtils.GetDbInt(reader["HasSend"]); entity.HasRead = StringUtils.GetDbInt(reader["HasRead"]); entity.HasQuote = StringUtils.GetDbInt(reader["HasQuote"]); entity.CreateTime = StringUtils.GetDbDateTime(reader["CreateTime"]); entity.SendWeChatTime = StringUtils.GetDbDateTime(reader["SendWeChatTime"]); entity.ReadTime = StringUtils.GetDbDateTime(reader["ReadTime"]); entity.QuoteTime = StringUtils.GetDbDateTime(reader["QuoteTime"]); entity.FromClass = StringUtils.GetDbInt(reader["FromClass"]); entity.SendWeChatStatus = StringUtils.GetDbInt(reader["SendWeChatStatus"]); entityList.Add(entity); } } cmd = db.GetSqlStringCommand(sql2); if (!string.IsNullOrEmpty(ordercode)) { db.AddInParameter(cmd, "@InquiryOrderCode", DbType.String, ordercode); } if (hasread != -1) { db.AddInParameter(cmd, "@HasRead", DbType.Int32, hasread); } if (hasquote != -1) { db.AddInParameter(cmd, "@HasQuote", DbType.Int32, hasquote); } if (cgmemid > 0) { db.AddInParameter(cmd, "@CGMemId", DbType.Int32, cgmemid); } if (status > 0) { db.AddInParameter(cmd, "@SendWeChatStatus", DbType.Int32, status); } using (IDataReader reader = db.ExecuteReader(cmd)) { if (reader.Read()) { recordCount = StringUtils.GetDbInt(reader[0]); } else { recordCount = 0; } } return(entityList); }