From 1937850814ddef14e78b8be8c8aba790eac842d1 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Fri, 21 Dec 2018 08:14:42 +0100 Subject: [PATCH] Statistics : 5 flow ranges and charts. --- ResultsBrowser/LocalSettings.cs | 2 +- Statistics/LocalSettings.cs | 102 +++++ Statistics/Program.cs | 82 +++- Statistics/Resources/Strings.Designer.cs | 81 ++++ Statistics/Resources/Strings.resx | 27 ++ Statistics/Resources/Strings.sk.resx | 21 + Statistics/Statistics.csproj | 1 + Statistics/StatisticsDlg.Designer.cs | 146 ++++--- Statistics/StatisticsDlg.cs | 69 +++- .../MidOrWaterMetersCtrl.Designer.cs | 362 +++++++++++++++--- .../UserControls/MidOrWaterMetersCtrl.cs | 112 +++++- .../UserControls/StatisticsCtrl.Designer.cs | 34 +- Statistics/UserControls/StatisticsCtrl.cs | 35 +- 13 files changed, 931 insertions(+), 143 deletions(-) create mode 100644 Statistics/LocalSettings.cs diff --git a/ResultsBrowser/LocalSettings.cs b/ResultsBrowser/LocalSettings.cs index c30bd914a..065a317c2 100644 --- a/ResultsBrowser/LocalSettings.cs +++ b/ResultsBrowser/LocalSettings.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2015 Sensus Metering Systems +/// Copyright (c) 2018 Sensus Slovensko a.s. /// using System; using System.IO; diff --git a/Statistics/LocalSettings.cs b/Statistics/LocalSettings.cs new file mode 100644 index 000000000..303c87436 --- /dev/null +++ b/Statistics/LocalSettings.cs @@ -0,0 +1,102 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +using System; +using System.IO; +using System.Text; +using System.Xml.Serialization; + +namespace Statistics +{ + /// + /// Class to be serialized to an XML file... + /// Public members are local settings. + /// These settings are modified by dialogs invoked by menu items + /// Edit->Preferences ... PreferencesDlg ... S1.1(language, etc. local settings), and + /// Edit->Advanced settings ... AdvancedSettingsDlg ... S1.2(spec. where bench settings are stored) + /// + [XmlRootAttribute("Statistics")] + public class LocalSettings + { + /// + /// User interface language (used as CultureInfo(..) constructor argument). + /// + public string Language; + + /// Names of servers. + public string Bench1; + public string Bench2; + public string Bench3; + public string Bench4; + public string Bench5; + public string Bench6; + + /// Database settings of servers. + public string ConnectionString1; + public string ConnectionString2; + public string ConnectionString3; + public string ConnectionString4; + public string ConnectionString5; + public string ConnectionString6; + + public string TimePeriodFormat; + + /// Statistics options + public bool TwoDim; + + /// MainWnd + public int MainWndLeft; + public int MainWndTop; + public int MainWndWidth; + public int MainWndHeight; + public bool ManiWndMaximized; + public int SplitterDistance; + + /// Last configuration file name + public string LastConfigFileName; + + + public LocalSettings() + { + } + + /// + /// Load public fields of this class from the XML file. + /// + public static LocalSettings Load(string fileName) + { + try + { + using (TextReader reader = new StreamReader(fileName)) + { + LocalSettings ls = (new XmlSerializer(typeof(LocalSettings))).Deserialize(reader) as LocalSettings; + // Copy the settings just in case De-serialize() completes OK + return ls; + } + } + catch (Exception e) + { + string msg = e.Message; + return null; + } + } + + /// + /// Save public fields of this class to the XML file. + /// + public void Save() + { + try + { + using (TextWriter writer = new StreamWriter(Program.LocalSettingsFileName)) + { + (new XmlSerializer(typeof(LocalSettings))).Serialize(writer, this); + } + } + catch (Exception e) + { + string msg = e.Message; + } + } + } +} diff --git a/Statistics/Program.cs b/Statistics/Program.cs index 2d85674a1..ceec41077 100644 --- a/Statistics/Program.cs +++ b/Statistics/Program.cs @@ -1,18 +1,96 @@ -using System; +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +using System; +using System.IO; using System.Collections.Generic; -using System.Linq; using System.Windows.Forms; +using Statistics.Resources; namespace Statistics { static class Program { + /// Program information + public static string Version; /// version string + public static DateTime BuildDateTime; /// date and time of program build + + /// Local settings + public static readonly string ExecutableDirectory; + public static readonly string ConfigDirectory; + public static readonly string LocalSettingsFileName; + public static readonly string LocalSettingsBackupName; + public static LocalSettings LocalSettings; + + static Program() + { + /// Program version string + System.Reflection.Assembly thisAssembly = System.Reflection.Assembly.GetExecutingAssembly(); + Version ver = thisAssembly.GetName().Version; + Version = string.Format("{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build); + BuildDateTime = new System.IO.FileInfo(thisAssembly.Location).LastWriteTime; + + /// Local program configuration directory including the trailing backslash + ExecutableDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + ConfigDirectory = Path.Combine(ExecutableDirectory, "..\\Cfg\\"); + LocalSettingsFileName = ConfigDirectory + "config.xml"; + LocalSettingsBackupName = ConfigDirectory + "config.backup.xml"; + } + + /// /// The main entry point for the application. /// [STAThread] static void Main() { + /// + /// Load the local settings + /// + LocalSettings = LocalSettings.Load(Program.LocalSettingsFileName); + if (LocalSettings == null) + { + /// Loading local seetings from regular config file failed. Use the backup + LocalSettings = LocalSettings.Load(Program.LocalSettingsBackupName); + if (LocalSettings == null) + { + MessageBox.Show(Strings.No_program_settings_found + Strings.Using_default_settings, + string.Empty, + MessageBoxButtons.OK, + MessageBoxIcon.Information); + + /// Create new default settings and save them + LocalSettings = new LocalSettings(); + Directory.CreateDirectory(ConfigDirectory); + LocalSettings.Save(); + } + else + { + LocalSettings.Save(); /// Save the settings to overwrite the wrong file + } + } + else + { + /// Loading local seetings from the regular config file was successful. Update the backup + File.Copy(Program.LocalSettingsFileName, Program.LocalSettingsBackupName, true); + } + + try + { + string culture = LocalSettings.Language.Replace('_', '-'); + System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(culture); + } + catch (Exception e) + { + string msg = e.Message; + MessageBox.Show(Strings.Selected_language_not_supported + Environment.NewLine + Strings.Using_English, + Strings.Warning, + MessageBoxButtons.OK, + MessageBoxIcon.Asterisk); + System.Threading.Thread.CurrentThread.CurrentUICulture = + new System.Globalization.CultureInfo("en"); + } + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new StatisticsDlg()); diff --git a/Statistics/Resources/Strings.Designer.cs b/Statistics/Resources/Strings.Designer.cs index 60465cc20..e710f538c 100644 --- a/Statistics/Resources/Strings.Designer.cs +++ b/Statistics/Resources/Strings.Designer.cs @@ -78,6 +78,51 @@ namespace Statistics.Resources { } } + /// + /// Looks up a localized string similar to From / to. + /// + internal static string From_to { + get { + return ResourceManager.GetString("From_to", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Last 3 months. + /// + internal static string Last_3_months { + get { + return ResourceManager.GetString("Last_3_months", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Last month. + /// + internal static string Last_month { + get { + return ResourceManager.GetString("Last_month", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Last week. + /// + internal static string Last_week { + get { + return ResourceManager.GetString("Last_week", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No program settings found.. + /// + internal static string No_program_settings_found { + get { + return ResourceManager.GetString("No_program_settings_found", resourceCulture); + } + } + /// /// Looks up a localized string similar to searching.... /// @@ -87,6 +132,15 @@ namespace Statistics.Resources { } } + /// + /// Looks up a localized string similar to Selected language is not supported.. + /// + internal static string Selected_language_not_supported { + get { + return ResourceManager.GetString("Selected_language_not_supported", resourceCulture); + } + } + /// /// Looks up a localized string similar to Statistics. /// @@ -114,6 +168,33 @@ namespace Statistics.Resources { } } + /// + /// Looks up a localized string similar to Default settings are used.. + /// + internal static string Using_default_settings { + get { + return ResourceManager.GetString("Using_default_settings", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to English will be used.. + /// + internal static string Using_English { + get { + return ResourceManager.GetString("Using_English", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Warning. + /// + internal static string Warning { + get { + return ResourceManager.GetString("Warning", resourceCulture); + } + } + /// /// Looks up a localized string similar to Water meters. /// diff --git a/Statistics/Resources/Strings.resx b/Statistics/Resources/Strings.resx index fea310568..7f9013b73 100644 --- a/Statistics/Resources/Strings.resx +++ b/Statistics/Resources/Strings.resx @@ -138,4 +138,31 @@ Water meters + + From / to + + + Last 3 months + + + Last month + + + Last week + + + No program settings found. + + + Selected language is not supported. + + + Default settings are used. + + + English will be used. + + + Warning + \ No newline at end of file diff --git a/Statistics/Resources/Strings.sk.resx b/Statistics/Resources/Strings.sk.resx index 6196e8b7b..78b6cd60c 100644 --- a/Statistics/Resources/Strings.sk.resx +++ b/Statistics/Resources/Strings.sk.resx @@ -138,4 +138,25 @@ Vodomery + + Od / do + + + Posledné 3 mesiace + + + Posledný mesiac + + + Posledný týždeň + + + Nebola nájdená konfigurácia programu. + + + Použijú sa štandardné nastavenia. + + + Upozornenie + \ No newline at end of file diff --git a/Statistics/Statistics.csproj b/Statistics/Statistics.csproj index 6effcae82..6ae3eb7ef 100644 --- a/Statistics/Statistics.csproj +++ b/Statistics/Statistics.csproj @@ -66,6 +66,7 @@ ModelessForm.cs + True True diff --git a/Statistics/StatisticsDlg.Designer.cs b/Statistics/StatisticsDlg.Designer.cs index 7001f4342..8d75f93c7 100644 --- a/Statistics/StatisticsDlg.Designer.cs +++ b/Statistics/StatisticsDlg.Designer.cs @@ -29,22 +29,25 @@ private void InitializeComponent() { this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.radioButton4 = new System.Windows.Forms.RadioButton(); + this.radioButton3 = new System.Windows.Forms.RadioButton(); + this.radioButton2 = new System.Windows.Forms.RadioButton(); + this.radioButton1 = new System.Windows.Forms.RadioButton(); this.timePeriodGroupBox = new System.Windows.Forms.GroupBox(); - this.timePeriodCheckBox = new System.Windows.Forms.CheckBox(); this.toLabel1 = new System.Windows.Forms.Label(); this.fromLabel1 = new System.Windows.Forms.Label(); this.dateTimeFromPicker = new System.Windows.Forms.DateTimePicker(); this.dateTimeToPicker = new System.Windows.Forms.DateTimePicker(); this.midsTabControl = new System.Windows.Forms.TabControl(); this.wr10TabPage = new System.Windows.Forms.TabPage(); - this.wr11TabPage = new System.Windows.Forms.TabPage(); - this.wr13TabPage = new System.Windows.Forms.TabPage(); - this.wr14TabPage = new System.Windows.Forms.TabPage(); - this.wr15TabPage = new System.Windows.Forms.TabPage(); this.wmsBenchesControl = new Statistics.UserControls.MidOrWaterMetersCtrl(); + this.wr11TabPage = new System.Windows.Forms.TabPage(); this.i1BenchesControl = new Statistics.UserControls.MidOrWaterMetersCtrl(); + this.wr13TabPage = new System.Windows.Forms.TabPage(); this.i2BbenchesControl = new Statistics.UserControls.MidOrWaterMetersCtrl(); + this.wr14TabPage = new System.Windows.Forms.TabPage(); this.i3BenchesControl = new Statistics.UserControls.MidOrWaterMetersCtrl(); + this.wr15TabPage = new System.Windows.Forms.TabPage(); this.i4BenchesControl = new Statistics.UserControls.MidOrWaterMetersCtrl(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); @@ -70,6 +73,10 @@ // // splitContainer1.Panel1 // + this.splitContainer1.Panel1.Controls.Add(this.radioButton4); + 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.timePeriodGroupBox); // // splitContainer1.Panel2 @@ -79,30 +86,63 @@ this.splitContainer1.SplitterDistance = 90; this.splitContainer1.TabIndex = 0; // + // radioButton4 + // + this.radioButton4.AutoSize = true; + this.radioButton4.Location = new System.Drawing.Point(136, 12); + this.radioButton4.Name = "radioButton4"; + this.radioButton4.Size = new System.Drawing.Size(68, 17); + this.radioButton4.TabIndex = 6; + this.radioButton4.TabStop = true; + this.radioButton4.Text = "From / to"; + this.radioButton4.UseVisualStyleBackColor = true; + this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged); + // + // radioButton3 + // + this.radioButton3.AutoSize = true; + this.radioButton3.Location = new System.Drawing.Point(12, 58); + this.radioButton3.Name = "radioButton3"; + this.radioButton3.Size = new System.Drawing.Size(91, 17); + this.radioButton3.TabIndex = 5; + this.radioButton3.TabStop = true; + this.radioButton3.Text = "Last 3 months"; + this.radioButton3.UseVisualStyleBackColor = true; + // + // radioButton2 + // + this.radioButton2.AutoSize = true; + this.radioButton2.Location = new System.Drawing.Point(12, 35); + this.radioButton2.Name = "radioButton2"; + this.radioButton2.Size = new System.Drawing.Size(77, 17); + this.radioButton2.TabIndex = 4; + this.radioButton2.TabStop = true; + this.radioButton2.Text = "Last month"; + this.radioButton2.UseVisualStyleBackColor = true; + // + // radioButton1 + // + this.radioButton1.AutoSize = true; + this.radioButton1.Location = new System.Drawing.Point(12, 12); + this.radioButton1.Name = "radioButton1"; + this.radioButton1.Size = new System.Drawing.Size(74, 17); + this.radioButton1.TabIndex = 3; + this.radioButton1.TabStop = true; + this.radioButton1.Text = "Last week"; + this.radioButton1.UseVisualStyleBackColor = true; + // // timePeriodGroupBox // - this.timePeriodGroupBox.Controls.Add(this.timePeriodCheckBox); this.timePeriodGroupBox.Controls.Add(this.toLabel1); this.timePeriodGroupBox.Controls.Add(this.fromLabel1); this.timePeriodGroupBox.Controls.Add(this.dateTimeFromPicker); this.timePeriodGroupBox.Controls.Add(this.dateTimeToPicker); - this.timePeriodGroupBox.Location = new System.Drawing.Point(12, 10); + this.timePeriodGroupBox.Location = new System.Drawing.Point(210, 10); this.timePeriodGroupBox.Name = "timePeriodGroupBox"; this.timePeriodGroupBox.Size = new System.Drawing.Size(296, 74); this.timePeriodGroupBox.TabIndex = 2; this.timePeriodGroupBox.TabStop = false; // - // timePeriodCheckBox - // - this.timePeriodCheckBox.AutoSize = true; - this.timePeriodCheckBox.Location = new System.Drawing.Point(6, -2); - this.timePeriodCheckBox.Name = "timePeriodCheckBox"; - this.timePeriodCheckBox.Size = new System.Drawing.Size(81, 17); - this.timePeriodCheckBox.TabIndex = 4; - this.timePeriodCheckBox.Text = "Time period"; - this.timePeriodCheckBox.UseVisualStyleBackColor = true; - this.timePeriodCheckBox.CheckedChanged += new System.EventHandler(this.timePeriodCheckBox_CheckedChanged); - // // toLabel1 // this.toLabel1.AutoSize = true; @@ -160,6 +200,14 @@ this.wr10TabPage.Text = "Water meters"; this.wr10TabPage.UseVisualStyleBackColor = true; // + // wmsBenchesControl + // + this.wmsBenchesControl.Dock = System.Windows.Forms.DockStyle.Fill; + this.wmsBenchesControl.Location = new System.Drawing.Point(3, 3); + this.wmsBenchesControl.Name = "wmsBenchesControl"; + this.wmsBenchesControl.Size = new System.Drawing.Size(1354, 700); + this.wmsBenchesControl.TabIndex = 0; + // // wr11TabPage // this.wr11TabPage.Controls.Add(this.i1BenchesControl); @@ -171,6 +219,14 @@ this.wr11TabPage.Text = "I1"; this.wr11TabPage.UseVisualStyleBackColor = true; // + // i1BenchesControl + // + this.i1BenchesControl.Dock = System.Windows.Forms.DockStyle.Fill; + this.i1BenchesControl.Location = new System.Drawing.Point(3, 3); + this.i1BenchesControl.Name = "i1BenchesControl"; + this.i1BenchesControl.Size = new System.Drawing.Size(1354, 700); + this.i1BenchesControl.TabIndex = 0; + // // wr13TabPage // this.wr13TabPage.Controls.Add(this.i2BbenchesControl); @@ -182,6 +238,14 @@ this.wr13TabPage.Text = "I2"; this.wr13TabPage.UseVisualStyleBackColor = true; // + // i2BbenchesControl + // + this.i2BbenchesControl.Dock = System.Windows.Forms.DockStyle.Fill; + this.i2BbenchesControl.Location = new System.Drawing.Point(3, 3); + this.i2BbenchesControl.Name = "i2BbenchesControl"; + this.i2BbenchesControl.Size = new System.Drawing.Size(1354, 700); + this.i2BbenchesControl.TabIndex = 0; + // // wr14TabPage // this.wr14TabPage.Controls.Add(this.i3BenchesControl); @@ -193,6 +257,14 @@ this.wr14TabPage.Text = "I3"; this.wr14TabPage.UseVisualStyleBackColor = true; // + // i3BenchesControl + // + this.i3BenchesControl.Dock = System.Windows.Forms.DockStyle.Fill; + this.i3BenchesControl.Location = new System.Drawing.Point(3, 3); + this.i3BenchesControl.Name = "i3BenchesControl"; + this.i3BenchesControl.Size = new System.Drawing.Size(1354, 700); + this.i3BenchesControl.TabIndex = 0; + // // wr15TabPage // this.wr15TabPage.Controls.Add(this.i4BenchesControl); @@ -204,38 +276,6 @@ this.wr15TabPage.Text = "I4"; this.wr15TabPage.UseVisualStyleBackColor = true; // - // wmsBenchesControl - // - this.wmsBenchesControl.Dock = System.Windows.Forms.DockStyle.Fill; - this.wmsBenchesControl.Location = new System.Drawing.Point(3, 3); - this.wmsBenchesControl.Name = "wmsBenchesControl"; - this.wmsBenchesControl.Size = new System.Drawing.Size(1354, 700); - this.wmsBenchesControl.TabIndex = 0; - // - // i1BenchesControl - // - this.i1BenchesControl.Dock = System.Windows.Forms.DockStyle.Fill; - this.i1BenchesControl.Location = new System.Drawing.Point(3, 3); - this.i1BenchesControl.Name = "i1BenchesControl"; - this.i1BenchesControl.Size = new System.Drawing.Size(1354, 700); - this.i1BenchesControl.TabIndex = 0; - // - // i2BbenchesControl - // - this.i2BbenchesControl.Dock = System.Windows.Forms.DockStyle.Fill; - this.i2BbenchesControl.Location = new System.Drawing.Point(3, 3); - this.i2BbenchesControl.Name = "i2BbenchesControl"; - this.i2BbenchesControl.Size = new System.Drawing.Size(1354, 700); - this.i2BbenchesControl.TabIndex = 0; - // - // i3BenchesControl - // - this.i3BenchesControl.Dock = System.Windows.Forms.DockStyle.Fill; - this.i3BenchesControl.Location = new System.Drawing.Point(3, 3); - this.i3BenchesControl.Name = "i3BenchesControl"; - this.i3BenchesControl.Size = new System.Drawing.Size(1354, 700); - this.i3BenchesControl.TabIndex = 0; - // // i4BenchesControl // this.i4BenchesControl.Dock = System.Windows.Forms.DockStyle.Fill; @@ -254,6 +294,7 @@ this.Text = "Statistics"; this.Load += new System.EventHandler(this.StatisticsDlg_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); @@ -283,12 +324,15 @@ private System.Windows.Forms.DateTimePicker dateTimeToPicker; private System.Windows.Forms.Label toLabel1; private System.Windows.Forms.Label fromLabel1; - private System.Windows.Forms.CheckBox timePeriodCheckBox; private UserControls.MidOrWaterMetersCtrl wmsBenchesControl; private UserControls.MidOrWaterMetersCtrl i1BenchesControl; private UserControls.MidOrWaterMetersCtrl i2BbenchesControl; private UserControls.MidOrWaterMetersCtrl i3BenchesControl; private UserControls.MidOrWaterMetersCtrl i4BenchesControl; + private System.Windows.Forms.RadioButton radioButton3; + private System.Windows.Forms.RadioButton radioButton2; + private System.Windows.Forms.RadioButton radioButton1; + private System.Windows.Forms.RadioButton radioButton4; } } diff --git a/Statistics/StatisticsDlg.cs b/Statistics/StatisticsDlg.cs index 9223b4fad..dbfb7351f 100644 --- a/Statistics/StatisticsDlg.cs +++ b/Statistics/StatisticsDlg.cs @@ -1,4 +1,7 @@ -using System; +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -51,7 +54,7 @@ namespace Statistics { InitializeComponent(); - ManageCheckGroupBox(timePeriodCheckBox, timePeriodGroupBox); + ///ManageCheckGroupBox(timePeriodCheckBox, timePeriodGroupBox); for (MidId midId = 0; midId < MidId.Count; midId++) { @@ -61,6 +64,9 @@ namespace Statistics (midsTabControl.TabPages[i].Controls[0] as MidOrWaterMetersCtrl).Parent = this; } midsTabControl.TabPages[0].Text = Strings.Water_meters; + + radioButton1.Checked = true; + timePeriodGroupBox.Enabled = false; Localize(); } @@ -68,13 +74,23 @@ namespace Statistics void Localize() { Text = Strings.Statistics; - timePeriodCheckBox.Text = Strings.Time_period; + //timePeriodCheckBox.Text = Strings.Time_period; fromLabel1.Text = Strings.From; toLabel1.Text = Strings.To; + radioButton1.Text = Strings.Last_week; + radioButton2.Text = Strings.Last_month; + radioButton3.Text = Strings.Last_3_months; + radioButton4.Text = Strings.From_to; } private void StatisticsDlg_Load(object sender, EventArgs e) { + Statistics.LocalSettings ls = Program.LocalSettings; + Width = (ls.MainWndWidth > 0) ? ls.MainWndWidth : 1000; + Height = (ls.MainWndHeight > 0) ? ls.MainWndHeight : 750; + Left = (ls.MainWndLeft != 0) ? ls.MainWndLeft : 50; + Top = (ls.MainWndTop != 0) ? ls.MainWndTop : 50; + for (int i = 0; i < testBenchNames.Length; i++) { if ((i < connectionStrings.Length) && !string.IsNullOrEmpty(connectionStrings[i])) @@ -116,10 +132,10 @@ namespace Statistics grp.Enabled = chk.Checked; } - private void timePeriodCheckBox_CheckedChanged(object sender, EventArgs e) - { - ManageCheckGroupBox(timePeriodCheckBox, timePeriodGroupBox); - } + //private void timePeriodCheckBox_CheckedChanged(object sender, EventArgs e) + //{ + // ManageCheckGroupBox(timePeriodCheckBox, timePeriodGroupBox); + //} public IList UpdateRequest(int benchId, MidId midId) @@ -150,6 +166,10 @@ namespace Statistics thread.CurrentUICulture = CultureInfo.CurrentUICulture; thread.Start(); + DateTime from; + DateTime to; + GetDateRange(out from, out to); + try { ISession session = sessionFactories[benchId].OpenSession(); @@ -160,7 +180,7 @@ namespace Statistics foreach (var cmpnts in listOfComponentsWithFlowmeter) { var listOfRslts = session.QueryOver() - .Where(x => ((x.EndTime >= dateTimeFromPicker.Value) && (x.EndTime <= dateTimeToPicker.Value))) + .Where(x => ((x.EndTime >= from) && (x.EndTime <= to))) .And(x => (x.Components == cmpnts)) .List(); foreach (var tr in listOfRslts) testRslts.Add(tr); @@ -177,5 +197,38 @@ namespace Statistics return null; } } + + void GetDateRange(out DateTime from, out DateTime to) + { + if (radioButton1.Checked) + { + /// Last week + from = DateTime.Now.Date.AddDays(-7); + to = DateTime.Now; + } + else if (radioButton2.Checked) + { + /// Last month + from = DateTime.Now.Date.AddDays(-31); + to = DateTime.Now; + } + else if (radioButton3.Checked) + { + /// Last 3 months + from = DateTime.Now.Date.AddDays(-91); + to = DateTime.Now; + } + else + { + /// From / to + from = dateTimeFromPicker.Value.Date; + to = dateTimeToPicker.Value.Date.AddDays(1).AddTicks(-1); + } + } + + private void radioButton4_CheckedChanged(object sender, EventArgs e) + { + timePeriodGroupBox.Enabled = radioButton4.Checked; + } } } diff --git a/Statistics/UserControls/MidOrWaterMetersCtrl.Designer.cs b/Statistics/UserControls/MidOrWaterMetersCtrl.Designer.cs index e6df15e24..c2fc713ef 100644 --- a/Statistics/UserControls/MidOrWaterMetersCtrl.Designer.cs +++ b/Statistics/UserControls/MidOrWaterMetersCtrl.Designer.cs @@ -61,16 +61,36 @@ this.flow1CheckBox = new System.Windows.Forms.CheckBox(); this.benchesTabControl = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); - this.wr10StatisticsCtrl1 = new Statistics.UserControls.StatisticsCtrl(); this.tabPage2 = new System.Windows.Forms.TabPage(); - this.wr11StatisticsCtrl = new Statistics.UserControls.StatisticsCtrl(); this.tabPage3 = new System.Windows.Forms.TabPage(); - this.wr13StatisticsCtrl = new Statistics.UserControls.StatisticsCtrl(); this.tabPage4 = new System.Windows.Forms.TabPage(); - this.wr14StatisticsCtrl = new Statistics.UserControls.StatisticsCtrl(); this.tabPage5 = new System.Windows.Forms.TabPage(); - this.wr15StatisticsCtrl = new Statistics.UserControls.StatisticsCtrl(); this.tabPage6 = new System.Windows.Forms.TabPage(); + this.flow4GroupBox = new System.Windows.Forms.GroupBox(); + this.flow4ToExclamation = new System.Windows.Forms.Label(); + this.flow4FromExclamation = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.toLabel5 = new System.Windows.Forms.Label(); + this.fromLabel5 = new System.Windows.Forms.Label(); + this.flow4ToTextBox = new System.Windows.Forms.TextBox(); + this.flow4FromTextBox = new System.Windows.Forms.TextBox(); + this.flow4CheckBox = new System.Windows.Forms.CheckBox(); + this.flow5GroupBox = new System.Windows.Forms.GroupBox(); + this.flow5ToExclamation = new System.Windows.Forms.Label(); + this.flow5FromExclamation = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.toLabel6 = new System.Windows.Forms.Label(); + this.fromLabel6 = new System.Windows.Forms.Label(); + this.flow5ToTextBox = new System.Windows.Forms.TextBox(); + this.flow5FromTextBox = new System.Windows.Forms.TextBox(); + this.flow5CheckBox = new System.Windows.Forms.CheckBox(); + this.wr10StatisticsCtrl1 = new Statistics.UserControls.StatisticsCtrl(); + this.wr11StatisticsCtrl = new Statistics.UserControls.StatisticsCtrl(); + this.wr13StatisticsCtrl = new Statistics.UserControls.StatisticsCtrl(); + this.wr14StatisticsCtrl = new Statistics.UserControls.StatisticsCtrl(); + this.wr15StatisticsCtrl = new Statistics.UserControls.StatisticsCtrl(); this.pt7StatisticsCtrl = new Statistics.UserControls.StatisticsCtrl(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); @@ -86,6 +106,8 @@ this.tabPage4.SuspendLayout(); this.tabPage5.SuspendLayout(); this.tabPage6.SuspendLayout(); + this.flow4GroupBox.SuspendLayout(); + this.flow5GroupBox.SuspendLayout(); this.SuspendLayout(); // // splitContainer1 @@ -99,6 +121,8 @@ // // splitContainer1.Panel1 // + this.splitContainer1.Panel1.Controls.Add(this.flow5GroupBox); + this.splitContainer1.Panel1.Controls.Add(this.flow4GroupBox); this.splitContainer1.Panel1.Controls.Add(this.flow3GroupBox); this.splitContainer1.Panel1.Controls.Add(this.flow2GroupBox); this.splitContainer1.Panel1.Controls.Add(this.flow1GroupBox); @@ -106,7 +130,7 @@ // splitContainer1.Panel2 // this.splitContainer1.Panel2.Controls.Add(this.benchesTabControl); - this.splitContainer1.Size = new System.Drawing.Size(800, 450); + this.splitContainer1.Size = new System.Drawing.Size(1202, 450); this.splitContainer1.SplitterDistance = 90; this.splitContainer1.TabIndex = 0; // @@ -428,7 +452,7 @@ this.benchesTabControl.Location = new System.Drawing.Point(0, 0); this.benchesTabControl.Name = "benchesTabControl"; this.benchesTabControl.SelectedIndex = 0; - this.benchesTabControl.Size = new System.Drawing.Size(800, 356); + this.benchesTabControl.Size = new System.Drawing.Size(1202, 356); this.benchesTabControl.TabIndex = 0; // // tabPage1 @@ -437,108 +461,312 @@ this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(792, 330); + this.tabPage1.Size = new System.Drawing.Size(1194, 330); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "WR10"; this.tabPage1.UseVisualStyleBackColor = true; // - // wr10StatisticsCtrl1 - // - this.wr10StatisticsCtrl1.Dock = System.Windows.Forms.DockStyle.Fill; - this.wr10StatisticsCtrl1.Location = new System.Drawing.Point(3, 3); - this.wr10StatisticsCtrl1.Name = "wr10StatisticsCtrl1"; - this.wr10StatisticsCtrl1.Size = new System.Drawing.Size(786, 324); - this.wr10StatisticsCtrl1.TabIndex = 0; - // // tabPage2 // this.tabPage2.Controls.Add(this.wr11StatisticsCtrl); this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Name = "tabPage2"; this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(792, 320); + this.tabPage2.Size = new System.Drawing.Size(1194, 330); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "WR11"; this.tabPage2.UseVisualStyleBackColor = true; // - // wr11StatisticsCtrl - // - this.wr11StatisticsCtrl.Dock = System.Windows.Forms.DockStyle.Fill; - this.wr11StatisticsCtrl.Location = new System.Drawing.Point(3, 3); - this.wr11StatisticsCtrl.Name = "wr11StatisticsCtrl"; - this.wr11StatisticsCtrl.Size = new System.Drawing.Size(786, 314); - this.wr11StatisticsCtrl.TabIndex = 0; - // // tabPage3 // this.tabPage3.Controls.Add(this.wr13StatisticsCtrl); this.tabPage3.Location = new System.Drawing.Point(4, 22); this.tabPage3.Name = "tabPage3"; - this.tabPage3.Size = new System.Drawing.Size(792, 320); + this.tabPage3.Size = new System.Drawing.Size(1194, 330); this.tabPage3.TabIndex = 2; this.tabPage3.Text = "WR13"; this.tabPage3.UseVisualStyleBackColor = true; // - // wr13StatisticsCtrl - // - this.wr13StatisticsCtrl.Dock = System.Windows.Forms.DockStyle.Fill; - this.wr13StatisticsCtrl.Location = new System.Drawing.Point(0, 0); - this.wr13StatisticsCtrl.Name = "wr13StatisticsCtrl"; - this.wr13StatisticsCtrl.Size = new System.Drawing.Size(792, 320); - this.wr13StatisticsCtrl.TabIndex = 0; - // // tabPage4 // this.tabPage4.Controls.Add(this.wr14StatisticsCtrl); this.tabPage4.Location = new System.Drawing.Point(4, 22); this.tabPage4.Name = "tabPage4"; - this.tabPage4.Size = new System.Drawing.Size(792, 320); + this.tabPage4.Size = new System.Drawing.Size(1194, 330); this.tabPage4.TabIndex = 3; this.tabPage4.Text = "WR14"; this.tabPage4.UseVisualStyleBackColor = true; // - // wr14StatisticsCtrl - // - this.wr14StatisticsCtrl.Dock = System.Windows.Forms.DockStyle.Fill; - this.wr14StatisticsCtrl.Location = new System.Drawing.Point(0, 0); - this.wr14StatisticsCtrl.Name = "wr14StatisticsCtrl"; - this.wr14StatisticsCtrl.Size = new System.Drawing.Size(792, 320); - this.wr14StatisticsCtrl.TabIndex = 0; - // // tabPage5 // this.tabPage5.Controls.Add(this.wr15StatisticsCtrl); this.tabPage5.Location = new System.Drawing.Point(4, 22); this.tabPage5.Name = "tabPage5"; - this.tabPage5.Size = new System.Drawing.Size(792, 320); + this.tabPage5.Size = new System.Drawing.Size(1194, 330); this.tabPage5.TabIndex = 4; this.tabPage5.Text = "WR15"; this.tabPage5.UseVisualStyleBackColor = true; // - // wr15StatisticsCtrl - // - this.wr15StatisticsCtrl.Dock = System.Windows.Forms.DockStyle.Fill; - this.wr15StatisticsCtrl.Location = new System.Drawing.Point(0, 0); - this.wr15StatisticsCtrl.Name = "wr15StatisticsCtrl"; - this.wr15StatisticsCtrl.Size = new System.Drawing.Size(792, 320); - this.wr15StatisticsCtrl.TabIndex = 0; - // // tabPage6 // this.tabPage6.Controls.Add(this.pt7StatisticsCtrl); this.tabPage6.Location = new System.Drawing.Point(4, 22); this.tabPage6.Name = "tabPage6"; - this.tabPage6.Size = new System.Drawing.Size(792, 320); + this.tabPage6.Size = new System.Drawing.Size(1194, 330); this.tabPage6.TabIndex = 5; this.tabPage6.Text = "PT7"; this.tabPage6.UseVisualStyleBackColor = true; // + // flow4GroupBox + // + this.flow4GroupBox.Controls.Add(this.flow4ToExclamation); + this.flow4GroupBox.Controls.Add(this.flow4FromExclamation); + this.flow4GroupBox.Controls.Add(this.label7); + this.flow4GroupBox.Controls.Add(this.label8); + this.flow4GroupBox.Controls.Add(this.toLabel5); + this.flow4GroupBox.Controls.Add(this.fromLabel5); + this.flow4GroupBox.Controls.Add(this.flow4ToTextBox); + this.flow4GroupBox.Controls.Add(this.flow4FromTextBox); + this.flow4GroupBox.Controls.Add(this.flow4CheckBox); + this.flow4GroupBox.Location = new System.Drawing.Point(706, 7); + this.flow4GroupBox.Name = "flow4GroupBox"; + this.flow4GroupBox.Size = new System.Drawing.Size(221, 77); + this.flow4GroupBox.TabIndex = 7; + this.flow4GroupBox.TabStop = false; + // + // flow4ToExclamation + // + this.flow4ToExclamation.AutoSize = true; + this.flow4ToExclamation.ForeColor = System.Drawing.Color.Red; + this.flow4ToExclamation.Location = new System.Drawing.Point(167, 48); + this.flow4ToExclamation.Name = "flow4ToExclamation"; + this.flow4ToExclamation.Size = new System.Drawing.Size(10, 13); + this.flow4ToExclamation.TabIndex = 9; + this.flow4ToExclamation.Text = "!"; + this.flow4ToExclamation.Visible = false; + // + // flow4FromExclamation + // + this.flow4FromExclamation.AutoSize = true; + this.flow4FromExclamation.ForeColor = System.Drawing.Color.Red; + this.flow4FromExclamation.Location = new System.Drawing.Point(167, 24); + this.flow4FromExclamation.Name = "flow4FromExclamation"; + this.flow4FromExclamation.Size = new System.Drawing.Size(10, 13); + this.flow4FromExclamation.TabIndex = 8; + this.flow4FromExclamation.Text = "!"; + this.flow4FromExclamation.Visible = false; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(178, 48); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(32, 13); + this.label7.TabIndex = 6; + this.label7.Text = "m3/h"; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(177, 23); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(32, 13); + this.label8.TabIndex = 5; + this.label8.Text = "m3/h"; + // + // toLabel5 + // + this.toLabel5.AutoSize = true; + this.toLabel5.Location = new System.Drawing.Point(14, 48); + this.toLabel5.Name = "toLabel5"; + this.toLabel5.Size = new System.Drawing.Size(20, 13); + this.toLabel5.TabIndex = 4; + this.toLabel5.Text = "To"; + // + // fromLabel5 + // + this.fromLabel5.AutoSize = true; + this.fromLabel5.Location = new System.Drawing.Point(14, 23); + this.fromLabel5.Name = "fromLabel5"; + this.fromLabel5.Size = new System.Drawing.Size(30, 13); + this.fromLabel5.TabIndex = 3; + this.fromLabel5.Text = "From"; + // + // flow4ToTextBox + // + this.flow4ToTextBox.Location = new System.Drawing.Point(65, 45); + this.flow4ToTextBox.Name = "flow4ToTextBox"; + this.flow4ToTextBox.Size = new System.Drawing.Size(100, 20); + this.flow4ToTextBox.TabIndex = 2; + this.flow4ToTextBox.TextChanged += new System.EventHandler(this.flow4ToTextBox_TextChanged); + // + // flow4FromTextBox + // + this.flow4FromTextBox.Location = new System.Drawing.Point(65, 20); + this.flow4FromTextBox.Name = "flow4FromTextBox"; + this.flow4FromTextBox.Size = new System.Drawing.Size(100, 20); + this.flow4FromTextBox.TabIndex = 1; + this.flow4FromTextBox.TextChanged += new System.EventHandler(this.flow4FromTextBox_TextChanged); + // + // flow4CheckBox + // + this.flow4CheckBox.AutoSize = true; + this.flow4CheckBox.Location = new System.Drawing.Point(10, 0); + this.flow4CheckBox.Name = "flow4CheckBox"; + this.flow4CheckBox.Size = new System.Drawing.Size(57, 17); + this.flow4CheckBox.TabIndex = 0; + this.flow4CheckBox.Text = "Flow 4"; + this.flow4CheckBox.UseVisualStyleBackColor = true; + this.flow4CheckBox.CheckedChanged += new System.EventHandler(this.flow4CheckBox_CheckedChanged); + // + // flow5GroupBox + // + this.flow5GroupBox.Controls.Add(this.flow5ToExclamation); + this.flow5GroupBox.Controls.Add(this.flow5FromExclamation); + this.flow5GroupBox.Controls.Add(this.label9); + this.flow5GroupBox.Controls.Add(this.label10); + this.flow5GroupBox.Controls.Add(this.toLabel6); + this.flow5GroupBox.Controls.Add(this.fromLabel6); + this.flow5GroupBox.Controls.Add(this.flow5ToTextBox); + this.flow5GroupBox.Controls.Add(this.flow5FromTextBox); + this.flow5GroupBox.Controls.Add(this.flow5CheckBox); + this.flow5GroupBox.Location = new System.Drawing.Point(939, 7); + this.flow5GroupBox.Name = "flow5GroupBox"; + this.flow5GroupBox.Size = new System.Drawing.Size(221, 77); + this.flow5GroupBox.TabIndex = 8; + this.flow5GroupBox.TabStop = false; + // + // flow5ToExclamation + // + this.flow5ToExclamation.AutoSize = true; + this.flow5ToExclamation.ForeColor = System.Drawing.Color.Red; + this.flow5ToExclamation.Location = new System.Drawing.Point(167, 48); + this.flow5ToExclamation.Name = "flow5ToExclamation"; + this.flow5ToExclamation.Size = new System.Drawing.Size(10, 13); + this.flow5ToExclamation.TabIndex = 9; + this.flow5ToExclamation.Text = "!"; + this.flow5ToExclamation.Visible = false; + // + // flow5FromExclamation + // + this.flow5FromExclamation.AutoSize = true; + this.flow5FromExclamation.ForeColor = System.Drawing.Color.Red; + this.flow5FromExclamation.Location = new System.Drawing.Point(167, 24); + this.flow5FromExclamation.Name = "flow5FromExclamation"; + this.flow5FromExclamation.Size = new System.Drawing.Size(10, 13); + this.flow5FromExclamation.TabIndex = 8; + this.flow5FromExclamation.Text = "!"; + this.flow5FromExclamation.Visible = false; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(178, 48); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(32, 13); + this.label9.TabIndex = 6; + this.label9.Text = "m3/h"; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(177, 23); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(32, 13); + this.label10.TabIndex = 5; + this.label10.Text = "m3/h"; + // + // toLabel6 + // + this.toLabel6.AutoSize = true; + this.toLabel6.Location = new System.Drawing.Point(14, 48); + this.toLabel6.Name = "toLabel6"; + this.toLabel6.Size = new System.Drawing.Size(20, 13); + this.toLabel6.TabIndex = 4; + this.toLabel6.Text = "To"; + // + // fromLabel6 + // + this.fromLabel6.AutoSize = true; + this.fromLabel6.Location = new System.Drawing.Point(14, 23); + this.fromLabel6.Name = "fromLabel6"; + this.fromLabel6.Size = new System.Drawing.Size(30, 13); + this.fromLabel6.TabIndex = 3; + this.fromLabel6.Text = "From"; + // + // flow5ToTextBox + // + this.flow5ToTextBox.Location = new System.Drawing.Point(65, 45); + this.flow5ToTextBox.Name = "flow5ToTextBox"; + this.flow5ToTextBox.Size = new System.Drawing.Size(100, 20); + this.flow5ToTextBox.TabIndex = 2; + this.flow5ToTextBox.TextChanged += new System.EventHandler(this.flow5ToTextBox_TextChanged); + // + // flow5FromTextBox + // + this.flow5FromTextBox.Location = new System.Drawing.Point(65, 20); + this.flow5FromTextBox.Name = "flow5FromTextBox"; + this.flow5FromTextBox.Size = new System.Drawing.Size(100, 20); + this.flow5FromTextBox.TabIndex = 1; + this.flow5FromTextBox.TextChanged += new System.EventHandler(this.flow5FromTextBox_TextChanged); + // + // flow5CheckBox + // + this.flow5CheckBox.AutoSize = true; + this.flow5CheckBox.Location = new System.Drawing.Point(10, 0); + this.flow5CheckBox.Name = "flow5CheckBox"; + this.flow5CheckBox.Size = new System.Drawing.Size(57, 17); + this.flow5CheckBox.TabIndex = 0; + this.flow5CheckBox.Text = "Flow 5"; + this.flow5CheckBox.UseVisualStyleBackColor = true; + this.flow5CheckBox.CheckedChanged += new System.EventHandler(this.flow5CheckBox_CheckedChanged); + // + // wr10StatisticsCtrl1 + // + this.wr10StatisticsCtrl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.wr10StatisticsCtrl1.Location = new System.Drawing.Point(3, 3); + this.wr10StatisticsCtrl1.Name = "wr10StatisticsCtrl1"; + this.wr10StatisticsCtrl1.Size = new System.Drawing.Size(1188, 324); + this.wr10StatisticsCtrl1.TabIndex = 0; + // + // wr11StatisticsCtrl + // + this.wr11StatisticsCtrl.Dock = System.Windows.Forms.DockStyle.Fill; + this.wr11StatisticsCtrl.Location = new System.Drawing.Point(3, 3); + this.wr11StatisticsCtrl.Name = "wr11StatisticsCtrl"; + this.wr11StatisticsCtrl.Size = new System.Drawing.Size(1188, 324); + this.wr11StatisticsCtrl.TabIndex = 0; + // + // wr13StatisticsCtrl + // + this.wr13StatisticsCtrl.Dock = System.Windows.Forms.DockStyle.Fill; + this.wr13StatisticsCtrl.Location = new System.Drawing.Point(0, 0); + this.wr13StatisticsCtrl.Name = "wr13StatisticsCtrl"; + this.wr13StatisticsCtrl.Size = new System.Drawing.Size(1194, 330); + this.wr13StatisticsCtrl.TabIndex = 0; + // + // wr14StatisticsCtrl + // + this.wr14StatisticsCtrl.Dock = System.Windows.Forms.DockStyle.Fill; + this.wr14StatisticsCtrl.Location = new System.Drawing.Point(0, 0); + this.wr14StatisticsCtrl.Name = "wr14StatisticsCtrl"; + this.wr14StatisticsCtrl.Size = new System.Drawing.Size(1194, 330); + this.wr14StatisticsCtrl.TabIndex = 0; + // + // wr15StatisticsCtrl + // + this.wr15StatisticsCtrl.Dock = System.Windows.Forms.DockStyle.Fill; + this.wr15StatisticsCtrl.Location = new System.Drawing.Point(0, 0); + this.wr15StatisticsCtrl.Name = "wr15StatisticsCtrl"; + this.wr15StatisticsCtrl.Size = new System.Drawing.Size(1194, 330); + this.wr15StatisticsCtrl.TabIndex = 0; + // // pt7StatisticsCtrl // this.pt7StatisticsCtrl.Dock = System.Windows.Forms.DockStyle.Fill; this.pt7StatisticsCtrl.Location = new System.Drawing.Point(0, 0); this.pt7StatisticsCtrl.Name = "pt7StatisticsCtrl"; - this.pt7StatisticsCtrl.Size = new System.Drawing.Size(792, 320); + this.pt7StatisticsCtrl.Size = new System.Drawing.Size(1194, 330); this.pt7StatisticsCtrl.TabIndex = 0; // // MidOrWaterMetersCtrl @@ -547,7 +775,7 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.splitContainer1); this.Name = "MidOrWaterMetersCtrl"; - this.Size = new System.Drawing.Size(800, 450); + this.Size = new System.Drawing.Size(1202, 450); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); @@ -565,6 +793,10 @@ this.tabPage4.ResumeLayout(false); this.tabPage5.ResumeLayout(false); this.tabPage6.ResumeLayout(false); + this.flow4GroupBox.ResumeLayout(false); + this.flow4GroupBox.PerformLayout(); + this.flow5GroupBox.ResumeLayout(false); + this.flow5GroupBox.PerformLayout(); this.ResumeLayout(false); } @@ -615,5 +847,25 @@ private System.Windows.Forms.Label flow3FromExclamation; private System.Windows.Forms.Label flow2ToExclamation; private System.Windows.Forms.Label flow2FromExclamation; + private System.Windows.Forms.GroupBox flow5GroupBox; + private System.Windows.Forms.Label flow5ToExclamation; + private System.Windows.Forms.Label flow5FromExclamation; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Label toLabel6; + private System.Windows.Forms.Label fromLabel6; + private System.Windows.Forms.TextBox flow5ToTextBox; + private System.Windows.Forms.TextBox flow5FromTextBox; + private System.Windows.Forms.CheckBox flow5CheckBox; + private System.Windows.Forms.GroupBox flow4GroupBox; + private System.Windows.Forms.Label flow4ToExclamation; + private System.Windows.Forms.Label flow4FromExclamation; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label toLabel5; + private System.Windows.Forms.Label fromLabel5; + private System.Windows.Forms.TextBox flow4ToTextBox; + private System.Windows.Forms.TextBox flow4FromTextBox; + private System.Windows.Forms.CheckBox flow4CheckBox; } } diff --git a/Statistics/UserControls/MidOrWaterMetersCtrl.cs b/Statistics/UserControls/MidOrWaterMetersCtrl.cs index e402744ff..1fc949e48 100644 --- a/Statistics/UserControls/MidOrWaterMetersCtrl.cs +++ b/Statistics/UserControls/MidOrWaterMetersCtrl.cs @@ -1,4 +1,7 @@ -using System; +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; @@ -16,17 +19,46 @@ namespace Statistics.UserControls public MidId MidId; public StatisticsDlg Parent; - public bool Flow1Enabled { get { return flow1CheckBox.Checked; } } - public double Flow1From { get { return flow1From; } } - public double Flow1To { get { return flow1To; } } - public bool Flow2Enabled { get { return flow2CheckBox.Checked; } } - public double Flow2From { get { return flow2From; } } - public double Flow2To { get { return flow2To; } } + public bool IsFlowEnabled(int i) + { + switch (i) + { + case 1: return flow1CheckBox.Checked; + case 2: return flow2CheckBox.Checked; + case 3: return flow3CheckBox.Checked; + case 4: return flow4CheckBox.Checked; + case 5: return flow5CheckBox.Checked; + default: return false; + } + } + + public double FlowFrom(int i) + { + switch (i) + { + case 1: return flow1From; + case 2: return flow2From; + case 3: return flow3From; + case 4: return flow4From; + case 5: return flow5From; + default: return 0; + } + } + + public double FlowTo(int i) + { + switch (i) + { + case 1: return flow1To; + case 2: return flow2To; + case 3: return flow3To; + case 4: return flow4To; + case 5: return flow5To; + default: return 0; + } + } - public bool Flow3Enabled { get { return flow3CheckBox.Checked; } } - public double Flow3From { get { return flow3From; } } - public double Flow3To { get { return flow3To; } } /// All flows are in m3/h double flow1From; @@ -35,6 +67,10 @@ namespace Statistics.UserControls double flow2To; double flow3From; double flow3To; + double flow4From; + double flow4To; + double flow5From; + double flow5To; StatisticsCtrl GetStatistics(int i) @@ -60,6 +96,8 @@ namespace Statistics.UserControls ManageCheckGroupBox(flow1CheckBox, flow1GroupBox); ManageCheckGroupBox(flow2CheckBox, flow2GroupBox); ManageCheckGroupBox(flow3CheckBox, flow3GroupBox); + ManageCheckGroupBox(flow4CheckBox, flow4GroupBox); + ManageCheckGroupBox(flow5CheckBox, flow5GroupBox); for (int i = 0; i < benchesTabControl.TabPages.Count; i++ ) { @@ -67,7 +105,7 @@ namespace Statistics.UserControls if ((tp.Controls.Count > 0) && (tp.Controls[0] is StatisticsCtrl)) { (tp.Controls[0] as StatisticsCtrl).Id = i; - (tp.Controls[0] as StatisticsCtrl).BenchesCtrl = this; + (tp.Controls[0] as StatisticsCtrl).MidCtrl = this; } } } @@ -77,17 +115,25 @@ namespace Statistics.UserControls flow1CheckBox.Text = string.Format("{0} 1", Strings.Flow); flow2CheckBox.Text = string.Format("{0} 2", Strings.Flow); flow3CheckBox.Text = string.Format("{0} 3", Strings.Flow); + flow4CheckBox.Text = string.Format("{0} 4", Strings.Flow); + flow5CheckBox.Text = string.Format("{0} 5", Strings.Flow); fromLabel2.Text = Strings.From; fromLabel3.Text = Strings.From; fromLabel4.Text = Strings.From; + fromLabel5.Text = Strings.From; + fromLabel6.Text = Strings.From; toLabel2.Text = Strings.To; toLabel3.Text = Strings.To; toLabel4.Text = Strings.To; + toLabel5.Text = Strings.To; + toLabel6.Text = Strings.To; } private void flow1CheckBox_CheckedChanged(object sender, EventArgs e) { ManageCheckGroupBox(flow1CheckBox, flow1GroupBox); } private void flow2CheckBox_CheckedChanged(object sender, EventArgs e) { ManageCheckGroupBox(flow2CheckBox, flow2GroupBox); } private void flow3CheckBox_CheckedChanged(object sender, EventArgs e) { ManageCheckGroupBox(flow3CheckBox, flow3GroupBox); } + private void flow4CheckBox_CheckedChanged(object sender, EventArgs e) { ManageCheckGroupBox(flow4CheckBox, flow4GroupBox); } + private void flow5CheckBox_CheckedChanged(object sender, EventArgs e) { ManageCheckGroupBox(flow5CheckBox, flow5GroupBox); } private void ManageCheckGroupBox(CheckBox chk, GroupBox grp) { @@ -168,5 +214,49 @@ namespace Statistics.UserControls else flow3ToExclamation.Visible = !(double.TryParse(flow3ToTextBox.Text, out flow3To) && (flow3To >= 0)); } + + private void flow4FromTextBox_TextChanged(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(flow4FromTextBox.Text)) + { + flow4From = 0; + flow4FromExclamation.Visible = false; + } + else + flow4FromExclamation.Visible = !(double.TryParse(flow4FromTextBox.Text, out flow4From) && (flow4From >= 0)); + } + + private void flow4ToTextBox_TextChanged(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(flow4ToTextBox.Text)) + { + flow4To = 0; + flow4ToExclamation.Visible = false; + } + else + flow4ToExclamation.Visible = !(double.TryParse(flow4ToTextBox.Text, out flow4To) && (flow4To >= 0)); + } + + private void flow5FromTextBox_TextChanged(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(flow5FromTextBox.Text)) + { + flow5From = 0; + flow5FromExclamation.Visible = false; + } + else + flow5FromExclamation.Visible = !(double.TryParse(flow5FromTextBox.Text, out flow5From) && (flow5From >= 0)); + } + + private void flow5ToTextBox_TextChanged(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(flow5ToTextBox.Text)) + { + flow5To = 0; + flow5ToExclamation.Visible = false; + } + else + flow5ToExclamation.Visible = !(double.TryParse(flow5ToTextBox.Text, out flow5To) && (flow5To >= 0)); + } } } diff --git a/Statistics/UserControls/StatisticsCtrl.Designer.cs b/Statistics/UserControls/StatisticsCtrl.Designer.cs index 760d21cb2..e1c31da65 100644 --- a/Statistics/UserControls/StatisticsCtrl.Designer.cs +++ b/Statistics/UserControls/StatisticsCtrl.Designer.cs @@ -31,6 +31,10 @@ System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend(); System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series(); + System.Windows.Forms.DataVisualization.Charting.Series series5 = new System.Windows.Forms.DataVisualization.Charting.Series(); this.updateButton = new System.Windows.Forms.Button(); this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); @@ -66,9 +70,33 @@ series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; series1.Color = System.Drawing.Color.ForestGreen; series1.Legend = "Legend1"; - series1.Name = "Error"; + series1.Name = "Flow 1"; + series2.ChartArea = "ChartArea1"; + series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; + series2.Color = System.Drawing.Color.Red; + series2.Legend = "Legend1"; + series2.Name = "Flow 2"; + series3.ChartArea = "ChartArea1"; + series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; + series3.Color = System.Drawing.Color.Blue; + series3.Legend = "Legend1"; + series3.Name = "Flow 3"; + series4.ChartArea = "ChartArea1"; + series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; + series4.Color = System.Drawing.Color.Yellow; + series4.Legend = "Legend1"; + series4.Name = "Flow 4"; + series5.ChartArea = "ChartArea1"; + series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; + series5.Color = System.Drawing.Color.Fuchsia; + series5.Legend = "Legend1"; + series5.Name = "Flow 5"; this.chart1.Series.Add(series1); - this.chart1.Size = new System.Drawing.Size(470, 381); + this.chart1.Series.Add(series2); + this.chart1.Series.Add(series3); + this.chart1.Series.Add(series4); + this.chart1.Series.Add(series5); + this.chart1.Size = new System.Drawing.Size(473, 381); this.chart1.TabIndex = 5; this.chart1.Text = "chart1"; // @@ -89,7 +117,7 @@ this.splitContainer1.Panel2.Controls.Add(this.exportButton); this.splitContainer1.Panel2.Controls.Add(this.updateButton); this.splitContainer1.Size = new System.Drawing.Size(577, 381); - this.splitContainer1.SplitterDistance = 470; + this.splitContainer1.SplitterDistance = 473; this.splitContainer1.SplitterWidth = 1; this.splitContainer1.TabIndex = 6; // diff --git a/Statistics/UserControls/StatisticsCtrl.cs b/Statistics/UserControls/StatisticsCtrl.cs index 8b04afce8..f7542862f 100644 --- a/Statistics/UserControls/StatisticsCtrl.cs +++ b/Statistics/UserControls/StatisticsCtrl.cs @@ -1,20 +1,19 @@ -using System; +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; using Results.Entities; +using Statistics.Resources; namespace Statistics.UserControls { public partial class StatisticsCtrl : UserControl { public int Id; /// Index of the tab page - public MidOrWaterMetersCtrl BenchesCtrl; /// Reference to the parent control + public MidOrWaterMetersCtrl MidCtrl; /// Reference to the parent control public StatisticsCtrl() { @@ -26,21 +25,33 @@ namespace Statistics.UserControls private void updateButton_Click(object sender, EventArgs e) { - if (BenchesCtrl != null) + if (MidCtrl != null) { - IList results = BenchesCtrl.UpdateRequest(Id); + for (int i = 1; i <= 5; i++) + { + chart1.Series[string.Format("{0} {1}", Strings.Flow, i)].Points.Clear(); + } + + IList results = MidCtrl.UpdateRequest(Id); if (results != null) { foreach (var r in results) { - chart1.Series["Error"].Points.AddXY(r.StartTime, r.ErrorMaster); + if (r.ErrorMaster != 0) + { + for (int i = 1; i <= 5; i++) + { + if (MidCtrl.IsFlowEnabled(i) && (MidCtrl.FlowFrom(i) <= r.FlowMean) && (r.FlowMean <= MidCtrl.FlowTo(i))) + { + chart1.Series[string.Format("{0} {1}", Strings.Flow, i)].Points.AddXY(r.StartTime, r.ErrorMaster); + } + } + } } return; } } - - chart1.Series["Error"].Points.Clear(); } private void exportButton_Click(object sender, EventArgs e)