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

public partial class AccountType_MemberInfo : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!this.Page.IsPostBack)
        {
            BindPage();
        }
    }
    /// <summary>
    /// 绑定页面数据
    /// </summary>
    public void BindPage()
    {
        if (!string.IsNullOrEmpty(Request["mtid"]))
        {
            DataSet ds = SqlHelper.GetDataSet("SELECT MemberTypeName FROM dbo.tabA_Type_Member WHERE MemberTypeId=" + ConvertHelper.GetInteger(Request["mtid"]) + "", "constring");
            if(ds.Tables[0].Rows.Count>0)
            {
                txtMember.Text = ConvertHelper.GetString(ds.Tables[0].Rows[0]["MemberTypeName"]);//成员类型名
            }
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request["mtid"]))//修改成员信息
        {
            int flag = SqlHelper.Operation("UPDATE dbo.tabA_Type_Member SET MemberTypeName='" + txtMember.Text.Trim() + "' WHERE MemberTypeId="+ConvertHelper.GetInteger(Request["mtid"])+"", "constring");
            if (flag > 0)
            {
                Response.Redirect("Member.aspx");
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"","<script language='javascript' defer>alert('修改失败，请联系管理员！')</script>");
            }
        }
        else//添加成员类型
        {
            int flag = SqlHelper.Operation("INSERT INTO dbo.tabA_Type_Member(MemberTypeName,CreateTime) VALUES('"+txtMember.Text.Trim()+"','"+System.DateTime.Now+"')", "constring");
            if (flag > 0)
            {
                Response.Redirect("Member.aspx");
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script language='javascript' defer>alert('添加失败，请联系管理员！')</script>");
            }
        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("Member.aspx");
    }
}
