diff --git a/Keps.WinForms/Forms/DataInputForm.cs b/Keps.WinForms/Forms/DataInputForm.cs index c528425..6386f2e 100644 --- a/Keps.WinForms/Forms/DataInputForm.cs +++ b/Keps.WinForms/Forms/DataInputForm.cs @@ -1,6 +1,7 @@ -using System; +using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; using Keps.WinForms.Models; @@ -41,6 +42,7 @@ namespace Keps.WinForms.Forms List elections = _excelImportService.LoadElectionYears(); + _cmbElection.DropDownStyle = ComboBoxStyle.DropDown; _cmbElection.Items.Clear(); foreach (string election in elections) { @@ -55,7 +57,7 @@ namespace Keps.WinForms.Forms private void BtnFolder_Click(object sender, EventArgs e) { - // 초기 디렉터리는 _txtFile의 값(폴더이거나 파일이면 그 폴더) 또는 _appBasePath + // 초기 디렉터리는 선택된 파일의 폴더 또는 앱 실행 폴더를 사용합니다. string initialDir = _appBasePath; if (!string.IsNullOrWhiteSpace(_txtFile.Text)) @@ -96,9 +98,10 @@ namespace Keps.WinForms.Forms return; } - if (_cmbElection.SelectedItem == null) + string electionName = _cmbElection.Text.Trim(); + if (!IsValidElectionYear(electionName)) { - MessageBox.Show(this, "선거년월을 선택하세요.", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning); + MessageBox.Show(this, "선거년월을 yyyymm 형식으로 입력 또는 선택해주세요.", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } @@ -109,11 +112,10 @@ namespace Keps.WinForms.Forms } string filePath = _txtFile.Text; - string electionName = _cmbElection.SelectedItem.ToString(); ToggleState(false); _progress.Value = 0; - _lblMain.Text = "엑셀자료 입력 시작 - 최종 투표구 추출용"; + _lblMain.Text = "엑셀자료 입력 시작 - 최종 투표소 추출용"; Progress progress = new Progress(p => { @@ -148,5 +150,12 @@ namespace Keps.WinForms.Forms _btnFolder.Enabled = enabled; _btnImportReal.Enabled = enabled; } + + private static bool IsValidElectionYear(string value) + { + return !string.IsNullOrWhiteSpace(value) + && value.Length == 6 + && value.All(char.IsDigit); + } } }