/// <summary> /// 增加一条数据 /// </summary> public bool Add(Eyousoft_yhq.Model.SendMSG model) { if (string.IsNullOrEmpty(model.SendNum) || string.IsNullOrEmpty(model.SendText)) { return(false); } return(dal.Add(model)); }
/// <summary> /// 添加发送信息 /// </summary> /// <param name="model">发送信息实体</param> /// <returns></returns> public bool Add(Eyousoft_yhq.Model.SendMSG model) { StringBuilder strSql = new StringBuilder(); strSql.Append(" INSERT INTO tbl_SendMSG (sendNum,SendText,issuetime,ProductID,FavourCode) VALUES (@sendNum,@SendText,@issuetime,@ProductID,@FavourCode) ;UPDATE [tbl_KV] SET v= v - @minusNum WHERE k='MsgNumber' "); DbCommand cmd = this._db.GetSqlStringCommand(strSql.ToString()); this._db.AddInParameter(cmd, "sendNum", System.Data.DbType.AnsiStringFixedLength, model.SendNum); this._db.AddInParameter(cmd, "SendText", System.Data.DbType.String, model.SendText); this._db.AddInParameter(cmd, "issuetime", System.Data.DbType.DateTime, model.IssueTime); this._db.AddInParameter(cmd, "ProductID", System.Data.DbType.AnsiStringFixedLength, model.ProductID); this._db.AddInParameter(cmd, "minusNum", System.Data.DbType.Int32, model.minusNum); this._db.AddInParameter(cmd, "FavourCode", System.Data.DbType.String, model.FavourCode); return(DbHelper.ExecuteSql(cmd, this._db) > 0 ? true : false); }
/// <summary> /// 获取发送列表 /// </summary> /// <param name="PageSize"></param> /// <param name="PageIndex"></param> /// <param name="RecordCount"></param> /// <param name="serModel"></param> /// <param name="i"></param> /// <returns></returns> public IList <Eyousoft_yhq.Model.SendMSG> GetList(int PageSize, int PageIndex, ref int RecordCount, Eyousoft_yhq.Model.serSendMSG serModel) { IList <Eyousoft_yhq.Model.SendMSG> list = new List <Eyousoft_yhq.Model.SendMSG>(); string tableName = "tbl_SendMSG"; string fileds = " msgId,sendNum,SendText,issuetime,ProductID "; string orderByString = "msgId desc"; StringBuilder query = new StringBuilder(); query.Append(" 1=1 "); if (serModel != null) { if (!string.IsNullOrEmpty(serModel.ProductID)) { query.AppendFormat(" and ProductID = '{0}' ", serModel.ProductID); } } using (IDataReader dr = DbHelper.ExecuteReader1(this._db, PageSize, PageIndex, ref RecordCount, tableName, fileds, query.ToString(), orderByString, null)) { while (dr.Read()) { Eyousoft_yhq.Model.SendMSG model = new Eyousoft_yhq.Model.SendMSG(); model.MsgID = dr.GetInt32(dr.GetOrdinal("msgId")); model.SendNum = dr.IsDBNull(dr.GetOrdinal("SendNum")) ? "" : dr.GetString(dr.GetOrdinal("SendNum")); model.SendText = dr.IsDBNull(dr.GetOrdinal("SendText")) ? "" : dr.GetString(dr.GetOrdinal("SendText")); model.IssueTime = dr.GetDateTime(dr.GetOrdinal("IssueTime")); model.ProductID = dr.IsDBNull(dr.GetOrdinal("ProductID")) ? "" : dr.GetString(dr.GetOrdinal("ProductID")).ToString(); list.Add(model); } } return(list); }
/// <summary> /// 获取发送列表 /// </summary> /// <param name="PageSize"></param> /// <param name="PageIndex"></param> /// <param name="RecordCount"></param> /// <param name="serModel"></param> /// <param name="i"></param> /// <returns></returns> public IList<Eyousoft_yhq.Model.SendMSG> GetList(int PageSize, int PageIndex, ref int RecordCount, Eyousoft_yhq.Model.serSendMSG serModel) { IList<Eyousoft_yhq.Model.SendMSG> list = new List<Eyousoft_yhq.Model.SendMSG>(); string tableName = "tbl_SendMSG"; string fileds = " msgId,sendNum,SendText,issuetime,ProductID "; string orderByString = "msgId desc"; StringBuilder query = new StringBuilder(); query.Append(" 1=1 "); if (serModel != null) { if (!string.IsNullOrEmpty(serModel.ProductID)) { query.AppendFormat(" and ProductID = '{0}' ", serModel.ProductID); } } using (IDataReader dr = DbHelper.ExecuteReader1(this._db, PageSize, PageIndex, ref RecordCount, tableName, fileds, query.ToString(), orderByString, null)) { while (dr.Read()) { Eyousoft_yhq.Model.SendMSG model = new Eyousoft_yhq.Model.SendMSG(); model.MsgID = dr.GetInt32(dr.GetOrdinal("msgId")); model.SendNum = dr.IsDBNull(dr.GetOrdinal("SendNum")) ? "" : dr.GetString(dr.GetOrdinal("SendNum")); model.SendText = dr.IsDBNull(dr.GetOrdinal("SendText")) ? "" : dr.GetString(dr.GetOrdinal("SendText")); model.IssueTime = dr.GetDateTime(dr.GetOrdinal("IssueTime")); model.ProductID = dr.IsDBNull(dr.GetOrdinal("ProductID")) ? "" : dr.GetString(dr.GetOrdinal("ProductID")).ToString(); list.Add(model); } } return list; }