コード例 #1
0
        /// <summary>
        /// 新增消费记录
        /// </summary>
        /// <param name="record"></param>
        /// <returns></returns>
        public OperationResult Insert(ConsumeRecordModel record)
        {
            var model = new ConsumeRecord
            {
                ConsumeType = record.ConsumeType,
                Money       = record.Money,
                User        = record.User
            };

            return(base.AddNewConsumeRecords(model));
        }
コード例 #2
0
ファイル: ConsumeRecordService.cs プロジェクト: tonybuff/blog
 /// <summary>
 /// 新增消费记录
 /// </summary>
 /// <param name="record"></param>
 /// <returns></returns>
 public OperationResult AddNewConsumeRecords(ConsumeRecord record)
 {
     UnitOfWork.Commit();
     if (string.IsNullOrWhiteSpace(record.ConsumeType))
     {
         return(new OperationResult(OperationResultType.NoChanged, "消费记录类型不能为空"));
     }
     if (record.Money == 0)
     {
         return(new OperationResult(OperationResultType.NoChanged, "消费金额不能为零"));
     }
     _consumeRecordRepository.Insert(record);
     return(new OperationResult(OperationResultType.Success, "新增成功", record));
 }
コード例 #3
0
        public long AddConsumeRecord(ConsumeRecord record)
        {
            string cmdText = @"INSERT INTO [ConsumeRecord] (
                                    [TypeId],[Money],[ConsumeTime],[RecordTime],[Memo],[UserId]
                                )
                                VALUES (
                                    @typeId, @money, @consumeTime, @recordTime, @memo, @userId
                                )";
            var parameters = new[]
                {
                    new SQLiteParameter("@typeId", record.Type.TypeId),
                    new SQLiteParameter("@money", record.Money),
                    new SQLiteParameter("@consumeTime", record.ConsumeTime),
                    new SQLiteParameter("@recordTime", DateTime.Now),
                    new SQLiteParameter("@memo", record.Memo),
                    new SQLiteParameter("@userId", record.User.UserId)
                };
            SqliteHelper.ExecuteNonQuery(cmdText, parameters);

            //查询刚插入数据的历史记录ID
            cmdText = @"SELECT last_insert_rowid()";
            return (long)SqliteHelper.ExecuteScalar(cmdText);
        }
コード例 #4
0
 public long AddConsumeRecord(ConsumeRecord record)
 {
     return _consumeRecordDal.AddConsumeRecord(record);
 }