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;
using Fm.Bussiness;

public partial class admin_sys_user_add : BasePage
{
 
    protected void Page_Load(object sender, EventArgs e)
    {
       
        if (!IsPostBack)
        {
            public_select ps = new public_select();
            drop_role.DataSource = ps.Getps("Fm_role","*","");
            drop_role.DataTextField = "r_name";
            drop_role.DataValueField = "r_id";
            drop_role.DataBind();
        } 
        if (Request.Form["value"] != null)
        {
            Response.ContentType = "text/html";
            Response.Write(GetUser(Request.Form["value"].ToString()));
            Response.Flush();
            Response.Close();
        }
    }
    string GetUser(string username)
    {
        public_select ps = new public_select();
        string str = "";
        DataView dv = ps.Getps("Fm_user","u_name","u_name='"+username+"'");
        if (dv.Count > 0)
        {
            str= "false";
        }
        else
        {
            str= "true";
        }
        return str;
    }
    //信息的添加
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        sys_user_user sys = new sys_user_user();
        public_select ps = new public_select();
        //将获取的密码进行加密
        string pass= FormsAuthentication.HashPasswordForStoringInConfigFile(txt_pass.Text.Trim(), "MD5");
        //会员信息实体类
        Fm.EntityClass.User user = new Fm.EntityClass.User();
        user.u_name=txt_name.Text.Trim();
        user.u_pass=pass;
        user.u_nc=txt_nichen.Text;
        user.u_mail=txt_email.Text.Trim();
        user.u_id=sys.sys_user_add(user);
        if (user.u_id>0)
        {  
            //会员所属角色添加
            Fm.EntityClass.Urcenter ur = new Fm.EntityClass.Urcenter();
            ur.r_id=int.Parse(drop_role.SelectedValue);
            ur.u_id=user.u_id;
            if (sys.sys_ur_add(ur))
            {
                Response.Redirect("../Erro.aspx?eid=新会员添加成功!&url=user/sys_user_list.aspx", false);
            }
        }
    }
}
