ResultsBrowser : (1) clean-up, (2) bug in statistics fixed, (3) captions used to select statistics, ver. 2.12.389

This commit is contained in:
Milan Hanajik 2016-11-18 11:39:07 +01:00
parent 2c0914baf8
commit 1487e7889b
16 changed files with 65 additions and 2760 deletions

View File

@ -11,18 +11,17 @@ namespace ResultsBrowser.Forms
IList<WaterMeter> waterMeters;
bool twoDim;
//int rowItemID;
//int columnItemID;
//string rowTestSpec;
//string columnTestSpec;
Results.WMeterRsltItemSpec rowItem;
Results.WMeterRsltItemSpec columnItem;
string rowTestSpec;
string columnTestSpec;
IList<string> rowValues;
IList<string> columnValues;
public StatisticsDlg(IList<WaterMeter> waterMeters, bool twoDim, int rowItemID, int columnItemID, string rowTestSpec, string columnTestSpec)
public StatisticsDlg(IList<WaterMeter> waterMeters, bool twoDim, Results.WMeterRsltItemSpec rowItem, Results.WMeterRsltItemSpec columnItem, string rowTestSpec, string columnTestSpec)
{
InitializeComponent();
@ -32,25 +31,10 @@ namespace ResultsBrowser.Forms
this.waterMeters = waterMeters;
this.twoDim = twoDim;
foreach (var item in Results.WMeterRsltItemSpec.AllItems)
{
if (item.Uid == rowItemID)
{
rowItem = item.Clone();
item.TestID = rowTestSpec;
}
if (twoDim && item.Uid == columnItemID)
{
columnItem = item.Clone();
item.TestID = columnTestSpec;
}
}
//this.rowItemID = rowItemID;
//this.columnItemID = columnItemID;
//this.rowTestSpec = rowTestSpec;
//this.columnTestSpec = columnTestSpec;
this.rowItem = rowItem;
this.columnItem = columnItem;
this.rowTestSpec = rowTestSpec;
this.columnTestSpec = columnTestSpec;
}
private void StatisticsDlg_Load(object sender, EventArgs e)
@ -114,10 +98,10 @@ namespace ResultsBrowser.Forms
statisticsListView.GridLines = true;
statisticsListView.FullRowSelect = true;
statisticsListView.Columns.Add("*", 200);
statisticsListView.Columns.Add(" ", 200);
for (int column = 0; column < columns; column++)
{
statisticsListView.Columns.Add((twoDim ? columnValues[column] : "Count"), 70);
statisticsListView.Columns.Add((twoDim ? columnValues[column] : Strings.Count), 70);
}
for (int row = 0; row < rowValues.Count; row++)

View File

