Exemplo n.º 1
0
        /// <summary>
        /// 增加一条管理员信息
        /// </summary>
        /// <param name="manager"></param>
        /// <returns></returns>
        public int AddManager(Manager manager)
        {
            int result = 0;
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append(" insert into T_Sys_Manager(");
                strSql.Append(" RoleId,DeptId,UserName,UserPwd,UserSalt,RealName,Tel,IsLock,Level,AddTime)");
                strSql.Append(" values (");
                strSql.Append(" @RoleId,@DeptId,@UserName,@UserPwd,@UserSalt,@RealName,@Tel,@IsLock,@Level,@AddTime)");
                strSql.Append(" ;select @@IDENTITY");

                SqlParameter[] parameters = {
                    new SqlParameter("@RoleId", SqlDbType.Int,4),
                    new SqlParameter("@DeptId", SqlDbType.Int,4),
                    new SqlParameter("@UserName", SqlDbType.NVarChar,50),
                    new SqlParameter("@UserPwd", SqlDbType.NVarChar,100),
                    new SqlParameter("@UserSalt", SqlDbType.NVarChar,20),
                    new SqlParameter("@RealName", SqlDbType.NVarChar,100),
                    new SqlParameter("@Tel", SqlDbType.NVarChar,20),
                    new SqlParameter("@IsLock", SqlDbType.Int,2),
                    new SqlParameter("@Level", SqlDbType.Int,2),
              					new SqlParameter("@AddTime", SqlDbType.DateTime)
                                            };
                parameters[0].Value = manager.RoleId;
                parameters[1].Value = manager.DeptId;
                parameters[2].Value = manager.UserName;
                parameters[3].Value = manager.UserPwd;
                parameters[4].Value = manager.UserSalt;
                parameters[5].Value = manager.RealName;
                parameters[6].Value = manager.Tel;
                parameters[7].Value = manager.IsLock;
                parameters[8].Value = manager.Level;
                parameters[9].Value = manager.AddTime;

                object obj = SqlHelper.ExecuteScalar(SqlHelper.connString, CommandType.Text, strSql.ToString(), parameters);
                if (obj != null)
                {
                    result = Convert.ToInt32(obj);
                }
            }

            catch (Exception e)
            {
                Log4Net.LogWrite("err", "Med_DAL:DAL_Manager//AddManager" + e.Message);  //发生异常,记录
            }
            return result;
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CheckAdminLevel("DrugManager"); //判断操作权限
                manager = GetAdminInfo();
                action = DTRequest.GetQueryString("action");
                BindData(action);

                if (action == "edit")
                {
                    this.txtDrugName.Enabled = false; //药品名 不能更改
                    BindDrug(int.Parse(DTRequest.GetQueryString("id")));
                }
            }
        }
 /// <summary>
 /// 页面加载
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     this.keywords = DTRequest.GetQueryString("keywords");
     this.pageSize = GetPageSize(10);  //默认每页显示十条数据
     if (!IsPostBack)
     {
         CheckAdminLevel("BossQuery");//判断操作权限
         manager = GetAdminInfo();
         listDept = BLL_Department.GetDepartmentList(" TypeId=4 or TypeId=2 or TypeId=5 or TypeId=6 "); //获取,药店 乡镇 救助类别 患者类别 信息
         BindDept(); //绑定下拉列表
         BindData(this.keywords);
     }
 }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     this.keywords = DTRequest.GetQueryString("keywords");
     this.pageSize = GetPageSize(10);  //默认每页显示十条数据
     if (!IsPostBack)
     {
         CheckAdminLevel("Civil");//判断操作权限
         manager = GetAdminInfo();
         listDept = BLL_Department.GetDepartmentList(" TypeId=1 or TypeId=3 or TypeId=4 "); //获取,医院 诊所 药店的部门信息
         BindData(this.keywords);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// 页面加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //分页使用
            this.keywords = DTRequest.GetQueryString("keywords");
            int.TryParse(DTRequest.GetQueryString("homeId"), out homeId);
            int.TryParse(DTRequest.GetQueryString("helpClass"), out helpClass);
            int.TryParse(DTRequest.GetQueryString("patientClass"), out patientClass);
            int.TryParse(DTRequest.GetQueryString("typeId"), out typeId);

            this.pageSize = GetPageSize(10);  //默认每页显示十条数据
            if (!IsPostBack)
            {
                CheckAdminLevel("Hospital");//判断操作权限
                manager = GetAdminInfo();
                listDept = BLL_Department.GetDepartmentList(" TypeId=6 or TypeId=5 or TypeId=2 "); //获取,救助类别 患者类别 乡镇 的部门数据
                BindDept(); //绑定下拉列表
                BindData(this.keywords);

            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 页面加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            this.keywords = DTRequest.GetQueryString("keywords");
            this.pageSize = GetPageSize(10);  //默认每页显示十条数据
            listDept = BLL_Department.GetDepartmentList(" TypeId=4 ");//找出所有的药店
            if (!IsPostBack)
            {
                CheckAdminLevel("DrugManager"); //判断操作权限
                manager = GetAdminInfo();
                BindDpet();
                BindData(this.keywords);

            }
        }
        /// <summary>
        /// 管理 管理员  添加 or 修改
        /// </summary>
        /// <param name="type">edit add</param>
        /// <returns></returns>
        private bool AdminManager(string type)
        {
            var manager = new Med_Model.Manager();
            CheckTheData(ref manager); //检查数据合法性
            if (type == "add")
            {
                //如果添加管理员成功 同时成功记录操作日志的话 返回true
                return (BLL_Manager.AddManager(manager) > 0) && (AddSysLog(CommonEnum.ActionType.Add.ToString(), "添加管理员") ? true : false);
            }
            if (type == "edit" || type == "ChangePwd")
            {
                //如果更新管理员信息成功,同时添加日志成功 返回true 否则返回false  更改密码后 下一次登录有效
                return (BLL_Manager.UpdateManager(manager)) && (AddSysLog(CommonEnum.ActionType.Update.ToString(), "修改管理员信息") ? true : false);

            }
            return false; //目前只有添加 修改两种操作,以后可能扩展
        }
Exemplo n.º 8
0
        private static readonly DAL_Manager DalManager = new DAL_Manager(); //实例化

        #endregion Fields

        #region Methods

        /// <summary>
        /// 增加一条管理员信息
        /// </summary>
        /// <param name="manager">管理员实体</param>
        /// <returns></returns>
        public static int AddManager(Manager manager)
        {
            return DalManager.AddManager(manager);
        }
Exemplo n.º 9
0
 /// <summary>
 /// 更新一条管理员记录信息
 /// </summary>
 /// <param name="manager"></param>
 /// <returns>
 ///     成功:true
 ///     失败:false
 /// </returns>
 public static bool UpdateManager(Manager manager)
 {
     return DalManager.UpdateManager(manager);
 }
Exemplo n.º 10
0
        /// <summary>
        /// 更新一条管理员记录信息
        /// </summary>
        /// <param name="manager"></param>
        /// <returns>
        ///     成功:true
        ///     失败:false
        /// </returns>
        public bool UpdateManager(Manager manager)
        {
            bool result = false;
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append(" update T_Sys_Manager set");
                strSql.Append(" RoleId=@RoleId,");
                strSql.Append(" DeptId=@DeptId,");
                strSql.Append(" UserPwd=@UserPwd,");
                strSql.Append(" UserSalt=@UserSalt,");
                strSql.Append(" RealName=@RealName,");
                strSql.Append(" Tel=@Tel,");
                strSql.Append(" IsLock=@IsLock,");
                strSql.Append(" Level=@Level,");
                strSql.Append(" AddTime=@AddTime");
                strSql.Append(" where UserName=@UserName");
                SqlParameter[] parameters = {
                    new SqlParameter("@RoleId", SqlDbType.Int,4),
                    new SqlParameter("@DeptId", SqlDbType.Int,4),
                    new SqlParameter("@UserPwd", SqlDbType.NVarChar,100),
                    new SqlParameter("@UserSalt", SqlDbType.NVarChar,20),
                    new SqlParameter("@RealName", SqlDbType.NVarChar,100),
                    new SqlParameter("@Tel", SqlDbType.NVarChar,20),
                    new SqlParameter("@IsLock", SqlDbType.Int,2),
                    new SqlParameter("@Level", SqlDbType.Int,2),
              					new SqlParameter("@AddTime", SqlDbType.DateTime),
                    new SqlParameter("@UserName", SqlDbType.NVarChar,50)
                                            };
                parameters[0].Value = manager.RoleId;
                parameters[1].Value = manager.DeptId;
                parameters[2].Value = manager.UserPwd;
                parameters[3].Value = manager.UserSalt;
                parameters[4].Value = manager.RealName;
                parameters[5].Value = manager.Tel;
                parameters[6].Value = manager.IsLock;
                parameters[7].Value = manager.Level;
                parameters[8].Value = manager.AddTime;
                parameters[9].Value = manager.UserName;

                if (SqlHelper.ExecuteNonQuery(SqlHelper.connString, CommandType.Text, strSql.ToString(), parameters) > 0) //更改成功 影响条数为1
                {
                    result = true;  //更新成功设置为true
                }
            }
            catch (Exception e)
            {
                Log4Net.LogWrite("err", "Med_DAL:DAL_Manager//UpdateManager" + e.Message);  //发生异常,记录
            }
            return result;
        }
Exemplo n.º 11
0
        /// <summary>
        /// 根据真实姓名或者用户名得到管理员实体信息
        /// </summary>
        /// <param name="Name">姓名或者用户名</param>
        /// <param name="typeId">
        ///     0:用户名
        ///     1:真实姓名
        /// </param>
        /// <returns></returns>
        public Manager SelectManagerByName(string Name, int typeId = 0)
        {
            Manager manager = new Manager();
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append(" select top 1 Id,RoleId,DeptId,UserName,UserName,UserPwd,UserSalt,RealName,Tel,IsLock,Level,AddTime from T_Sys_Manager");
                if (typeId == 1)
                    strSql.Append(" where RealName=@Name");
                strSql.Append(" where UserName=@Name");

                SqlParameter[] parameters = {
                    new SqlParameter("@Name", SqlDbType.NVarChar,50)};
                parameters[0].Value = Name;

                // manager = LoadEntity(SqlHelper.ExecuteDataset(SqlHelper.connString, CommandType.Text, strSql.ToString(), parameters).Tables[0]);

                manager = SqlHelper.ExecuteDataset(SqlHelper.connString, CommandType.StoredProcedure, "sp_divpage", parameters).Tables[0].ToList<Manager>()[0]; //当前List<> 中只有一条记录,用这种方式得到
            }
            catch (Exception e)
            {
                Log4Net.LogWrite("err", "Med_DAL:DAL_Manager//SelectManagerByName" + e.Message);  //发生异常,记录
            }
            return manager;
        }
Exemplo n.º 12
0
        /// <summary>
        /// 根据管理员编号找到相应管理员信息
        /// </summary>
        /// <param name="id">管理员编号</param>
        /// <returns></returns>
        public Manager SelectManagerById(int id)
        {
            Manager manager = new Manager();
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append(" select top 1 Id,RoleId,DeptId,UserName,UserName,UserPwd,UserSalt,RealName,Tel,IsLock,Level,AddTime from T_Sys_Manager");
                strSql.Append(" where Id=@id");

                SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)};
                parameters[0].Value = id;

                // manager = LoadEntity(SqlHelper.ExecuteDataset(SqlHelper.connString, CommandType.Text, strSql.ToString(), parameters).Tables[0]);
                manager = SqlHelper.ExecuteDataset(SqlHelper.connString, CommandType.Text, strSql.ToString(), parameters).Tables[0].ToList<Manager>()[0];//当前List<> 中只有一条记录,用这种方式得到
            }
            catch (Exception e)
            {
                Log4Net.LogWrite("err", "Med_DAL:DAL_Manager//SelectManagerByName" + e.Message);  //发生异常,记录
            }
            return manager;
        }
Exemplo n.º 13
0
        /// <summary>
        ///  根据用户名密码返回一个实体
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="userPwd">密码</param>
        /// <returns></returns>
        public Manager GetManager(string userName, string userPwd)
        {
            string salt = this.GetSaltByUserName(userName);
            if (string.IsNullOrEmpty(salt))
            {
                return null;
            }
            Manager manager = new Manager();
            //把明文进行加密重新赋值
            userPwd = DESEncrypt.Encrypt(userPwd, salt);
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("select Id,RoleId,DeptId,UserName,UserPwd,UserSalt,RealName,Tel,IsLock,Level,AddTime from T_Sys_Manager");
                strSql.Append(" where UserName=@UserName and UserPwd=@UserPwd ");
                SqlParameter[] parameters = {
                    new SqlParameter("@UserName", SqlDbType.NVarChar,50),
                    new SqlParameter("@UserPwd", SqlDbType.NVarChar,50)};
                parameters[0].Value = userName;
                parameters[1].Value = userPwd;

                manager = SqlHelper.ExecuteDataset(SqlHelper.connString, CommandType.Text, strSql.ToString(), parameters).Tables[0].ToModel<Manager>();

            }
            catch (Exception e)
            {
                Log4Net.LogWrite("err", "Med_DAL:DAL_Manager//GetManager" + e.Message);  //发生异常,记录
            }
            return manager;
        }