private async void UpLoad_Click(object sender, EventArgs e) //上传配额表 { Search search = new Search { Year = int.Parse(this.IdYear.Text), CategoryId = int.Parse(((ComboboxItem)this.CategoryId.SelectedItem).Value), }; OpenFileDialog ofd = new OpenFileDialog(); //设置文件类型 ofd.Filter = "Microsoft Excel(*.xls) | *.xls"; // 设置默认文件类型显示顺序 //sfd.FilterIndex = 1; //保存对话框是否记忆上次打开的目录 ofd.RestoreDirectory = true; if (ofd.ShowDialog() == DialogResult.OK) { MainWindow mw = (MainWindow)this.MdiParent; cmd.ShowOpaqueLayer(this.ReportAnalysis, 125, true, true, "正在上传中,请稍候"); mw.treeView1.Enabled = false; string filepath = ofd.FileName.ToString(); var result = await _sc.UploadRegularload(search, filepath); cmd.HideOpaqueLayer(); mw.treeView1.Enabled = true; if (result) { MessageBox.Show("上传成功!"); } else { MessageBox.Show("上传失败, 请重新上传!"); } } this.UpLoad.Visible = false; }