first commit
This commit is contained in:
104
Keps.WinForms/Forms/MainMdiForm.cs
Normal file
104
Keps.WinForms/Forms/MainMdiForm.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Keps.WinForms.Infrastructure;
|
||||
using Keps.WinForms.Services;
|
||||
|
||||
namespace Keps.WinForms.Forms
|
||||
{
|
||||
public sealed partial class MainMdiForm : Form
|
||||
{
|
||||
private SqlConnectionFactory _connectionFactory;
|
||||
private AppVersionService _versionService;
|
||||
private ExcelImportService _excelImportService;
|
||||
|
||||
private DataInputForm _dataForm;
|
||||
private RealExtractionForm _realForm;
|
||||
|
||||
public MainMdiForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
WireEvents();
|
||||
}
|
||||
|
||||
public MainMdiForm(SqlConnectionFactory connectionFactory)
|
||||
: this()
|
||||
{
|
||||
InitializeRuntime(connectionFactory);
|
||||
}
|
||||
|
||||
public void InitializeRuntime(SqlConnectionFactory connectionFactory)
|
||||
{
|
||||
_connectionFactory = connectionFactory;
|
||||
_versionService = connectionFactory == null ? null : new AppVersionService(connectionFactory);
|
||||
_excelImportService = connectionFactory == null ? null : new ExcelImportService(connectionFactory);
|
||||
}
|
||||
|
||||
private void WireEvents()
|
||||
{
|
||||
Load += MainMdiForm_Load;
|
||||
_mnuData.Click += delegate { ShowDataInput(); };
|
||||
_mnuReal.Click += delegate { ShowReal(); };
|
||||
}
|
||||
|
||||
private void MainMdiForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (DesignTimeHelper.IsDesignMode(this) || _versionService == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
string version = _versionService.GetCurrentVersion();
|
||||
if (!string.IsNullOrWhiteSpace(version))
|
||||
{
|
||||
Text += " - DB Ver: " + version;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(this,
|
||||
"초기 DB 연결에는 성공했지만 버전 조회 중 오류가 발생했습니다.\r\n\r\n" + ex.Message,
|
||||
"초기화 경고",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowDataInput()
|
||||
{
|
||||
HideChildren();
|
||||
if (_dataForm == null || _dataForm.IsDisposed)
|
||||
{
|
||||
_dataForm = new DataInputForm();
|
||||
_dataForm.SetServices(_excelImportService);
|
||||
_dataForm.MdiParent = this;
|
||||
}
|
||||
|
||||
_dataForm.Show();
|
||||
_dataForm.BringToFront();
|
||||
}
|
||||
|
||||
private void ShowReal()
|
||||
{
|
||||
HideChildren();
|
||||
if (_realForm == null || _realForm.IsDisposed)
|
||||
{
|
||||
_realForm = new RealExtractionForm();
|
||||
_realForm.SetConnectionFactory(_connectionFactory);
|
||||
_realForm.MdiParent = this;
|
||||
}
|
||||
|
||||
_realForm.Show();
|
||||
_realForm.BringToFront();
|
||||
}
|
||||
|
||||
private void HideChildren()
|
||||
{
|
||||
foreach (Form child in MdiChildren)
|
||||
{
|
||||
child.Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user