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;
using edu.jhu.Cas.Util;
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 lmessage;
        protected Group ThisGroup;
        protected static CasGroups cg = new CasGroups();
        private void Page_Load(object sender, System.EventArgs e)
		{
			bool loggedin;
			loggedin = Session["USER"] != null;
            long gid = int.Parse(Request.Params["gid"]);
            if (loggedin) {
                wsid = (long)Session["USER"];
                ThisGroup = cg.GetGroupByID(wsid, gid);
            }
		}

        protected void Yes(object source, EventArgs E) {
            lmessage = "Group " + ThisGroup.Name + " destroyed.";
            try {
                (new CasGroups()).DestroyGroup(wsid, ThisGroup.GID);
                Response.Redirect("Groups.aspx?lmessage=" + lmessage);
            } catch (Exception e) {
                lmessage = e.ToString();
            }
        }

        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
    }
}