/// /// 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 bool reloadEn; public int BatchNr; public DateTime StarTime; public DateTime EndTime; 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 proc, string pOrd, int passCnt, int failCnt, bool sent, bool reloadEn) : this() { this.parent = parent; this.reloadEn = reloadEn; BatchNr = bnr; StarTime = s; EndTime = e; 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()); procedureLabel.Text = ProcedureName; purchaseOrderLabel.Text = string.Format("{0}: {1}", Strings.PO, PurchaseOrder); passedCountLabel.Text = string.Format("{0}: {1}", Strings.Passed, PassedCount); failedCountLabel.Text = string.Format("{0}: {1}", Strings.Failed, FailedCount); #if MUNICH sentCheckBox.Text = Strings.Printed; sentCheckBox.Checked = Sent; sendReloadButton.Enabled = true; /// 'Print again' function always available sendReloadButton.Text = reloadEn ? Strings.Restore : Strings.Print_again; #elif ORACLE_DB sentCheckBox.Text = Strings.Sent; sentCheckBox.Checked = Sent; sendReloadButton.Enabled = reloadEn || !Sent; sendReloadButton.Text = reloadEn ? Strings.Restore : Strings.Save_again; #else sentCheckBox.Visible = false; sendReloadButton.Enabled = reloadEn; sendReloadButton.Visible = reloadEn; sendReloadButton.Text = Strings.Restore; #endif showButton.Text = Strings.Show; } 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 sendReloadButton_Click(object sender, EventArgs e) { if (reloadEn) parent.OnReload(this, new PreviousResultIdEventArgs(BatchNr)); else parent.OnSendAgain(this, new PreviousResultIdEventArgs(BatchNr)); } private void showButton_Click(object sender, EventArgs e) { parent.OnShowResults(this, new PreviousResultIdEventArgs(BatchNr)); } } }