示例#1
0
        public PidUsingInformation Query(Guid userId)
        {
            PidUsingInformation pidUsingInfo = null;
            const string        sql          = @"SELECT UserId, FromDate , ThruDate, Total FROM T_PidUsingInfo " +
                                               @"WHERE UserId = @UserId";

            using (var dbOperator = new DbOperator(Provider, ConnectionString))
            {
                dbOperator.AddParameter("UserId", userId);
                using (var reader = dbOperator.ExecuteReader(sql))
                {
                    if (reader.Read())
                    {
                        var id       = reader.GetGuid(0);
                        var fromDate = reader.GetDateTime(1);
                        var thruDate = reader.GetDateTime(2);
                        var total    = reader.GetInt64(3);
                        pidUsingInfo = new PidUsingInformation {
                            UserId   = id,
                            FromDate = fromDate,
                            ThruDate = thruDate,
                            Total    = total
                        };
                    }
                }
            }
            return(pidUsingInfo);
        }
示例#2
0
        public int Update(PidUsingInformation pidUsingInfo)
        {
            const string sql = @"UPDATE dbo.T_PidUsingInfo " +
                               "SET FromDate = @FromDate, ThruDate = @ThruDate, Total = @Total " +
                               "WHERE UserId = @UserId; ";

            using (var dbOperator = new DbOperator(Provider, ConnectionString))
            {
                dbOperator.AddParameter("UserId", pidUsingInfo.UserId);
                dbOperator.AddParameter("FromDate", pidUsingInfo.FromDate);
                dbOperator.AddParameter("ThruDate", pidUsingInfo.ThruDate);
                dbOperator.AddParameter("Total", pidUsingInfo.Total);
                return(dbOperator.ExecuteNonQuery(sql));
            }
        }
示例#3
0
        public int Insert(PidUsingInformation pidUsingInfo)
        {
            const string sql = @"INSERT INTO dbo.T_PidUsingInfo(UserId, FromDate, ThruDate, Total) " +
                               "VALUES  (@UserId, @FromDate, @ThruDate, @Total)";

            using (var dbOperator = new DbOperator(Provider, ConnectionString))
            {
                dbOperator.AddParameter("UserId", pidUsingInfo.UserId);
                dbOperator.AddParameter("FromDate", pidUsingInfo.FromDate);
                dbOperator.AddParameter("ThruDate", pidUsingInfo.ThruDate);
                dbOperator.AddParameter("Total", pidUsingInfo.Total);

                return(dbOperator.ExecuteNonQuery(sql));
            }
        }