当前位置: 首页>>代码示例>>C#>>正文


C# DateTime.ToTimeNode方法代码示例

本文整理汇总了C#中DateTime.ToTimeNode方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.ToTimeNode方法的具体用法?C# DateTime.ToTimeNode怎么用?C# DateTime.ToTimeNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateTime的用法示例。


在下文中一共展示了DateTime.ToTimeNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ActionUseExt

 public static Guid ActionUseExt(this StoreEntity db, List<CachedUse> list, Guid userId, DateTime time, Guid operatorId, Guid storeId, string code = "")
 {
     if (list.Count == 0)
     {
         return Guid.Empty;
     }
     var gid = db.GlobalId();
     var su = new StoreUse
     {
         Id = gid,
         UserId = userId,
         Time = time,
         TimeNode = time.ToTimeNode(),
         OperationUserId = operatorId,
         OperationTime = DateTime.Now,
         UsageTarget = list.First().UserTarget,
         StoreId = storeId,
         Money = 0
     };
     db.StoreUse.Add(su);
     db.SaveChanges();
     foreach (var use in list)
     {
         decimal _money = 0;
         var objId = use.ObjectId.Value;
         var obj = db.StoreObject.Single(o => o.Id == objId);
         if (!obj.Single)
         {
             if (obj.Amount < use.Amount.Value)
                 use.Amount = obj.Amount;
             if (use.Type == "领用")
             {
                 var consume = new StoreConsume
                 {
                     Id = db.GlobalId(),
                     ObjectId = use.ObjectId.Value,
                     ConsumeUserId = userId,
                     Note = use.Note,
                     TimeNode = time.ToTimeNode(),
                     Time = time,
                     OperationUserId = operatorId,
                     OperationTime = DateTime.Now,
                     Code = code,
                     Amount = use.Amount.Value,
                     Money = 0
                 };
                 db.StoreConsume.Add(consume);
                 var counter = 0;
                 var left = consume.Amount;
                 foreach (var @in in obj.StoreIn.Where(o => o.Amount > 0).OrderBy(o => o.TimeNode))
                 {
                     counter++;
                     if (@in.Amount >= left)
                     {
                         var @single = new StoreConsumeSingle();
                         @single.Id = db.GlobalId();
                         var us = new StoreUseSingle
                         {
                             Id = db.GlobalId(),
                             UseId = gid,
                             Type = 0,
                             InId = @in.Id,
                             SingleInId = null,
                             ObjectId = obj.Id,
                             Note = use.Note,
                             Amount = left,
                             Money = (decimal.Divide(@in.SourceMoney, @in.SourceAmount)) * left,
                             SingleConsumeId = @single.Id
                         };
                         db.StoreUseSingle.Add(us);
                         consume.Money += (decimal.Divide(@in.SourceMoney, @in.SourceAmount)) * left;
                         @single.InId = @in.Id;
                         @single.ConsumeId = consume.Id;
                         @single.Ordinal = counter;
                         @single.Amount = left;
                         @single.PerPrice = @in.PerPrice;
                         @single.SourcePerPrice = @in.SourcePerPrice;
                         @single.Fee = (decimal.Divide(@in.Fee, @in.Amount)) * left;
                         @single.Money = (decimal.Divide(@in.SourceMoney, @in.SourceAmount)) * left;
                         @in.Amount -= left;
                         if (@in.Amount == 0)
                             @in.Money = 0;
                         else
                             @in.Money -= (decimal.Divide(@in.SourceMoney, @in.SourceAmount)) * left;
                         db.StoreConsumeSingle.Add(@single);
                         break;
                     }
                     else
                     {
                         left -= @in.Amount;
                         var @single = new StoreConsumeSingle();
                         @single.Id = db.GlobalId();
                         var us = new StoreUseSingle
                         {
                             Id = db.GlobalId(),
                             UseId = gid,
                             Type = 0,
                             InId = @in.Id,
                             SingleInId = null,
                             ObjectId = obj.Id,
//.........这里部分代码省略.........
开发者ID:Homory-Temp,项目名称:LeYi,代码行数:101,代码来源:BusinessExtensions.cs

示例2: ActionInExt

 public static void ActionInExt(this StoreEntity db, Guid targetId, Guid objectId, string age, string place, string image, Guid? responsibleId, string note, DateTime inTime, Guid operatorId, string code, decimal amount, decimal totalPrice, decimal sourcePerPrice, decimal fee, decimal money)
 {
     var @in = new StoreIn
     {
         Id = db.GlobalId(),
         TargetId = targetId,
         ObjectId = objectId,
         Age = age,
         Place = place,
         Image = image,
         ResponsibleUserId = responsibleId,
         Note = note,
         TimeNode = inTime.ToTimeNode(),
         Time = inTime,
         OperationUserId = operatorId,
         OperationTime = DateTime.Now,
         Code = code,
         Amount = amount,
         SourceAmount = amount,
         OriginalAmount = amount,
         PerPrice = decimal.Divide(totalPrice, amount),
         SourcePerPrice = sourcePerPrice,
         Fee = fee,
         Money = totalPrice + fee,
         SourceMoney = totalPrice + fee,
         OriginalMoney = totalPrice + fee
     };
     db.StoreIn.Add(@in);
     var obj = db.StoreObject.Single(o => o.Id == objectId);
     obj.Amount += amount;
     obj.Money += money;
     var catalog = obj.StoreCatalog;
     var store = catalog.Store;
     if (store.State != StoreState.食品 && db.StoreDictionary.Count(o => o.StoreId == store.Id && o.Type == DictionaryType.年龄段 && o.Name == age) == 0)
     {
         var dictionary = new StoreDictionary
         {
             StoreId = catalog.StoreId,
             Type = DictionaryType.年龄段,
             Name = age,
             PinYin = db.ToPinYin(age).Single()
         };
         db.StoreDictionary.Add(dictionary);
     }
     var flow = new StoreFlow
     {
         Id = db.GlobalId(),
         ObjectId = objectId,
         UserId = operatorId,
         Type = FlowType.入库,
         TypeName = FlowType.入库.ToString(),
         TimeNode = inTime.ToTimeNode(),
         Time = inTime,
         Amount = amount,
         Money = money,
         Note = note
     };
     db.StoreFlow.Add(flow);
     db.ActionRecord(objectId, inTime, amount, money, 0M, 0M, 0M, 0M, 0M, 0M, 0M, 0M);
     if (obj.Single)
     {
         // To Do
     }
     db.SaveChanges();
 }
开发者ID:Homory-Temp,项目名称:LeYi,代码行数:65,代码来源:BusinessExtensions.cs

示例3: ActionInEditExt

 public static void ActionInEditExt(this StoreEntity db, StoreIn @in, DateTime day, decimal amount, decimal perPrice, decimal money, string place, string note, Guid operatorId)
 {
     var obj = db.StoreObject.Single(o => o.Id == @in.ObjectId);
     var target = db.StoreTarget.Single(o => o.Id == @in.TargetId);
     if (obj.Single)
         return;
     decimal plusAmount = amount - @in.Amount;
     decimal plusMoney = money - @in.Money;
     if (day.Year == @in.Time.Year || day.Month == @in.Time.Month)
     {
         db.ActionRecord(obj.Id, day, plusAmount, plusMoney, 0, 0, 0, 0, 0, 0, 0, 0);
     }
     else
     {
         db.ActionRecord(obj.Id, @in.Time, plusAmount, plusMoney, 0, 0, 0, 0, 0, 0, 0, 0);
         db.ActionRecord(obj.Id, day, amount, money, 0, 0, 0, 0, 0, 0, 0, 0);
     }
     if (amount != @in.OriginalAmount || money != @in.OriginalMoney)
     {
         if (amount > 0 && money > 0)
         {
             @in.Amount = amount;
             @in.OriginalAmount = amount;
             @in.SourceAmount = amount;
             @in.Money = money;
             @in.OriginalMoney = money;
             @in.SourceMoney = money;
             @in.SourcePerPrice = perPrice;
             @in.PerPrice = decimal.Divide(money, amount);
             @in.Place = place;
             @in.Note = note;
             @in.Time = day;
             @in.TimeNode = day.ToTimeNode();
             obj.Amount += plusAmount;
             obj.Money += plusMoney;
             target.Paid += plusMoney;
             var flow = new StoreFlow
             {
                 Id = db.GlobalId(),
                 ObjectId = obj.Id,
                 UserId = operatorId,
                 Type = FlowType.入库修改,
                 TypeName = FlowType.入库修改.ToString(),
                 TimeNode = day.ToTimeNode(),
                 Time = day,
                 Amount = plusAmount,
                 Money = plusMoney,
                 Note = note
             };
             db.StoreFlow.Add(flow);
         }
         else
         {
             db.StoreIn.Remove(@in);
             obj.Amount += plusAmount;
             obj.Money += plusMoney;
             target.Paid += plusMoney;
             var flow = new StoreFlow
             {
                 Id = db.GlobalId(),
                 ObjectId = obj.Id,
                 UserId = operatorId,
                 Type = FlowType.入库修改,
                 TypeName = FlowType.入库修改.ToString(),
                 TimeNode = day.ToTimeNode(),
                 Time = day,
                 Amount = plusAmount,
                 Money = plusMoney,
                 Note = note
             };
             db.StoreFlow.Add(flow);
         }
     }
     db.SaveChanges();
 }
开发者ID:Homory-Temp,项目名称:LeYi,代码行数:75,代码来源:BusinessExtensions.cs


注:本文中的DateTime.ToTimeNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。