(1) PreviousResultsDlg with filters, (2) Procedure history can be inspected.

This commit is contained in:
Milan Hanajik
2021-01-19 09:28:05 +01:00
parent 34f8bb226f
commit 1fb76a2167
8 changed files with 293 additions and 44 deletions
+1 -1
View File
@@ -7,6 +7,6 @@ namespace TBF.UI
public const int Dpi100pct = 96; public const int Dpi100pct = 96;
public const string DateFormat = "dd.MM.yyyy"; public const string DateFormat = "dd.MM.yyyy";
public const string DateTimeFormat = "dd.MM.yyyy HH:mm"; 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);
} }
} }
+1
View File
@@ -452,6 +452,7 @@ namespace TBF.UI.Procedures
this.historyListViewEx.Name = "historyListViewEx"; this.historyListViewEx.Name = "historyListViewEx";
this.historyListViewEx.UseCompatibleStateImageBehavior = false; this.historyListViewEx.UseCompatibleStateImageBehavior = false;
this.historyListViewEx.View = System.Windows.Forms.View.Details; this.historyListViewEx.View = System.Windows.Forms.View.Details;
this.historyListViewEx.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.historyListViewEx_MouseDoubleClick);
// //
// metrology1TabPage // metrology1TabPage
// //
+26 -5
View File
@@ -20,12 +20,19 @@ namespace TBF.UI.Procedures
{ {
public partial class ProcedureDlg : Form, IParentOfListViewEx public partial class ProcedureDlg : Form, IParentOfListViewEx
{ {
public enum Mode
{
Unlocked,
Locked,
PermanentlyLocked,
}
static readonly ILog log = LogManager.GetLogger(typeof(ProcedureDlg)); static readonly ILog log = LogManager.GetLogger(typeof(ProcedureDlg));
/// Used when re-scaling the dialog: 100% = 96dpi, 125% = 120dpi, 150% = 144dpi /// Used when re-scaling the dialog: 100% = 96dpi, 125% = 120dpi, 150% = 144dpi
public readonly int Dpi; public readonly int Dpi;
readonly bool openUnlocked; readonly Mode initialMode;
/// <summary> /// <summary>
/// Procedure to be updated by this dialog. /// Procedure to be updated by this dialog.
@@ -61,7 +68,7 @@ namespace TBF.UI.Procedures
{ {
/// Detect display setting: 100% = 96dpi, 125% = 120dpi, 150% = 144dpi. /// Detect display setting: 100% = 96dpi, 125% = 120dpi, 150% = 144dpi.
Dpi = (int)this.CreateGraphics().DpiX; Dpi = (int)this.CreateGraphics().DpiX;
openUnlocked = false; initialMode = Mode.Locked;
InitializeComponent(); InitializeComponent();
@@ -111,14 +118,14 @@ namespace TBF.UI.Procedures
SelectedTestIx = -1; SelectedTestIx = -1;
} }
public ProcedureDlg(Config.Entities.Procedure procedure, IList<string> usedNames, bool openUnlocked = false) public ProcedureDlg(Config.Entities.Procedure procedure, IList<string> usedNames, Mode initialMode)
: this() : this()
{ {
if (procedure == null) throw new ArgumentNullException("procedure"); if (procedure == null) throw new ArgumentNullException("procedure");
LoadedProcedure = procedure; LoadedProcedure = procedure;
this.usedNames = usedNames; this.usedNames = usedNames;
this.openUnlocked = openUnlocked; this.initialMode = initialMode;
#if KEMPNO_50 || KRAKOW_50 #if KEMPNO_50 || KRAKOW_50
sharedButtons.RequiredGroupMembership = procedure.Protected ? new Users.Entities.GID[] { Users.Entities.GID.WaterMeterAuthority } 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 } sharedButtons.RequiredGroupMembership = procedure.Protected ? new Users.Entities.GID[] { Users.Entities.GID.Metrologists }
: new Users.Entities.GID[] { Users.Entities.GID.TestingSpecialists, Users.Entities.GID.Metrologists }; : new Users.Entities.GID[] { Users.Entities.GID.TestingSpecialists, Users.Entities.GID.Metrologists };
#endif #endif
if (initialMode == Mode.PermanentlyLocked) sharedButtons.DisableUnlock();
using (NHibernate.ISession session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config)) using (NHibernate.ISession session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config))
{ {
/// ///
@@ -408,7 +417,7 @@ namespace TBF.UI.Procedures
} }
/// Optionally unlock this dialog /// Optionally unlock this dialog
if (openUnlocked) if (initialMode == Mode.Unlocked)
{ {
sharedButtons.UnlockButtons(); sharedButtons.UnlockButtons();
Unlocked(sender, e); Unlocked(sender, e);
@@ -698,6 +707,7 @@ namespace TBF.UI.Procedures
{ {
found = true; found = true;
ListViewItem item = new ListViewItem(p.Name); ListViewItem item = new ListViewItem(p.Name);
item.Tag = p;
item.SubItems.Add(p.Revision.ToString()); item.SubItems.Add(p.Revision.ToString());
item.SubItems.Add(p.LastChgTime.ToString()); item.SubItems.Add(p.LastChgTime.ToString());
item.SubItems.Add(p.LastChgUser.ToString()); item.SubItems.Add(p.LastChgUser.ToString());
@@ -2828,5 +2838,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<string>(), ProcedureDlg.Mode.PermanentlyLocked)).ShowDialog();
}
}
} }
} }
+6 -6
View File
@@ -1363,7 +1363,7 @@
<value>historyListViewEx</value> <value>historyListViewEx</value>
</data> </data>
<data name="&gt;&gt;historyListViewEx.Type" xml:space="preserve"> <data name="&gt;&gt;historyListViewEx.Type" xml:space="preserve">
<value>Results.Forms.ListViewEx, Results, Version=2.26.1458.0, Culture=neutral, PublicKeyToken=null</value> <value>Results.Forms.ListViewEx, Results, Version=2.26.1560.0, Culture=neutral, PublicKeyToken=null</value>
</data> </data>
<data name="&gt;&gt;historyListViewEx.Parent" xml:space="preserve"> <data name="&gt;&gt;historyListViewEx.Parent" xml:space="preserve">
<value>historyTabPage</value> <value>historyTabPage</value>
@@ -1414,7 +1414,7 @@
<value>metrology1ListViewEx</value> <value>metrology1ListViewEx</value>
</data> </data>
<data name="&gt;&gt;metrology1ListViewEx.Type" xml:space="preserve"> <data name="&gt;&gt;metrology1ListViewEx.Type" xml:space="preserve">
<value>Results.Forms.ListViewEx, Results, Version=2.26.1458.0, Culture=neutral, PublicKeyToken=null</value> <value>Results.Forms.ListViewEx, Results, Version=2.26.1560.0, Culture=neutral, PublicKeyToken=null</value>
</data> </data>
<data name="&gt;&gt;metrology1ListViewEx.Parent" xml:space="preserve"> <data name="&gt;&gt;metrology1ListViewEx.Parent" xml:space="preserve">
<value>metrology1TabPage</value> <value>metrology1TabPage</value>
@@ -1465,7 +1465,7 @@
<value>metrology2ListViewEx</value> <value>metrology2ListViewEx</value>
</data> </data>
<data name="&gt;&gt;metrology2ListViewEx.Type" xml:space="preserve"> <data name="&gt;&gt;metrology2ListViewEx.Type" xml:space="preserve">
<value>Results.Forms.ListViewEx, Results, Version=2.26.1458.0, Culture=neutral, PublicKeyToken=null</value> <value>Results.Forms.ListViewEx, Results, Version=2.26.1560.0, Culture=neutral, PublicKeyToken=null</value>
</data> </data>
<data name="&gt;&gt;metrology2ListViewEx.Parent" xml:space="preserve"> <data name="&gt;&gt;metrology2ListViewEx.Parent" xml:space="preserve">
<value>metrology2TabPage</value> <value>metrology2TabPage</value>
@@ -1516,7 +1516,7 @@
<value>processListViewEx</value> <value>processListViewEx</value>
</data> </data>
<data name="&gt;&gt;processListViewEx.Type" xml:space="preserve"> <data name="&gt;&gt;processListViewEx.Type" xml:space="preserve">
<value>Results.Forms.ListViewEx, Results, Version=2.26.1458.0, Culture=neutral, PublicKeyToken=null</value> <value>Results.Forms.ListViewEx, Results, Version=2.26.1560.0, Culture=neutral, PublicKeyToken=null</value>
</data> </data>
<data name="&gt;&gt;processListViewEx.Parent" xml:space="preserve"> <data name="&gt;&gt;processListViewEx.Parent" xml:space="preserve">
<value>processTabPage</value> <value>processTabPage</value>
@@ -1567,7 +1567,7 @@
<value>parametersListViewEx</value> <value>parametersListViewEx</value>
</data> </data>
<data name="&gt;&gt;parametersListViewEx.Type" xml:space="preserve"> <data name="&gt;&gt;parametersListViewEx.Type" xml:space="preserve">
<value>Results.Forms.ListViewEx, Results, Version=2.26.1458.0, Culture=neutral, PublicKeyToken=null</value> <value>Results.Forms.ListViewEx, Results, Version=2.26.1560.0, Culture=neutral, PublicKeyToken=null</value>
</data> </data>
<data name="&gt;&gt;parametersListViewEx.Parent" xml:space="preserve"> <data name="&gt;&gt;parametersListViewEx.Parent" xml:space="preserve">
<value>parametersTabPage</value> <value>parametersTabPage</value>
@@ -1651,7 +1651,7 @@
<value>sharedButtons</value> <value>sharedButtons</value>
</data> </data>
<data name="&gt;&gt;sharedButtons.Type" xml:space="preserve"> <data name="&gt;&gt;sharedButtons.Type" xml:space="preserve">
<value>TBF.UI.Shared.SharedButtons, TBF, Version=2.26.1537.0, Culture=neutral, PublicKeyToken=null</value> <value>TBF.UI.Shared.SharedButtons, TBF, Version=2.26.1574.0, Culture=neutral, PublicKeyToken=null</value>
</data> </data>
<data name="&gt;&gt;sharedButtons.Parent" xml:space="preserve"> <data name="&gt;&gt;sharedButtons.Parent" xml:space="preserve">
<value>mainSplitContainer.Panel2</value> <value>mainSplitContainer.Panel2</value>
+5 -5
View File
@@ -306,7 +306,7 @@ namespace TBF.UI.Procedures
newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName; newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName;
newProcedure.CreationTime = DateTime.Now; 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 /// TODO: Make name uniqueness test
parent.Unlock(); parent.Unlock();
@@ -541,7 +541,7 @@ namespace TBF.UI.Procedures
IList<string> usedNames = GetUsedNames(false); IList<string> usedNames = GetUsedNames(false);
usedNames.Remove(originalProcedure.Name.ToLower()); /// Allow original procedure name 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(); parent.Unlock();
@@ -594,7 +594,7 @@ namespace TBF.UI.Procedures
newProcedure.CreationTime = DateTime.Now; newProcedure.CreationTime = DateTime.Now;
newProcedure.Protected = false; 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 /// TODO: Make name uniqueness test
parent.Unlock(); parent.Unlock();
@@ -647,7 +647,7 @@ namespace TBF.UI.Procedures
newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName; newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName;
newProcedure.CreationTime = DateTime.Now; 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 /// TODO: Make name uniqueness test
parent.Unlock(); parent.Unlock();
@@ -862,7 +862,7 @@ namespace TBF.UI.Procedures
newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName; newProcedure.CreationUser = Users.GlobalData.CurrentUser.UserName;
newProcedure.CreationTime = DateTime.Now; 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 /// TODO: Make name uniqueness test
parent.Unlock(); parent.Unlock();
+167 -8
View File
@@ -32,21 +32,42 @@
this.closeButton = new System.Windows.Forms.Button(); this.closeButton = new System.Windows.Forms.Button();
this.previousButton = new System.Windows.Forms.Button(); this.previousButton = new System.Windows.Forms.Button();
this.nextButton = 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(); this.SuspendLayout();
// //
// flowLayoutPanel1 // flowLayoutPanel1
// //
this.flowLayoutPanel1.AutoScroll = true; this.flowLayoutPanel1.AutoScroll = true;
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel1.Name = "flowLayoutPanel1"; 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; this.flowLayoutPanel1.TabIndex = 0;
// //
// closeButton // 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.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.Name = "closeButton";
this.closeButton.Size = new System.Drawing.Size(103, 37); this.closeButton.Size = new System.Drawing.Size(103, 37);
this.closeButton.TabIndex = 1; this.closeButton.TabIndex = 1;
@@ -56,7 +77,8 @@
// //
// previousButton // 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.Name = "previousButton";
this.previousButton.Size = new System.Drawing.Size(103, 37); this.previousButton.Size = new System.Drawing.Size(103, 37);
this.previousButton.TabIndex = 2; this.previousButton.TabIndex = 2;
@@ -66,7 +88,8 @@
// //
// nextButton // 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.Name = "nextButton";
this.nextButton.Size = new System.Drawing.Size(103, 37); this.nextButton.Size = new System.Drawing.Size(103, 37);
this.nextButton.TabIndex = 3; this.nextButton.TabIndex = 3;
@@ -74,22 +97,148 @@
this.nextButton.UseVisualStyleBackColor = true; this.nextButton.UseVisualStyleBackColor = true;
this.nextButton.Click += new System.EventHandler(this.nextButton_Click); 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 // PreviousResultsDlg
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.closeButton; this.CancelButton = this.closeButton;
this.ClientSize = new System.Drawing.Size(1194, 892); this.ClientSize = new System.Drawing.Size(1194, 892);
this.Controls.Add(this.nextButton); this.Controls.Add(this.vertSplitContainer);
this.Controls.Add(this.previousButton);
this.Controls.Add(this.closeButton);
this.Controls.Add(this.flowLayoutPanel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false; this.MaximizeBox = false;
this.Name = "PreviousResultsDlg"; this.Name = "PreviousResultsDlg";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "Previous results"; this.Text = "Previous results";
this.Load += new System.EventHandler(this.PreviousResultsDlg_Load); 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); this.ResumeLayout(false);
} }
@@ -100,5 +249,15 @@
private System.Windows.Forms.Button closeButton; private System.Windows.Forms.Button closeButton;
private System.Windows.Forms.Button previousButton; private System.Windows.Forms.Button previousButton;
private System.Windows.Forms.Button nextButton; 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;
} }
} }
+83 -19
View File
@@ -1,5 +1,5 @@
/// ///
/// Copyright (c) 2016-2017 Sensus Slovensko a.s. /// Copyright (c) 2016-2021 Sensus Slovensko a.s.
/// ///
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -9,8 +9,8 @@ using log4net;
using Oracle.DataAccess.Client; using Oracle.DataAccess.Client;
using Results; using Results;
using Results.Entities; using Results.Entities;
using TBF.Resources;
using TBF.BenchControl.Output.DB.SensusOracle; using TBF.BenchControl.Output.DB.SensusOracle;
using TBF.Resources;
namespace TBF.UI.ResultsMI namespace TBF.UI.ResultsMI
{ {
@@ -27,9 +27,11 @@ namespace TBF.UI.ResultsMI
ISession session; ISession session;
int currentBatchNr; int currentBatchNr;
int lastDisplayedBatchNr;
const int LinesCount = 25; IList<Batch> batches; /// A list of batches selected from all batches using criteria from/to date and procedure name
IList<Batch> batches; 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; PreviousResultsMode mode;
@@ -62,11 +64,31 @@ namespace TBF.UI.ResultsMI
{ {
Localize(); 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; toDateTimePicker.MinDate = Constants.MinDate;
DrawBatches(lastDisplayedBatchNr - LinesCount + 1, lastDisplayedBatchNr); 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(); UpdateButtons();
Redraw();
} }
void Localize() void Localize()
@@ -75,10 +97,44 @@ namespace TBF.UI.ResultsMI
closeButton.Text = TBF.Resources.Strings.CloseBtnText; closeButton.Text = TBF.Resources.Strings.CloseBtnText;
previousButton.Text = TBF.Resources.Strings.Previous; previousButton.Text = TBF.Resources.Strings.Previous;
nextButton.Text = TBF.Resources.Strings.Next; nextButton.Text = TBF.Resources.Strings.Next;
fromLabel.Text = Strings.from;
toLabel.Text = Strings.to;
procedureLabel.Text = Strings.Procedure;
} }
IList<Batch> GetFilteredBatches()
{
try
{
if (string.IsNullOrEmpty(procedureTextBox.Text))
{
batches = session.QueryOver<Batch>()
.Where(x => (x.StartTime >= fromDateTimePicker.Value))
.And(x => (x.StartTime <= toDateTimePicker.Value.AddDays(1)))
.OrderBy(x => x.BatchNr).Asc
.List();
}
else
{
batches = session.QueryOver<Batch>()
.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<Batch>();
log.ErrorFormat("Reading batches from Results DB failed: {0}", exc.Message);
}
lastDisplayedIx = batches.Count - 1;
return batches;
}
public void OnReload(object sender, PreviousResultIdEventArgs data) public void OnReload(object sender, PreviousResultIdEventArgs data)
{ {
foreach (var batch in batches) foreach (var batch in batches)
@@ -318,10 +374,11 @@ namespace TBF.UI.ResultsMI
if (batches == null || batches.Count == 0) return; 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 passedCount = 0;
int failedCount = 0; int failedCount = 0;
foreach (var wm in b.WaterMeters) foreach (var wm in b.WaterMeters)
{ {
if ((wm != null) && wm.Passed) { passedCount++; } else { failedCount++; } if ((wm != null) && wm.Passed) { passedCount++; } else { failedCount++; }
@@ -340,7 +397,7 @@ namespace TBF.UI.ResultsMI
failedCount, failedCount,
b.RsltsSent, b.RsltsSent,
mode)); mode));
} }
ResumeLayout(); ResumeLayout();
} }
@@ -354,22 +411,29 @@ namespace TBF.UI.ResultsMI
private void previousButton_Click(object sender, EventArgs e) private void previousButton_Click(object sender, EventArgs e)
{ {
lastDisplayedBatchNr = Math.Max(lastDisplayedBatchNr - LinesCount, LinesCount); lastDisplayedIx = Math.Max(lastDisplayedIx - LinesCount, LinesCount - 1);
DrawBatches(lastDisplayedBatchNr - LinesCount + 1, lastDisplayedBatchNr); Redraw();
UpdateButtons(); UpdateButtons();
} }
private void nextButton_Click(object sender, EventArgs e) private void nextButton_Click(object sender, EventArgs e)
{ {
lastDisplayedBatchNr = Math.Min(lastDisplayedBatchNr + LinesCount, currentBatchNr - 1); lastDisplayedIx = Math.Min(lastDisplayedIx + LinesCount, batches.Count - 1);
DrawBatches(lastDisplayedBatchNr - LinesCount + 1, lastDisplayedBatchNr); Redraw();
UpdateButtons(); UpdateButtons();
} }
private void UpdateButtons() private void UpdateButtons()
{ {
nextButton.Enabled = (lastDisplayedBatchNr < currentBatchNr - 1); nextButton.Enabled = (lastDisplayedIx < batches.Count - 1);
previousButton.Enabled = (lastDisplayedBatchNr > LinesCount); previousButton.Enabled = (lastDisplayedIx > LinesCount - 1);
}
private void reloadButton_Click(object sender, EventArgs e)
{
batches = GetFilteredBatches();
UpdateButtons();
Redraw();
} }
} }
} }
+4
View File
@@ -164,6 +164,10 @@ namespace TBF.UI.Shared
} }
} }
public void DisableUnlock()
{
unlockButton.Enabled = false;
}
/// <summary> /// <summary>
/// Update the visibility of buttons and OK button text when the dialog is unlocked /// Update the visibility of buttons and OK button text when the dialog is unlocked