149 lines
5.8 KiB
C#
149 lines
5.8 KiB
C#
///
|
|
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace ResultsBrowser.Forms
|
|
{
|
|
public partial class CustomQuerySpecificationForm : Form
|
|
{
|
|
public CQCriteria CQCriteria;
|
|
public string InputList { get { return inputListSB.ToString(); } }
|
|
public int IntParameter { get { return intParameter; } }
|
|
public DateTime From { get { return fromDateTimePicker.Value.Date; } }
|
|
public DateTime To { get { return toDateTimePicker.Value.Date.AddDays(1).AddTicks(-1); } }
|
|
public string DestinationFile
|
|
{
|
|
get
|
|
{
|
|
return String.IsNullOrEmpty(destinationFileTextBox.Text)
|
|
? string.Format("vysledky_hladania_{0:ddMMyyyy_HHmm}.csv", DateTime.Now)
|
|
: destinationFileTextBox.Text;
|
|
}
|
|
}
|
|
|
|
StringBuilder inputListSB;
|
|
int intParameter;
|
|
|
|
public CustomQuerySpecificationForm()
|
|
{
|
|
InitializeComponent();
|
|
|
|
inputListSB = new StringBuilder();
|
|
|
|
queryTypeComboBox.Items.Add(new CQSelectionItem(CQCriteria.ListOfOrders, "Všetky vodomery s číslami objednávok podľa zadaného zoznamu"));
|
|
queryTypeComboBox.Items.Add(new CQSelectionItem(CQCriteria.ListOfPcbNumbers, "Všetky vodomery s číslami PCB podľa zadaného zoznamu"));
|
|
//queryTypeComboBox.Items.Add(new CQSelectionItem(CQCriteria.RangeOfSerialNumbers, "Všetky vodomery so sériovými číslami v zadanom rozsahu"));
|
|
//queryTypeComboBox.Items.Add(new CQSelectionItem(CQCriteria.ListOfSerialNumbers, "Všetky vodomery so sériovými číslami podľa zadaného zoznamu"));
|
|
queryTypeComboBox.Items.Add(new CQSelectionItem(CQCriteria.WZTypeIdAndTimePeriod, "Všetky vodomery so zadaným WZTypeID vyrobené v zadanom časovom období"));
|
|
queryTypeComboBox.Items.Add(new CQSelectionItem(CQCriteria.ProducedWithinTimePeriod, "Všetky vodomery vyrobené v zadanom časovom období"));
|
|
queryTypeComboBox.Items.Add(new CQSelectionItem(CQCriteria.BenchAndBatchNr, "Stanica a číslo dávky"));
|
|
queryTypeComboBox.Text = "Všetky vodomery vyrobené v zadanom časovom období";
|
|
|
|
destinationFileTextBox.Text = string.Format("vysledky_hladania_{0:ddMMyyyy_HHmm}.csv", DateTime.Now);
|
|
}
|
|
|
|
private void queryTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
CQCriteria = CQCriteria.Undefined;
|
|
|
|
/// Determine selected criteria
|
|
foreach (var item in queryTypeComboBox.Items)
|
|
{
|
|
if (item.ToString() == queryTypeComboBox.Text)
|
|
{
|
|
CQCriteria = (item as CQSelectionItem).CQCriteria;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (CQCriteria == CQCriteria.Undefined)
|
|
{
|
|
/// No criteria selected
|
|
inputListGroupBox.Enabled = false;
|
|
return;
|
|
}
|
|
|
|
/// Update UI elements visibility
|
|
inputListGroupBox.Enabled = (CQCriteria == CQCriteria.ListOfOrders) ||
|
|
(CQCriteria == CQCriteria.ListOfPcbNumbers) ||
|
|
(CQCriteria == CQCriteria.ListOfSerialNumbers) ||
|
|
(CQCriteria == CQCriteria.BenchAndBatchNr);
|
|
|
|
timePeriodGroupBox.Enabled = (CQCriteria == CQCriteria.WZTypeIdAndTimePeriod) ||
|
|
(CQCriteria == CQCriteria.ProducedWithinTimePeriod);
|
|
|
|
if (CQCriteria == CQCriteria.WZTypeIdAndTimePeriod)
|
|
{
|
|
parameterGroupBox.Enabled = true;
|
|
parameterNameLabel.Text = "WZ Type ID";
|
|
}
|
|
else if (CQCriteria == CQCriteria.BenchAndBatchNr)
|
|
{
|
|
parameterGroupBox.Enabled = true;
|
|
parameterNameLabel.Text = "wr10=5, wr11=6, wr13=8, wr14=10, wr15=9, wr18=11, wr19=12, wr20=13, wr21=14";
|
|
}
|
|
else
|
|
{
|
|
parameterGroupBox.Enabled = false;
|
|
parameterNameLabel.Text = string.Empty;
|
|
}
|
|
}
|
|
|
|
private void addToListButton_Click(object sender, EventArgs e)
|
|
{
|
|
AddItemForm dlg = new AddItemForm();
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
{
|
|
if (inputListSB.Length != 0)
|
|
{
|
|
inputListSB.Append(",");
|
|
}
|
|
|
|
inputListSB.Append(dlg.ItemText);
|
|
inputListTextBox.Text = inputListSB.ToString();
|
|
}
|
|
}
|
|
|
|
private void importFromFileButton_Click(object sender, EventArgs e)
|
|
{
|
|
MessageBox.Show("Zatiaľ nie je naimplementované");
|
|
}
|
|
|
|
private void clearListButton_Click(object sender, EventArgs e)
|
|
{
|
|
inputListSB.Clear();
|
|
inputListTextBox.Text = String.Empty;
|
|
}
|
|
|
|
private void okButton_Click(object sender, EventArgs e)
|
|
{
|
|
if (parameterGroupBox.Enabled && !int.TryParse(parameterValueTextBox.Text, out intParameter))
|
|
{
|
|
MessageBox.Show("Parameter je neplatný!");
|
|
return;
|
|
}
|
|
|
|
DialogResult = DialogResult.OK;
|
|
Close();
|
|
}
|
|
|
|
private void cancelButton_Click(object sender, EventArgs e)
|
|
{
|
|
DialogResult = DialogResult.Cancel;
|
|
Close();
|
|
}
|
|
|
|
private void destinationFileButton_Click(object sender, EventArgs e)
|
|
{
|
|
SaveFileDialog dlg = new SaveFileDialog { FileName = destinationFileTextBox.Text };
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
{
|
|
destinationFileTextBox.Text = dlg.FileName;
|
|
}
|
|
}
|
|
}
|
|
}
|