583 lines
22 KiB
C#
583 lines
22 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
using Keps.WinForms.Infrastructure;
|
|
using Keps.WinForms.Models;
|
|
using Keps.WinForms.Services;
|
|
|
|
namespace Keps.WinForms.Forms
|
|
{
|
|
public sealed partial class RealExtractionForm : Form
|
|
{
|
|
private SqlConnectionFactory _connectionFactory;
|
|
private LookupService _lookupService;
|
|
private SamplingService _samplingService;
|
|
private ExcelReportService _excelReportService;
|
|
private RealScenarioContext _preparedContext;
|
|
|
|
private BindingList<ClusterSummaryRow> _autoRows = new BindingList<ClusterSummaryRow>();
|
|
private BindingList<ClusterSummaryRow> _manualRows = new BindingList<ClusterSummaryRow>();
|
|
private BindingList<AdjustmentRow> _adjustmentRows = new BindingList<AdjustmentRow>();
|
|
private BindingList<VerificationSummaryRow> _verificationRows = new BindingList<VerificationSummaryRow>();
|
|
private BindingList<ExtractionRow> _resultRows = new BindingList<ExtractionRow>();
|
|
private RealExtractionResult _lastResult;
|
|
private List<string> _candidateNames = new List<string>();
|
|
|
|
public RealExtractionForm()
|
|
{
|
|
InitializeComponent();
|
|
WireEvents();
|
|
InitializeDefaults();
|
|
InitializeGridColumns();
|
|
}
|
|
|
|
public void SetConnectionFactory(SqlConnectionFactory connectionFactory)
|
|
{
|
|
_connectionFactory = connectionFactory;
|
|
if (_connectionFactory == null)
|
|
{
|
|
_lookupService = null;
|
|
_samplingService = null;
|
|
_excelReportService = null;
|
|
return;
|
|
}
|
|
|
|
_lookupService = new LookupService(_connectionFactory);
|
|
_samplingService = new SamplingService(_connectionFactory);
|
|
_excelReportService = new ExcelReportService();
|
|
}
|
|
|
|
private void WireEvents()
|
|
{
|
|
Load += RealExtractionForm_Load;
|
|
_cmbElection.SelectedIndexChanged += CmbElection_SelectedIndexChanged;
|
|
_cmbArea.SelectedIndexChanged += CmbArea_SelectedIndexChanged;
|
|
_btnPrepare.Click += BtnPrepare_Click;
|
|
_btnExtract.Click += BtnExtract_Click;
|
|
_btnExportExcel.Click += BtnExportExcel_Click;
|
|
_rdoAuto.CheckedChanged += ToggleAllocationMode;
|
|
_rdoManual.CheckedChanged += ToggleAllocationMode;
|
|
_optOffsetSubtract.CheckedChanged += OffsetModeChanged;
|
|
_optOffsetBasic.CheckedChanged += OffsetModeChanged;
|
|
_optOffsetAdd.CheckedChanged += OffsetModeChanged;
|
|
_numOffsetValue.ValueChanged += OffsetModeChanged;
|
|
_numTotalSamples.ValueChanged += TotalSamplesChanged;
|
|
}
|
|
|
|
private void InitializeDefaults()
|
|
{
|
|
_cmbElection.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
_cmbArea.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
_cmbClusterMax.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
_cmbSortMetric.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
_cmbSortDirection.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
|
|
_cmbSortDirection.Items.Add("내림차순");
|
|
_cmbSortDirection.Items.Add("오름차순");
|
|
_cmbSortDirection.SelectedIndex = 0;
|
|
|
|
_numTotalSamples.Minimum = 1;
|
|
_numTotalSamples.Maximum = 5000;
|
|
_numTotalSamples.Value = 1;
|
|
_numTotalSamples.Text = string.Empty;
|
|
_numOffsetValue.Minimum = 0;
|
|
_numOffsetValue.Maximum = 100;
|
|
_preparedContext = null;
|
|
|
|
_rdoAuto.Checked = true;
|
|
_optOffsetBasic.Checked = true;
|
|
_lblMainStatus.Text = "완료......";
|
|
_lblDetailStatus.Text = "0.000 %";
|
|
_progressBar.Value = 0;
|
|
ToggleAllocationMode(this, EventArgs.Empty);
|
|
OffsetModeChanged(this, EventArgs.Empty);
|
|
}
|
|
|
|
private void RealExtractionForm_Load(object sender, EventArgs e)
|
|
{
|
|
if (_lookupService == null)
|
|
{
|
|
_lblMainStatus.Text = "서비스 미연결";
|
|
return;
|
|
}
|
|
|
|
ReloadElections();
|
|
}
|
|
|
|
private void ReloadElections()
|
|
{
|
|
_cmbElection.Items.Clear();
|
|
foreach (string item in _lookupService.LoadRealElections())
|
|
{
|
|
_cmbElection.Items.Add(item);
|
|
}
|
|
|
|
if (_cmbElection.Items.Count > 0)
|
|
{
|
|
_cmbElection.SelectedIndex = 0;
|
|
}
|
|
}
|
|
private void CmbElection_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (DesignTimeHelper.IsDesignMode(this) || _lookupService == null || _cmbElection.SelectedItem == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_cmbArea.Items.Clear();
|
|
_cmbClusterMax.Items.Clear();
|
|
_cmbSortMetric.Items.Clear();
|
|
|
|
foreach (string area in _lookupService.LoadRealAreas(_cmbElection.SelectedItem.ToString()))
|
|
{
|
|
_cmbArea.Items.Add(area);
|
|
}
|
|
if (_cmbArea.Items.Count > 0)
|
|
{
|
|
_cmbArea.SelectedIndex = 0;
|
|
}
|
|
|
|
foreach (CandidateOption option in _lookupService.LoadCandidateOptions(_cmbElection.SelectedItem.ToString()))
|
|
{
|
|
_cmbSortMetric.Items.Add(option);
|
|
}
|
|
_cmbSortMetric.DisplayMember = "DisplayName";
|
|
_cmbSortMetric.ValueMember = "Key";
|
|
if (_cmbSortMetric.Items.Count > 0)
|
|
{
|
|
_cmbSortMetric.SelectedIndex = 0;
|
|
}
|
|
}
|
|
|
|
private void CmbArea_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (DesignTimeHelper.IsDesignMode(this) || _lookupService == null || _cmbElection.SelectedItem == null || _cmbArea.SelectedItem == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_cmbClusterMax.Items.Clear();
|
|
foreach (int value in _lookupService.LoadRealClusterMaxList(_cmbElection.SelectedItem.ToString(), _cmbArea.SelectedItem.ToString()))
|
|
{
|
|
_cmbClusterMax.Items.Add(value);
|
|
}
|
|
if (_cmbClusterMax.Items.Count > 0)
|
|
{
|
|
_cmbClusterMax.SelectedIndex = 0;
|
|
}
|
|
}
|
|
|
|
private void BtnPrepare_Click(object sender, EventArgs e)
|
|
{
|
|
if (!ValidateScenarioInputs() || _samplingService == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
SetProgress(10, "조건 로드 중...");
|
|
string election = _cmbElection.SelectedItem.ToString();
|
|
string area = _cmbArea.SelectedItem.ToString();
|
|
int clusterMax = Convert.ToInt32(_cmbClusterMax.SelectedItem);
|
|
int totalSamples = GetTotalSamples();
|
|
|
|
RealScenarioContext context = _samplingService.LoadRealScenario(election, area, clusterMax);
|
|
_preparedContext = context;
|
|
_autoRows = new BindingList<ClusterSummaryRow>(_samplingService.AllocateAutoSampleCounts(context.AutoRows, totalSamples));
|
|
_manualRows = new BindingList<ClusterSummaryRow>(context.ManualRows.Select(CloneRow).ToList());
|
|
for (int i = 0; i < _manualRows.Count && i < _autoRows.Count; i++)
|
|
{
|
|
_manualRows[i].SampleCount = _autoRows[i].SampleCount;
|
|
}
|
|
|
|
_adjustmentRows = new BindingList<AdjustmentRow>(BuildDefaultAdjustmentRows(GetWorkingRows()));
|
|
_verificationRows = new BindingList<VerificationSummaryRow>();
|
|
_resultRows = new BindingList<ExtractionRow>();
|
|
_lastResult = null;
|
|
BindGridSources();
|
|
ApplyVerificationHeaders();
|
|
UpdateOffsetRange();
|
|
SetProgress(100, "사전 단계 완료");
|
|
}
|
|
|
|
private void BtnExtract_Click(object sender, EventArgs e)
|
|
{
|
|
if (!ValidateScenarioInputs() || _samplingService == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
List<ClusterSummaryRow> workingRows = GetWorkingRows();
|
|
if (workingRows.Count == 0 || workingRows.All(x => x.SampleCount <= 0))
|
|
{
|
|
MessageBox.Show(this, "추출 대상 층별 개수를 먼저 설정하세요.", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
string election = _cmbElection.SelectedItem.ToString();
|
|
string area = _cmbArea.SelectedItem.ToString();
|
|
int clusterMax = Convert.ToInt32(_cmbClusterMax.SelectedItem);
|
|
CandidateOption option = _cmbSortMetric.SelectedItem as CandidateOption;
|
|
string sortKey = option == null ? "투표인수" : option.Key;
|
|
bool descending = _cmbSortDirection.SelectedIndex == 0;
|
|
int offset = GetSignedOffset();
|
|
|
|
SetProgress(15, "최종 추출 실행 중...");
|
|
_lastResult = _samplingService.RunRealExtraction(election, area, clusterMax, sortKey, option == null ? "투표인수" : option.DisplayName, descending, workingRows, offset, GetOffsetDescription(), _rdoAuto.Checked);
|
|
_candidateNames = (_lastResult.CandidateNames ?? new List<string>()).ToList();
|
|
_resultRows = new BindingList<ExtractionRow>(_lastResult.ExtractedRows ?? new List<ExtractionRow>());
|
|
_adjustmentRows = new BindingList<AdjustmentRow>(_lastResult.AdjustmentRows ?? new List<AdjustmentRow>());
|
|
_verificationRows = new BindingList<VerificationSummaryRow>(_lastResult.VerificationRows ?? new List<VerificationSummaryRow>());
|
|
BindGridSources();
|
|
ApplyVerificationHeaders();
|
|
SetProgress(100, "최종 추출 완료");
|
|
}
|
|
|
|
private void BtnExportExcel_Click(object sender, EventArgs e)
|
|
{
|
|
if (_lastResult == null || _resultRows.Count == 0)
|
|
{
|
|
MessageBox.Show(this, "먼저 최종 추출을 실행하세요.", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
using (SaveFileDialog dialog = new SaveFileDialog())
|
|
{
|
|
dialog.Filter = "Excel 파일 (*.xlsx)|*.xlsx";
|
|
dialog.FileName = string.Format("층화_후_득표율_기준_{0}-{1}_최종_{2:yyyyMMdd_HHmmss}.xlsx", _cmbElection.SelectedItem, _cmbArea.SelectedItem, DateTime.Now);
|
|
if (dialog.ShowDialog(this) == DialogResult.OK)
|
|
{
|
|
var adjustList = ((BindingList<AdjustmentRow>)_gridAdjustment.DataSource).ToList();
|
|
_excelReportService.ExportRealExtractionWorkbook(dialog.FileName, _cmbElection.SelectedItem.ToString(), _cmbArea.SelectedItem.ToString(), GetWorkingRows(), _lastResult, adjustList);
|
|
MessageBox.Show(this, "엑셀 저장 완료" + Environment.NewLine + dialog.FileName, "완료", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void TotalSamplesChanged(object sender, EventArgs e)
|
|
{
|
|
if (_samplingService == null || _preparedContext == null)
|
|
{
|
|
_lblOffsetPreview.Text = GetOffsetDescription();
|
|
return;
|
|
}
|
|
|
|
if (_rdoAuto.Checked)
|
|
{
|
|
int totalSamples;
|
|
if (!TryGetTotalSamples(out totalSamples))
|
|
{
|
|
return;
|
|
}
|
|
|
|
_autoRows = new BindingList<ClusterSummaryRow>(_samplingService.AllocateAutoSampleCounts(_preparedContext.AutoRows, totalSamples));
|
|
|
|
if (_manualRows == null || _manualRows.Count != _autoRows.Count)
|
|
{
|
|
_manualRows = new BindingList<ClusterSummaryRow>(_preparedContext.ManualRows.Select(CloneRow).ToList());
|
|
}
|
|
|
|
for (int i = 0; i < _manualRows.Count && i < _autoRows.Count; i++)
|
|
{
|
|
_manualRows[i].SampleCount = _autoRows[i].SampleCount;
|
|
}
|
|
|
|
BindGridSources();
|
|
}
|
|
|
|
UpdateOffsetRange();
|
|
}
|
|
|
|
private void ToggleAllocationMode(object sender, EventArgs e)
|
|
{
|
|
_gridAuto.Visible = _rdoAuto.Checked;
|
|
_gridManual.Visible = _rdoManual.Checked;
|
|
UpdateOffsetRange();
|
|
}
|
|
|
|
private void OffsetModeChanged(object sender, EventArgs e)
|
|
{
|
|
bool showOffset = !_optOffsetBasic.Checked;
|
|
_lblOffsetValue.Enabled = showOffset;
|
|
_numOffsetValue.Enabled = showOffset && _numOffsetValue.Maximum > 0;
|
|
_lblOffsetPreview.Text = GetOffsetDescription();
|
|
}
|
|
|
|
private string GetOffsetDescription()
|
|
{
|
|
if (_optOffsetBasic.Checked)
|
|
{
|
|
return "n - 0";
|
|
}
|
|
|
|
string prefix = _optOffsetSubtract.Checked ? "n - " : "n + ";
|
|
return prefix + Convert.ToInt32(_numOffsetValue.Value);
|
|
}
|
|
|
|
private int GetSignedOffset()
|
|
{
|
|
if (_optOffsetBasic.Checked)
|
|
{
|
|
return 0;
|
|
}
|
|
int value = Convert.ToInt32(_numOffsetValue.Value);
|
|
return _optOffsetSubtract.Checked ? -value : value;
|
|
}
|
|
|
|
private void UpdateOffsetRange()
|
|
{
|
|
List<ClusterSummaryRow> rows = GetWorkingRows();
|
|
ClusterSummaryRow targetRow = rows.LastOrDefault(x => x.SampleCount > 0);
|
|
int maxRange = 0;
|
|
bool offsetEnabled = true;
|
|
|
|
if (targetRow != null)
|
|
{
|
|
int total = targetRow.PollingPlaceCount;
|
|
int sample = targetRow.SampleCount;
|
|
|
|
int interval = total / sample;
|
|
int start = interval / 2;
|
|
int endPoint = start + (interval * (sample - 1));
|
|
int x1 = total - endPoint;
|
|
int x2 = start - 1;
|
|
start = (int)Math.Round((x1 + x2) / 2m, 0, MidpointRounding.AwayFromZero);
|
|
maxRange = total - (interval * (sample - 1)) - start;
|
|
|
|
if (interval == 0)
|
|
{
|
|
maxRange = 0;
|
|
offsetEnabled = false;
|
|
}
|
|
}
|
|
|
|
if (maxRange < 0)
|
|
{
|
|
maxRange = 0;
|
|
}
|
|
|
|
_lblOffsetRange.Text = "가감 범위 1 ~ " + maxRange;
|
|
_numOffsetValue.Maximum = Math.Max(0, maxRange);
|
|
|
|
if (!offsetEnabled)
|
|
{
|
|
_numOffsetValue.Value = 0;
|
|
_numOffsetValue.Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
if (!_optOffsetBasic.Checked)
|
|
{
|
|
_numOffsetValue.Enabled = true;
|
|
}
|
|
if (_numOffsetValue.Value > _numOffsetValue.Maximum)
|
|
{
|
|
_numOffsetValue.Value = _numOffsetValue.Maximum;
|
|
}
|
|
}
|
|
|
|
_lblOffsetPreview.Text = GetOffsetDescription();
|
|
}
|
|
|
|
private bool ValidateScenarioInputs()
|
|
{
|
|
if (_cmbElection.SelectedItem == null)
|
|
{
|
|
MessageBox.Show(this, "선거를 선택하세요.", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return false;
|
|
}
|
|
if (_cmbArea.SelectedItem == null)
|
|
{
|
|
MessageBox.Show(this, "지역을 선택하세요.", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return false;
|
|
}
|
|
if (_cmbClusterMax.SelectedItem == null)
|
|
{
|
|
MessageBox.Show(this, "군집수를 선택하세요.", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return false;
|
|
}
|
|
if (!TryGetTotalSamples(out _))
|
|
{
|
|
MessageBox.Show(this, "총 표본 수를 입력하세요.", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
_numTotalSamples.Focus();
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private int GetTotalSamples()
|
|
{
|
|
int totalSamples;
|
|
if (!TryGetTotalSamples(out totalSamples))
|
|
{
|
|
throw new InvalidOperationException("총 표본 수를 입력하세요.");
|
|
}
|
|
return totalSamples;
|
|
}
|
|
|
|
private bool TryGetTotalSamples(out int totalSamples)
|
|
{
|
|
totalSamples = 0;
|
|
if (string.IsNullOrWhiteSpace(_numTotalSamples.Text))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
totalSamples = Convert.ToInt32(_numTotalSamples.Value);
|
|
return totalSamples >= _numTotalSamples.Minimum && totalSamples <= _numTotalSamples.Maximum;
|
|
}
|
|
|
|
private List<ClusterSummaryRow> GetWorkingRows()
|
|
{
|
|
return (_rdoAuto.Checked ? _autoRows : _manualRows).Select(CloneRow).ToList();
|
|
}
|
|
|
|
private static ClusterSummaryRow CloneRow(ClusterSummaryRow source)
|
|
{
|
|
return new ClusterSummaryRow
|
|
{
|
|
ClusterNo = source.ClusterNo,
|
|
ClusterLabel = source.ClusterLabel,
|
|
PollingPlaceCount = source.PollingPlaceCount,
|
|
Ratio = source.Ratio,
|
|
SampleCount = source.SampleCount
|
|
};
|
|
}
|
|
|
|
private static List<AdjustmentRow> BuildDefaultAdjustmentRows(List<ClusterSummaryRow> rows)
|
|
{
|
|
List<AdjustmentRow> result = new List<AdjustmentRow>();
|
|
foreach (ClusterSummaryRow row in rows)
|
|
{
|
|
int interval = row.SampleCount <= 0 ? 1 : Math.Max(1, row.PollingPlaceCount / row.SampleCount);
|
|
for (int i = 0; i < row.SampleCount; i++)
|
|
{
|
|
result.Add(new AdjustmentRow { ClusterNo = row.ClusterNo, ExtractId = 1 + (i * interval) });
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private void BindGridSources()
|
|
{
|
|
_gridAuto.DataSource = _autoRows;
|
|
_gridManual.DataSource = _manualRows;
|
|
_gridAdjustment.DataSource = _adjustmentRows;
|
|
_gridVerification.DataSource = _verificationRows;
|
|
_gridResult.DataSource = _resultRows;
|
|
}
|
|
|
|
private void SetProgress(int percent, string text)
|
|
{
|
|
_progressBar.Value = Math.Max(0, Math.Min(100, percent));
|
|
_lblMainStatus.Text = text;
|
|
_lblDetailStatus.Text = string.Format("{0:0.000} %", percent);
|
|
}
|
|
|
|
private void InitializeGridColumns()
|
|
{
|
|
ConfigureGridBase(_gridAuto);
|
|
ConfigureGridBase(_gridManual);
|
|
ConfigureGridBase(_gridAdjustment);
|
|
ConfigureGridBase(_gridVerification);
|
|
ConfigureGridBase(_gridResult);
|
|
|
|
ConfigureClusterGrid(_gridAuto, true);
|
|
ConfigureClusterGrid(_gridManual, false);
|
|
ConfigureAdjustmentGrid();
|
|
ConfigureVerificationGrid();
|
|
ConfigureResultGrid();
|
|
BindGridSources();
|
|
}
|
|
|
|
private static void ConfigureGridBase(DataGridView grid)
|
|
{
|
|
grid.AllowUserToAddRows = false;
|
|
grid.AllowUserToDeleteRows = false;
|
|
grid.RowHeadersVisible = false;
|
|
grid.SelectionMode = DataGridViewSelectionMode.CellSelect;
|
|
grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
|
|
grid.BackgroundColor = System.Drawing.Color.White;
|
|
grid.BorderStyle = BorderStyle.FixedSingle;
|
|
}
|
|
|
|
private static void ConfigureClusterGrid(DataGridView grid, bool readOnlySampleCount)
|
|
{
|
|
grid.AutoGenerateColumns = false;
|
|
grid.Columns.Clear();
|
|
grid.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "ClusterNo", HeaderText = "층", ReadOnly = true, Width = 50 });
|
|
grid.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "PollingPlaceCount", HeaderText = "투표구수", ReadOnly = true, Width = 80 });
|
|
grid.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "Ratio", HeaderText = "층의비율", ReadOnly = true, Width = 85, DefaultCellStyle = new DataGridViewCellStyle { Format = "0.00000" } });
|
|
grid.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "SampleCount", HeaderText = "층별추출개수", ReadOnly = readOnlySampleCount, Width = 95 });
|
|
}
|
|
|
|
private void ConfigureAdjustmentGrid()
|
|
{
|
|
_gridAdjustment.AutoGenerateColumns = false;
|
|
_gridAdjustment.Columns.Clear();
|
|
_gridAdjustment.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "ClusterNo", HeaderText = "층", ReadOnly = true, Width = 45 });
|
|
_gridAdjustment.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "ExtractId", HeaderText = "추출ID", ReadOnly = true, Width = 70 });
|
|
_gridAdjustment.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "AdjustId", HeaderText = "조정ID", Width = 70 });
|
|
}
|
|
|
|
private void ConfigureVerificationGrid()
|
|
{
|
|
_gridVerification.AutoGenerateColumns = false;
|
|
_gridVerification.Columns.Clear();
|
|
_gridVerification.ColumnHeadersHeight = 42; // 원하는 높이
|
|
|
|
_gridVerification.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "RowLabel", HeaderText = "구분", ReadOnly = true, Width = 70 });
|
|
_gridVerification.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "Extracted1", HeaderText = "추출1", ReadOnly = true, Width = 80 });
|
|
_gridVerification.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "Extracted2", HeaderText = "추출2", ReadOnly = true, Width = 80 });
|
|
_gridVerification.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "Extracted3", HeaderText = "추출3", ReadOnly = true, Width = 80 });
|
|
_gridVerification.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "Actual1", HeaderText = "실제1", ReadOnly = true, Width = 80 });
|
|
_gridVerification.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "Actual2", HeaderText = "실제2", ReadOnly = true, Width = 80 });
|
|
_gridVerification.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "Actual3", HeaderText = "실제3", ReadOnly = true, Width = 80 });
|
|
_gridVerification.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "WeightedError1", HeaderText = "1오차", ReadOnly = true, Width = 80 });
|
|
_gridVerification.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "WeightedError2", HeaderText = "2오차", ReadOnly = true, Width = 80 });
|
|
_gridVerification.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "WeightedError3", HeaderText = "3오차", ReadOnly = true, Width = 80 });
|
|
_gridVerification.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "WeightedErrorSum", HeaderText = "오차합", ReadOnly = true, Width = 80 });
|
|
}
|
|
|
|
private void ConfigureResultGrid()
|
|
{
|
|
_gridResult.AutoGenerateColumns = false;
|
|
_gridResult.Columns.Clear();
|
|
_gridResult.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "ClusterNo", HeaderText = "층", ReadOnly = true, Width = 45 });
|
|
_gridResult.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "ClusterOrder", HeaderText = "추출순번", ReadOnly = true, Width = 80 });
|
|
_gridResult.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "OriginalOrder", HeaderText = "원본정렬순번", ReadOnly = true, Width = 120 });
|
|
_gridResult.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "Interval", HeaderText = "간격", ReadOnly = true, Width = 50 });
|
|
_gridResult.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "StartPosition", HeaderText = "시작위치", ReadOnly = true, Width = 80 });
|
|
_gridResult.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "OffsetDescription", HeaderText = "추출위치", ReadOnly = true, Width = 80 });
|
|
_gridResult.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "DistrictName", HeaderText = "선거구명", ReadOnly = true, Width = 120 });
|
|
_gridResult.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "EupMyeonDong", HeaderText = "읍면동", ReadOnly = true, Width = 120 });
|
|
_gridResult.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "PollingPlaceNo", HeaderText = "투표구", ReadOnly = true, Width = 60 });
|
|
_gridResult.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "EligibleVoterCount", HeaderText = "유권자수", ReadOnly = true, Width = 80 });
|
|
_gridResult.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "VoteCount", HeaderText = "투표인수", ReadOnly = true, Width = 80 });
|
|
_gridResult.Columns.Add(new DataGridViewTextBoxColumn { DataPropertyName = "SortValue", HeaderText = "정렬값", ReadOnly = true, Width = 60 });
|
|
}
|
|
|
|
private void ApplyVerificationHeaders()
|
|
{
|
|
List<string> names = (_candidateNames ?? new List<string>()).ToList();
|
|
while (names.Count < 3)
|
|
{
|
|
names.Add("후보" + (names.Count + 1));
|
|
}
|
|
|
|
if (_gridVerification.Columns.Count >= 11)
|
|
{
|
|
_gridVerification.Columns[1].HeaderText = "추출" + Environment.NewLine + names[0];
|
|
_gridVerification.Columns[2].HeaderText = "추출" + Environment.NewLine + names[1];
|
|
_gridVerification.Columns[3].HeaderText = "추출" + Environment.NewLine + names[2];
|
|
_gridVerification.Columns[4].HeaderText = "실제" + Environment.NewLine + names[0];
|
|
_gridVerification.Columns[5].HeaderText = "실제" + Environment.NewLine + names[1];
|
|
_gridVerification.Columns[6].HeaderText = "실제" + Environment.NewLine + names[2];
|
|
}
|
|
}
|
|
}
|
|
}
|