private async void button1_Click(object sender, EventArgs e) { if (this.Category.SelectedItem == null) { MessageBox.Show("请选择希望下载的会签单类别信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Search search = new Search { Year = int.Parse(this.IdYear.Text), CategoryId = int.Parse(((ComboboxItem)this.Category.SelectedItem).Value), }; SaveFileDialog sfd = new SaveFileDialog(); //设置文件类型 sfd.Filter = "Microsoft Excel(*.xls) | *.xls"; // 设置默认文件类型显示顺序 //sfd.FilterIndex = 1; //保存对话框是否记忆上次打开的目录 sfd.RestoreDirectory = true; sfd.FileName = this.Category.Text + "年度费用分配表"; if (sfd.ShowDialog() == DialogResult.OK) { MainWindow mw = (MainWindow)this.MdiParent; cmd.ShowOpaqueLayer(this.ReportAnalysis, 125, true, true, "正在下载中,请稍候"); mw.treeView1.Enabled = false; string filepath = sfd.FileName.ToString(); await _sc.DownloadStatistic(search, filepath); cmd.HideOpaqueLayer(); MessageBox.Show("下载完成!"); mw.treeView1.Enabled = true; } }