protected void Page_Load(object sender, EventArgs e)
 {
     if (Page.IsPostBack == true)
     {
         if (!string.IsNullOrEmpty(txb_Start_date.Text) & !string.IsNullOrEmpty(txb_End_date.Text))
         {
             Dictionary <string, object> d  = new Dictionary <string, object>();
             Lib.DataUtility             du = new Lib.DataUtility();
             try
             {
                 d.Add("start_date", txb_Start_date.Text);
                 d.Add("end_date", txb_End_date.Text);
                 DataTable dt = new DataTable();
                 //2017-11-23使用新的函式,加長timeout為120秒
                 dt = du.getDataTableBysp_BigData(@"Ex107_GetResultByDate", d);
                 if (dt.Rows.Count > 0)
                 {
                     string svPath = "Result(" + txb_Start_date.Text + "_" + txb_End_date.Text + ").csv";
                     Save_csv_toClient(dt, svPath);
                     ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + "成績儲存完成,共計「" + dt.Rows.Count.ToString() + "」筆" + "')", true);
                 }
                 else
                 {
                     ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + "查無資料!!" + "')", true);
                 }
             }
             catch (Exception ex)
             {
                 ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + ex.Message + "')", true);
             }
         }
         else
         {
             ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + "日期不可空白" + "')", true);
         }
     }
     else
     {
         txb_Start_date.Text = DateTime.Now.Year.ToString() + "-01-01";
         txb_End_date.Text   = DateTime.Now.ToString("yyyy-MM-dd");
     }
 }
Пример #2
0
    protected void btn_InqResult_Simple_Click(object sender, EventArgs e)
    {
        string year       = ddl_year.SelectedItem.Text.ToString() + "-";
        string start_date = string.Empty;
        string end_date   = string.Empty;

        switch (ddl_season.SelectedValue)
        {
        case "1":
            start_date = year + "01-01";
            end_date   = year + "03-31";
            break;

        case "2":
            start_date = year + "04-01";
            end_date   = year + "06-30";
            break;

        case "3":
            start_date = year + "07-01";
            end_date   = year + "09-30";
            break;

        case "4":
            start_date = year + "10-01";
            end_date   = year + "12-31";
            break;

        default:
            start_date = year + "01-01";
            end_date   = year + "03-31";
            break;
        }

        Dictionary <string, object> d = new Dictionary <string, object>();

        Lib.DataUtility du = new Lib.DataUtility();
        try
        {
            d.Add("start_date", start_date);
            d.Add("end_date", end_date);
            DataTable dt = new DataTable();
            //2017-11-23使用新的函式,加長timeout為120秒
            dt = du.getDataTableBysp_BigData(@"Ex108_GetResultByDate_Simple", d);
            if (dt.Rows.Count > 0)
            {
                string svPath = "Result(" + start_date + "_" + end_date + ")-exl.csv";
                Save_csv_toClient(dt, svPath, true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + "查無資料!!" + "')", true);
            }
        }
        catch (Exception ex)
        {
            //記錄錯誤訊息
            SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + ex.Message + "')", true);
        }
    }