private void Upload_Click(object sender, EventArgs e)
 {
     Forms.ImportReportDocumentTemplate form = new ImportReportDocumentTemplate();
     if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         this.BindReceiptTemplate();
 }
 private void Update_Click(object sender, EventArgs e)
 {
     if (this.dgvData.SelectedRows.Count > 1)
     {
         MessageBox.Show("僅允許單筆修改。");
         return;
     }
     this.Delete.Enabled = false;
     this.Update.Enabled = false;
     this.Upload.Enabled = false;
     this.CircleProgress.Visible = true;
     this.CircleProgress.IsRunning = true;
     string SurveyID = this.dgvData.CurrentRow.Tag + "";
     Task<UDT.ReportTemplate> task = Task<UDT.ReportTemplate>.Factory.StartNew(() =>
     {
         List<UDT.ReportTemplate> templates = Access.Select<UDT.ReportTemplate>(string.Format("ref_survey_id = {0}", SurveyID));
         return templates.ElementAt(0);
     });
     task.ContinueWith((x) =>
     {
         if (x.Exception != null)
         {
             MessageBox.Show(x.Exception.InnerException.Message);
             goto TheEnd;
         }
         UDT.ReportTemplate template = x.Result;
         string TemplateName = this.dgvData.CurrentRow.Cells[0].Value + "";
         Forms.ImportReportDocumentTemplate form = new ImportReportDocumentTemplate(template, TemplateName);
         if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             this.BindReceiptTemplate();
         }
     TheEnd:
         this.Delete.Enabled = true;
         this.Update.Enabled = true;
         this.Upload.Enabled = true;
         this.CircleProgress.Visible = false;
         this.CircleProgress.IsRunning = false;
     }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
 }