private void ImportDoctorPriceFile(object parameter) { string doctorPriceFileName = parameter.ToString(); if (!File.Exists(doctorPriceFileName)) { Console.WriteLine("不存在医生价格文件,文件名:" + doctorPriceFileName); Logger.Info($"不存在医生价格文件,文件名:" + doctorPriceFileName); return; } string fileFullName = doctorPriceFileName; DataTable table = _importFileService.GetDataTableFromExcelFile(fileFullName, "医生价格"); if (table == null) { MessageBox.Show("读取文件失败,文件路径:" + fileFullName); Console.WriteLine("读取医生价格文件失败,文件名:" + doctorPriceFileName); Logger.Info($"读取医生价格文件失败,文件名:" + doctorPriceFileName); return; } InsertDoctorPriceDataIntoDB(table); UpdateDgvHandler updateDgvHandler = new UpdateDgvHandler(UpdateDoctorPriceDgv); dgvOrgionView.Invoke(updateDgvHandler, table); Logger.Info($"医生价格数据导入成功!"); MessageBox.Show("医生价格数据导入成功!"); }
private void ImportFile(object parameter) { string fileFold = parameter.ToString(); if (!Directory.Exists(fileFold)) { return; } DirectoryInfo directoryInfo = new DirectoryInfo(fileFold); foreach (var item in directoryInfo.GetFiles()) { string fileFullName = item.FullName; string fileName = item.Name; string directoryTemp = Path.Combine(fileFold, "Temp"); if (!Directory.Exists(directoryTemp)) { Directory.CreateDirectory(directoryTemp); } string tempFileFullName = Path.Combine(directoryTemp, fileName); SaveCopyAs(fileFullName, tempFileFullName); } UpdateDgvHandler updateDgvHandler = new UpdateDgvHandler(UpdateDoctorPriceDgv); btnBrowns.Invoke(updateDgvHandler); MessageBox.Show("文件处理完成!"); }
private void ImportFile(object parameter) { string fileFold = parameter.ToString(); if (!Directory.Exists(fileFold)) { return; } DirectoryInfo directoryInfo = new DirectoryInfo(fileFold); bool isExistSuccess = false; foreach (var item in directoryInfo.GetFiles()) { string fileFullName = item.FullName; UpdateLableHandler updateFileHandler = new UpdateLableHandler(UpdateFileName); lblFileName.Invoke(updateFileHandler, $"正在读取文件:" + fileFullName); DataTable table = _importFileService.GetDataTableFromExcelFile(fileFullName, string.Empty); if (table == null) { MessageBox.Show("读取文件失败,文件路径:" + fileFullName); lblFileName.Invoke(updateFileHandler, $"读取文件失败,文件路径:" + fileFullName); continue; } isExistSuccess = true; UpdateDgvHandler updateDgvHandler = new UpdateDgvHandler(UpdateDgv); dgvOrgionView.Invoke(updateDgvHandler, table); lblFileName.Invoke(updateFileHandler, $"正在导入文件到数据库:" + fileFullName); InsertOrgionDataIntoDB(table, item.Name); lblFileName.Invoke(updateFileHandler, $"导入文件到数据库完成:" + fileFullName); } UpdateControlHandler updateControlHandler = new UpdateControlHandler(UpdateControl); processBarImport.Invoke(updateControlHandler); if (!isExistSuccess) { UpdateDgvHandler updateDgvHandler = new UpdateDgvHandler(UpdateDgv); dgvOrgionView.Invoke(updateDgvHandler, new DataTable()); MessageBox.Show("数据导入完成,但没读取到任何数据!"); return; } MessageBox.Show("数据导入完成!"); }