using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ModuleManage_AddModule : System.Web.UI.Page
{
    ModuleManage modulemanage = new ModuleManage();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            txtID.Text = modulemanage.GetMID();
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (txtName.Text == string.Empty)
        {
            Response.Write("<script language=javascript>alert('版块名称不能为空！')</script>");
            return;
        }
        else
        {
            modulemanage.ModuleName=txtName.Text;
            if (modulemanage.FindModuleByName(modulemanage, "tb_Module").Tables[0].Rows.Count > 0)
            {
                Response.Write("<script language=javascript>alert('该版块名已经存在！')</script>");
                txtName.Text = string.Empty;
                txtName.Focus();
                return;
            }
            else
            {
                modulemanage.ModuleID = txtID.Text;
                modulemanage.ModuleName = txtName.Text;
                modulemanage.AddModule(modulemanage);
                Response.Redirect("ModuleManage.aspx");
            }
        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        txtName.Text = string.Empty;
    }
}
