简体   繁体   English

我正在尝试使用asp.net C#每月自动填充报告

[英]I am trying to auto populate the report monthly using asp.net c#

My task is that every month, the quantity column in the medicine table will be updated to the current month's column in the report table. 我的任务是,每个月药品表中的数量列将更新为报告表中当前月的列。 I would like to do this without using task scheduler. 我想不使用任务计划程序来执行此操作。 I researched online about threading and timer. 我在线研究了线程和计时器。 However, I am unsure if it will work as threading will only auto update the same column every month. 但是,我不确定它是否会正常工作,因为线程只会每月自动更新同一列。 As you can see, I need to update different columns every month. 如您所见,我每个月需要更新不同的列。

Here are my codes: 这是我的代码:

DateTime today = DateTime.Today;
DateTime firstDay = new DateTime(today.Year, today.Month, 1);
if (today == firstDay)
{
    while (true)
    {
        string sql1 = "SELECT quantity FROM medicine";
        DataSet ds = DBMgr.GetDataSet(sql1);
        int quantity = int.Parse(ds.Tables[0].Rows[0]["quantity"].ToString());
        string month = DateTime.Now.ToString("MMMM");

    if (month.Equals("January"))
    {
        string sql = "UPDATE report SET Jan = '{0}'";
        DBMgr.ExecuteSQL(sql, quantity);
    }
    if (month.Equals("February"))
    {
        string sql = "UPDATE report SET Feb = '{0}'";
        DBMgr.ExecuteSQL(sql, quantity);
    }
    if (month.Equals("March"))
    {
        string sql = "UPDATE report SET Mar = '{0}'";
        DBMgr.ExecuteSQL(sql, quantity);
    }
    if (month.Equals("April"))
    {
        string sql = "UPDATE report SET Apr = '{0}'";
        DBMgr.ExecuteSQL(sql, quantity);

    }
    if (month.Equals("May"))
    {
        string sql = "UPDATE report SET May = '{0}'";
        DBMgr.ExecuteSQL(sql, quantity);
    }
    if (month.Equals("June"))
    {
        string sql = "UPDATE report SET June = '{0}'";
        DBMgr.ExecuteSQL(sql, quantity);
    }
    if (month.Equals("July"))
    {
        string sql = "UPDATE report SET July = '{0}'";
        DBMgr.ExecuteSQL(sql, quantity);
    }
    if (month.Equals("August"))
    {
        string sql = "UPDATE report SET Aug = '{0}'";
        DBMgr.ExecuteSQL(sql, quantity);
    }
    if (month.Equals("September"))
    {
        string sql = "UPDATE report SET Sep = '{0}'";
        DBMgr.ExecuteSQL(sql, quantity);
    }
    if (month.Equals("October"))
    {
        string sql = "UPDATE report SET Oct = '{0}'";
        DBMgr.ExecuteSQL(sql, quantity);
    }
    if (month.Equals("November"))
    {
        string sql = "UPDATE report SET Nov = '{0}'";
        DBMgr.ExecuteSQL(sql, quantity);
    }
    if (month.Equals("December"))
    {
        string sql = "UPDATE report SET Dec = '{0}'";
        DBMgr.ExecuteSQL(sql, quantity);
    }
    else
    {
        LblMsg.Text = "An Error Occurred";
    }
}

the current month's column was not updated at all. 当前月份的列完全没有更新。 Thanks in advance! 提前致谢!

Not sure that timer will work for your case. 不确定计时器是否适合您的情况。 Most probably it is not called, because the current pool, that has a timer was stoped and there are no other requests to 'wake up' the pool and restart timer. 它很可能没有被调用,因为具有计时器的当前池已停止,并且没有其他请求“唤醒”池并重新启动计时器。 Read about recycling app pools and default settings 了解有关回收应用程序池和默认设置的信息

To be sure that your code is working, check it separatelly with another test 为确保您的代码正常运行,请与其他测试分开检查

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修改查询以使用ASP.NET C#与Sql Server获取每月的出勤报告 - how to modify the query to get monthly attendence report using asp.net c# with Sql Server 我试图从我的SQL语句的下拉菜单中使用selectedItem来填充C#asp.net中的文本框 - I am trying to use a selectedItem from a drop down menu in my SQL statement to populate a textbox in C# asp.net 我正在尝试使用c#从asp.net页执行ar脚本,但未执行 - i am trying to execute a r script from asp.net page using c# but it's not executing 在ASP.NET C#中使用SQLCommand从代码填充报表查看器 - Populate Report Viewer From Code using SQLCommand in ASP.NET C# 我正在尝试在 asp.net c# 中使用 google API 发送 email 并收到错误 400 redirect_uri_mismatch - I am trying to send email using google API in asp.net c# and getting Error 400 redirect_uri_mismatch 在Crystal Report和ASP.NET C#中使用子报表 - Using Subreport in Crystal Report and ASP.NET C# 使用C#的ASP.NET,在Repeater中自动刷新div - ASP.NET using C#, auto refresh div in a Repeater 在ASP.NET C#中生成报告 - Generate report in asp.net c# C#中的rdlc报告,ASP.net - rdlc report in C#, ASP.net 我如何在c#asp.net应用程序中使用jquery实现文本框自动建议? - How can i implement textbox auto suggest using jquery in my c# asp.net application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM