using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Microsoft.RFIDLab.EPCISDemo.Common;

namespace Microsoft.RFIDLab.EPCISDemo
{
	/// <summary>
	/// Summary description for AdminPage.
	/// </summary>
	public class AdminPage : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label lblResetPalletInformation;
		protected System.Web.UI.WebControls.Button btnPalletInformation;
		protected System.Web.UI.WebControls.Label lblResetDatabase;
		protected System.Web.UI.WebControls.Button btnResetDatabase;
		protected System.Web.UI.WebControls.Label Label2;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			lblResetPalletInformation.Text = "Click on this button to reset all pallet EPC information from the database. <br>This will clear all previous palletizations carried out.";
			lblResetDatabase.Text = "Click on this button to reset all case and pallet EPC information from the database. <br>This will clear all previous case and pallet EPCs generated.";
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.btnPalletInformation.Click += new System.EventHandler(this.btnPalletInformation_Click);
			this.btnResetDatabase.Click += new System.EventHandler(this.btnResetDatabase_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void btnPalletInformation_Click(object sender, System.EventArgs e)
		{
			DatabaseManager dm = new DatabaseManager(System.Configuration.ConfigurationSettings.AppSettings["ManufacturerString"]);
			dm.ResetPalletInformation();
			btnPalletInformation.Enabled = false;
		}

		private void btnResetDatabase_Click(object sender, System.EventArgs e)
		{
			DatabaseManager dm = new DatabaseManager(System.Configuration.ConfigurationSettings.AppSettings["ManufacturerString"]);
			dm.ResetDatabase();
			btnResetDatabase.Enabled=false;
		}
	}
}
