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 edu.jhu.Cas.Users;
namespace edu.jhu.Cas
{
	/// <summary>
	/// Summary description for DropTable.
	/// </summary>
	public class DestroyGroup : System.Web.UI.Page
	{
		protected long wsid;
		protected System.Web.UI.WebControls.Button yesButton;
		protected System.Web.UI.WebControls.Button noButton;
		protected string groupName,lmessage;
		private void Page_Load(object sender, System.EventArgs e)
		{
			bool loggedin;
			loggedin = Session["USER"] != null;
			groupName = Request.Params["groupName"];
			if (loggedin) 
				wsid = (long)Session["USER"];
			if(groupName == null)
				Response.Redirect("groups.aspx");
		}
		
		protected void Yes(object source, EventArgs E)
		{
			lmessage = "Group "+groupName+" destroyed.";
			try
			{
				long gID = (new CasGroups()).FindGroups(wsid, " Name = '"+groupName+"'",false)[0].GID;
				(new CasGroups()).DestroyGroup(wsid,gID);
			}
			catch(Exception e)
			{
				lmessage = e.ToString();
			}
			//Response.Redirect("Groups.aspx?lmessage="+lmessage);
		}
		
		protected void No(object source, EventArgs e)
		{
			Response.Redirect("Groups.aspx");
		}
		#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.Load += new System.EventHandler(this.Page_Load);
		}
		#endregion
	}
}