using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace Northwind
{
	/// <summary>
	/// Summary description for frmDashboard.
	/// </summary>
	public class frmDashboard : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label lblOrderCount;
		private System.Windows.Forms.TextBox tbOrderCount;
		private System.Windows.Forms.TextBox tbCustomerCount;
		private System.Windows.Forms.Label lblCustomerCount;
		private System.Windows.Forms.TextBox tbCountries;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmDashboard()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(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.lblOrderCount = new System.Windows.Forms.Label();
			this.tbOrderCount = new System.Windows.Forms.TextBox();
			this.tbCustomerCount = new System.Windows.Forms.TextBox();
			this.lblCustomerCount = new System.Windows.Forms.Label();
			this.tbCountries = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// lblOrderCount
			// 
			this.lblOrderCount.Dock = System.Windows.Forms.DockStyle.Left;
			this.lblOrderCount.Location = new System.Drawing.Point(0, 0);
			this.lblOrderCount.Name = "lblOrderCount";
			this.lblOrderCount.Size = new System.Drawing.Size(48, 26);
			this.lblOrderCount.TabIndex = 0;
			this.lblOrderCount.Text = "Orders:";
			// 
			// tbOrderCount
			// 
			this.tbOrderCount.Dock = System.Windows.Forms.DockStyle.Left;
			this.tbOrderCount.Location = new System.Drawing.Point(152, 0);
			this.tbOrderCount.Name = "tbOrderCount";
			this.tbOrderCount.ReadOnly = true;
			this.tbOrderCount.TabIndex = 1;
			this.tbOrderCount.Text = "";
			// 
			// tbCustomerCount
			// 
			this.tbCustomerCount.Dock = System.Windows.Forms.DockStyle.Left;
			this.tbCustomerCount.Location = new System.Drawing.Point(252, 0);
			this.tbCustomerCount.Name = "tbCustomerCount";
			this.tbCustomerCount.ReadOnly = true;
			this.tbCustomerCount.TabIndex = 3;
			this.tbCustomerCount.Text = "";
			// 
			// lblCustomerCount
			// 
			this.lblCustomerCount.Dock = System.Windows.Forms.DockStyle.Left;
			this.lblCustomerCount.Location = new System.Drawing.Point(48, 0);
			this.lblCustomerCount.Name = "lblCustomerCount";
			this.lblCustomerCount.Size = new System.Drawing.Size(72, 26);
			this.lblCustomerCount.TabIndex = 2;
			this.lblCustomerCount.Text = "Customers:";
			// 
			// tbCountries
			// 
			this.tbCountries.Dock = System.Windows.Forms.DockStyle.Left;
			this.tbCountries.Location = new System.Drawing.Point(352, 0);
			this.tbCountries.Name = "tbCountries";
			this.tbCountries.ReadOnly = true;
			this.tbCountries.TabIndex = 5;
			this.tbCountries.Text = "";
			// 
			// label1
			// 
			this.label1.Dock = System.Windows.Forms.DockStyle.Left;
			this.label1.Location = new System.Drawing.Point(120, 0);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(32, 26);
			this.label1.TabIndex = 4;
			this.label1.Text = "in";
			// 
			// label2
			// 
			this.label2.Dock = System.Windows.Forms.DockStyle.Left;
			this.label2.Location = new System.Drawing.Point(452, 0);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(72, 26);
			this.label2.TabIndex = 6;
			this.label2.Text = "Countries.";
			// 
			// frmDashboard
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(544, 26);
			this.ControlBox = false;
			this.Controls.Add(this.label2);
			this.Controls.Add(this.tbCountries);
			this.Controls.Add(this.tbCustomerCount);
			this.Controls.Add(this.tbOrderCount);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.lblCustomerCount);
			this.Controls.Add(this.lblOrderCount);
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "frmDashboard";
			this.Load += new System.EventHandler(this.frmDashboard_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void frmDashboard_Load(object sender, System.EventArgs e)
		{
			try
			{
				this.Cursor = Cursors.WaitCursor;
				this.Dock = DockStyle.Top;
				using(NorthwindBusinessLogicFacade nwda = new NorthwindBusinessLogicFacade())
					  {
					//TODO: Load up the dashboard data
					tbOrderCount.Text = nwda.RetrieveOrderCount().ToString();
					tbCustomerCount.Text = nwda.RetrieveCustomerCount().ToString();
					tbCountries.Text = nwda.RetrieveCustomerCountryList().Count.ToString();
				}
			}
			catch(Exception ex)
			{
				MainClass.MainUIThreadExceptionHandler(ex);
			}
			finally
			{
				this.Cursor=Cursors.Default;
			}
		}
	}
}
