summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Config.cs1
-rw-r--r--Config.xml63
-rw-r--r--MainForm.cs186
-rw-r--r--TLReader.MainForm.resourcesbin4949 -> 7121 bytes
-rw-r--r--Util.cs10
5 files changed, 228 insertions, 32 deletions
diff --git a/Config.cs b/Config.cs
index ce60029..4df6d43 100644
--- a/Config.cs
+++ b/Config.cs
@@ -69,6 +69,7 @@ namespace TLReader
public string Connect;
public string DisplayNames;
+ public string ColumnNames;
public string Query;
}
}
diff --git a/Config.xml b/Config.xml
index 4f7df03..f4d4a45 100644
--- a/Config.xml
+++ b/Config.xml
@@ -2,19 +2,76 @@
<Connect>Driver={Microsoft Access Driver (*.mdb)};DBQ=E:\\tuglist00.mdb</Connect>
<DisplayNames>
Tug Name,
+Registration Number,
+Euro Number,
+Callsign,
Nationality,
+Specifications,
+Link,
+Build Date,
+Scrap Date,
+BRT,
+PK,
Owner's Name,
Owner's Nationality,
Owner's Description,
-Owner's Address
+Owner's Address,
+Wharf Short Name,
+Wharf Nationality,
+Wharf Description,
+Wharf Address,
+Old Names
</DisplayNames>
+<ColumnNames>
+tuglist00.name,
+tuglist00.regNR,
+tuglist00.euroNR,
+tuglist00.callsign,
+tuglist00.nat,
+tugdetails.specifications,
+tugdetails.link,
+tuglist00.build,
+tuglist00.scrap,
+tuglist00.brt,
+tuglist00.pk,
+owners.short,
+owners.nat,
+owners.description,
+owners.adres,
+wharves.short,
+wharves.nat,
+wharves.description,
+wharves.adres,
+tuglist00.onames
+</ColumnNames>
<Query>
select tuglist00.name,
+ tuglist00.regNR,
+ tuglist00.euroNR,
+ tuglist00.callsign,
tuglist00.nat,
+ tugdetails.specifications,
+ tugdetails.link,
+ tuglist00.build,
+ tuglist00.scrap,
+ tuglist00.brt,
+ tuglist00.pk,
owners.short,
owners.nat,
owners.description,
- owners.adres
- from tuglist00,owners where tuglist00.ownerNR=owners.ownerNR
+ owners.adres,
+ wharves.short,
+ wharves.nat,
+ wharves.description,
+ wharves.adres,
+ tuglist00.onames
+ from tugdetails,
+ tuglist00,
+ owners,
+ wharves
+ where
+ tugdetails.tugNR=tuglist00.tugNR and
+ tuglist00.ownerNR=owners.ownerNR and
+ tugdetails.wharfNR=wharves.wharfNR
</Query>
</TLConfig>
diff --git a/MainForm.cs b/MainForm.cs
index dc1e38a..3fa3257 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -21,6 +21,7 @@ using System.Data;
using System.Data.Common;
using System.Data.Odbc;
using System.Collections;
+using System.Collections.Specialized;
using System.IO;
namespace TLReader
@@ -31,14 +32,22 @@ namespace TLReader
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Button m_quitButton;
- private System.Windows.Forms.ListView m_list;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.CheckBox m_sortOrder;
private System.Windows.Forms.Button m_aboutButton;
- private System.Windows.Forms.ProgressBar m_progress;
+ private System.Windows.Forms.Label label;
+ private System.Windows.Forms.ComboBox m_sortBy;
private System.Windows.Forms.Button m_csvButton;
+ private System.Windows.Forms.ListView m_list;
+ private System.Windows.Forms.TextBox m_noRowsText;
+ private System.Windows.Forms.ProgressBar m_progress;
+ private System.Windows.Forms.Button m_sortButton;
- private OdbcConnection m_dbase;
- private Query m_query;
- private TLConfig m_config;
+ private OdbcConnection m_dbase;
+ private Query m_query;
+ private TLConfig m_config;
+ private StringCollection m_colDesc;
+ private StringCollection m_colName;
public MainForm()
{
@@ -55,9 +64,19 @@ namespace TLReader
Text+=" - "+m_dbase.Database;
- m_query=new Query(m_dbase,m_config.DisplayNames,m_config.Query);
-
- FillList();
+ m_colDesc=Util.Split(m_config.DisplayNames);
+ m_colName=Util.Split(m_config.ColumnNames);
+
+ m_sortBy.Items.Clear();
+
+ foreach (string s in m_colDesc)
+ {
+ m_sortBy.Items.Add(s);
+ }
+
+ m_sortBy.SelectedIndex=0;
+
+ DoQuery();
}
[STAThread]
@@ -67,6 +86,21 @@ namespace TLReader
{
Application.Run(new MainForm());
}
+ catch (OdbcException e)
+ {
+ string error="";
+
+ for (int i=0; i < e.Errors.Count; i++)
+ {
+ error += "Index #" + i + "\n" +
+ "Message: " + e.Errors[i].Message + "\n" +
+ "NativeError: " + e.Errors[i].NativeError.ToString() + "\n" +
+ "Source: " + e.Errors[i].Source + "\n" +
+ "SQL: " + e.Errors[i].SQLState + "\n";
+ }
+
+ Util.Error(error);
+ }
catch(Exception e)
{
Util.Error(e.ToString());
@@ -80,22 +114,28 @@ namespace TLReader
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
- this.m_csvButton = new System.Windows.Forms.Button();
+ this.m_sortButton = new System.Windows.Forms.Button();
this.m_progress = new System.Windows.Forms.ProgressBar();
- this.m_aboutButton = new System.Windows.Forms.Button();
+ this.m_noRowsText = new System.Windows.Forms.TextBox();
this.m_list = new System.Windows.Forms.ListView();
+ this.m_csvButton = new System.Windows.Forms.Button();
+ this.m_sortBy = new System.Windows.Forms.ComboBox();
+ this.label = new System.Windows.Forms.Label();
+ this.m_aboutButton = new System.Windows.Forms.Button();
+ this.m_sortOrder = new System.Windows.Forms.CheckBox();
+ this.label2 = new System.Windows.Forms.Label();
this.m_quitButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
- // m_csvButton
+ // m_sortButton
//
- this.m_csvButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.m_csvButton.Location = new System.Drawing.Point(448, 504);
- this.m_csvButton.Name = "m_csvButton";
- this.m_csvButton.Size = new System.Drawing.Size(104, 32);
- this.m_csvButton.TabIndex = 1;
- this.m_csvButton.Text = "Export as CSV";
- this.m_csvButton.Click += new System.EventHandler(this.OnExportCSV);
+ this.m_sortButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.m_sortButton.Location = new System.Drawing.Point(568, 8);
+ this.m_sortButton.Name = "m_sortButton";
+ this.m_sortButton.Size = new System.Drawing.Size(104, 32);
+ this.m_sortButton.TabIndex = 9;
+ this.m_sortButton.Text = "Sort";
+ this.m_sortButton.Click += new System.EventHandler(this.OnSort);
//
// m_progress
//
@@ -106,15 +146,15 @@ namespace TLReader
this.m_progress.Size = new System.Drawing.Size(304, 16);
this.m_progress.TabIndex = 3;
//
- // m_aboutButton
+ // m_noRowsText
//
- this.m_aboutButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.m_aboutButton.Location = new System.Drawing.Point(8, 504);
- this.m_aboutButton.Name = "m_aboutButton";
- this.m_aboutButton.Size = new System.Drawing.Size(104, 32);
- this.m_aboutButton.TabIndex = 4;
- this.m_aboutButton.Text = "About";
- this.m_aboutButton.Click += new System.EventHandler(this.OnAbout);
+ this.m_noRowsText.Location = new System.Drawing.Point(104, 8);
+ this.m_noRowsText.Name = "m_noRowsText";
+ this.m_noRowsText.ReadOnly = true;
+ this.m_noRowsText.Size = new System.Drawing.Size(72, 20);
+ this.m_noRowsText.TabIndex = 6;
+ this.m_noRowsText.TabStop = false;
+ this.m_noRowsText.Text = "textBox";
//
// m_list
//
@@ -124,13 +164,68 @@ namespace TLReader
this.m_list.FullRowSelect = true;
this.m_list.GridLines = true;
this.m_list.HideSelection = false;
- this.m_list.Location = new System.Drawing.Point(8, 8);
+ this.m_list.Location = new System.Drawing.Point(8, 48);
this.m_list.Name = "m_list";
- this.m_list.Size = new System.Drawing.Size(664, 488);
- this.m_list.Sorting = System.Windows.Forms.SortOrder.Ascending;
+ this.m_list.Size = new System.Drawing.Size(664, 440);
this.m_list.TabIndex = 2;
this.m_list.View = System.Windows.Forms.View.Details;
//
+ // m_csvButton
+ //
+ this.m_csvButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.m_csvButton.Location = new System.Drawing.Point(448, 504);
+ this.m_csvButton.Name = "m_csvButton";
+ this.m_csvButton.Size = new System.Drawing.Size(104, 32);
+ this.m_csvButton.TabIndex = 1;
+ this.m_csvButton.Text = "Export as CSV";
+ this.m_csvButton.Click += new System.EventHandler(this.OnExportCSV);
+ //
+ // m_sortBy
+ //
+ this.m_sortBy.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.m_sortBy.Location = new System.Drawing.Point(256, 8);
+ this.m_sortBy.Name = "m_sortBy";
+ this.m_sortBy.Size = new System.Drawing.Size(208, 21);
+ this.m_sortBy.TabIndex = 8;
+ //
+ // label
+ //
+ this.label.Location = new System.Drawing.Point(8, 8);
+ this.label.Name = "label";
+ this.label.Size = new System.Drawing.Size(88, 24);
+ this.label.TabIndex = 5;
+ this.label.Text = "Number of Rows";
+ this.label.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ //
+ // m_aboutButton
+ //
+ this.m_aboutButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.m_aboutButton.Location = new System.Drawing.Point(8, 504);
+ this.m_aboutButton.Name = "m_aboutButton";
+ this.m_aboutButton.Size = new System.Drawing.Size(104, 32);
+ this.m_aboutButton.TabIndex = 4;
+ this.m_aboutButton.Text = "About";
+ this.m_aboutButton.Click += new System.EventHandler(this.OnAbout);
+ //
+ // m_sortOrder
+ //
+ this.m_sortOrder.Checked = true;
+ this.m_sortOrder.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.m_sortOrder.Location = new System.Drawing.Point(480, 8);
+ this.m_sortOrder.Name = "m_sortOrder";
+ this.m_sortOrder.Size = new System.Drawing.Size(80, 24);
+ this.m_sortOrder.TabIndex = 10;
+ this.m_sortOrder.Text = "Ascending";
+ //
+ // label2
+ //
+ this.label2.Location = new System.Drawing.Point(200, 8);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(56, 24);
+ this.label2.TabIndex = 7;
+ this.label2.Text = "Sort By";
+ this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ //
// m_quitButton
//
this.m_quitButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
@@ -145,6 +240,12 @@ namespace TLReader
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(680, 541);
+ this.Controls.Add(this.m_sortOrder);
+ this.Controls.Add(this.m_sortButton);
+ this.Controls.Add(this.m_sortBy);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.m_noRowsText);
+ this.Controls.Add(this.label);
this.Controls.Add(this.m_aboutButton);
this.Controls.Add(this.m_progress);
this.Controls.Add(this.m_list);
@@ -213,10 +314,31 @@ namespace TLReader
m_progress.Value=0;
}
+ private void DoQuery()
+ {
+ Enabled=false;
+ Cursor=Cursors.WaitCursor;
+
+ string sort=m_colName[m_sortBy.SelectedIndex];
+ string order=m_sortOrder.Checked ? "asc":"desc";
+
+ m_query=new Query(m_dbase,
+ m_config.DisplayNames,
+ m_config.Query+" order by "+sort+" "+order);
+ FillList();
+
+ m_noRowsText.Text=m_query.Count.ToString();
+
+ Cursor=Cursors.Default;
+ Enabled=true;
+ }
+
private void FillList()
{
int f;
+ m_list.BeginUpdate();
+
m_list.Columns.Clear();
m_list.Items.Clear();
@@ -236,6 +358,8 @@ namespace TLReader
AddRow(l);
}
+
+ m_list.EndUpdate();
}
private void AddRow(ArrayList l)
@@ -257,5 +381,9 @@ namespace TLReader
a.ShowDialog(this);
}
+ void OnSort(object sender, System.EventArgs e)
+ {
+ DoQuery();
+ }
}
}
diff --git a/TLReader.MainForm.resources b/TLReader.MainForm.resources
index ac48dbd..6945882 100644
--- a/TLReader.MainForm.resources
+++ b/TLReader.MainForm.resources
Binary files differ
diff --git a/Util.cs b/Util.cs
index 32acb51..25ba921 100644
--- a/Util.cs
+++ b/Util.cs
@@ -17,6 +17,8 @@
//
using System;
using System.Windows.Forms;
+using System.Collections;
+using System.Collections.Specialized;
namespace TLReader
{
@@ -54,5 +56,13 @@ namespace TLReader
return s;
}
+
+ public static StringCollection Split(string s)
+ {
+ StringCollection sc=new StringCollection();
+ sc.AddRange(s.Split(new char[] {','}));
+
+ return sc;
+ }
}
}