@ -12,39 +12,38 @@ namespace ResultsBrowser.Forms
{
public partial class StatisticsOptionsDlg : Form
{
IList<Results.WMeterRsltItemSpec> items;
public bool TwoDim;
public int RowItemID;
public int ColumnItemID;
public Results.WMeterRsltItemSpec RowItem;
public Results.WMeterRsltItemSpec ColumnItem;
public string RowTestSpecifier;
public string ColumnTestSpecifier;
public StatisticsOptionsDlg()
public StatisticsOptionsDlg(IList<Results.WMeterRsltItemSpec> items)
{
InitializeComponent();
this.items = items;
}
private void StatisticsOptionsDlg_Load(object sender, EventArgs e)
{
Localize();
twoDimCheckBox.Checked = TwoDim = Program.LocalSettings.TwoDim;
RowItemID = Math.Max(1, Program.LocalSettings.RowItemID);
ColumnItemID = Math.Max(1, Program.LocalSettings.ColumnItemID);
rowTestSpecTextBox.Text = RowTestSpecifier = Program.LocalSettings.RowTestSpecifier;
columnTestSpecTextBox.Text = ColumnTestSpecifier = Program.LocalSettings.ColumnTestSpecifier;
columnsComboBox.Enabled = twoDimCheckBox.Checked = TwoDim = Program.LocalSettings.TwoDim;
rowsComboBox.Text = Results.WMeterRsltItemSpec.AllItems[RowItemID].Name; /// TODO: Use Caption
columnsComboBox.Text = Results.WMeterRsltItemSpec.AllItems[ColumnItemID].Name; /// TODO: Use Caption
rowsComboBox.Text = Program.LocalSettings.RowItemCaption;
columnsComboBox.Text = Program.LocalSettings.ColumnItemCaption;
///
for (int i = 1; i < Results.WMeterRsltItemSpec.AllItems.Count; i++)
foreach (var item in items)
{
string item = Results.WMeterRsltItemSpec.AllItems[i].Name; /// TODO: Use Caption
rowsComboBox.Items.Add(item);
columnsComboBox.Items.Add(item);
rowsComboBox.Items.Add(item.Caption);
columnsComboBox.Items.Add(item.Caption);
}
columnsComboBox.Enabled = TwoDim;
rowTestSpecTextBox.Text = RowTestSpecifier = Program.LocalSettings.RowTestSpecifier;
columnTestSpecTextBox.Text = ColumnTestSpecifier = Program.LocalSettings.ColumnTestSpecifier;
}
void Localize()
@ -69,40 +68,32 @@ namespace ResultsBrowser.Forms
RowTestSpecifier = rowTestSpecTextBox.Text;
ColumnTestSpecifier = columnTestSpecTextBox.Text;
RowItemID = 0;
RowItem = null;
ColumnItem = null;
for (int i = 0; i < rowsComboBox.Items.Count; i++)
foreach (var item in items)
{
if (rowsComboBox.Text.Equals(rowsComboBox.Items[i]))
if (rowsComboBox.Text.Equals(item.Caption))
{
RowItemID = i + 1;
break;
RowItem = item;
}
}
if (TwoDim)
{
ColumnItemID = 0;
if (TwoDim && columnsComboBox.Text.Equals(item.Caption))
{
ColumnItem = item;
}
}
for (int i = 0; i < columnsComboBox.Items.Count; i++)
{
if (columnsComboBox.Text.Equals(columnsComboBox.Items[i]))
{
ColumnItemID = i + 1;
break;
}
}
}
if (RowItemID == 0 || ColumnItemID == 0)
if (RowItem == null || (TwoDim && ColumnItem == null))
{
MessageBox.Show(Strings.Error, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
DialogResult = DialogResult.Cancel;
}
Program.LocalSettings.TwoDim = TwoDim;
Program.LocalSettings.RowItemID = RowItemID;
Program.LocalSettings.ColumnItemID = ColumnItemID;
Program.LocalSettings.RowItemCaption = RowItem.Caption;
Program.LocalSettings.ColumnItemCaption = (ColumnItem != null) ? ColumnItem.Caption : string.Empty;
Program.LocalSettings.RowTestSpecifier = RowTestSpecifier;
Program.LocalSettings.ColumnTestSpecifier = ColumnTestSpecifier;
Program.LocalSettings.Save();

View File

@ -39,8 +39,8 @@ namespace ResultsBrowser
/// Statistics options
public bool TwoDim;
public int RowItemID;
public int ColumnItemID;
public string RowItemCaption;
public string ColumnItemCaption;
public string RowTestSpecifier;
public string ColumnTestSpecifier;

View File

@ -1,590 +0,0 @@
namespace ResultsBrowser
{
partial class MainWnd
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.queryBatchesButton = new System.Windows.Forms.Button();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.queryWatermetersButton = new System.Windows.Forms.Button();
this.batchNrGroupBox = new System.Windows.Forms.GroupBox();
this.batchNrToTextBox = new System.Windows.Forms.TextBox();
this.batchNrFromTextBox = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.batchNrCheckBox = new System.Windows.Forms.CheckBox();
this.removeFromQueryButton = new System.Windows.Forms.Button();
this.addToReportButton = new System.Windows.Forms.Button();
this.resolveManuallyCheckBox = new System.Windows.Forms.CheckBox();
this.procedureGroupBox = new System.Windows.Forms.GroupBox();
this.procedureCheckBox = new System.Windows.Forms.CheckBox();
this.procedureComboBox = new System.Windows.Forms.ComboBox();
this.fromGroupBox = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.filterDateCheckBox = new System.Windows.Forms.CheckBox();
this.toDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.fromDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.purchaseOrderGroupBox = new System.Windows.Forms.GroupBox();
this.purchaseOrderCheckBox = new System.Windows.Forms.CheckBox();
this.purchaseOrderComboBox = new System.Windows.Forms.ComboBox();
this.queryResultsListBox = new System.Windows.Forms.ListBox();
this.configReportButton = new System.Windows.Forms.Button();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.splitContainer3 = new System.Windows.Forms.SplitContainer();
this.configButton = new System.Windows.Forms.Button();
this.makeReportButton = new System.Windows.Forms.Button();
this.removeFromReportButton = new System.Windows.Forms.Button();
this.reportFileGroupBox = new System.Windows.Forms.GroupBox();
this.browseFileButton = new System.Windows.Forms.Button();
this.reportFileComboBox = new System.Windows.Forms.ComboBox();
this.makeAscFileButton = new System.Windows.Forms.Button();
this.addOracleDataButton = new System.Windows.Forms.Button();
this.reportListBox = new System.Windows.Forms.ListBox();
this.queryResultsItemsLabel = new System.Windows.Forms.Label();
this.reportItemsLabel = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.batchNrGroupBox.SuspendLayout();
this.procedureGroupBox.SuspendLayout();
this.fromGroupBox.SuspendLayout();
this.purchaseOrderGroupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit();
this.splitContainer3.Panel1.SuspendLayout();
this.splitContainer3.Panel2.SuspendLayout();
this.splitContainer3.SuspendLayout();
this.reportFileGroupBox.SuspendLayout();
this.SuspendLayout();
//
// queryBatchesButton
//
this.queryBatchesButton.Location = new System.Drawing.Point(15, 178);
this.queryBatchesButton.Name = "queryBatchesButton";
this.queryBatchesButton.Size = new System.Drawing.Size(108, 29);
this.queryBatchesButton.TabIndex = 3;
this.queryBatchesButton.Text = "Query batches";
this.queryBatchesButton.UseVisualStyleBackColor = true;
this.queryBatchesButton.Click += new System.EventHandler(this.queryBatchesButton_Click);
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.IsSplitterFixed = true;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.queryResultsItemsLabel);
this.splitContainer1.Panel1.Controls.Add(this.queryWatermetersButton);
this.splitContainer1.Panel1.Controls.Add(this.batchNrGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.removeFromQueryButton);
this.splitContainer1.Panel1.Controls.Add(this.addToReportButton);
this.splitContainer1.Panel1.Controls.Add(this.resolveManuallyCheckBox);
this.splitContainer1.Panel1.Controls.Add(this.procedureGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.fromGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.queryBatchesButton);
this.splitContainer1.Panel1.Controls.Add(this.purchaseOrderGroupBox);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.queryResultsListBox);
this.splitContainer1.Size = new System.Drawing.Size(604, 624);
this.splitContainer1.SplitterDistance = 220;
this.splitContainer1.TabIndex = 5;
//
// queryWatermetersButton
//
this.queryWatermetersButton.Location = new System.Drawing.Point(129, 178);
this.queryWatermetersButton.Name = "queryWatermetersButton";
this.queryWatermetersButton.Size = new System.Drawing.Size(108, 29);
this.queryWatermetersButton.TabIndex = 12;
this.queryWatermetersButton.Text = "Query water meters";
this.queryWatermetersButton.UseVisualStyleBackColor = true;
this.queryWatermetersButton.Click += new System.EventHandler(this.queryWatermetersButton_Click);
//
// batchNrGroupBox
//
this.batchNrGroupBox.Controls.Add(this.batchNrToTextBox);
this.batchNrGroupBox.Controls.Add(this.batchNrFromTextBox);
this.batchNrGroupBox.Controls.Add(this.label4);
this.batchNrGroupBox.Controls.Add(this.label3);
this.batchNrGroupBox.Controls.Add(this.batchNrCheckBox);
this.batchNrGroupBox.Location = new System.Drawing.Point(15, 122);
this.batchNrGroupBox.Name = "batchNrGroupBox";
this.batchNrGroupBox.Size = new System.Drawing.Size(242, 50);
this.batchNrGroupBox.TabIndex = 11;
this.batchNrGroupBox.TabStop = false;
this.batchNrGroupBox.Visible = false;
//
// batchNrToTextBox
//
this.batchNrToTextBox.Location = new System.Drawing.Point(157, 21);
this.batchNrToTextBox.Name = "batchNrToTextBox";
this.batchNrToTextBox.Size = new System.Drawing.Size(62, 20);
this.batchNrToTextBox.TabIndex = 5;
//
// batchNrFromTextBox
//
this.batchNrFromTextBox.Location = new System.Drawing.Point(56, 21);
this.batchNrFromTextBox.Name = "batchNrFromTextBox";
this.batchNrFromTextBox.Size = new System.Drawing.Size(62, 20);
this.batchNrFromTextBox.TabIndex = 4;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(131, 24);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(20, 13);
this.label4.TabIndex = 3;
this.label4.Text = "To";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(19, 24);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(30, 13);
this.label3.TabIndex = 2;
this.label3.Text = "From";
//
// batchNrCheckBox
//
this.batchNrCheckBox.AutoSize = true;
this.batchNrCheckBox.Location = new System.Drawing.Point(19, 0);
this.batchNrCheckBox.Name = "batchNrCheckBox";
this.batchNrCheckBox.Size = new System.Drawing.Size(116, 17);
this.batchNrCheckBox.TabIndex = 1;
this.batchNrCheckBox.Text = "Filter batch number";
this.batchNrCheckBox.UseVisualStyleBackColor = true;
this.batchNrCheckBox.Visible = false;
//
// removeFromQueryButton
//
this.removeFromQueryButton.Location = new System.Drawing.Point(380, 178);
this.removeFromQueryButton.Name = "removeFromQueryButton";
this.removeFromQueryButton.Size = new System.Drawing.Size(114, 29);
this.removeFromQueryButton.TabIndex = 9;
this.removeFromQueryButton.Text = "Remove selected";
this.removeFromQueryButton.UseVisualStyleBackColor = true;
this.removeFromQueryButton.Click += new System.EventHandler(this.removeFromQueryButton_Click);
//
// addToReportButton
//
this.addToReportButton.Location = new System.Drawing.Point(558, 162);
this.addToReportButton.Name = "addToReportButton";
this.addToReportButton.Size = new System.Drawing.Size(46, 40);
this.addToReportButton.TabIndex = 8;
this.addToReportButton.Text = ">>>";
this.addToReportButton.UseVisualStyleBackColor = true;
this.addToReportButton.Click += new System.EventHandler(this.addToReportButton_Click);
//
// resolveManuallyCheckBox
//
this.resolveManuallyCheckBox.AutoSize = true;
this.resolveManuallyCheckBox.Location = new System.Drawing.Point(282, 143);
this.resolveManuallyCheckBox.Name = "resolveManuallyCheckBox";
this.resolveManuallyCheckBox.Size = new System.Drawing.Size(158, 17);
this.resolveManuallyCheckBox.TabIndex = 7;
this.resolveManuallyCheckBox.Text = "Resolve duplicities manually";
this.resolveManuallyCheckBox.UseVisualStyleBackColor = true;
//
// procedureGroupBox
//
this.procedureGroupBox.Controls.Add(this.procedureCheckBox);
this.procedureGroupBox.Controls.Add(this.procedureComboBox);
this.procedureGroupBox.Location = new System.Drawing.Point(15, 68);
this.procedureGroupBox.Name = "procedureGroupBox";
this.procedureGroupBox.Size = new System.Drawing.Size(242, 50);
this.procedureGroupBox.TabIndex = 6;
this.procedureGroupBox.TabStop = false;
//
// procedureCheckBox
//
this.procedureCheckBox.AutoSize = true;
this.procedureCheckBox.Location = new System.Drawing.Point(19, 0);
this.procedureCheckBox.Name = "procedureCheckBox";
this.procedureCheckBox.Size = new System.Drawing.Size(99, 17);
this.procedureCheckBox.TabIndex = 1;
this.procedureCheckBox.Text = "Filter procedure";
this.procedureCheckBox.UseVisualStyleBackColor = true;
this.procedureCheckBox.CheckedChanged += new System.EventHandler(this.procedureCheckBox_CheckedChanged);
//
// procedureComboBox
//
this.procedureComboBox.FormattingEnabled = true;
this.procedureComboBox.Location = new System.Drawing.Point(18, 19);
this.procedureComboBox.Name = "procedureComboBox";
this.procedureComboBox.Size = new System.Drawing.Size(201, 21);
this.procedureComboBox.TabIndex = 0;
//
// fromGroupBox
//
this.fromGroupBox.Controls.Add(this.label2);
this.fromGroupBox.Controls.Add(this.label1);
this.fromGroupBox.Controls.Add(this.filterDateCheckBox);
this.fromGroupBox.Controls.Add(this.toDateTimePicker);
this.fromGroupBox.Controls.Add(this.fromDateTimePicker);
this.fromGroupBox.Location = new System.Drawing.Point(263, 14);
this.fromGroupBox.Name = "fromGroupBox";
this.fromGroupBox.Size = new System.Drawing.Size(242, 104);
this.fromGroupBox.TabIndex = 3;
this.fromGroupBox.TabStop = false;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(16, 68);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(20, 13);
this.label2.TabIndex = 3;
this.label2.Text = "To";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(16, 36);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(30, 13);
this.label1.TabIndex = 2;
this.label1.Text = "From";
//
// filterDateCheckBox
//
this.filterDateCheckBox.AutoSize = true;
this.filterDateCheckBox.Location = new System.Drawing.Point(19, -1);
this.filterDateCheckBox.Name = "filterDateCheckBox";
this.filterDateCheckBox.Size = new System.Drawing.Size(72, 17);
this.filterDateCheckBox.TabIndex = 1;
this.filterDateCheckBox.Text = "Filter date";
this.filterDateCheckBox.UseVisualStyleBackColor = true;
//
// toDateTimePicker
//
this.toDateTimePicker.Location = new System.Drawing.Point(68, 65);
this.toDateTimePicker.Name = "toDateTimePicker";
this.toDateTimePicker.Size = new System.Drawing.Size(151, 20);
this.toDateTimePicker.TabIndex = 0;
//
// fromDateTimePicker
//
this.fromDateTimePicker.Location = new System.Drawing.Point(68, 32);
this.fromDateTimePicker.Name = "fromDateTimePicker";
this.fromDateTimePicker.Size = new System.Drawing.Size(151, 20);
this.fromDateTimePicker.TabIndex = 0;
//
// purchaseOrderGroupBox
//
this.purchaseOrderGroupBox.Controls.Add(this.purchaseOrderCheckBox);
this.purchaseOrderGroupBox.Controls.Add(this.purchaseOrderComboBox);
this.purchaseOrderGroupBox.Location = new System.Drawing.Point(15, 14);
this.purchaseOrderGroupBox.Name = "purchaseOrderGroupBox";
this.purchaseOrderGroupBox.Size = new System.Drawing.Size(242, 50);
this.purchaseOrderGroupBox.TabIndex = 2;
this.purchaseOrderGroupBox.TabStop = false;
//
// purchaseOrderCheckBox
//
this.purchaseOrderCheckBox.AutoSize = true;
this.purchaseOrderCheckBox.Location = new System.Drawing.Point(19, 0);
this.purchaseOrderCheckBox.Name = "purchaseOrderCheckBox";
this.purchaseOrderCheckBox.Size = new System.Drawing.Size(122, 17);
this.purchaseOrderCheckBox.TabIndex = 1;
this.purchaseOrderCheckBox.Text = "Filter purchase order";
this.purchaseOrderCheckBox.UseVisualStyleBackColor = true;
//
// purchaseOrderComboBox
//
this.purchaseOrderComboBox.FormattingEnabled = true;
this.purchaseOrderComboBox.Location = new System.Drawing.Point(18, 19);
this.purchaseOrderComboBox.Name = "purchaseOrderComboBox";
this.purchaseOrderComboBox.Size = new System.Drawing.Size(201, 21);
this.purchaseOrderComboBox.TabIndex = 0;
//
// queryResultsListBox
//
this.queryResultsListBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.queryResultsListBox.FormattingEnabled = true;
this.queryResultsListBox.Location = new System.Drawing.Point(0, 0);
this.queryResultsListBox.Name = "queryResultsListBox";
this.queryResultsListBox.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple;
this.queryResultsListBox.Size = new System.Drawing.Size(604, 400);
this.queryResultsListBox.TabIndex = 0;
this.queryResultsListBox.DoubleClick += new System.EventHandler(this.queryResultsListBox_DoubleClick);
//
// configReportButton
//
this.configReportButton.Location = new System.Drawing.Point(226, 95);
this.configReportButton.Name = "configReportButton";
this.configReportButton.Size = new System.Drawing.Size(103, 47);
this.configReportButton.TabIndex = 5;
this.configReportButton.Text = "Configure Report";
this.configReportButton.UseVisualStyleBackColor = true;
this.configReportButton.Click += new System.EventHandler(this.configReportButton_Click);
//
// splitContainer2
//
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer2.Location = new System.Drawing.Point(0, 0);
this.splitContainer2.Name = "splitContainer2";
//
// splitContainer2.Panel1
//
this.splitContainer2.Panel1.Controls.Add(this.splitContainer1);
//
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.splitContainer3);
this.splitContainer2.Size = new System.Drawing.Size(1284, 624);
this.splitContainer2.SplitterDistance = 604;
this.splitContainer2.TabIndex = 6;
//
// splitContainer3
//
this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer3.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer3.IsSplitterFixed = true;
this.splitContainer3.Location = new System.Drawing.Point(0, 0);
this.splitContainer3.Name = "splitContainer3";
this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer3.Panel1
//
this.splitContainer3.Panel1.Controls.Add(this.reportItemsLabel);
this.splitContainer3.Panel1.Controls.Add(this.configButton);
this.splitContainer3.Panel1.Controls.Add(this.makeReportButton);
this.splitContainer3.Panel1.Controls.Add(this.removeFromReportButton);
this.splitContainer3.Panel1.Controls.Add(this.reportFileGroupBox);
this.splitContainer3.Panel1.Controls.Add(this.makeAscFileButton);
this.splitContainer3.Panel1.Controls.Add(this.addOracleDataButton);
this.splitContainer3.Panel1.Controls.Add(this.configReportButton);
//
// splitContainer3.Panel2
//
this.splitContainer3.Panel2.Controls.Add(this.reportListBox);
this.splitContainer3.Size = new System.Drawing.Size(676, 624);
this.splitContainer3.SplitterDistance = 220;
this.splitContainer3.TabIndex = 6;
//
// configButton
//
this.configButton.Location = new System.Drawing.Point(589, 14);
this.configButton.Name = "configButton";
this.configButton.Size = new System.Drawing.Size(75, 71);
this.configButton.TabIndex = 12;
this.configButton.Text = "Configure";
this.configButton.UseVisualStyleBackColor = true;
this.configButton.Click += new System.EventHandler(this.configButton_Click);
//
// makeReportButton
//
this.makeReportButton.Location = new System.Drawing.Point(335, 95);
this.makeReportButton.Name = "makeReportButton";
this.makeReportButton.Size = new System.Drawing.Size(103, 47);
this.makeReportButton.TabIndex = 11;
this.makeReportButton.Text = "Make Report";
this.makeReportButton.UseVisualStyleBackColor = true;
this.makeReportButton.Click += new System.EventHandler(this.makeReportButton_Click);
//
// removeFromReportButton
//
this.removeFromReportButton.Location = new System.Drawing.Point(55, 178);
this.removeFromReportButton.Name = "removeFromReportButton";
this.removeFromReportButton.Size = new System.Drawing.Size(114, 29);
this.removeFromReportButton.TabIndex = 10;
this.removeFromReportButton.Text = "Remove selected";
this.removeFromReportButton.UseVisualStyleBackColor = true;
this.removeFromReportButton.Click += new System.EventHandler(this.removeFromReportButton_Click);
//
// reportFileGroupBox
//
this.reportFileGroupBox.Controls.Add(this.browseFileButton);
this.reportFileGroupBox.Controls.Add(this.reportFileComboBox);
this.reportFileGroupBox.Location = new System.Drawing.Point(18, 14);
this.reportFileGroupBox.Name = "reportFileGroupBox";
this.reportFileGroupBox.Size = new System.Drawing.Size(546, 63);
this.reportFileGroupBox.TabIndex = 8;
this.reportFileGroupBox.TabStop = false;
this.reportFileGroupBox.Text = "Report file name";
//
// browseFileButton
//
this.browseFileButton.Location = new System.Drawing.Point(453, 22);
this.browseFileButton.Name = "browseFileButton";
this.browseFileButton.Size = new System.Drawing.Size(75, 27);
this.browseFileButton.TabIndex = 2;
this.browseFileButton.Text = "Browse";
this.browseFileButton.UseVisualStyleBackColor = true;
this.browseFileButton.Click += new System.EventHandler(this.browseFileButton_Click);
//
// reportFileComboBox
//
this.reportFileComboBox.FormattingEnabled = true;
this.reportFileComboBox.Location = new System.Drawing.Point(20, 25);
this.reportFileComboBox.Name = "reportFileComboBox";
this.reportFileComboBox.Size = new System.Drawing.Size(414, 21);
this.reportFileComboBox.TabIndex = 1;
//
// makeAscFileButton
//
this.makeAscFileButton.Location = new System.Drawing.Point(443, 95);
this.makeAscFileButton.Name = "makeAscFileButton";
this.makeAscFileButton.Size = new System.Drawing.Size(103, 47);
this.makeAscFileButton.TabIndex = 7;
this.makeAscFileButton.Text = "Make *.asc File";
this.makeAscFileButton.UseVisualStyleBackColor = true;
this.makeAscFileButton.Click += new System.EventHandler(this.makeAscFileButton_Click);
//
// addOracleDataButton
//
this.addOracleDataButton.Location = new System.Drawing.Point(117, 95);
this.addOracleDataButton.Name = "addOracleDataButton";
this.addOracleDataButton.Size = new System.Drawing.Size(103, 47);
this.addOracleDataButton.TabIndex = 6;
this.addOracleDataButton.Text = "Add Oracle Data";
this.addOracleDataButton.UseVisualStyleBackColor = true;
this.addOracleDataButton.Click += new System.EventHandler(this.addOracleDataButton_Click);
//
// reportListBox
//
this.reportListBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.reportListBox.FormattingEnabled = true;
this.reportListBox.Location = new System.Drawing.Point(0, 0);
this.reportListBox.Name = "reportListBox";
this.reportListBox.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple;
this.reportListBox.Size = new System.Drawing.Size(676, 400);
this.reportListBox.TabIndex = 0;
this.reportListBox.DoubleClick += new System.EventHandler(this.reportListBox_DoubleClick);
//
// queryResultsItemsLabel
//
this.queryResultsItemsLabel.AutoSize = true;
this.queryResultsItemsLabel.Location = new System.Drawing.Point(255, 207);
this.queryResultsItemsLabel.Name = "queryResultsItemsLabel";
this.queryResultsItemsLabel.Size = new System.Drawing.Size(40, 13);
this.queryResultsItemsLabel.TabIndex = 13;
this.queryResultsItemsLabel.Text = "0 items";
//
// reportItemsLabel
//
this.reportItemsLabel.AutoSize = true;
this.reportItemsLabel.Location = new System.Drawing.Point(261, 207);
this.reportItemsLabel.Name = "reportItemsLabel";
this.reportItemsLabel.Size = new System.Drawing.Size(40, 13);
this.reportItemsLabel.TabIndex = 14;
this.reportItemsLabel.Text = "0 items";
//
// MainWnd
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1284, 624);
this.Controls.Add(this.splitContainer2);
this.Name = "MainWnd";
this.Text = "Results browser";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainWnd_FormClosing);
this.Load += new System.EventHandler(this.MainWnd_Load);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.batchNrGroupBox.ResumeLayout(false);
this.batchNrGroupBox.PerformLayout();
this.procedureGroupBox.ResumeLayout(false);
this.procedureGroupBox.PerformLayout();
this.fromGroupBox.ResumeLayout(false);
this.fromGroupBox.PerformLayout();
this.purchaseOrderGroupBox.ResumeLayout(false);
this.purchaseOrderGroupBox.PerformLayout();
this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
this.splitContainer2.ResumeLayout(false);
this.splitContainer3.Panel1.ResumeLayout(false);
this.splitContainer3.Panel1.PerformLayout();
this.splitContainer3.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit();
this.splitContainer3.ResumeLayout(false);
this.reportFileGroupBox.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button queryBatchesButton;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.GroupBox fromGroupBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.CheckBox filterDateCheckBox;
private System.Windows.Forms.DateTimePicker toDateTimePicker;
private System.Windows.Forms.DateTimePicker fromDateTimePicker;
private System.Windows.Forms.GroupBox purchaseOrderGroupBox;
private System.Windows.Forms.CheckBox purchaseOrderCheckBox;
private System.Windows.Forms.ComboBox purchaseOrderComboBox;
private System.Windows.Forms.Button configReportButton;
private System.Windows.Forms.CheckBox resolveManuallyCheckBox;
private System.Windows.Forms.GroupBox procedureGroupBox;
private System.Windows.Forms.CheckBox procedureCheckBox;
private System.Windows.Forms.ComboBox procedureComboBox;
private System.Windows.Forms.SplitContainer splitContainer2;
private System.Windows.Forms.SplitContainer splitContainer3;
private System.Windows.Forms.Button addOracleDataButton;
private System.Windows.Forms.Button makeAscFileButton;
private System.Windows.Forms.ListBox queryResultsListBox;
private System.Windows.Forms.ListBox reportListBox;
private System.Windows.Forms.GroupBox reportFileGroupBox;
private System.Windows.Forms.Button browseFileButton;
private System.Windows.Forms.ComboBox reportFileComboBox;
private System.Windows.Forms.Button removeFromQueryButton;
private System.Windows.Forms.Button addToReportButton;
private System.Windows.Forms.Button removeFromReportButton;
private System.Windows.Forms.GroupBox batchNrGroupBox;
private System.Windows.Forms.TextBox batchNrToTextBox;
private System.Windows.Forms.TextBox batchNrFromTextBox;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.CheckBox batchNrCheckBox;
private System.Windows.Forms.Button makeReportButton;
private System.Windows.Forms.Button configButton;
private System.Windows.Forms.Button queryWatermetersButton;
private System.Windows.Forms.Label queryResultsItemsLabel;
private System.Windows.Forms.Label reportItemsLabel;
}
}

