写个服务,凌晨运行,实现价格递增。

解决方案 »

  1.   


    不需要实时,只要打开软件时,比前一天增加价格就行。
      

  2.   

    程序记录2个数据,一个是原始价格,比如100元,一个是最初定价时间,当然还可以设定价格增幅,代码如下(如果是数据库的,可以在SQL语句里面实现)using System;namespace DateDiffDemo
    {
    class Program
    {
    public static void Main(string[] args)
    {
    GetPrice();
    Console.Write("Press any key to continue . . . ");
    Console.ReadKey(true);
    }

    static double price = 100.00;
    static DateTime priceDate = new DateTime(2014, 08, 01);
    static double increase = 5.00;
    public static double GetPrice()
    {
    double currentPrice = 0;

                TimeSpan dateDiff = DateTime.Today - priceDate;
                
                for (int i = 0; i < dateDiff.TotalDays; i++) {
                 currentPrice = price + increase * Math.Pow(2, i);
                 Console.WriteLine(
                 string.Format(
                 "{0}: 第{1}天价格增加{2},当前价格为{3}",
                 priceDate.AddDays(i + 1),
                 i + 1,
                 increase * Math.Pow(2, i),
                 currentPrice
                 )
                 );
                }
                
                return currentPrice;
    }
    }
    }
      

  3.   


    不需要实时,只要打开软件时,比前一天增加价格就行。那就在打开的时候异步调用个方法去更新数据库数据。当然,前提是你有用数据库。
    更新方法,随便找本书或者网上搜索一大把。