protected void FileUpload_ExcelFile_FileSelected(object sender, EventArgs e)
        {
            if (FileUpload_ExcelFile.HasFile)
            {
                string fileName = FileUpload_ExcelFile.ShortFileName;

                if (fileName != "考评人信息.xls")
                {
                    Button_Submit.Enabled = false;
                    Label_FileName.Text   = "";
                    FileUpload_ExcelFile.Reset();
                    Alert.Show("无效的文件!", MessageBoxIcon.Error);
                    return;
                }

                Label_FileName.Text   = fileName;
                fileName              = DateTime.Now.Ticks.ToString() + "_" + fileName;
                ViewState["filename"] = fileName;

                FileUpload_ExcelFile.SaveAs(Server.MapPath("~/upload/" + fileName));


                Button_Submit.Enabled = true;
                // 清空文件上传组件
                FileUpload_ExcelFile.Reset();
            }
        }
Exemplo n.º 2
0
        protected void Button_Submit_Click(object sender, EventArgs e)
        {
            string exception = "";
            string fileName  = Server.MapPath("../../upload/" + ViewState["filename"].ToString());

            if (EvaluatedManagementCtrl.AddNewByExl(fileName, ref exception))
            {
                FileUpload_ExcelFile.Reset();
                Alert.ShowInTop("上传成功!", MessageBoxIcon.Information);
                bindEvaluatedToGrid();
            }
            else
            {
                FileUpload_ExcelFile.Reset();
                Alert.ShowInTop("上传失败!\n失败原因:" + exception, MessageBoxIcon.Error);
            }
        }