/// /// Copyright (c) 2016-2022 Sensus Slovensko a.s. /// using System; using System.Windows.Forms; using Common; using TBF.Resources; namespace TBF.UI.ResultsMI { 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; 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 = StarTime.ToString(Constants.DateTimeFormat); endTimeLabel.Text = EndTime.ToString(Constants.DateTimeFormat); 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_IPERL_NEW || TURA_SPECIAL else if (mode == PreviousResultsMode.Fix) { /// Access only to thise who manage production tracing GID[] rqrdGroupMembership = new GID[] { GID.TraceabilityManagement }; if ((new SharedDatabase.Forms.LoginDlg(CurrentUser.UserName(), rqrdGroupMembership, parent)).ShowDialog() != DialogResult.OK) { return; } Program.MainWnd.UpdateUser(); parent.OnReloadAndFix(this, new PreviousResultIdEventArgs(BatchNr)); } #endif } } }