using System;
using System.Data;
using System.Configuration;
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 System.Data.SqlClient;

/// <summary>
/// AdminManage 的摘要说明
/// </summary>
public class AdminManage
{
    public AdminManage()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }
    DataBase data = new DataBase();

    #region 定义管理员--数据结构
    private string adminname = "";
    private string adminpwd = "";
    /// <summary>
    /// 管理员姓名
    /// </summary>
    public string AdminName
    {
        get { return adminname; }
        set { adminname = value; }
    }
    /// <summary>
    /// 管理员密码
    /// </summary>
    public string AdminPwd
    {
        get { return adminpwd; }
        set { adminpwd = value; }
    }
    #endregion

    #region 修改--管理员信息
    /// <summary>
    /// 修改--管理员信息
    /// </summary>
    /// <param name="adminmanage"></param>
    /// <returns></returns>
    public int UpdateAdmin(AdminManage adminmanage)
    {
        SqlParameter[] prams = {
									    data.MakeInParam("@adminname",  SqlDbType.NVarChar, 50, adminmanage.AdminName),
                						data.MakeInParam("@adminpwd",  SqlDbType.NVarChar, 50,adminmanage.AdminPwd),
			};
        return (data.RunProc("update tb_Admin set 管理员姓名=@adminname,管理员密码=@adminpwd", prams));
    }
    #endregion

    #region 查询--管理员信息
    /// <summary>
    /// 得到所有--管理员信息
    /// </summary>
    /// <param name="tbName"></param>
    /// <returns></returns>
    public DataSet GetAllAdmin(string tbName)
    {
        return (data.RunProcReturn("select * from tb_Admin", tbName));
    }
    #endregion

    #region 管理员登录
    /// <summary>
    /// 管理员登录
    /// </summary>
    /// <param name="adminmanage"></param>
    /// <returns></returns>
    public DataSet Login(AdminManage adminmanage)
    {
        SqlParameter[] prams = {
									    data.MakeInParam("@adminname",  SqlDbType.NVarChar, 50, adminmanage.AdminName),
                						data.MakeInParam("@adminpwd",  SqlDbType.NVarChar, 50,adminmanage.AdminPwd),
			};
        return (data.RunProcReturn("SELECT * FROM tb_Admin WHERE (管理员姓名 = @adminname) AND (管理员密码 = @adminpwd)", prams, "tb_Admin"));
    }
    #endregion
}