148 lines
3.7 KiB
C#
148 lines
3.7 KiB
C#
///
|
|
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.Windows.Forms;
|
|
using log4net;
|
|
using TBF.Resources;
|
|
|
|
#pragma warning disable 162 /// Disables 'Unreachable code detected' warning
|
|
|
|
namespace TBF.BenchControl.DataEntry.Combined
|
|
{
|
|
public partial class CycleBeginningForm : Form, GenericDevices.IHasCompleted
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(CycleBeginningForm));
|
|
|
|
// To be retrieved after the form closes
|
|
public string PurchaseOrder;
|
|
public string[] MainSNText;
|
|
public string[] AuxSNText;
|
|
public bool[] Disabled;
|
|
|
|
// Set to 'true' when the form closes
|
|
public bool Completed { get { return completed; } }
|
|
bool completed;
|
|
|
|
private readonly int cmbndWMsCount;
|
|
|
|
public CycleBeginningForm()
|
|
{
|
|
InitializeComponent();
|
|
|
|
MainSNText = new string[Program.WMsCount / 2];
|
|
AuxSNText = new string[Program.WMsCount / 2];
|
|
completed = false;
|
|
StartForceCloseHandler();
|
|
|
|
cmbndWMsCount = Program.WMsCount / 2;
|
|
|
|
Height = 145 + cmbndWMsCount * 155;
|
|
}
|
|
|
|
private void CycleBeginningForm_Load(object sender, EventArgs e)
|
|
{
|
|
Localize();
|
|
|
|
PrepareOrderCombo(orderComboBox);
|
|
|
|
if (cmbndWMsCount < 1) groupBox1.Visible = false;
|
|
if (cmbndWMsCount < 2) groupBox2.Visible = false;
|
|
if (cmbndWMsCount < 3) groupBox3.Visible = false;
|
|
}
|
|
|
|
void Localize()
|
|
{
|
|
Text = Strings.Data;
|
|
orderGroupBox.Text = Strings.Purchase_Order;
|
|
groupBox1.Text = Strings.Water_Meter + " 1";
|
|
groupBox2.Text = Strings.Water_Meter + " 2";
|
|
groupBox3.Text = Strings.Water_Meter + " 3";
|
|
mainSN1Label.Text = Strings.Main_WM_SerialNr;
|
|
mainSN2Label.Text = Strings.Main_WM_SerialNr;
|
|
mainSN3Label.Text = Strings.Main_WM_SerialNr;
|
|
auxSN1Label.Text = Strings.Aux_WM_SerialNr;
|
|
auxSN2Label.Text = Strings.Aux_WM_SerialNr;
|
|
auxSN3Label.Text = Strings.Aux_WM_SerialNr;
|
|
okButton.Text = Strings.OkBtnText;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Load Purchase order combo box items from the LocalSettings PurchaseOrderHistory array
|
|
/// </summary>
|
|
/// <param name="orderComboBox">Puchase order ComboBox</param>
|
|
void PrepareOrderCombo(ComboBox orderComboBox)
|
|
{
|
|
for (int i = 0; i < Program.LocalSettings.PurchaseOrderHistoryCount; i++)
|
|
{
|
|
orderComboBox.Items.Add(Program.LocalSettings.PurchaseOrderHistory[i]);
|
|
}
|
|
|
|
if (orderComboBox.Items.Count > 0)
|
|
{
|
|
orderComboBox.Text = orderComboBox.Items[0].ToString();
|
|
}
|
|
}
|
|
|
|
private void okButton_Click(object sender, EventArgs e)
|
|
{
|
|
PurchaseOrder = orderComboBox.Text;
|
|
Program.LocalSettings.UpdateHistory(orderComboBox.Text,
|
|
ref Program.LocalSettings.PurchaseOrderHistory
|
|
#if FUZHOU150 || FUZHOU300
|
|
, 20
|
|
#endif
|
|
);
|
|
|
|
if (cmbndWMsCount >= 1)
|
|
{
|
|
MainSNText[0] = mainSN1TextBox.Text;
|
|
AuxSNText[0] = auxSN1TextBox.Text;
|
|
Disabled[0] = !checkBox1.Checked;
|
|
}
|
|
|
|
if (cmbndWMsCount >= 2)
|
|
{
|
|
MainSNText[1] = mainSN2TextBox.Text;
|
|
AuxSNText[1] = auxSN2TextBox.Text;
|
|
Disabled[1] = !checkBox2.Checked;
|
|
}
|
|
|
|
if (cmbndWMsCount >= 3)
|
|
{
|
|
MainSNText[2] = mainSN3TextBox.Text;
|
|
AuxSNText[2] = auxSN3TextBox.Text;
|
|
Disabled[2] = !checkBox3.Checked;
|
|
}
|
|
|
|
completed = true;
|
|
Close();
|
|
}
|
|
|
|
private void clearButton_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
#region Forced close handling
|
|
|
|
public void StartForceCloseHandler()
|
|
{
|
|
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
|
|
{
|
|
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
|
|
else OnForceClose(sender, args);
|
|
};
|
|
}
|
|
|
|
void OnForceClose(object sender, EventArgs args)
|
|
{
|
|
DialogResult = DialogResult.Cancel;
|
|
Close();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|