SVN-Revision: r464
This commit is contained in:
wyf
2025-04-09 09:46:13 +00:00
parent fc0781a421
commit ffa4627f8f
8 changed files with 433 additions and 415 deletions
+79 -57
View File
@@ -80,7 +80,7 @@ namespace Lskj.PubBomImport
InitGridColumns();
InitMulitControl();
InitDataSource();
if (showType)
if (showTypeValue == 0 || showTypeValue == 3 || (showTypeValue > 0 && showType))
{
OnBtnImportClick(null, null);
}
@@ -101,13 +101,45 @@ namespace Lskj.PubBomImport
{
try
{
if (Model.ShowType.Equals("1"))
if (Model.ShowType.Equals("0"))//多选文件并返回到表中
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Multiselect = true;
dialog.InitialDirectory = Properties.Settings.Default.LastSelectFolder;
dialog.Title = "选择导入文件";
dialog.Filter = "Excel文件(*.xlsx)|*.xlsx|Excel文件(*.xls)|*.xls";
DialogResult dialogResult = dialog.ShowDialog();
if (dialogResult == DialogResult.OK)
{
Properties.Settings.Default.LastSelectFolder = Path.GetDirectoryName(dialog.FileName);
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
{
ShowType = Model.ShowType,
AfterBomFieldName = Model.AfterBomFieldName,
FileNames = dialog.FileNames
};
FormDialogModel dialogModel = new FormDialogModel()
{
DialogDllName = "Lskj.PubBomImport.dll",
PubDialogType = DialogType.PubAddRecord,
ReturnTag = bomImpRtnModel
};
this.Tag = dialogModel;
}
else
{
this.Close();
}
}
else if (Model.ShowType.Equals("1"))
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.SelectedPath = Properties.Settings.Default.LastSelectFolder;
dialog.Description = "选择导入文件夹";
DialogResult dialogResult = dialog.ShowDialog();
if (dialogResult == DialogResult.OK)
{
Properties.Settings.Default.LastSelectFolder = dialog.SelectedPath;
string dirPath = dialog.SelectedPath;
FrmProgress frmProgress = new FrmProgress();
frmProgress.frmMain = this;
@@ -128,11 +160,13 @@ namespace Lskj.PubBomImport
else if (Model.ShowType.Equals("2"))
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.InitialDirectory = Properties.Settings.Default.LastSelectFolder;
dialog.Title = "选择导入文件";
dialog.Filter = "Excel文件(*.xlsx)|*.xlsx|Excel文件(*.xls)|*.xls";
DialogResult dialogResult = dialog.ShowDialog();
if (dialogResult == DialogResult.OK)
{
Properties.Settings.Default.LastSelectFolder = Path.GetDirectoryName(dialog.FileName);
string dirPath = dialog.FileName;
FrmProgress frmProgress = new FrmProgress();
frmProgress.frmMain = this;
@@ -152,57 +186,61 @@ namespace Lskj.PubBomImport
}
else if (Model.ShowType.Equals("3"))
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Title = "选择导入文件";
dialog.Filter = "Excel文件(*.xlsx)|*.xlsx|Excel文件(*.xls)|*.xls";
DialogResult dialogResult = dialog.ShowDialog();
if (dialogResult == DialogResult.OK)
DataTable sourceTable = StaticControl.RightMenuGridView.GridControl.DataSourceTable();
if (StaticControl.RightMenuGridView.Tag is Dictionary<string, string> filesDic)
{
string dirPath = dialog.FileName;
FrmProgress frmProgress = new FrmProgress();
frmProgress.frmMain = this;
frmProgress.Model = Model;
frmProgress.ImportTimer.Tick += (ts, te) =>
{
frmProgress.ImportTimer.Enabled = false;
frmProgress.StartImportInQDFile(dirPath);
frmProgress.StartImportInQDFile(sourceTable, filesDic);
};
frmProgress.ImportTimer.Enabled = true;
frmProgress.OnImportCallBack += OnImportCallBack;
frmProgress.ShowDialog();
DialogResult dialogResult = frmProgress.ShowDialog();
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
{
ShowType = Model.ShowType,
AfterBomFieldName = Model.AfterBomFieldName,
CanSave = dialogResult == DialogResult.OK
};
FormDialogModel dialogModel = new FormDialogModel()
{
DialogDllName = "Lskj.PubBomImport.dll",
PubDialogType = DialogType.PubAddRecord,
ReturnTag = bomImpRtnModel
};
this.Tag = dialogModel;
frmProgress.Dispose();
}
else
{
this.Close();
}
}
//else if (Model.ShowType.Equals("4"))//禁用
//{
// OpenFileDialog dialog = new OpenFileDialog();
// dialog.Title = "选择导入文件";
// dialog.Filter = "Excel文件(*.xlsx)|*.xlsx|Excel文件(*.xls)|*.xls";
// DialogResult dialogResult = dialog.ShowDialog();
// if (dialogResult == DialogResult.OK)
// {
// string dirPath = dialog.FileName;
// FrmProgress frmProgress = new FrmProgress();
// frmProgress.frmMain = this;
// frmProgress.ImportTimer.Tick += (ts, te) =>
// {
// frmProgress.ImportTimer.Enabled = false;
// frmProgress.StartImportInMxFileNew(dirPath);
// };
// frmProgress.ImportTimer.Enabled = true;
// frmProgress.ShowDialog();
// frmProgress.Dispose();
// }
// else
// {
// this.Close();
// }
//}
}
//else if (Model.ShowType.Equals("4"))//禁用
//{
// OpenFileDialog dialog = new OpenFileDialog();
// dialog.Title = "选择导入文件";
// dialog.Filter = "Excel文件(*.xlsx)|*.xlsx|Excel文件(*.xls)|*.xls";
// DialogResult dialogResult = dialog.ShowDialog();
// if (dialogResult == DialogResult.OK)
// {
// string dirPath = dialog.FileName;
// FrmProgress frmProgress = new FrmProgress();
// frmProgress.frmMain = this;
// frmProgress.ImportTimer.Tick += (ts, te) =>
// {
// frmProgress.ImportTimer.Enabled = false;
// frmProgress.StartImportInMxFileNew(dirPath);
// };
// frmProgress.ImportTimer.Enabled = true;
// frmProgress.ShowDialog();
// frmProgress.Dispose();
// }
// else
// {
// this.Close();
// }
//}
catch (Exception ex)
{
MessageUtil.Show(ex.Message);
@@ -213,22 +251,6 @@ namespace Lskj.PubBomImport
this.Dispose();
}
}
/// <summary>
/// 导入后关闭回调
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnImportCallBack(object sender, EventArgs e)
{
FormDialogModel dialogModel = new FormDialogModel()
{
DialogDllName = "Lskj.PubBomImport.dll",
PubDialogType = DialogType.PubAddRecord,
ReturnTag = Model.ShowType
};
this.Tag = dialogModel;
}
/// <summary>
/// 读取按钮点击
/// </summary>