public List <TicketUsersEntity> GetTicketUserList(int ticketId) { List <TicketUsersEntity> list = new List <TicketUsersEntity>(); StringBuilder strSql = new StringBuilder(); strSql.AppendFormat(" select * from ticketUsers where ticketid={0};", ticketId); Database db = DatabaseFactory.CreateDatabase(); using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString())) { try { using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { list.Add(TicketUsersEntity.ReaderBind(dataReader)); } } } catch (Exception ex) { WebLogAgent.Write(string.Format("[SQLText:{0},{1}Messages:\r\n{2}]", strSql.ToString(), base.FormatParameters(dbCommand.Parameters), ex.Message)); } return(list); } }
public TicketUsersEntity Get(int ticket, int user) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from TicketUsers where TicketID = @TicketID AND UserID = @UserID Order by TUID desc"); Database db = DatabaseFactory.CreateDatabase(); using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString())) { db.AddInParameter(dbCommand, "UserID", DbType.Int32, user); db.AddInParameter(dbCommand, "TicketID", DbType.Int32, ticket); TicketUsersEntity model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { try { if (dataReader.Read()) { model = TicketUsersEntity.ReaderBind(dataReader); } return(model); } catch (Exception ex) { WebLogAgent.Write(string.Format("[SQLText:{0},{1}Messages:\r\n{2}]", strSql, base.FormatParameters(dbCommand.Parameters), ex.Message)); return(null); } } } }
public List <TicketUsersEntity> GetTicketUser(int ticketID, TicketUsersType type) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from TicketUsers "); strSql.AppendFormat(" where TicketID=@TicketID and [type] = {0} ", (int)type); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "TicketID", DbType.Int32, ticketID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { var list = new List <TicketUsersEntity>(); while (dataReader.Read()) { list.Add(TicketUsersEntity.ReaderBind(dataReader)); } return(list); } return(null); }
public List <TicketUsersEntity> GetListByUserId(int userId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from TicketUsers "); strSql.Append(" where UserID=@UserID "); Database db = DatabaseFactory.CreateDatabase(); List <TicketUsersEntity> list = new List <TicketUsersEntity>(); using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString())) { db.AddInParameter(dbCommand, "UserID", DbType.Int32, userId); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { list.Add(TicketUsersEntity.ReaderBind(dataReader)); } } } return(list); }
/// <summary> /// Get an object entity /// </summary> public TicketUsersEntity Get(int TUID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from TicketUsers "); strSql.Append(" where TUID=@TUID "); Database db = DatabaseFactory.CreateDatabase(); using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString())) { db.AddInParameter(dbCommand, "TUID", DbType.Int32, TUID); TicketUsersEntity model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = TicketUsersEntity.ReaderBind(dataReader); } } return(model); } }