【问题标题】:How would i create a delivery date notifier我将如何创建交货日期通知器
【发布时间】:2016-01-23 15:41:43
【问题描述】:

我想在确切的交货日期前 30 天通知,但我不知道怎么做。我正在使用datagridview 来显示数据库中的数据。

我想创建一个倒计时,它会每天通知我,直到确切的交货日期。

DateTime answer = today.AddDays(30);`enter code here`
string convert1 = today.ToString("MM/dd/yy"); //Today's date
string convert = answer.ToString("MM/dd/yy"); //Today + 30days

sqlcon.Open();
command.Connection = sqlcon;

command.CommandText = "SELECT [ID], [Delivery Date], [Delivery Time], [Delivery Description] From Delivery WHERE [Delivery Date] < '" + convert + "' ORDER BY [Delivery Date] ASC";
using (SqlDataReader reader = command.ExecuteReader())
{
    while (reader.Read())
    {
        if (today.Date < answer.Date)
        {
            MessageBox.Show("Upcoming Delivery in less than 30 days!" + "\n\n*Delivery Date:\n" + "     " + reader["Delivery Date"].ToString() + "\n\n*Delivery Description:\n" + "     " + reader["Delivery Description"].ToString());
         }
     }
 }
 sqlcon.Close();

【问题讨论】:

    标签: c# sql-server datagridview


    【解决方案1】:

    您可以创建 Windows 服务,该服务将定期检查要通知的实体。 Topshelf (https://github.com/Topshelf/Topshelf) 是使用 Windows 服务的正确方式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-16
      • 2022-10-31
      • 1970-01-01
      相关资源
      最近更新 更多