diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index a56bd9083..6ca6000a7 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.26.1573.0")] -[assembly: AssemblyFileVersion("2.26.1573.0")] +[assembly: AssemblyVersion("2.26.1577.0")] +[assembly: AssemblyFileVersion("2.26.1577.0")] diff --git a/TBF/UI/Constants.cs b/TBF/UI/Constants.cs index a55f4518a..2b983a4ad 100644 --- a/TBF/UI/Constants.cs +++ b/TBF/UI/Constants.cs @@ -7,6 +7,6 @@ namespace TBF.UI public const int Dpi100pct = 96; public const string DateFormat = "dd.MM.yyyy"; public const string DateTimeFormat = "dd.MM.yyyy HH:mm"; - public static readonly DateTime MinDate = new DateTime(1753, 1, 1); + public static readonly DateTime MinDate = new DateTime(2016, 1, 1); } } diff --git a/TBF/UI/Procedures/ProcedureDlg.Designer.cs b/TBF/UI/Procedures/ProcedureDlg.Designer.cs index c95710e2b..672f48e06 100644 --- a/TBF/UI/Procedures/ProcedureDlg.Designer.cs +++ b/TBF/UI/Procedures/ProcedureDlg.Designer.cs @@ -452,6 +452,7 @@ namespace TBF.UI.Procedures this.historyListViewEx.Name = "historyListViewEx"; this.historyListViewEx.UseCompatibleStateImageBehavior = false; this.historyListViewEx.View = System.Windows.Forms.View.Details; + this.historyListViewEx.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.historyListViewEx_MouseDoubleClick); // // metrology1TabPage // diff --git a/TBF/UI/Procedures/ProcedureDlg.cs b/TBF/UI/Procedures/ProcedureDlg.cs index b5ddf86d1..8969a5016 100644 --- a/TBF/UI/Procedures/ProcedureDlg.cs +++ b/TBF/UI/Procedures/ProcedureDlg.cs @@ -20,12 +20,19 @@ namespace TBF.UI.Procedures { public partial class ProcedureDlg : Form, IParentOfListViewEx { + public enum Mode + { + Unlocked, + Locked, + PermanentlyLocked, + } + static readonly ILog log = LogManager.GetLogger(typeof(ProcedureDlg)); /// Used when re-scaling the dialog: 100% = 96dpi, 125% = 120dpi, 150% = 144dpi public readonly int Dpi; - readonly bool openUnlocked; + readonly Mode initialMode; /// /// Procedure to be updated by this dialog. @@ -61,7 +68,7 @@ namespace TBF.UI.Procedures { /// Detect display setting: 100% = 96dpi, 125% = 120dpi, 150% = 144dpi. Dpi = (int)this.CreateGraphics().DpiX; - openUnlocked = false; + initialMode = Mode.Locked; InitializeComponent(); @@ -111,14 +118,14 @@ namespace TBF.UI.Procedures SelectedTestIx = -1; } - public ProcedureDlg(Config.Entities.Procedure procedure, IList usedNames, bool openUnlocked = false) + public ProcedureDlg(Config.Entities.Procedure procedure, IList usedNames, Mode initialMode) : this() { if (procedure == null) throw new ArgumentNullException("procedure"); LoadedProcedure = procedure; this.usedNames = usedNames; - this.openUnlocked = openUnlocked; + this.initialMode = initialMode; #if KEMPNO_50 || KRAKOW_50 sharedButtons.RequiredGroupMembership = procedure.Protected ? new Users.Entities.GID[] { Users.Entities.GID.WaterMeterAuthority } @@ -127,6 +134,8 @@ namespace TBF.UI.Procedures sharedButtons.RequiredGroupMembership = procedure.Protected ? new Users.Entities.GID[] { Users.Entities.GID.Metrologists } : new Users.Entities.GID[] { Users.Entities.GID.TestingSpecialists, Users.Entities.GID.Metrologists }; #endif + if (initialMode == Mode.PermanentlyLocked) sharedButtons.DisableUnlock(); + using (NHibernate.ISession session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config)) { /// @@ -406,7 +415,7 @@ namespace TBF.UI.Procedures } /// Optionally unlock this dialog - if (openUnlocked) + if (initialMode == Mode.Unlocked) { sharedButtons.UnlockButtons(); Unlocked(sender, e); @@ -696,6 +705,7 @@ namespace TBF.UI.Procedures { found = true; ListViewItem item = new ListViewItem(p.Name); + item.Tag = p; item.SubItems.Add(p.Revision.ToString()); item.SubItems.Add(p.LastChgTime.ToString()); item.SubItems.Add(p.LastChgUser.ToString()); @@ -2832,5 +2842,16 @@ namespace TBF.UI.Procedures } } } + + private void historyListViewEx_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (historyListViewEx.SelectedIndices.Count != 1) return; + ListViewItem lvi = historyListViewEx.SelectedItems[0]; + + if (lvi.Tag is Procedure) + { + (new ProcedureDlg(lvi.Tag as Procedure, new List(), ProcedureDlg.Mode.PermanentlyLocked)).ShowDialog(); + } + } } } diff --git a/TBF/UI/Procedures/ProcedureDlg.resx b/TBF/UI/Procedures/ProcedureDlg.resx index e91b08900..b16100da7 100644 --- a/TBF/UI/Procedures/ProcedureDlg.resx +++ b/TBF/UI/Procedures/ProcedureDlg.resx @@ -1363,7 +1363,7 @@ historyListViewEx - Results.Forms.ListViewEx, Results, Version=2.26.1458.0, Culture=neutral, PublicKeyToken=null + Results.Forms.ListViewEx, Results, Version=2.26.1560.0, Culture=neutral, PublicKeyToken=null historyTabPage @@ -1414,7 +1414,7 @@ metrology1ListViewEx - Results.Forms.ListViewEx, Results, Version=2.26.1458.0, Culture=neutral, PublicKeyToken=null + Results.Forms.ListViewEx, Results, Version=2.26.1560.0, Culture=neutral, PublicKeyToken=null metrology1TabPage @@ -1465,7 +1465,7 @@ metrology2ListViewEx - Results.Forms.ListViewEx, Results, Version=2.26.1458.0, Culture=neutral, PublicKeyToken=null + Results.Forms.ListViewEx, Results, Version=2.26.1560.0, Culture=neutral, PublicKeyToken=null metrology2TabPage @@ -1516,7 +1516,7 @@ processListViewEx - Results.Forms.ListViewEx, Results, Version=2.26.1458.0, Culture=neutral, PublicKeyToken=null + Results.Forms.ListViewEx, Results, Version=2.26.1560.0, Culture=neutral, PublicKeyToken=null processTabPage @@ -1567,7 +1567,7 @@ parametersListViewEx - Results.Forms.ListViewEx, Results, Version=2.26.1458.0, Culture=neutral, PublicKeyToken=null + Results.Forms.ListViewEx, Results, Version=2.26.1560.0, Culture=neutral, PublicKeyToken=null parametersTabPage @@ -1651,7 +1651,7 @@ sharedButtons - TBF.UI.Shared.SharedButtons, TBF, Version=2.26.1537.0, Culture=neutral, PublicKeyToken=null + TBF.UI.Shared.SharedButtons, TBF, Version=2.26.1574.0, Culture=neutral, PublicKeyToken=null mainSplitContainer.Panel2 diff --git a/TBF/UI/Procedures/ProceduresCtrl.cs b/TBF/UI/Procedures/ProceduresCtrl.cs index 38dbf921d..4a7cec941 100644 --- a/TBF/UI/Procedures/ProceduresCtrl.cs +++ b/TBF/UI/Procedures/ProceduresCtrl.cs @@ -303,7 +303,7 @@ namespace TBF.UI.Procedures newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName; newProcedure.CreationTime = DateTime.Now; - if (new ProcedureDlg(newProcedure, GetUsedNames(false), true).ShowDialog() == DialogResult.OK) + if (new ProcedureDlg(newProcedure, GetUsedNames(false), ProcedureDlg.Mode.Unlocked).ShowDialog() == DialogResult.OK) { /// TODO: Make name uniqueness test parent.Unlock(); @@ -538,7 +538,7 @@ namespace TBF.UI.Procedures IList usedNames = GetUsedNames(false); usedNames.Remove(originalProcedure.Name.ToLower()); /// Allow original procedure name /// - if (new ProcedureDlg(modifiedProcedure, usedNames).ShowDialog() == DialogResult.OK) + if (new ProcedureDlg(modifiedProcedure, usedNames, ProcedureDlg.Mode.Locked).ShowDialog() == DialogResult.OK) { parent.Unlock(); @@ -591,7 +591,7 @@ namespace TBF.UI.Procedures newProcedure.CreationTime = DateTime.Now; newProcedure.Protected = false; - if ((new ProcedureDlg(newProcedure, GetUsedNames(false), true)).ShowDialog() == DialogResult.OK) + if ((new ProcedureDlg(newProcedure, GetUsedNames(false), ProcedureDlg.Mode.Unlocked)).ShowDialog() == DialogResult.OK) { /// TODO: Make name uniqueness test parent.Unlock(); @@ -644,7 +644,7 @@ namespace TBF.UI.Procedures newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName; newProcedure.CreationTime = DateTime.Now; - if ((new ProcedureDlg(newProcedure, GetUsedNames(false), true)).ShowDialog() == DialogResult.OK) + if ((new ProcedureDlg(newProcedure, GetUsedNames(false), ProcedureDlg.Mode.Unlocked)).ShowDialog() == DialogResult.OK) { /// TODO: Make name uniqueness test parent.Unlock(); @@ -862,7 +862,7 @@ namespace TBF.UI.Procedures newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName; newProcedure.CreationTime = DateTime.Now; - if (new ProcedureDlg(newProcedure, GetUsedNames(false), true).ShowDialog() == DialogResult.OK) + if (new ProcedureDlg(newProcedure, GetUsedNames(false), ProcedureDlg.Mode.Unlocked).ShowDialog() == DialogResult.OK) { /// TODO: Make name uniqueness test parent.Unlock(); diff --git a/TBF/UI/ResultsMI/PreviousResultsDlg.Designer.cs b/TBF/UI/ResultsMI/PreviousResultsDlg.Designer.cs index 11ce8e166..914ec1c64 100644 --- a/TBF/UI/ResultsMI/PreviousResultsDlg.Designer.cs +++ b/TBF/UI/ResultsMI/PreviousResultsDlg.Designer.cs @@ -32,21 +32,42 @@ this.closeButton = new System.Windows.Forms.Button(); this.previousButton = new System.Windows.Forms.Button(); this.nextButton = new System.Windows.Forms.Button(); + this.vertSplitContainer = new System.Windows.Forms.SplitContainer(); + this.horizSplitContainer = new System.Windows.Forms.SplitContainer(); + this.filterGroupBox = new System.Windows.Forms.GroupBox(); + this.procedureTextBox = new System.Windows.Forms.TextBox(); + this.procedureLabel = new System.Windows.Forms.Label(); + this.toLabel = new System.Windows.Forms.Label(); + this.fromLabel = new System.Windows.Forms.Label(); + this.toDateTimePicker = new System.Windows.Forms.DateTimePicker(); + this.fromDateTimePicker = new System.Windows.Forms.DateTimePicker(); + this.reloadButton = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.vertSplitContainer)).BeginInit(); + this.vertSplitContainer.Panel1.SuspendLayout(); + this.vertSplitContainer.Panel2.SuspendLayout(); + this.vertSplitContainer.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.horizSplitContainer)).BeginInit(); + this.horizSplitContainer.Panel1.SuspendLayout(); + this.horizSplitContainer.Panel2.SuspendLayout(); + this.horizSplitContainer.SuspendLayout(); + this.filterGroupBox.SuspendLayout(); this.SuspendLayout(); // // flowLayoutPanel1 // this.flowLayoutPanel1.AutoScroll = true; + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(1073, 897); + this.flowLayoutPanel1.Size = new System.Drawing.Size(1060, 828); this.flowLayoutPanel1.TabIndex = 0; // // closeButton // + this.closeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.closeButton.Location = new System.Drawing.Point(1079, 12); + this.closeButton.Location = new System.Drawing.Point(12, 25); this.closeButton.Name = "closeButton"; this.closeButton.Size = new System.Drawing.Size(103, 37); this.closeButton.TabIndex = 1; @@ -56,7 +77,8 @@ // // previousButton // - this.previousButton.Location = new System.Drawing.Point(1079, 82); + this.previousButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.previousButton.Location = new System.Drawing.Point(12, 95); this.previousButton.Name = "previousButton"; this.previousButton.Size = new System.Drawing.Size(103, 37); this.previousButton.TabIndex = 2; @@ -66,7 +88,8 @@ // // nextButton // - this.nextButton.Location = new System.Drawing.Point(1079, 125); + this.nextButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.nextButton.Location = new System.Drawing.Point(12, 138); this.nextButton.Name = "nextButton"; this.nextButton.Size = new System.Drawing.Size(103, 37); this.nextButton.TabIndex = 3; @@ -74,22 +97,148 @@ this.nextButton.UseVisualStyleBackColor = true; this.nextButton.Click += new System.EventHandler(this.nextButton_Click); // + // vertSplitContainer + // + this.vertSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.vertSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; + this.vertSplitContainer.IsSplitterFixed = true; + this.vertSplitContainer.Location = new System.Drawing.Point(0, 0); + this.vertSplitContainer.Name = "vertSplitContainer"; + // + // vertSplitContainer.Panel1 + // + this.vertSplitContainer.Panel1.Controls.Add(this.horizSplitContainer); + // + // vertSplitContainer.Panel2 + // + this.vertSplitContainer.Panel2.Controls.Add(this.closeButton); + this.vertSplitContainer.Panel2.Controls.Add(this.nextButton); + this.vertSplitContainer.Panel2.Controls.Add(this.previousButton); + this.vertSplitContainer.Size = new System.Drawing.Size(1194, 892); + this.vertSplitContainer.SplitterDistance = 1060; + this.vertSplitContainer.TabIndex = 4; + // + // horizSplitContainer + // + this.horizSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.horizSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + this.horizSplitContainer.Location = new System.Drawing.Point(0, 0); + this.horizSplitContainer.Name = "horizSplitContainer"; + this.horizSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // horizSplitContainer.Panel1 + // + this.horizSplitContainer.Panel1.Controls.Add(this.filterGroupBox); + // + // horizSplitContainer.Panel2 + // + this.horizSplitContainer.Panel2.Controls.Add(this.flowLayoutPanel1); + this.horizSplitContainer.Size = new System.Drawing.Size(1060, 892); + this.horizSplitContainer.SplitterDistance = 60; + this.horizSplitContainer.TabIndex = 0; + // + // filterGroupBox + // + this.filterGroupBox.Controls.Add(this.reloadButton); + this.filterGroupBox.Controls.Add(this.procedureTextBox); + this.filterGroupBox.Controls.Add(this.procedureLabel); + this.filterGroupBox.Controls.Add(this.toLabel); + this.filterGroupBox.Controls.Add(this.fromLabel); + this.filterGroupBox.Controls.Add(this.toDateTimePicker); + this.filterGroupBox.Controls.Add(this.fromDateTimePicker); + this.filterGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.filterGroupBox.Location = new System.Drawing.Point(0, 0); + this.filterGroupBox.Name = "filterGroupBox"; + this.filterGroupBox.Size = new System.Drawing.Size(1060, 60); + this.filterGroupBox.TabIndex = 0; + this.filterGroupBox.TabStop = false; + this.filterGroupBox.Text = "Filter"; + // + // procedureTextBox + // + this.procedureTextBox.Location = new System.Drawing.Point(460, 25); + this.procedureTextBox.Name = "procedureTextBox"; + this.procedureTextBox.Size = new System.Drawing.Size(523, 20); + this.procedureTextBox.TabIndex = 22; + // + // procedureLabel + // + this.procedureLabel.AutoSize = true; + this.procedureLabel.Location = new System.Drawing.Point(378, 30); + this.procedureLabel.Name = "procedureLabel"; + this.procedureLabel.Size = new System.Drawing.Size(56, 13); + this.procedureLabel.TabIndex = 21; + this.procedureLabel.Text = "Procedure"; + // + // toLabel + // + this.toLabel.AutoSize = true; + this.toLabel.Location = new System.Drawing.Point(216, 31); + this.toLabel.Name = "toLabel"; + this.toLabel.Size = new System.Drawing.Size(16, 13); + this.toLabel.TabIndex = 20; + this.toLabel.Text = "to"; + // + // fromLabel + // + this.fromLabel.AutoSize = true; + this.fromLabel.Location = new System.Drawing.Point(44, 31); + this.fromLabel.Name = "fromLabel"; + this.fromLabel.Size = new System.Drawing.Size(27, 13); + this.fromLabel.TabIndex = 19; + this.fromLabel.Text = "from"; + // + // toDateTimePicker + // + this.toDateTimePicker.CustomFormat = "dd.MM.yyyy"; + this.toDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.toDateTimePicker.Location = new System.Drawing.Point(252, 25); + this.toDateTimePicker.Name = "toDateTimePicker"; + this.toDateTimePicker.Size = new System.Drawing.Size(82, 20); + this.toDateTimePicker.TabIndex = 18; + // + // fromDateTimePicker + // + this.fromDateTimePicker.CustomFormat = "dd.MM.yyyy"; + this.fromDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.fromDateTimePicker.Location = new System.Drawing.Point(89, 25); + this.fromDateTimePicker.Name = "fromDateTimePicker"; + this.fromDateTimePicker.Size = new System.Drawing.Size(82, 20); + this.fromDateTimePicker.TabIndex = 17; + // + // reloadButton + // + this.reloadButton.Location = new System.Drawing.Point(1005, 23); + this.reloadButton.Name = "reloadButton"; + this.reloadButton.Size = new System.Drawing.Size(37, 23); + this.reloadButton.TabIndex = 0; + this.reloadButton.Text = "@"; + this.reloadButton.UseVisualStyleBackColor = true; + this.reloadButton.Click += new System.EventHandler(this.reloadButton_Click); + // // PreviousResultsDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.closeButton; this.ClientSize = new System.Drawing.Size(1194, 892); - this.Controls.Add(this.nextButton); - this.Controls.Add(this.previousButton); - this.Controls.Add(this.closeButton); - this.Controls.Add(this.flowLayoutPanel1); + this.Controls.Add(this.vertSplitContainer); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.Name = "PreviousResultsDlg"; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.Text = "Previous results"; this.Load += new System.EventHandler(this.PreviousResultsDlg_Load); + this.vertSplitContainer.Panel1.ResumeLayout(false); + this.vertSplitContainer.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.vertSplitContainer)).EndInit(); + this.vertSplitContainer.ResumeLayout(false); + this.horizSplitContainer.Panel1.ResumeLayout(false); + this.horizSplitContainer.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.horizSplitContainer)).EndInit(); + this.horizSplitContainer.ResumeLayout(false); + this.filterGroupBox.ResumeLayout(false); + this.filterGroupBox.PerformLayout(); this.ResumeLayout(false); } @@ -100,5 +249,15 @@ private System.Windows.Forms.Button closeButton; private System.Windows.Forms.Button previousButton; private System.Windows.Forms.Button nextButton; + private System.Windows.Forms.SplitContainer vertSplitContainer; + private System.Windows.Forms.SplitContainer horizSplitContainer; + private System.Windows.Forms.GroupBox filterGroupBox; + private System.Windows.Forms.Label toLabel; + private System.Windows.Forms.Label fromLabel; + private System.Windows.Forms.DateTimePicker toDateTimePicker; + private System.Windows.Forms.DateTimePicker fromDateTimePicker; + private System.Windows.Forms.Label procedureLabel; + private System.Windows.Forms.TextBox procedureTextBox; + private System.Windows.Forms.Button reloadButton; } } \ No newline at end of file diff --git a/TBF/UI/ResultsMI/PreviousResultsDlg.cs b/TBF/UI/ResultsMI/PreviousResultsDlg.cs index 8ab33ce97..5883c050a 100644 --- a/TBF/UI/ResultsMI/PreviousResultsDlg.cs +++ b/TBF/UI/ResultsMI/PreviousResultsDlg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2016-2017 Sensus Slovensko a.s. +/// Copyright (c) 2016-2021 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -9,8 +9,8 @@ using log4net; using Oracle.DataAccess.Client; using Results; using Results.Entities; -using TBF.Resources; using TBF.BenchControl.Output.DB.SensusOracle; +using TBF.Resources; namespace TBF.UI.ResultsMI { @@ -27,9 +27,11 @@ namespace TBF.UI.ResultsMI ISession session; int currentBatchNr; - int lastDisplayedBatchNr; - const int LinesCount = 25; - IList batches; + + IList batches; /// A list of batches selected from all batches using criteria from/to date and procedure name + int lastDisplayedIx; /// Index of the last displayed batch from the list 'batches' + const int LinesCount = 25; /// Number of batches displayed on one screen + PreviousResultsMode mode; @@ -62,11 +64,31 @@ namespace TBF.UI.ResultsMI { Localize(); - session = DB.CreateSession(); + fromDateTimePicker.MinDate = Constants.MinDate; + fromDateTimePicker.MaxDate = DateTime.Today; + fromDateTimePicker.Value = Constants.MinDate; + fromDateTimePicker.CustomFormat = Constants.DateFormat; + fromDateTimePicker.ShowUpDown = true; - lastDisplayedBatchNr = currentBatchNr - 1; - DrawBatches(lastDisplayedBatchNr - LinesCount + 1, lastDisplayedBatchNr); + toDateTimePicker.MinDate = Constants.MinDate; + toDateTimePicker.MaxDate = DateTime.Today; + toDateTimePicker.Value = DateTime.Today; + toDateTimePicker.CustomFormat = Constants.DateFormat; + toDateTimePicker.ShowUpDown = true; + + try + { + session = DB.CreateSession(); + } + catch (Exception exc) + { + session = null; + log.ErrorFormat("Opening Results DB failed: {0}", exc.Message); + } + + var batches = GetFilteredBatches(); UpdateButtons(); + Redraw(); } void Localize() @@ -75,10 +97,44 @@ namespace TBF.UI.ResultsMI closeButton.Text = TBF.Resources.Strings.CloseBtnText; previousButton.Text = TBF.Resources.Strings.Previous; nextButton.Text = TBF.Resources.Strings.Next; + fromLabel.Text = Strings.from; + toLabel.Text = Strings.to; + procedureLabel.Text = Strings.Procedure; } + IList GetFilteredBatches() + { + try + { + if (string.IsNullOrEmpty(procedureTextBox.Text)) + { + batches = session.QueryOver() + .Where(x => (x.StartTime >= fromDateTimePicker.Value)) + .And(x => (x.StartTime <= toDateTimePicker.Value.AddDays(1))) + .OrderBy(x => x.BatchNr).Asc + .List(); + } + else + { + batches = session.QueryOver() + .Where(x => (x.ProcedureName == procedureTextBox.Text)) + .And(x => (x.StartTime >= fromDateTimePicker.Value)) + .And(x => (x.StartTime <= toDateTimePicker.Value.AddDays(1))) + .OrderBy(x => x.BatchNr).Asc + .List(); + } + } + catch (Exception exc) + { + batches = new List(); + log.ErrorFormat("Reading batches from Results DB failed: {0}", exc.Message); + } + + lastDisplayedIx = batches.Count - 1; + + return batches; + } - public void OnReload(object sender, PreviousResultIdEventArgs data) { foreach (var batch in batches) @@ -318,10 +374,11 @@ namespace TBF.UI.ResultsMI if (batches == null || batches.Count == 0) return; - foreach (var b in batches) - { + for (int i = Math.Max(0, lastDisplayedIx - LinesCount + 1); i <= lastDisplayedIx; i++) + { + var b = batches[i]; int passedCount = 0; - int failedCount = 0; + int failedCount = 0; foreach (var wm in b.WaterMeters) { if ((wm != null) && wm.Passed) { passedCount++; } else { failedCount++; } @@ -340,7 +397,7 @@ namespace TBF.UI.ResultsMI failedCount, b.RsltsSent, mode)); - } + } ResumeLayout(); } @@ -354,22 +411,29 @@ namespace TBF.UI.ResultsMI private void previousButton_Click(object sender, EventArgs e) { - lastDisplayedBatchNr = Math.Max(lastDisplayedBatchNr - LinesCount, LinesCount); - DrawBatches(lastDisplayedBatchNr - LinesCount + 1, lastDisplayedBatchNr); + lastDisplayedIx = Math.Max(lastDisplayedIx - LinesCount, LinesCount - 1); + Redraw(); UpdateButtons(); } private void nextButton_Click(object sender, EventArgs e) { - lastDisplayedBatchNr = Math.Min(lastDisplayedBatchNr + LinesCount, currentBatchNr - 1); - DrawBatches(lastDisplayedBatchNr - LinesCount + 1, lastDisplayedBatchNr); + lastDisplayedIx = Math.Min(lastDisplayedIx + LinesCount, batches.Count - 1); + Redraw(); UpdateButtons(); } private void UpdateButtons() { - nextButton.Enabled = (lastDisplayedBatchNr < currentBatchNr - 1); - previousButton.Enabled = (lastDisplayedBatchNr > LinesCount); + nextButton.Enabled = (lastDisplayedIx < batches.Count - 1); + previousButton.Enabled = (lastDisplayedIx > LinesCount - 1); + } + + private void reloadButton_Click(object sender, EventArgs e) + { + batches = GetFilteredBatches(); + UpdateButtons(); + Redraw(); } } } diff --git a/TBF/UI/Shared/SharedButtons.cs b/TBF/UI/Shared/SharedButtons.cs index c1c5356d2..75e06ca5e 100644 --- a/TBF/UI/Shared/SharedButtons.cs +++ b/TBF/UI/Shared/SharedButtons.cs @@ -164,6 +164,10 @@ namespace TBF.UI.Shared } } + public void DisableUnlock() + { + unlockButton.Enabled = false; + } /// /// Update the visibility of buttons and OK button text when the dialog is unlocked