View File

@ -1,590 +0,0 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using log4net;
using NHibernate;
using Oracle.DataAccess.Client; // ODP.NET Oracle managed provider
using Oracle.DataAccess.Types;
using Results.Entities;
namespace ResultsBrowser
{
public partial class MainWnd : Form
{
static readonly ILog log = LogManager.GetLogger(typeof(MainWnd));
bool batchesQueried;
public static IList<Batch> QueryBatches;
public static IList<WaterMeter> QueryWaterMeters;
public static IList<Batch> ReportBatches;
public static IList<WaterMeter> ReportWaterMeters;
public IList<Results.ItemSpec> ReportItems_Single;
public IList<Results.ItemSpec> ReportItems_Compound;
public MainWnd()
{
InitializeComponent();
QueryBatches = new List<Batch>();
QueryWaterMeters = new List<WaterMeter>();
ReportBatches = new List<Batch>();
ReportWaterMeters = new List<WaterMeter>();
}
private void MainWnd_Load(object sender, EventArgs e)
{
PrepareComboBoxHistory(Program.LocalSettings.PurchaseOrderHistory, purchaseOrderComboBox);
PrepareComboBoxHistory(Program.LocalSettings.ProcedureHistory, procedureComboBox);
PrepareComboBoxHistory(Program.LocalSettings.ReportFileNameHistory, reportFileComboBox);
purchaseOrderComboBox.Text = Program.LocalSettings.LastPurchaseOrder;
procedureComboBox.Text = Program.LocalSettings.LastProcedure;
reportFileComboBox.Text = Program.LocalSettings.LastReportFileName;
ReportItems_Single = Results.ItemSpec.FromStrArray(Program.LocalSettings.ReportItems_Single);
ReportItems_Compound = Results.ItemSpec.FromStrArray(Program.LocalSettings.ReportItems_Compound);
purchaseOrderCheckBox.Checked = Program.LocalSettings.FilterPurchaseOrder;
procedureCheckBox.Checked = Program.LocalSettings.FilterProcedure;
batchNrCheckBox.Checked = Program.LocalSettings.FilterBatchNr;
filterDateCheckBox.Checked = Program.LocalSettings.FilterDate;
resolveManuallyCheckBox.Checked = Program.LocalSettings.ResolveManually;
batchNrFromTextBox.Text = Program.LocalSettings.BatchFrom;
batchNrToTextBox.Text = Program.LocalSettings.BatchTo;
Results.DB.ConnectionString = Program.LocalSettings.ConnectionString1;
}
private void MainWnd_FormClosing(object sender, FormClosingEventArgs e)
{
Program.LocalSettings.UpdateHistory(purchaseOrderComboBox.Text, ref Program.LocalSettings.PurchaseOrderHistory);
Program.LocalSettings.UpdateHistory(procedureComboBox.Text, ref Program.LocalSettings.PurchaseOrderHistory);
Program.LocalSettings.UpdateHistory(reportFileComboBox.Text, ref Program.LocalSettings.ReportFileNameHistory);
Program.LocalSettings.LastPurchaseOrder = purchaseOrderComboBox.Text;
Program.LocalSettings.LastProcedure = procedureComboBox.Text;
Program.LocalSettings.LastReportFileName = reportFileComboBox.Text;
Program.LocalSettings.ReportItems_Single = Results.ItemSpec.ToStrArray(ReportItems_Single);
Program.LocalSettings.ReportItems_Compound = Results.ItemSpec.ToStrArray(ReportItems_Compound);
Program.LocalSettings.FilterPurchaseOrder = purchaseOrderCheckBox.Checked;
Program.LocalSettings.FilterProcedure = procedureCheckBox.Checked;
Program.LocalSettings.FilterBatchNr = batchNrCheckBox.Checked;
Program.LocalSettings.FilterDate = filterDateCheckBox.Checked;
Program.LocalSettings.BatchFrom = batchNrFromTextBox.Text;
Program.LocalSettings.BatchTo = batchNrToTextBox.Text;
Program.LocalSettings.ResolveManually = resolveManuallyCheckBox.Checked;
Program.LocalSettings.Save();
}
void RedrawLists()
{
RedrawQueryList();
RedrawReportList();
}
void RedrawQueryList()
{
queryResultsListBox.Items.Clear();
if (batchesQueried)
{
foreach (var b in QueryBatches) queryResultsListBox.Items.Add(b.ToString());
}
else
{
foreach (var wmr in QueryWaterMeters) queryResultsListBox.Items.Add(wmr);
}
int nrItems = queryResultsListBox.Items.Count;
if (nrItems == 0) queryResultsListBox.Items.Add("<empty>");
queryResultsItemsLabel.Text = string.Format("{0} items", nrItems);
}
void RedrawReportList()
{
reportListBox.Items.Clear();
foreach (var wmr in ReportWaterMeters) reportListBox.Items.Add(wmr);
int nrItems = reportListBox.Items.Count;
if (nrItems == 0) reportListBox.Items.Add("<empty>");
reportItemsLabel.Text = string.Format("{0} items", nrItems);
}
/// <summary>
/// Load Purchase order combo box items from the LocalSettings PurchaseOrderHistory array
/// </summary>
/// <param name="comboBox">Puchase order ComboBox</param>
void PrepareComboBoxHistory(string[] history, ComboBox comboBox)
{
if (history == null || history.Length == 0) return;
for (int i = 0; i < history.Length; i++) comboBox.Items.Add(history[i]);
if (comboBox.Items.Count > 0) comboBox.Text = comboBox.Items[0].ToString();
}
private void filterDateCheckBox_CheckedChanged(object sender, EventArgs e)
{
fromDateTimePicker.Enabled = toDateTimePicker.Enabled = filterDateCheckBox.Checked;
}
private void purchaseOrderCheckBox_CheckedChanged(object sender, EventArgs e)
{
purchaseOrderComboBox.Enabled = purchaseOrderCheckBox.Checked;
}
private void procedureCheckBox_CheckedChanged(object sender, EventArgs e)
{
procedureComboBox.Enabled = procedureCheckBox.Checked;
}
private void clearButton_Click(object sender, EventArgs e)
{
QueryWaterMeters.Clear();
queryResultsListBox.Items.Clear();
}
private void configReportButton_Click(object sender, EventArgs e)
{
Forms.ResultsConfig dlg = new Forms.ResultsConfig(false);
dlg.ReportItems_Single = ReportItems_Single;
dlg.ReportItems_Compound = ReportItems_Compound;
if (DialogResult.OK == dlg.ShowDialog())
{
ReportItems_Single = dlg.ReportItems_Single;
ReportItems_Compound = dlg.ReportItems_Compound;
Program.LocalSettings.ReportItems_Single = Results.ItemSpec.ToStrArray(ReportItems_Single);
Program.LocalSettings.ReportItems_Compound = Results.ItemSpec.ToStrArray(ReportItems_Compound);
}
}
private void removeFromQueryButton_Click(object sender, EventArgs e)
{
try
{
/// Remove from the list (the last selected item first so that the indexes are not affected)
for (int i = queryResultsListBox.SelectedIndices.Count - 1; i >= 0; i--)
{
if (batchesQueried)
{
QueryBatches.RemoveAt(queryResultsListBox.SelectedIndices[i]);
}
else
{
QueryWaterMeters.RemoveAt(queryResultsListBox.SelectedIndices[i]);
}
}
RedrawLists();
}
catch
{
MessageBox.Show("Something strange happened", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
private void removeFromReportButton_Click(object sender, EventArgs e)
{
/// Remove from the list (the last selected item first so that the indexes are not affected)
for (int i = reportListBox.SelectedIndices.Count - 1; i >= 0; i--)
{
ReportWaterMeters.RemoveAt(reportListBox.SelectedIndices[i]);
}
RedrawLists();
}
private void addToReportButton_Click(object sender, EventArgs e)
{
if (batchesQueried)
{
foreach (var b in QueryBatches)
{
foreach (var wm in b.WaterMeters) ReportWaterMeters.Add(wm);
}
}
else
{
foreach (var wm in QueryWaterMeters)
{
if (!ReportWaterMeters.Contains(wm)) ReportWaterMeters.Add(wm);
}
}
RedrawLists();
}
private void browseFileButton_Click(object sender, EventArgs e)
{
SaveFileDialog dlg = new SaveFileDialog();
dlg.Title = "Target file";
if (dlg.ShowDialog() == DialogResult.OK)
{
reportFileComboBox.Text = dlg.FileName;
}
}
private void addOracleDataButton_Click(object sender, EventArgs e)
{
#if IPERLST || IPERLST_SPECIAL
if (ReportWaterMeters.Count == 0) return;
/// Oracle database connection
OracleConnection conn = new OracleConnection("Data Source=STARA01.WORLD;User Id=deltachef;Password=deltachef;");
try
{
conn.Open();
for (int i = 0; i < ReportWaterMeters.Count; i++)
{
Results.Entities.WaterMeter wm = ReportWaterMeters[i];
IList<int> serialNrExes = new List<int>();
{
OracleParameter parm = new OracleParameter();
parm.OracleDbType = OracleDbType.Varchar2;
parm.Value = wm.SerialNr; /// PCB Nr.
OracleCommand cmd1 = new OracleCommand("SELECT Zaehlernummer, Auftragsnummer FROM VT_ZAEHLER_PD WHERE VT_Fernum = :1 AND ANBID = 4", conn);
cmd1.Parameters.Add(parm);
OracleDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
wm.SerialNrEx = dr.GetInt32(0);
wm.PurchaseOrder = dr.GetString(1);
}
dr.Close();
}
}
conn.Close();
}
catch (Exception exc)
{
MessageBox.Show(string.Format("Error when querying Oracle database:\r\n{0}", exc.Message),
"Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
RedrawLists();
return;
}
RedrawLists();
#endif
}
/// <summary>
/// Create ASC file in R.Uhlik format
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void makeAscFileButton_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(reportFileComboBox.Text))
{
MessageBox.Show("No report file selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (ReportItems_Single == null || ReportItems_Single.Count == 0)
{
MessageBox.Show("Please, configure the report first", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
using (TextWriter report = new StreamWriter(reportFileComboBox.Text, true))
{
foreach (var wm in ReportWaterMeters)
{
try
{
StringBuilder sb = new StringBuilder();
#if IPERLST || IPERLST_SPECIAL
sb.Append(wm.SerialNrEx);
#else
sb.Append(wm.SerialNr);
#endif
sb.Append(';'); sb.Append(wm.ProductName());
sb.Append(';'); sb.Append(wm.ApprovalInfo());
sb.Append(';'); sb.Append(wm.MetrologicalClass());
sb.Append(';'); sb.Append("0");
sb.Append(';'); sb.Append((1000 * (wm.GetTestRslt("Q1") != null ? wm.GetTestRslt("Q1").Qfrom() : 0)).ToString("F0")); /// Q1 nominal
sb.Append(';'); sb.Append((1000 * (wm.GetTestRslt("Q2") != null ? wm.GetTestRslt("Q2").Qfrom() : 0)).ToString("F0")); /// Q2 nominal
sb.Append(';'); sb.Append((1000 * (wm.GetTestRslt("Q3") != null ? wm.GetTestRslt("Q3").Qto() : 0)).ToString("F0")); /// Q3 nominal
sb.Append(';'); sb.Append("0"); /// Q4 nominal
sb.Append(';'); sb.Append("6"); /// Worker code
sb.Append(';'); sb.Append(ToShortStr(wm.EndTime()));
sb.Append(';'); sb.Append((wm.GetMeterTestRslt("Q1") != null ? wm.GetMeterTestRslt("Q1").Error : 99).ToString("F1")); /// Q1 Error [%]
sb.Append(';'); sb.Append((wm.GetMeterTestRslt("Q2") != null ? wm.GetMeterTestRslt("Q2").Error : 99).ToString("F1")); /// Q2 Error [%]
sb.Append(';'); sb.Append((wm.GetMeterTestRslt("Q3") != null ? wm.GetMeterTestRslt("Q3").Error : 99).ToString("F1")); /// Q3 Error [%]
sb.Append(';'); sb.Append("0"); /// Q4 Error [%]
sb.Append(';'); sb.Append(wm.BenchId().ToString()); ///
sb.Append(';'); sb.Append(wm.PurchaseOrder);
sb.Append(';'); sb.Append("");
sb.Append(';'); sb.Append("10000");
sb.Append(';'); sb.Append(wm.ProcedureName().Substring(0, 8));
sb.Append(";\""); sb.Append(wm.SerialNr); sb.Append('"');
report.WriteLine(sb);
}
catch (Exception exc)
{
string msg = exc.Message;
}
}
}
MessageBox.Show("Report saved", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
static string ToShortStr(DateTime date)
{
return (((date.Year % 100) * 100 + date.Month) * 100 + date.Day).ToString();
}
private void makeReportButton_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(reportFileComboBox.Text))
{
MessageBox.Show("No report file selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (ReportItems_Single == null || ReportItems_Single.Count == 0)
{
MessageBox.Show("Please, configure the report first", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
using (TextWriter report = new StreamWriter(reportFileComboBox.Text, true))
{
foreach (var wm in ReportWaterMeters)
{
try
{
StringBuilder sb = new StringBuilder();
#if IPERLST || IPERLST_SPECIAL
sb.Append(wm.SerialNrEx);
#else
sb.Append(wm.SerialNr);
#endif
sb.Append(";\""); sb.Append(wm.SerialNr); sb.Append('"'); /// PCB number
sb.Append(";\""); sb.Append(wm.ProcedureName()); sb.Append('"'); /// Procedure name
sb.Append(';'); sb.Append((1000 * (wm.GetTestRslt("q3") != null ? wm.GetTestRslt("q3").Qto() : 0)).ToString("F0")); /// Q3 nominal
sb.Append(';'); sb.Append((wm.GetMeterTestRslt("adjustment") != null ? wm.GetMeterTestRslt("adjustment").Error : 99).ToString("F2"));/// Adjustment Error [%]
sb.Append(';'); sb.Append((wm.GetMeterTestRslt("q3") != null ? wm.GetMeterTestRslt("q1").Error : 99).ToString("F2")); /// Q1 Error [%]
sb.Append(';'); sb.Append((wm.GetMeterTestRslt("q2") != null ? wm.GetMeterTestRslt("q2").Error : 99).ToString("F2")); /// Q2 Error [%]
sb.Append(';'); sb.Append((wm.GetMeterTestRslt("q1") != null ? wm.GetMeterTestRslt("q3").Error : 99).ToString("F2")); /// Q3 Error [%]
sb.Append(';'); sb.Append(wm.StartTime().ToShortTimeString());
sb.Append(';'); sb.Append(wm.EndTime().ToShortTimeString());
report.WriteLine(sb);
}
catch (Exception exc)
{
string msg = exc.Message;
}
}
}
MessageBox.Show("Report saved", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void configButton_Click(object sender, EventArgs e)
{
if ((new Forms.DatabaseSettingsDlg()).ShowDialog() == DialogResult.OK)
{
Results.DB.ConnectionString = Program.LocalSettings.ConnectionString1;
}
}
private void queryBatchesButton_Click(object sender, EventArgs e)
{
if (!purchaseOrderCheckBox.Checked && !procedureCheckBox.Checked &&
!filterDateCheckBox.Checked && !batchNrCheckBox.Checked)
{
return;
}
queryResultsListBox.Items.Clear();
try
{
ISession session = Results.DB.CreateSession();
IList<Batch> batches;
if (filterDateCheckBox.Checked)
{
batches = session.QueryOver<Batch>()
.WhereRestrictionOn(x => x.EndTime)
.IsBetween(fromDateTimePicker.Value.Date)
.And(toDateTimePicker.Value.Date.AddDays(1).AddTicks(-1))
//.OrderBy(x => x.BatchNr).Asc
.List<Batch>();
}
else
{
batches = session.QueryOver<Batch>()
.List<Batch>();
}
if (procedureCheckBox.Checked)
{
IList<Batch> batches2 = new List<Batch>();
foreach (var b in batches)
{
if (b.ProcedureName.Equals(procedureComboBox.Text)) batches2.Add(b);
}
batches = batches2;
}
if (purchaseOrderCheckBox.Checked)
{
IList<Batch> batches3 = new List<Batch>();
foreach (var b in batches)
{
if (b.WaterMeters[0].PurchaseOrder.Equals(purchaseOrderComboBox.Text)) batches3.Add(b);
}
batches = batches3;
}
QueryBatches = batches;
batchesQueried = true;
RedrawQueryList();
///
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void queryWatermetersButton_Click(object sender, EventArgs e)
{
if (!purchaseOrderCheckBox.Checked && !procedureCheckBox.Checked &&
!filterDateCheckBox.Checked && !batchNrCheckBox.Checked)
{
return;
}
queryResultsListBox.Items.Clear();
try
{
bool purchaseOrderFiltered = false;
bool procedureFiltered = false;
ISession session = Results.DB.CreateSession();
IList<WaterMeter> waterMeters;
if (filterDateCheckBox.Checked)
{
IList<Batch> batches = session.QueryOver<Batch>()
.WhereRestrictionOn(x => x.EndTime)
.IsBetween(fromDateTimePicker.Value.Date)
.And(toDateTimePicker.Value.Date.AddDays(1).AddTicks(-1))
//.OrderBy(x => x.BatchNr).Asc
.List<Batch>();
waterMeters = new List<WaterMeter>();
foreach (var b in batches)
{
foreach (var wm in b.WaterMeters) waterMeters.Add(wm);
}
}
else if (purchaseOrderCheckBox.Checked)
{
waterMeters = session.QueryOver<WaterMeter>()
.Where(x => (x.PurchaseOrder == purchaseOrderCheckBox.Text))
.List<WaterMeter>();
purchaseOrderFiltered = true;
}
else if (procedureCheckBox.Checked && !procedureFiltered)
{
waterMeters = session.QueryOver<WaterMeter>()
.Where(x => (x.Batch.ProcedureName == procedureComboBox.Text))
.List<WaterMeter>();
procedureFiltered = true;
}
else
{
waterMeters = session.QueryOver<WaterMeter>().List<WaterMeter>();
}
if (purchaseOrderCheckBox.Checked && !purchaseOrderFiltered)
{
IList<WaterMeter> waterMeters3 = new List<WaterMeter>();
foreach (var wm in waterMeters)
{
if (wm.PurchaseOrder.Equals(purchaseOrderComboBox.Text)) waterMeters3.Add(wm);
}
waterMeters = waterMeters3;
purchaseOrderFiltered = true;
}
if (procedureCheckBox.Checked && !procedureFiltered)
{
IList<WaterMeter> waterMeters2 = new List<WaterMeter>();
foreach (var wm in waterMeters)
{
if (wm.Batch.ProcedureName.Equals(procedureComboBox.Text)) waterMeters2.Add(wm);
}
waterMeters = waterMeters2;
procedureFiltered = true;
}
QueryWaterMeters = waterMeters;
batchesQueried = false;
RedrawQueryList();
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void queryResultsListBox_DoubleClick(object sender, EventArgs e)
{
}
private void reportListBox_DoubleClick(object sender, EventArgs e)
{
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -31,13 +31,6 @@ namespace ResultsBrowser
static readonly ILog log; /// log4net
/// <summary>
/// Main window object.
/// </summary>
public static MainWnd MainWnd;
public static RBrowserWnd RBrowserWnd;
public static ResultsBrowserWnd ResultsBrowserWnd;
static Program()
{
/// Program version string
@ -127,21 +120,13 @@ namespace ResultsBrowser
try
{
/// Open the main application window
log.Info("Creating the main window");
#if false //IPERLST || IPERLST_SPECIAL
MainWnd = new MainWnd();
log.Info("Opening the main window");
Application.Run(MainWnd);
#else
ResultsBrowserWnd = new ResultsBrowserWnd(args);
log.Info("Opening the main window");
Application.Run(ResultsBrowserWnd);
#endif
log.Info("Creating and opening the main window");
Application.Run(new ResultsBrowserWnd(args));
log.Info("The main window was closed");
}
catch (Exception e)
{
LogException(log, "Exception in Application.Run(MainWnd)", e);
LogException(log, "Exception in Application.Run(new ResultsBrowserWnd(args))", e);
}
finally
{

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.12.384.0")]
[assembly: AssemblyFileVersion("2.12.384.0")]
[assembly: AssemblyVersion("2.12.389.0")]
[assembly: AssemblyFileVersion("2.12.389.0")]

View File

@ -1,607 +0,0 @@
namespace ResultsBrowser
{
partial class RBrowserWnd
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.queryBatchesButton = new System.Windows.Forms.Button();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.queryResultsItemsLabel = new System.Windows.Forms.Label();
this.queryWatermetersButton = new System.Windows.Forms.Button();
this.batchNrGroupBox = new System.Windows.Forms.GroupBox();
this.batchNrToTextBox = new System.Windows.Forms.TextBox();
this.batchNrFromTextBox = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.batchNrCheckBox = new System.Windows.Forms.CheckBox();
this.removeFromQueryButton = new System.Windows.Forms.Button();
this.addToReportButton = new System.Windows.Forms.Button();
this.procedureGroupBox = new System.Windows.Forms.GroupBox();
this.procedureCheckBox = new System.Windows.Forms.CheckBox();
this.procedureComboBox = new System.Windows.Forms.ComboBox();
this.fromGroupBox = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.filterDateCheckBox = new System.Windows.Forms.CheckBox();
this.toDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.fromDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.purchaseOrderGroupBox = new System.Windows.Forms.GroupBox();
this.purchaseOrderCheckBox = new System.Windows.Forms.CheckBox();
this.purchaseOrderComboBox = new System.Windows.Forms.ComboBox();
this.queryResultsListBox = new System.Windows.Forms.ListBox();
this.configReportButton = new System.Windows.Forms.Button();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.splitContainer3 = new System.Windows.Forms.SplitContainer();
this.reportItemsLabel = new System.Windows.Forms.Label();
this.configButton = new System.Windows.Forms.Button();
this.makeReportButton = new System.Windows.Forms.Button();
this.removeFromReportButton = new System.Windows.Forms.Button();
this.reportFileGroupBox = new System.Windows.Forms.GroupBox();
this.browseFileButton = new System.Windows.Forms.Button();
this.reportFileComboBox = new System.Windows.Forms.ComboBox();
this.makeAscFileButton = new System.Windows.Forms.Button();
this.reportListBox = new System.Windows.Forms.ListBox();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.batchNrGroupBox.SuspendLayout();
this.procedureGroupBox.SuspendLayout();
this.fromGroupBox.SuspendLayout();
this.purchaseOrderGroupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit();
this.splitContainer3.Panel1.SuspendLayout();
this.splitContainer3.Panel2.SuspendLayout();
this.splitContainer3.SuspendLayout();
this.reportFileGroupBox.SuspendLayout();
this.SuspendLayout();
//
// queryBatchesButton
//
this.queryBatchesButton.Location = new System.Drawing.Point(130, 136);
this.queryBatchesButton.Name = "queryBatchesButton";
this.queryBatchesButton.Size = new System.Drawing.Size(108, 29);
this.queryBatchesButton.TabIndex = 3;
this.queryBatchesButton.Text = "Query batches";
this.queryBatchesButton.UseVisualStyleBackColor = true;
this.queryBatchesButton.Click += new System.EventHandler(this.queryBatchesButton_Click);
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.IsSplitterFixed = true;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.radioButton3);
this.splitContainer1.Panel1.Controls.Add(this.radioButton2);
this.splitContainer1.Panel1.Controls.Add(this.radioButton1);
this.splitContainer1.Panel1.Controls.Add(this.queryResultsItemsLabel);
this.splitContainer1.Panel1.Controls.Add(this.queryWatermetersButton);
this.splitContainer1.Panel1.Controls.Add(this.batchNrGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.removeFromQueryButton);
this.splitContainer1.Panel1.Controls.Add(this.addToReportButton);
this.splitContainer1.Panel1.Controls.Add(this.procedureGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.fromGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.queryBatchesButton);
this.splitContainer1.Panel1.Controls.Add(this.purchaseOrderGroupBox);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.queryResultsListBox);
this.splitContainer1.Size = new System.Drawing.Size(604, 624);
this.splitContainer1.SplitterDistance = 190;
this.splitContainer1.TabIndex = 5;
//
// radioButton3
//
this.radioButton3.AutoSize = true;
this.radioButton3.Location = new System.Drawing.Point(15, 164);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(61, 17);
this.radioButton3.TabIndex = 16;
this.radioButton3.TabStop = true;
this.radioButton3.Text = "bench3";
this.radioButton3.UseVisualStyleBackColor = true;
this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(15, 145);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(61, 17);
this.radioButton2.TabIndex = 15;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "bench2";
this.radioButton2.UseVisualStyleBackColor = true;
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(15, 126);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(61, 17);
this.radioButton1.TabIndex = 14;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "bench1";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// queryResultsItemsLabel
//
this.queryResultsItemsLabel.AutoSize = true;
this.queryResultsItemsLabel.Location = new System.Drawing.Point(255, 177);
this.queryResultsItemsLabel.Name = "queryResultsItemsLabel";
this.queryResultsItemsLabel.Size = new System.Drawing.Size(40, 13);
this.queryResultsItemsLabel.TabIndex = 13;
this.queryResultsItemsLabel.Text = "0 items";
//
// queryWatermetersButton
//
this.queryWatermetersButton.Location = new System.Drawing.Point(258, 136);
this.queryWatermetersButton.Name = "queryWatermetersButton";
this.queryWatermetersButton.Size = new System.Drawing.Size(108, 29);
this.queryWatermetersButton.TabIndex = 12;
this.queryWatermetersButton.Text = "Query water meters";
this.queryWatermetersButton.UseVisualStyleBackColor = true;
this.queryWatermetersButton.Click += new System.EventHandler(this.queryWatermetersButton_Click);
//
// batchNrGroupBox
//
this.batchNrGroupBox.Controls.Add(this.batchNrToTextBox);
this.batchNrGroupBox.Controls.Add(this.batchNrFromTextBox);
this.batchNrGroupBox.Controls.Add(this.label4);
this.batchNrGroupBox.Controls.Add(this.label3);
this.batchNrGroupBox.Controls.Add(this.batchNrCheckBox);
this.batchNrGroupBox.Location = new System.Drawing.Point(222, 14);
this.batchNrGroupBox.Name = "batchNrGroupBox";
this.batchNrGroupBox.Size = new System.Drawing.Size(149, 104);
this.batchNrGroupBox.TabIndex = 11;
this.batchNrGroupBox.TabStop = false;
//
// batchNrToTextBox
//
this.batchNrToTextBox.Location = new System.Drawing.Point(56, 65);
this.batchNrToTextBox.Name = "batchNrToTextBox";
this.batchNrToTextBox.Size = new System.Drawing.Size(62, 20);
this.batchNrToTextBox.TabIndex = 5;
//
// batchNrFromTextBox
//
this.batchNrFromTextBox.Location = new System.Drawing.Point(56, 33);
this.batchNrFromTextBox.Name = "batchNrFromTextBox";
this.batchNrFromTextBox.Size = new System.Drawing.Size(62, 20);
this.batchNrFromTextBox.TabIndex = 4;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(19, 68);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(20, 13);
this.label4.TabIndex = 3;
this.label4.Text = "To";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(19, 36);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(30, 13);
this.label3.TabIndex = 2;
this.label3.Text = "From";
//
// batchNrCheckBox
//
this.batchNrCheckBox.AutoSize = true;
this.batchNrCheckBox.Location = new System.Drawing.Point(19, 0);
this.batchNrCheckBox.Name = "batchNrCheckBox";
this.batchNrCheckBox.Size = new System.Drawing.Size(116, 17);
this.batchNrCheckBox.TabIndex = 1;
this.batchNrCheckBox.Text = "Filter batch number";
this.batchNrCheckBox.UseVisualStyleBackColor = true;
//
// removeFromQueryButton
//
this.removeFromQueryButton.Location = new System.Drawing.Point(377, 136);
this.removeFromQueryButton.Name = "removeFromQueryButton";
this.removeFromQueryButton.Size = new System.Drawing.Size(114, 29);
this.removeFromQueryButton.TabIndex = 9;
this.removeFromQueryButton.Text = "Remove selected";
this.removeFromQueryButton.UseVisualStyleBackColor = true;
this.removeFromQueryButton.Click += new System.EventHandler(this.removeFromQueryButton_Click);
//
// addToReportButton
//
this.addToReportButton.Location = new System.Drawing.Point(558, 130);
this.addToReportButton.Name = "addToReportButton";
this.addToReportButton.Size = new System.Drawing.Size(46, 40);
this.addToReportButton.TabIndex = 8;
this.addToReportButton.Text = ">>>";
this.addToReportButton.UseVisualStyleBackColor = true;
this.addToReportButton.Click += new System.EventHandler(this.addToReportButton_Click);
//
// procedureGroupBox
//
this.procedureGroupBox.Controls.Add(this.procedureCheckBox);
this.procedureGroupBox.Controls.Add(this.procedureComboBox);
this.procedureGroupBox.Location = new System.Drawing.Point(15, 68);
this.procedureGroupBox.Name = "procedureGroupBox";
this.procedureGroupBox.Size = new System.Drawing.Size(201, 50);
this.procedureGroupBox.TabIndex = 6;
this.procedureGroupBox.TabStop = false;
//
// procedureCheckBox
//
this.procedureCheckBox.AutoSize = true;
this.procedureCheckBox.Location = new System.Drawing.Point(19, 0);
this.procedureCheckBox.Name = "procedureCheckBox";
this.procedureCheckBox.Size = new System.Drawing.Size(99, 17);
this.procedureCheckBox.TabIndex = 1;
this.procedureCheckBox.Text = "Filter procedure";
this.procedureCheckBox.UseVisualStyleBackColor = true;
this.procedureCheckBox.CheckedChanged += new System.EventHandler(this.procedureCheckBox_CheckedChanged);
//
// procedureComboBox
//
this.procedureComboBox.FormattingEnabled = true;
this.procedureComboBox.Location = new System.Drawing.Point(18, 19);
this.procedureComboBox.Name = "procedureComboBox";
this.procedureComboBox.Size = new System.Drawing.Size(170, 21);
this.procedureComboBox.TabIndex = 0;
//
// fromGroupBox
//
this.fromGroupBox.Controls.Add(this.label2);
this.fromGroupBox.Controls.Add(this.label1);
this.fromGroupBox.Controls.Add(this.filterDateCheckBox);
this.fromGroupBox.Controls.Add(this.toDateTimePicker);
this.fromGroupBox.Controls.Add(this.fromDateTimePicker);
this.fromGroupBox.Location = new System.Drawing.Point(377, 14);
this.fromGroupBox.Name = "fromGroupBox";
this.fromGroupBox.Size = new System.Drawing.Size(221, 104);
this.fromGroupBox.TabIndex = 3;
this.fromGroupBox.TabStop = false;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(16, 68);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(20, 13);
this.label2.TabIndex = 3;
this.label2.Text = "To";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(16, 36);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(30, 13);
this.label1.TabIndex = 2;
this.label1.Text = "From";
//
// filterDateCheckBox
//
this.filterDateCheckBox.AutoSize = true;
this.filterDateCheckBox.Location = new System.Drawing.Point(19, -1);
this.filterDateCheckBox.Name = "filterDateCheckBox";
this.filterDateCheckBox.Size = new System.Drawing.Size(72, 17);
this.filterDateCheckBox.TabIndex = 1;
this.filterDateCheckBox.Text = "Filter date";
this.filterDateCheckBox.UseVisualStyleBackColor = true;
//
// toDateTimePicker
//
this.toDateTimePicker.Location = new System.Drawing.Point(56, 65);
this.toDateTimePicker.Name = "toDateTimePicker";
this.toDateTimePicker.Size = new System.Drawing.Size(151, 20);
this.toDateTimePicker.TabIndex = 0;
//
// fromDateTimePicker
//
this.fromDateTimePicker.Location = new System.Drawing.Point(56, 32);
this.fromDateTimePicker.Name = "fromDateTimePicker";
this.fromDateTimePicker.Size = new System.Drawing.Size(151, 20);
this.fromDateTimePicker.TabIndex = 0;
//
// purchaseOrderGroupBox
//
this.purchaseOrderGroupBox.Controls.Add(this.purchaseOrderCheckBox);
this.purchaseOrderGroupBox.Controls.Add(this.purchaseOrderComboBox);
this.purchaseOrderGroupBox.Location = new System.Drawing.Point(15, 14);
this.purchaseOrderGroupBox.Name = "purchaseOrderGroupBox";
this.purchaseOrderGroupBox.Size = new System.Drawing.Size(201, 50);
this.purchaseOrderGroupBox.TabIndex = 2;
this.purchaseOrderGroupBox.TabStop = false;
//
// purchaseOrderCheckBox
//
this.purchaseOrderCheckBox.AutoSize = true;
this.purchaseOrderCheckBox.Location = new System.Drawing.Point(19, 0);
this.purchaseOrderCheckBox.Name = "purchaseOrderCheckBox";
this.purchaseOrderCheckBox.Size = new System.Drawing.Size(122, 17);
this.purchaseOrderCheckBox.TabIndex = 1;
this.purchaseOrderCheckBox.Text = "Filter purchase order";
this.purchaseOrderCheckBox.UseVisualStyleBackColor = true;
//
// purchaseOrderComboBox
//
this.purchaseOrderComboBox.FormattingEnabled = true;
this.purchaseOrderComboBox.Location = new System.Drawing.Point(18, 19);
this.purchaseOrderComboBox.Name = "purchaseOrderComboBox";
this.purchaseOrderComboBox.Size = new System.Drawing.Size(170, 21);
this.purchaseOrderComboBox.TabIndex = 0;
//
// queryResultsListBox
//
this.queryResultsListBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.queryResultsListBox.FormattingEnabled = true;
this.queryResultsListBox.Location = new System.Drawing.Point(0, 0);
this.queryResultsListBox.Name = "queryResultsListBox";
this.queryResultsListBox.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple;
this.queryResultsListBox.Size = new System.Drawing.Size(604, 430);
this.queryResultsListBox.TabIndex = 0;
this.queryResultsListBox.DoubleClick += new System.EventHandler(this.queryResultsListBox_DoubleClick);
//
// configReportButton
//
this.configReportButton.Location = new System.Drawing.Point(226, 95);
this.configReportButton.Name = "configReportButton";
this.configReportButton.Size = new System.Drawing.Size(103, 47);
this.configReportButton.TabIndex = 5;
this.configReportButton.Text = "Configure Report";
this.configReportButton.UseVisualStyleBackColor = true;
this.configReportButton.Click += new System.EventHandler(this.configReportButton_Click);
//
// splitContainer2
//
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer2.Location = new System.Drawing.Point(0, 0);
this.splitContainer2.Name = "splitContainer2";
//
// splitContainer2.Panel1
//
this.splitContainer2.Panel1.Controls.Add(this.splitContainer1);
//
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.splitContainer3);
this.splitContainer2.Size = new System.Drawing.Size(1284, 624);
this.splitContainer2.SplitterDistance = 604;
this.splitContainer2.TabIndex = 6;
//
// splitContainer3
//
this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer3.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer3.IsSplitterFixed = true;
this.splitContainer3.Location = new System.Drawing.Point(0, 0);
this.splitContainer3.Name = "splitContainer3";
this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer3.Panel1
//
this.splitContainer3.Panel1.Controls.Add(this.reportItemsLabel);
this.splitContainer3.Panel1.Controls.Add(this.configButton);
this.splitContainer3.Panel1.Controls.Add(this.makeReportButton);
this.splitContainer3.Panel1.Controls.Add(this.removeFromReportButton);
this.splitContainer3.Panel1.Controls.Add(this.reportFileGroupBox);
this.splitContainer3.Panel1.Controls.Add(this.makeAscFileButton);
this.splitContainer3.Panel1.Controls.Add(this.configReportButton);
//
// splitContainer3.Panel2
//
this.splitContainer3.Panel2.Controls.Add(this.reportListBox);
this.splitContainer3.Size = new System.Drawing.Size(676, 624);
this.splitContainer3.SplitterDistance = 190;
this.splitContainer3.TabIndex = 6;
//
// reportItemsLabel
//
this.reportItemsLabel.AutoSize = true;
this.reportItemsLabel.Location = new System.Drawing.Point(261, 177);
this.reportItemsLabel.Name = "reportItemsLabel";
this.reportItemsLabel.Size = new System.Drawing.Size(40, 13);
this.reportItemsLabel.TabIndex = 14;
this.reportItemsLabel.Text = "0 items";
//
// configButton
//
this.configButton.Location = new System.Drawing.Point(589, 14);
this.configButton.Name = "configButton";
this.configButton.Size = new System.Drawing.Size(75, 71);
this.configButton.TabIndex = 12;
this.configButton.Text = "Configure";
this.configButton.UseVisualStyleBackColor = true;
this.configButton.Click += new System.EventHandler(this.configButton_Click);
//
// makeReportButton
//
this.makeReportButton.Location = new System.Drawing.Point(335, 95);
this.makeReportButton.Name = "makeReportButton";
this.makeReportButton.Size = new System.Drawing.Size(103, 47);
this.makeReportButton.TabIndex = 11;
this.makeReportButton.Text = "Make Report";
this.makeReportButton.UseVisualStyleBackColor = true;
this.makeReportButton.Click += new System.EventHandler(this.makeReportButton_Click);
//
// removeFromReportButton
//
this.removeFromReportButton.Location = new System.Drawing.Point(60, 136);
this.removeFromReportButton.Name = "removeFromReportButton";
this.removeFromReportButton.Size = new System.Drawing.Size(114, 29);
this.removeFromReportButton.TabIndex = 10;
this.removeFromReportButton.Text = "Remove selected";
this.removeFromReportButton.UseVisualStyleBackColor = true;
this.removeFromReportButton.Click += new System.EventHandler(this.removeFromReportButton_Click);
//
// reportFileGroupBox
//
this.reportFileGroupBox.Controls.Add(this.browseFileButton);
this.reportFileGroupBox.Controls.Add(this.reportFileComboBox);
this.reportFileGroupBox.Location = new System.Drawing.Point(18, 14);
this.reportFileGroupBox.Name = "reportFileGroupBox";
this.reportFileGroupBox.Size = new System.Drawing.Size(546, 63);
this.reportFileGroupBox.TabIndex = 8;
this.reportFileGroupBox.TabStop = false;
this.reportFileGroupBox.Text = "Report file name";
//
// browseFileButton
//
this.browseFileButton.Location = new System.Drawing.Point(453, 22);
this.browseFileButton.Name = "browseFileButton";
this.browseFileButton.Size = new System.Drawing.Size(75, 27);
this.browseFileButton.TabIndex = 2;
this.browseFileButton.Text = "Browse";
this.browseFileButton.UseVisualStyleBackColor = true;
this.browseFileButton.Click += new System.EventHandler(this.browseFileButton_Click);
//
// reportFileComboBox
//
this.reportFileComboBox.FormattingEnabled = true;
this.reportFileComboBox.Location = new System.Drawing.Point(20, 25);
this.reportFileComboBox.Name = "reportFileComboBox";
this.reportFileComboBox.Size = new System.Drawing.Size(414, 21);
this.reportFileComboBox.TabIndex = 1;
//
// makeAscFileButton
//
this.makeAscFileButton.Location = new System.Drawing.Point(443, 95);
this.makeAscFileButton.Name = "makeAscFileButton";
this.makeAscFileButton.Size = new System.Drawing.Size(103, 47);
this.makeAscFileButton.TabIndex = 7;
this.makeAscFileButton.Text = "Make *.asc File";
this.makeAscFileButton.UseVisualStyleBackColor = true;
this.makeAscFileButton.Click += new System.EventHandler(this.makeAscFileButton_Click);
//
// reportListBox
//
this.reportListBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.reportListBox.FormattingEnabled = true;
this.reportListBox.Location = new System.Drawing.Point(0, 0);
this.reportListBox.Name = "reportListBox";
this.reportListBox.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple;
this.reportListBox.Size = new System.Drawing.Size(676, 430);
this.reportListBox.TabIndex = 0;
this.reportListBox.DoubleClick += new System.EventHandler(this.reportListBox_DoubleClick);
//
// RBrowserWnd
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1284, 624);
this.Controls.Add(this.splitContainer2);
this.Name = "RBrowserWnd";
this.Text = "Results browser";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainWnd_FormClosing);
this.Load += new System.EventHandler(this.MainWnd_Load);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.batchNrGroupBox.ResumeLayout(false);
this.batchNrGroupBox.PerformLayout();
this.procedureGroupBox.ResumeLayout(false);
this.procedureGroupBox.PerformLayout();
this.fromGroupBox.ResumeLayout(false);
this.fromGroupBox.PerformLayout();
this.purchaseOrderGroupBox.ResumeLayout(false);
this.purchaseOrderGroupBox.PerformLayout();
this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
this.splitContainer2.ResumeLayout(false);
this.splitContainer3.Panel1.ResumeLayout(false);
this.splitContainer3.Panel1.PerformLayout();
this.splitContainer3.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit();
this.splitContainer3.ResumeLayout(false);
this.reportFileGroupBox.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button queryBatchesButton;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.GroupBox fromGroupBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.CheckBox filterDateCheckBox;
private System.Windows.Forms.DateTimePicker toDateTimePicker;
private System.Windows.Forms.DateTimePicker fromDateTimePicker;
private System.Windows.Forms.GroupBox purchaseOrderGroupBox;
private System.Windows.Forms.CheckBox purchaseOrderCheckBox;
private System.Windows.Forms.ComboBox purchaseOrderComboBox;
private System.Windows.Forms.Button configReportButton;
private System.Windows.Forms.GroupBox procedureGroupBox;
private System.Windows.Forms.CheckBox procedureCheckBox;
private System.Windows.Forms.ComboBox procedureComboBox;
private System.Windows.Forms.SplitContainer splitContainer2;
private System.Windows.Forms.SplitContainer splitContainer3;
private System.Windows.Forms.Button makeAscFileButton;
private System.Windows.Forms.ListBox queryResultsListBox;
private System.Windows.Forms.ListBox reportListBox;
private System.Windows.Forms.GroupBox reportFileGroupBox;
private System.Windows.Forms.Button browseFileButton;
private System.Windows.Forms.ComboBox reportFileComboBox;
private System.Windows.Forms.Button removeFromQueryButton;
private System.Windows.Forms.Button addToReportButton;
private System.Windows.Forms.Button removeFromReportButton;
private System.Windows.Forms.GroupBox batchNrGroupBox;
private System.Windows.Forms.TextBox batchNrToTextBox;
private System.Windows.Forms.TextBox batchNrFromTextBox;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.CheckBox batchNrCheckBox;
private System.Windows.Forms.Button makeReportButton;
private System.Windows.Forms.Button configButton;
private System.Windows.Forms.Button queryWatermetersButton;
private System.Windows.Forms.Label queryResultsItemsLabel;
private System.Windows.Forms.Label reportItemsLabel;
private System.Windows.Forms.RadioButton radioButton3;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton1;
}
}

View File

@ -1,627 +0,0 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using log4net;
using NHibernate;
using Results.Entities;
namespace ResultsBrowser
{
public partial class RBrowserWnd : Form
{
static readonly ILog log = LogManager.GetLogger(typeof(RBrowserWnd));
bool batchesQueried;
public static IList<Batch> QueryBatches;
public static IList<WaterMeter> QueryWaterMeters;
public static IList<Batch> ReportBatches;
public static IList<WaterMeter> ReportWaterMeters;
public IList<Results.ItemSpec> ReportItems_Single;
public IList<Results.ItemSpec> ReportItems_Compound;
int batchFrom;
int batchTo;
public RBrowserWnd()
{
InitializeComponent();
QueryBatches = new List<Batch>();
QueryWaterMeters = new List<WaterMeter>();
ReportBatches = new List<Batch>();
ReportWaterMeters = new List<WaterMeter>();
}
private void MainWnd_Load(object sender, EventArgs e)
{
PrepareComboBoxHistory(Program.LocalSettings.PurchaseOrderHistory, purchaseOrderComboBox);
PrepareComboBoxHistory(Program.LocalSettings.ProcedureHistory, procedureComboBox);
PrepareComboBoxHistory(Program.LocalSettings.ReportFileNameHistory, reportFileComboBox);
purchaseOrderComboBox.Text = Program.LocalSettings.LastPurchaseOrder;
procedureComboBox.Text = Program.LocalSettings.LastProcedure;
reportFileComboBox.Text = Program.LocalSettings.LastReportFileName;
ReportItems_Single = Results.ItemSpec.FromStrArray(Program.LocalSettings.ReportItems_Single);
ReportItems_Compound = Results.ItemSpec.FromStrArray(Program.LocalSettings.ReportItems_Compound);
purchaseOrderCheckBox.Checked = Program.LocalSettings.FilterPurchaseOrder;
procedureCheckBox.Checked = Program.LocalSettings.FilterProcedure;
batchNrCheckBox.Checked = Program.LocalSettings.FilterBatchNr;
filterDateCheckBox.Checked = Program.LocalSettings.FilterDate;
batchNrFromTextBox.Text = Program.LocalSettings.BatchFrom;
batchNrToTextBox.Text = Program.LocalSettings.BatchTo;
Results.DB.ConnectionString = Program.LocalSettings.ConnectionString1;
UpdateRadioButtons();
radioButton1.Checked = true;
radioButton2.Checked = false;
radioButton3.Checked = false;
}
void UpdateRadioButtons()
{
if (string.IsNullOrEmpty(Program.LocalSettings.Bench1))
{
radioButton1.Visible = false;
}
else
{
radioButton1.Visible = true;
radioButton1.Text = Program.LocalSettings.Bench1;
}
if (string.IsNullOrEmpty(Program.LocalSettings.Bench2))
{
radioButton2.Visible = false;
}
else
{
radioButton2.Visible = true;
radioButton2.Text = Program.LocalSettings.Bench1;
}
if (string.IsNullOrEmpty(Program.LocalSettings.Bench3))
{
radioButton3.Visible = false;
}
else
{
radioButton3.Visible = true;
radioButton3.Text = Program.LocalSettings.Bench1;
}
}
private void MainWnd_FormClosing(object sender, FormClosingEventArgs e)
{
Program.LocalSettings.UpdateHistory(purchaseOrderComboBox.Text, ref Program.LocalSettings.PurchaseOrderHistory);
Program.LocalSettings.UpdateHistory(procedureComboBox.Text, ref Program.LocalSettings.PurchaseOrderHistory);
Program.LocalSettings.UpdateHistory(reportFileComboBox.Text, ref Program.LocalSettings.ReportFileNameHistory);
Program.LocalSettings.LastPurchaseOrder = purchaseOrderComboBox.Text;
Program.LocalSettings.LastProcedure = procedureComboBox.Text;
Program.LocalSettings.LastReportFileName = reportFileComboBox.Text;
Program.LocalSettings.ReportItems_Single = Results.ItemSpec.ToStrArray(ReportItems_Single);
Program.LocalSettings.ReportItems_Compound = Results.ItemSpec.ToStrArray(ReportItems_Compound);
Program.LocalSettings.FilterPurchaseOrder = purchaseOrderCheckBox.Checked;
Program.LocalSettings.FilterProcedure = procedureCheckBox.Checked;
Program.LocalSettings.FilterBatchNr = batchNrCheckBox.Checked;
Program.LocalSettings.FilterDate = filterDateCheckBox.Checked;
Program.LocalSettings.BatchFrom = batchNrFromTextBox.Text;
Program.LocalSettings.BatchTo = batchNrToTextBox.Text;
Program.LocalSettings.Save();
}
void RedrawLists()
{
RedrawQueryList();
RedrawReportList();
}
void RedrawQueryList()
{
queryResultsListBox.Items.Clear();
if (batchesQueried)
{
foreach (var b in QueryBatches) queryResultsListBox.Items.Add(b.ToString());
}
else
{
foreach (var wmr in QueryWaterMeters) queryResultsListBox.Items.Add(wmr);
}
int nrItems = queryResultsListBox.Items.Count;
if (nrItems == 0) queryResultsListBox.Items.Add("<empty>");
queryResultsItemsLabel.Text = string.Format("{0} items", nrItems);
}
void RedrawReportList()
{
reportListBox.Items.Clear();
foreach (var wmr in ReportWaterMeters) reportListBox.Items.Add(wmr);
int nrItems = reportListBox.Items.Count;
if (nrItems == 0) reportListBox.Items.Add("<empty>");
reportItemsLabel.Text = string.Format("{0} items", nrItems);
}
/// <summary>
/// Load Purchase order combo box items from the LocalSettings PurchaseOrderHistory array
/// </summary>
/// <param name="comboBox">Puchase order ComboBox</param>
void PrepareComboBoxHistory(string[] history, ComboBox comboBox)
{
if (history == null || history.Length == 0) return;
for (int i = 0; i < history.Length; i++) comboBox.Items.Add(history[i]);
if (comboBox.Items.Count > 0) comboBox.Text = comboBox.Items[0].ToString();
}
private bool ParseAllFields()
{
try
{
if (batchNrCheckBox.Checked)
{
batchFrom = int.Parse(batchNrFromTextBox.Text);
batchTo = int.Parse(batchNrToTextBox.Text);
if (batchFrom < 0) throw new Exception("Batch numbers: from < 0 !");
if (batchTo < batchFrom) throw new Exception("Batch numbers: from > to !");
}
return true;
}
catch (Exception e)
{
MessageBox.Show(string.Format("{0}", e.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return false;
}
}
private void filterDateCheckBox_CheckedChanged(object sender, EventArgs e)
{
fromDateTimePicker.Enabled = toDateTimePicker.Enabled = filterDateCheckBox.Checked;
}
private void purchaseOrderCheckBox_CheckedChanged(object sender, EventArgs e)
{
purchaseOrderComboBox.Enabled = purchaseOrderCheckBox.Checked;
}
private void procedureCheckBox_CheckedChanged(object sender, EventArgs e)
{
procedureComboBox.Enabled = procedureCheckBox.Checked;
}
private void clearButton_Click(object sender, EventArgs e)
{
QueryWaterMeters.Clear();
queryResultsListBox.Items.Clear();
}
private void configReportButton_Click(object sender, EventArgs e)
{
Forms.ResultsConfig dlg = new Forms.ResultsConfig(false);
dlg.ReportItems_Single = ReportItems_Single;
dlg.ReportItems_Compound = ReportItems_Compound;
if (DialogResult.OK == dlg.ShowDialog())
{
ReportItems_Single = dlg.ReportItems_Single;
ReportItems_Compound = dlg.ReportItems_Compound;
Program.LocalSettings.ReportItems_Single = Results.ItemSpec.ToStrArray(ReportItems_Single);
Program.LocalSettings.ReportItems_Compound = Results.ItemSpec.ToStrArray(ReportItems_Compound);
}
}
private void removeFromQueryButton_Click(object sender, EventArgs e)
{
try
{
/// Remove from the list (the last selected item first so that the indexes are not affected)
for (int i = queryResultsListBox.SelectedIndices.Count - 1; i >= 0; i--)
{
if (batchesQueried)
{
QueryBatches.RemoveAt(queryResultsListBox.SelectedIndices[i]);
}
else
{
QueryWaterMeters.RemoveAt(queryResultsListBox.SelectedIndices[i]);
}
}
RedrawLists();
}
catch
{
MessageBox.Show("Something strange happened", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
private void removeFromReportButton_Click(object sender, EventArgs e)
{
/// Remove from the list (the last selected item first so that the indexes are not affected)
for (int i = reportListBox.SelectedIndices.Count - 1; i >= 0; i--)
{
ReportWaterMeters.RemoveAt(reportListBox.SelectedIndices[i]);
}
RedrawLists();
}
private void addToReportButton_Click(object sender, EventArgs e)
{
if (batchesQueried)
{
foreach (var b in QueryBatches)
{
foreach (var wm in b.WaterMeters) ReportWaterMeters.Add(wm);
}
}
else
{
foreach (var wm in QueryWaterMeters)
{
if (!ReportWaterMeters.Contains(wm)) ReportWaterMeters.Add(wm);
}
}
RedrawLists();
}
private void browseFileButton_Click(object sender, EventArgs e)
{
SaveFileDialog dlg = new SaveFileDialog();
dlg.Title = "Target file";
if (dlg.ShowDialog() == DialogResult.OK)
{
reportFileComboBox.Text = dlg.FileName;
}
}
/// <summary>
/// Create ASC file in R.Uhlik format
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void makeAscFileButton_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(reportFileComboBox.Text))
{
MessageBox.Show("No report file selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (ReportItems_Single == null || ReportItems_Single.Count == 0)
{
MessageBox.Show("Please, configure the report first", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
using (TextWriter report = new StreamWriter(reportFileComboBox.Text, true))
{
foreach (var wm in ReportWaterMeters)
{
try
{
StringBuilder sb = new StringBuilder();
sb.Append(wm.SerialNr);
sb.Append(';'); sb.Append(wm.ProductName());
sb.Append(';'); sb.Append(wm.ApprovalInfo());
sb.Append(';'); sb.Append(wm.MetrologicalClass());
sb.Append(';'); sb.Append("0");
sb.Append(';'); sb.Append((1000 * (wm.GetTestRslt("Q1") != null ? wm.GetTestRslt("Q1").Qfrom() : 0)).ToString("F0")); /// Q1 nominal
sb.Append(';'); sb.Append((1000 * (wm.GetTestRslt("Q2") != null ? wm.GetTestRslt("Q2").Qfrom() : 0)).ToString("F0")); /// Q2 nominal
sb.Append(';'); sb.Append((1000 * (wm.GetTestRslt("Q3") != null ? wm.GetTestRslt("Q3").Qto() : 0)).ToString("F0")); /// Q3 nominal
sb.Append(';'); sb.Append("0"); /// Q4 nominal
sb.Append(';'); sb.Append("6"); /// Worker code
sb.Append(';'); sb.Append(ToShortStr(wm.EndTime()));
sb.Append(';'); sb.Append((wm.GetMeterTestRslt("Q1") != null ? wm.GetMeterTestRslt("Q1").Error : 99).ToString("F1")); /// Q1 Error [%]
sb.Append(';'); sb.Append((wm.GetMeterTestRslt("Q2") != null ? wm.GetMeterTestRslt("Q2").Error : 99).ToString("F1")); /// Q2 Error [%]
sb.Append(';'); sb.Append((wm.GetMeterTestRslt("Q3") != null ? wm.GetMeterTestRslt("Q3").Error : 99).ToString("F1")); /// Q3 Error [%]
sb.Append(';'); sb.Append("0"); /// Q4 Error [%]
sb.Append(';'); sb.Append(wm.BenchId().ToString()); ///
sb.Append(';'); sb.Append(wm.PurchaseOrder);
sb.Append(';'); sb.Append("");
sb.Append(';'); sb.Append("10000");
sb.Append(';'); sb.Append(wm.ProcedureName().Substring(0, 8));
sb.Append(";\""); sb.Append(wm.SerialNr); sb.Append('"');
report.WriteLine(sb);
}
catch (Exception exc)
{
string msg = exc.Message;
}
}
}
MessageBox.Show("Report saved", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
static string ToShortStr(DateTime date)
{
return (((date.Year % 100) * 100 + date.Month) * 100 + date.Day).ToString();
}
private void makeReportButton_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(reportFileComboBox.Text))
{
MessageBox.Show("No report file selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (ReportItems_Single == null || ReportItems_Single.Count == 0)
{
MessageBox.Show("Please, configure the report first", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
using (TextWriter report = new StreamWriter(reportFileComboBox.Text, true))
{
foreach (var wm in ReportWaterMeters)
{
try
{
StringBuilder sb = new StringBuilder();
sb.Append(wm.SerialNr);
sb.Append(";\""); sb.Append(wm.SerialNr); sb.Append('"'); /// PCB number
sb.Append(";\""); sb.Append(wm.ProcedureName()); sb.Append('"'); /// Procedure name
sb.Append(';'); sb.Append((1000 * (wm.GetTestRslt("q3") != null ? wm.GetTestRslt("q3").Qto() : 0)).ToString("F0")); /// Q3 nominal
sb.Append(';'); sb.Append((wm.GetMeterTestRslt("adjustment") != null ? wm.GetMeterTestRslt("adjustment").Error : 99).ToString("F2"));/// Adjustment Error [%]
sb.Append(';'); sb.Append((wm.GetMeterTestRslt("q3") != null ? wm.GetMeterTestRslt("q1").Error : 99).ToString("F2")); /// Q1 Error [%]
sb.Append(';'); sb.Append((wm.GetMeterTestRslt("q2") != null ? wm.GetMeterTestRslt("q2").Error : 99).ToString("F2")); /// Q2 Error [%]
sb.Append(';'); sb.Append((wm.GetMeterTestRslt("q1") != null ? wm.GetMeterTestRslt("q3").Error : 99).ToString("F2")); /// Q3 Error [%]
sb.Append(';'); sb.Append(wm.StartTime().ToShortTimeString());
sb.Append(';'); sb.Append(wm.EndTime().ToShortTimeString());
report.WriteLine(sb);
}
catch (Exception exc)
{
string msg = exc.Message;
}
}
}
MessageBox.Show("Report saved", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void configButton_Click(object sender, EventArgs e)
{
if ((new Forms.DatabaseSettingsDlg()).ShowDialog() == DialogResult.OK)
{
Results.DB.ConnectionString = Program.LocalSettings.ConnectionString1;
radioButton1.Text = Program.LocalSettings.Bench1;
radioButton2.Text = Program.LocalSettings.Bench2;
radioButton3.Text = Program.LocalSettings.Bench3;
}
}
private void queryBatchesButton_Click(object sender, EventArgs e)
{
if (!ParseAllFields())
{
MessageBox.Show("Something's wrong", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (!purchaseOrderCheckBox.Checked && !procedureCheckBox.Checked &&
!filterDateCheckBox.Checked && !batchNrCheckBox.Checked)
{
MessageBox.Show("At least one filter must be on", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
queryResultsListBox.Items.Clear();
try
{
ISession session = Results.DB.CreateSession();
IList<Batch> batches;
if (filterDateCheckBox.Checked)
{
batches = session.QueryOver<Batch>()
.WhereRestrictionOn(x => x.EndTime)
.IsBetween(fromDateTimePicker.Value.Date)
.And(toDateTimePicker.Value.Date.AddDays(1).AddTicks(-1))
//.OrderBy(x => x.BatchNr).Asc
.List<Batch>();
}
else if (batchNrCheckBox.Checked)
{
batches = session.QueryOver<Batch>()
.WhereRestrictionOn(x => x.BatchNr)
.IsBetween(batchFrom).And(batchTo)
.List<Batch>();
}
else
{
batches = new List<Batch>();
}
//if (procedureCheckBox.Checked)
//{
// IList<Batch> batches2 = new List<Batch>();
// foreach (var b in batches)
// {
// if (b.ProcedureName.Equals(procedureComboBox.Text)) batches2.Add(b);
// }
// batches = batches2;
//}
//if (purchaseOrderCheckBox.Checked)
//{
// IList<Batch> batches3 = new List<Batch>();
// foreach (var b in batches)
// {
// if (b.WaterMeters[0].PurchaseOrder.Equals(purchaseOrderComboBox.Text)) batches3.Add(b);
// }
// batches = batches3;
//}
QueryBatches = batches;
batchesQueried = true;
RedrawQueryList();
///
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void queryWatermetersButton_Click(object sender, EventArgs e)
{
if (!purchaseOrderCheckBox.Checked && !procedureCheckBox.Checked &&
!filterDateCheckBox.Checked && !batchNrCheckBox.Checked)
{
return;
}
queryResultsListBox.Items.Clear();
try
{
bool purchaseOrderFiltered = false;
bool procedureFiltered = false;
ISession session = Results.DB.CreateSession();
IList<WaterMeter> waterMeters;
if (filterDateCheckBox.Checked)
{
IList<Batch> batches = session.QueryOver<Batch>()
.WhereRestrictionOn(x => x.EndTime)
.IsBetween(fromDateTimePicker.Value.Date)
.And(toDateTimePicker.Value.Date.AddDays(1).AddTicks(-1))
//.OrderBy(x => x.BatchNr).Asc
.List<Batch>();
waterMeters = new List<WaterMeter>();
foreach (var b in batches)
{
foreach (var wm in b.WaterMeters) waterMeters.Add(wm);
}
}
else if (purchaseOrderCheckBox.Checked)
{
waterMeters = session.QueryOver<WaterMeter>()
.Where(x => (x.PurchaseOrder == purchaseOrderCheckBox.Text))
.List<WaterMeter>();
purchaseOrderFiltered = true;
}
else if (procedureCheckBox.Checked && !procedureFiltered)
{
waterMeters = session.QueryOver<WaterMeter>()
.Where(x => (x.Batch.ProcedureName == procedureComboBox.Text))
.List<WaterMeter>();
procedureFiltered = true;
}
else
{
waterMeters = session.QueryOver<WaterMeter>().List<WaterMeter>();
}
if (purchaseOrderCheckBox.Checked && !purchaseOrderFiltered)
{
IList<WaterMeter> waterMeters3 = new List<WaterMeter>();
foreach (var wm in waterMeters)
{
if (wm.PurchaseOrder.Equals(purchaseOrderComboBox.Text)) waterMeters3.Add(wm);
}
waterMeters = waterMeters3;
purchaseOrderFiltered = true;
}
if (procedureCheckBox.Checked && !procedureFiltered)
{
IList<WaterMeter> waterMeters2 = new List<WaterMeter>();
foreach (var wm in waterMeters)
{
if (wm.Batch.ProcedureName.Equals(procedureComboBox.Text)) waterMeters2.Add(wm);
}
waterMeters = waterMeters2;
procedureFiltered = true;
}
QueryWaterMeters = waterMeters;
batchesQueried = false;
RedrawQueryList();
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void queryResultsListBox_DoubleClick(object sender, EventArgs e)
{
}
private void reportListBox_DoubleClick(object sender, EventArgs e)
{
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
Results.DB.ConnectionString = Program.LocalSettings.ConnectionString1;
}
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (radioButton2.Checked)
{
Results.DB.ConnectionString = Program.LocalSettings.ConnectionString2;
}
}
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
if (radioButton3.Checked)
{
Results.DB.ConnectionString = Program.LocalSettings.ConnectionString3;
}
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -234,4 +234,7 @@
<data name="CombinedBtnText" xml:space="preserve">
<value>Verbund</value>
</data>
<data name="Count" xml:space="preserve">
<value>Anzahl</value>
</data>
</root>

View File

@ -795,4 +795,7 @@
<data name="Warning" xml:space="preserve">
<value>Warning</value>
</data>
<data name="Count" xml:space="preserve">
<value>Count</value>
</data>
</root>

View File

@ -636,6 +636,15 @@ namespace ResultsBrowser.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Count.
/// </summary>
internal static string Count {
get {
return ResourceManager.GetString("Count", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Create DB.
/// </summary>

View File

@ -144,21 +144,9 @@
<DependentUpon>StatisticsOptionsDlg.cs</DependentUpon>
</Compile>
<Compile Include="LocalSettings.cs" />
<Compile Include="MainWnd.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainWnd.Designer.cs">
<DependentUpon>MainWnd.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="FiltersConfig.cs" />
<Compile Include="RBrowserWnd.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="RBrowserWnd.Designer.cs">
<DependentUpon>RBrowserWnd.cs</DependentUpon>
</Compile>
<Compile Include="Resources\Strings1.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@ -203,9 +191,6 @@
<EmbeddedResource Include="Forms\StatisticsOptionsDlg.resx">
<DependentUpon>StatisticsOptionsDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MainWnd.resx">
<DependentUpon>MainWnd.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@ -216,9 +201,6 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="RBrowserWnd.resx">
<DependentUpon>RBrowserWnd.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Resources\Strings.cs.resx" />
<EmbeddedResource Include="Resources\Strings.de.resx" />
<EmbeddedResource Include="Resources\Strings.resx">

View File

@ -307,16 +307,18 @@ namespace ResultsBrowser
{
if (waterMeters == null || waterMeters.Count == 0) return;
IList<Results.WMeterRsltItemSpec> items = Results.WMeterRsltItemSpec.FromStrArray(filtersConfig.ResultItems);
///
/// Enter options
///
Forms.StatisticsOptionsDlg dlg = new Forms.StatisticsOptionsDlg();
if (dlg.ShowDialog() != DialogResult.OK) return;
Forms.StatisticsOptionsDlg optionsDlg = new Forms.StatisticsOptionsDlg(items);
if (optionsDlg.ShowDialog() != DialogResult.OK) return;
///
/// Calculate statistics
///
Forms.StatisticsDlg statisticsDlg = new Forms.StatisticsDlg(waterMeters, dlg.TwoDim, dlg.RowItemID, dlg.ColumnItemID, dlg.RowTestSpecifier, dlg.ColumnTestSpecifier);
Forms.StatisticsDlg statisticsDlg = new Forms.StatisticsDlg(waterMeters, optionsDlg.TwoDim, optionsDlg.RowItem, optionsDlg.ColumnItem, optionsDlg.RowTestSpecifier, optionsDlg.ColumnTestSpecifier);
statisticsDlg.ShowDialog();
}
}