/// <summary> /// 判断当前节点是否已存在相同的 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int ExistNum(CGMemQuotedEntity entity) { ///id=0,判断总数,ID>0判断除自己之外的总数 string sql = @"Select count(1) from dbo.[CGMemQuoted] 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)); }
public CGMemQuotedEntity GetHasCheckedCGMem(string ordercode) { string sql = @" SELECT top 1 [Id],[InquiryOrderCode],[CGMemId],[CreateTime],[SendWeChatTime], [ReadTime],HasQuote,[QuoteTime],[FromClass],[SendWeChatStatus],HasChecked from dbo.[CGMemQuoted] WITH(NOLOCK) WHERE InquiryOrderCode=@InquiryOrderCode and HasChecked=1 order by Id desc "; CGMemQuotedEntity entity = new CGMemQuotedEntity(); DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@InquiryOrderCode", DbType.String, ordercode); using (IDataReader reader = db.ExecuteReader(cmd)) { if (reader.Read()) { 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.HasQuote = StringUtils.GetDbInt(reader["HasQuote"]); entity.QuoteTime = StringUtils.GetDbDateTime(reader["QuoteTime"]); entity.FromClass = StringUtils.GetDbInt(reader["FromClass"]); entity.SendWeChatStatus = StringUtils.GetDbInt(reader["SendWeChatStatus"]); entity.HasChecked = StringUtils.GetDbInt(reader["HasChecked"]); } } return(entity); }
/// <summary> /// 读取记录列表。 /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param> public IList <CGMemQuotedEntity> GetCGMemQuotedAll() { string sql = @"SELECT [Id],[InquiryOrderCode],[CGMemId],[CreateTime],[SendWeChatTime],[ReadTime],HasQuote,[QuoteTime],[FromClass],[SendWeChatStatus] from dbo.[CGMemQuoted] WITH(NOLOCK) "; IList <CGMemQuotedEntity> entityList = new List <CGMemQuotedEntity>(); DbCommand cmd = db.GetSqlStringCommand(sql); using (IDataReader reader = db.ExecuteReader(cmd)) { while (reader.Read()) { CGMemQuotedEntity entity = new CGMemQuotedEntity(); 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.HasQuote = StringUtils.GetDbInt(reader["HasQuote"]); entity.QuoteTime = StringUtils.GetDbDateTime(reader["QuoteTime"]); entity.FromClass = StringUtils.GetDbInt(reader["FromClass"]); entity.SendWeChatStatus = StringUtils.GetDbInt(reader["SendWeChatStatus"]); entityList.Add(entity); } } return(entityList); }
public IList <CGMemQuotedEntity> GetCGMemQuotedListSend(int num) { string sql = @" SELECT top " + num + @" [Id],[InquiryOrderCode],[CGMemId],[CreateTime],[SendWeChatTime], [ReadTime],HasQuote,[QuoteTime],[FromClass],[SendWeChatStatus] into #temp from dbo.[CGMemQuoted] WITH(NOLOCK) WHERE SendWeChatStatus=@WaitSendStatus order by id desc update a set Status=@SendingStatus from dbo.[CGMemQuoted] a inner join #temp b on a.Id=b.Id where a.InquiryOrderCode=b.InquiryOrderCode; drop table #temp;"; IList <CGMemQuotedEntity> entityList = new List <CGMemQuotedEntity>(); DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@SendingStatus", DbType.Int32, (int)SendWeChatStatus.Sending); db.AddInParameter(cmd, "@WaitSendStatus", DbType.Int32, (int)SendWeChatStatus.WaitSend); using (IDataReader reader = db.ExecuteReader(cmd)) { while (reader.Read()) { CGMemQuotedEntity entity = new CGMemQuotedEntity(); 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.HasQuote = StringUtils.GetDbInt(reader["HasQuote"]); entity.QuoteTime = StringUtils.GetDbDateTime(reader["QuoteTime"]); entity.FromClass = StringUtils.GetDbInt(reader["FromClass"]); entity.SendWeChatStatus = StringUtils.GetDbInt(reader["SendWeChatStatus"]); entityList.Add(entity); } } return(entityList); }
public IList <CGMemQuotedEntity> GetCGMemQuotedAllByCode(string ordercode) { string sql = @" SELECT [Id],[InquiryOrderCode],[CGMemId],[CreateTime],[SendWeChatTime], [ReadTime],HasQuote,[QuoteTime],[FromClass],[SendWeChatStatus],HasChecked,HasInStock,RemarkByCGMem from dbo.[CGMemQuoted] WITH(NOLOCK) WHERE InquiryOrderCode=@InquiryOrderCode order by CGMemId desc "; IList <CGMemQuotedEntity> entityList = new List <CGMemQuotedEntity>(); DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@InquiryOrderCode", DbType.String, ordercode); using (IDataReader reader = db.ExecuteReader(cmd)) { while (reader.Read()) { CGMemQuotedEntity entity = new CGMemQuotedEntity(); 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.HasQuote = StringUtils.GetDbInt(reader["HasQuote"]); 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 CGMemQuotedEntity GetCGMemQuotedByCode(string code, int memid) { string sql = @"SELECT [Id],[InquiryOrderCode],[CGMemId],[CreateTime],[SendWeChatTime],[ReadTime],HasQuote,[QuoteTime],[FromClass],[SendWeChatStatus],HasInStock,RemarkByCGMem FROM dbo.[CGMemQuoted] WITH(NOLOCK) WHERE [InquiryOrderCode]=@InquiryOrderCode and CGMemId=@CGMemId" ; DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@InquiryOrderCode", DbType.String, code); db.AddInParameter(cmd, "@CGMemId", DbType.Int32, memid); CGMemQuotedEntity entity = new CGMemQuotedEntity(); using (IDataReader reader = db.ExecuteReader(cmd)) { if (reader.Read()) { 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.HasQuote = StringUtils.GetDbInt(reader["HasQuote"]); entity.QuoteTime = StringUtils.GetDbDateTime(reader["QuoteTime"]); entity.FromClass = StringUtils.GetDbInt(reader["FromClass"]); entity.SendWeChatStatus = StringUtils.GetDbInt(reader["SendWeChatStatus"]); entity.HasInStock = StringUtils.GetDbInt(reader["HasInStock"]); entity.RemarkByCGMem = StringUtils.GetDbString(reader["RemarkByCGMem"]); } } return(entity); }
/// <summary> /// 读取记录列表。 /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param> public IList <CGMemQuotedEntity> GetCGMemQuotedList(int pagesize, int pageindex, ref int recordCount) { string sql = @"SELECT [Id],[InquiryOrderCode],[CGMemId],[CreateTime],[SendWeChatTime],[ReadTime],HasQuote,[QuoteTime],[FromClass],[SendWeChatStatus] FROM (SELECT ROW_NUMBER() OVER (ORDER BY Id desc) AS ROWNUMBER, [Id],[InquiryOrderCode],[CGMemId],[CreateTime],[SendWeChatTime],[ReadTime],HasQuote,[QuoteTime],[FromClass],[SendWeChatStatus] from dbo.[CGMemQuoted] WITH(NOLOCK) WHERE 1=1 ) as temp where rownumber BETWEEN ((@PageIndex - 1) * @PageSize + 1) AND @PageIndex * @PageSize" ; string sql2 = @"Select count(1) from dbo.[CGMemQuoted] with (nolock) "; IList <CGMemQuotedEntity> entityList = new List <CGMemQuotedEntity>(); 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()) { CGMemQuotedEntity entity = new CGMemQuotedEntity(); 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.HasQuote = StringUtils.GetDbInt(reader["HasQuote"]); 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); using (IDataReader reader = db.ExecuteReader(cmd)) { if (reader.Read()) { recordCount = StringUtils.GetDbInt(reader[0]); } else { recordCount = 0; } } return(entityList); }
public ActionResult OrderDetail() { string _ordercode = QueryString.SafeQ("code"); InquiryOrderEntity order = InquiryOrderBLL.Instance.GetInquiryOrderByCode(_ordercode); if (order != null) { VWInquiryOrderEntity vworder = InquiryOrderBLL.Instance.GetInquiryOrderDataByCode(_ordercode); IList <InquiryOrderFeedBackEntity> feedbacklist = InquiryOrderFeedBackBLL.Instance.GetOrderFeedBackAllByCode(_ordercode); IList <InquiryOrderPicsEntity> orderpics = vworder.OrderPics; IList <InquiryProductEntity> productlist = vworder.OrderProducts; IList <InquiryProductSubEntity> productsublist = vworder.OrderProductSubs; IList <VWCGMemQuotedEntity> quotelist = CGMemQuotedBLL.Instance.GetVWCGMemQuotedAllByCode(_ordercode); IList <CGQuotedPriceEntity> pricelist = CGQuotedPriceBLL.Instance.GetCGQuotedPriceAll(_ordercode, -1, true); Dictionary <string, CGQuotedPriceEntity> pricedic = new Dictionary <string, CGQuotedPriceEntity>(); IList <InquiryProductSubEntity> productsubs = vworder.OrderProductSubs; Dictionary <int, IList <InquiryProductSubEntity> > productsubdic = new Dictionary <int, IList <InquiryProductSubEntity> >(); foreach (CGQuotedPriceEntity price in pricelist) { if (!pricedic.ContainsKey(price.InquiryProductSubId + "_" + price.CGMemId)) { pricedic.Add(price.InquiryProductSubId + "_" + price.CGMemId, price); } } if (productsubs != null && productsubs.Count > 0) { foreach (InquiryProductSubEntity prod in productsubs) { if (!productsubdic.ContainsKey(prod.InquiryProductId)) { productsubdic.Add(prod.InquiryProductId, new List <InquiryProductSubEntity>()); } productsubdic[prod.InquiryProductId].Add(prod); } } CGMemQuotedEntity quote = CGMemQuotedBLL.Instance.GetCGMemHasCheckedByCode(_ordercode); MemStoreEntity store = StoreBLL.Instance.GetStoreByMemId(quote.CGMemId); ViewBag.QuotedCGMemList = quotelist; ViewBag.ProductSubDIc = productsubdic; ViewBag.PriceDic = pricedic; ViewBag.VWOrder = vworder; ViewBag.ProductSubDic = productsubdic; ViewBag.CGMemStore = store; ViewBag.CGMemQuote = quote; ViewBag.FeedBackList = feedbacklist; } return(View()); }
/// <summary> /// 插入一条记录到表CGMemQuoted,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0。 /// 该方法提供给界面等UI层调用 /// </summary> /// <param name="cGMemQuoted">要添加的CGMemQuoted数据实体对象</param> public int AddCGMemQuoted(CGMemQuotedEntity cGMemQuoted) { if (cGMemQuoted.Id > 0) { return(UpdateCGMemQuoted(cGMemQuoted)); } else if (CGMemQuotedBLL.Instance.IsExist(cGMemQuoted)) { return((int)CommonStatus.ADD_Fail_Exist); } else { return(CGMemQuotedDA.Instance.AddCGMemQuoted(cGMemQuoted)); } }
/// <summary> /// 根据主键值更新记录的全部字段(注意:该方法不会对自增字段、timestamp类型字段以及主键字段更新!如果要更新主键字段,请使用Update方法)。 /// 如果数据库有数据被更新了则返回True,否则返回False /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="cGMemQuoted">待更新的实体对象</param> public int UpdateCGMemQuoted(CGMemQuotedEntity entity) { string sql = @" UPDATE dbo.[CGMemQuoted] SET [InquiryOrderCode]=@InquiryOrderCode,[CGMemId]=@CGMemId,[CreateTime]=@CreateTime,[SendWeChatTime]=@SendWeChatTime,[ReadTime]=@ReadTime,[QuoteTime]=@QuoteTime,[FromClass]=@FromClass,[SendWeChatStatus]=@SendWeChatStatus 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, "@CGMemId", DbType.Int32, entity.CGMemId); db.AddInParameter(cmd, "@CreateTime", DbType.DateTime, entity.CreateTime); db.AddInParameter(cmd, "@SendWeChatTime", DbType.DateTime, entity.SendWeChatTime); db.AddInParameter(cmd, "@ReadTime", DbType.DateTime, entity.ReadTime); db.AddInParameter(cmd, "@QuoteTime", DbType.DateTime, entity.QuoteTime); db.AddInParameter(cmd, "@FromClass", DbType.Int32, entity.FromClass); db.AddInParameter(cmd, "@SendWeChatStatus", DbType.Int32, entity.SendWeChatStatus); return(db.ExecuteNonQuery(cmd)); }
public string GetQuotedCGMemByCode(string code) { string memids = ""; string sql = @"SELECT [CGMemId] FROM dbo.[CGMemQuoted] WITH(NOLOCK) where InquiryOrderCode=@InquiryOrderCode " ; DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@InquiryOrderCode", DbType.String, code); CGMemQuotedEntity entity = new CGMemQuotedEntity(); using (IDataReader reader = db.ExecuteReader(cmd)) { if (reader.Read()) { memids += StringUtils.GetDbInt(reader["CGMemId"]) + ","; } } return(memids); }
/// <summary> /// 插入一条记录到表CGMemQuoted,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0 /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="cGMemQuoted">待插入的实体对象</param> public int AddCGMemQuoted(CGMemQuotedEntity entity) { string sql = @"insert into CGMemQuoted( [InquiryOrderCode],[CGMemId],[CreateTime],[SendWeChatTime],[ReadTime],[QuoteTime],[FromClass],[SendWeChatStatus])VALUES ( @InquiryOrderCode,@CGMemId,@CreateTime,@SendWeChatTime,@ReadTime,@QuoteTime,@FromClass,@SendWeChatStatus); SELECT SCOPE_IDENTITY();" ; DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@InquiryOrderCode", DbType.String, entity.InquiryOrderCode); db.AddInParameter(cmd, "@CGMemId", DbType.Int32, entity.CGMemId); db.AddInParameter(cmd, "@CreateTime", DbType.DateTime, entity.CreateTime); db.AddInParameter(cmd, "@SendWeChatTime", DbType.DateTime, entity.SendWeChatTime); db.AddInParameter(cmd, "@ReadTime", DbType.DateTime, entity.ReadTime); db.AddInParameter(cmd, "@QuoteTime", DbType.DateTime, entity.QuoteTime); db.AddInParameter(cmd, "@FromClass", DbType.Int32, entity.FromClass); db.AddInParameter(cmd, "@SendWeChatStatus", DbType.Int32, entity.SendWeChatStatus); object identity = db.ExecuteScalar(cmd); if (identity == null || identity == DBNull.Value) { return(0); } return(Convert.ToInt32(identity)); }
/// <summary> /// 判断对象是否存在 /// </summary> /// <param name="dicEnum"></param> /// <returns></returns> public bool IsExist(CGMemQuotedEntity cGMemQuoted) { return(CGMemQuotedDA.Instance.ExistNum(cGMemQuoted) > 0); }
/// <summary> /// 更新一条CGMemQuoted记录。 /// 该方法提供给界面等UI层调用 /// </summary> /// <param name="cGMemQuoted">待更新的实体对象</param> /// <param name="columns">要更新的列名,不提供任何列名时默认将更新主键之外的所有列</param> public int UpdateCGMemQuoted(CGMemQuotedEntity cGMemQuoted) { return(CGMemQuotedDA.Instance.UpdateCGMemQuoted(cGMemQuoted)); }