所以我试图创建一个报表,自动计算流程中关键事件的预期日期。目前,该程序根据流程开始的日期创建预测。如果预测与事件发生的实际日期不同,我无法弄清楚如何将其考虑在内。
我可以看到为什么我的代码以它的方式运行,只是不确定如何改变它。
此代码从数据库中提取某些内容,但预测显然是在本地计算的,不会发送到数据库。
DateTime recDate = DateTime.Now;
DateTime resaltDate = DateTime.Now;
DateTime springDate = DateTime.Now;
DateTime summerDate = DateTime.Now;
DateTime releaseDate = DateTime.Now;
int size = 0;
MySqlConnection conDatabase = new MySqlConnection(conString);
MySqlCommand cmdDatabase = new MySqlCommand(query, conDatabase);
try
{
conDatabase.Open();
MySqlDataReader myReader = cmdDatabase.ExecuteReader(); ;
while (myReader.Read())
{
size = myReader.GetInt32("size");
recDate = myReader.GetDateTime("recDate");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
springDate = dateTimePResalt.Value;
summerDate = dateTimePSpring.Value;
releaseDate = dateTimePSummer.Value;
if (size == 0)
{
dateTimePResalt.Value = recDate.AddDays(6);
dateTimePSpring.Value = springDate.AddDays(44);
dateTimePSummer.Value = summerDate.AddDays(58);
dateTimePRelease.Value = releaseDate.AddDays(70);
}
else if (size == 1)
{
dateTimePResalt.Value = recDate.AddDays(6);
dateTimePSpring.Value = springDate.AddDays(47);
dateTimePSummer.Value = summerDate.AddDays(61);
dateTimePRelease.Value = releaseDate.AddDays(73);
}