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 System.Data.SqlClient;
using System.Configuration;

namespace IntranetApp
{
	/// <summary>
	/// Summary description for Conference.
	/// </summary>
	public partial class Conference : System.Web.UI.Page
	{
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
			Label2.Text="";
			txtAll.Text = Application["all"].ToString();
			if (!IsPostBack)
			{
				//txtAll.Text = Application["all"].ToString();
				try
				{
				Session["back"]=Request.UrlReferrer.AbsolutePath;
                if (con.State == ConnectionState.Closed) con.Open();
				SqlCommand cmd = new SqlCommand("select ename from emp", con);
                SqlDataReader dr;
                dr = cmd.ExecuteReader();
                while (dr.Read())
					{
						ListBox1.Items.Add(dr.GetValue(0).ToString());
					}
                dr.Close();
				}
				catch (Exception ex)
				{
					Label2.Text=ex.Message;
				}
			}
			
		}


		#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()
		{    

		}
		#endregion

		SqlConnection con=new SqlConnection(ConfigurationSettings.AppSettings.Get("con"));

		protected void Button2_Click(object sender, System.EventArgs e)
		{
			Session.Abandon();
			Session.RemoveAll();
			Response.Redirect("home.aspx");
		}

		protected void Button1_Click(object sender, System.EventArgs e)
		{
			if (con.State == ConnectionState.Closed) con.Open();
			SqlCommand cmd = new SqlCommand("select ename from emp where empno="+Session["eid"], con);
			SqlDataReader dr;
			dr = cmd.ExecuteReader();
			while(dr.Read())
			{
				txtAll.Text = dr.GetValue(0).ToString() +  ":" + txtSend.Text+"\n"+Application["all"];
				Application["all"] = txtAll.Text;
				txtSend.Text = "";
			}
			dr.Close();
		}

		protected void LinkButton1_Click(object sender, System.EventArgs e)
		{
			Response.Redirect(Session["back"].ToString());
		}

		protected void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}

		protected void txtAll_TextChanged(object sender, System.EventArgs e)
		{
			txtAll.Text=Application["all"].ToString();					
		}
	}
}
