122 lines
4.0 KiB
C#
122 lines
4.0 KiB
C#
///
|
|
/// Copyright (c) 2016-2017 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.Windows.Forms;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.Forms
|
|
{
|
|
public partial class PreviousResultCtrl : UserControl
|
|
{
|
|
readonly PreviousResultsDlg parent;
|
|
readonly PreviousResultsMode mode;
|
|
|
|
public int BatchNr;
|
|
public DateTime StarTime;
|
|
public DateTime EndTime;
|
|
public string Ver;
|
|
public string ProcedureName;
|
|
public string PurchaseOrder;
|
|
public int PassedCount;
|
|
public int FailedCount;
|
|
public bool Sent;
|
|
|
|
protected PreviousResultCtrl()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public PreviousResultCtrl(PreviousResultsDlg parent, int bnr, DateTime s, DateTime e, string ver, string proc, string pOrd, int passCnt, int failCnt, bool sent, PreviousResultsMode mode)
|
|
: this()
|
|
{
|
|
this.parent = parent;
|
|
this.mode = mode;
|
|
|
|
BatchNr = bnr;
|
|
StarTime = s;
|
|
EndTime = e;
|
|
Ver = ver;
|
|
ProcedureName = proc;
|
|
PurchaseOrder = pOrd;
|
|
PassedCount = passCnt;
|
|
FailedCount = failCnt;
|
|
Sent = sent;
|
|
|
|
batchNrLabel.Text = BatchNr.ToString();
|
|
startTimeLabel.Text = string.Format("{0} {1}", StarTime.ToShortDateString(), StarTime.ToShortTimeString());
|
|
endTimeLabel.Text = string.Format("{0} {1}", EndTime.ToShortDateString(), EndTime.ToShortTimeString());
|
|
swVerLabel.Text = Ver;
|
|
procedureLabel.Text = ProcedureName;
|
|
purchaseOrderLabel.Text = PurchaseOrder;
|
|
passedCountLabel.Text = string.Format("{0}: {1}", Strings.Passed, PassedCount);
|
|
failedCountLabel.Text = string.Format("{0}: {1}", Strings.Failed, FailedCount);
|
|
|
|
switch (mode)
|
|
{
|
|
case PreviousResultsMode.Show: sendReloadButton.Text = Strings.Save_again; break;
|
|
case PreviousResultsMode.Reload: sendReloadButton.Text = Strings.Restore; break;
|
|
case PreviousResultsMode.Fix: sendReloadButton.Text = Strings.Fix; break;
|
|
}
|
|
showButton.Text = Strings.Show;
|
|
#if MUNICH
|
|
if (mode == PreviousResultsMode.Show) sendReloadButton.Text = Strings.Print_again;
|
|
sentCheckBox.Text = Strings.Printed;
|
|
sentCheckBox.Checked = Sent;
|
|
sendReloadButton.Enabled = true; /// 'Print again' function always available
|
|
#elif ORACLE_DB
|
|
sentCheckBox.Text = Strings.Sent;
|
|
sentCheckBox.Checked = Sent;
|
|
sendReloadButton.Enabled = (mode != PreviousResultsMode.Show) || !Sent;
|
|
#else
|
|
sentCheckBox.Visible = false;
|
|
sendReloadButton.Enabled = (mode != PreviousResultsMode.Show);
|
|
sendReloadButton.Visible = (mode != PreviousResultsMode.Show);
|
|
#endif
|
|
}
|
|
|
|
public void UpdateSentState(bool sent)
|
|
{
|
|
this.Sent = sent;
|
|
#if MUNICH
|
|
sentCheckBox.Checked = sent;
|
|
sendReloadButton.Enabled = true;
|
|
#elif ORACLE_DB
|
|
sentCheckBox.Checked = sent;
|
|
sendReloadButton.Enabled = !sent;
|
|
#endif
|
|
}
|
|
|
|
private void showButton_Click(object sender, EventArgs e)
|
|
{
|
|
parent.OnShowResults(this, new PreviousResultIdEventArgs(BatchNr));
|
|
}
|
|
|
|
private void sendReloadButton_MouseClick(object sender, MouseEventArgs e)
|
|
{
|
|
if (mode == PreviousResultsMode.Show)
|
|
{
|
|
parent.OnSendAgain(this, new PreviousResultIdEventArgs(BatchNr));
|
|
}
|
|
else if (mode == PreviousResultsMode.Reload)
|
|
{
|
|
parent.OnReload(this, new PreviousResultIdEventArgs(BatchNr));
|
|
}
|
|
#if TURA_IPERL || TURA_SPECIAL
|
|
else if (mode == PreviousResultsMode.Fix)
|
|
{
|
|
/// Access only to thise who manage production tracing
|
|
Users.Grp.GID[] rqrdGroupMembership = new Users.Grp.GID[] { Users.Grp.GID.TraceabilityManagement };
|
|
|
|
if ((new Users.Forms.LoginDlg(Users.GlobalData.CurrentUser.UserName, rqrdGroupMembership)).ShowDialog() != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
|
|
parent.OnReloadAndFix(this, new PreviousResultIdEventArgs(BatchNr));
|
|
}
|
|
#endif
|
|
}
|
|
}
|
|
}
|