Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="GUID">    </param>
        /// <returns></returns>
        public static Entity.User GetUser(string GUID)
        {
            Entity.User           entity    = null;
            DBOperatorBase        db        = new DataBase();
            IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory();

            try
            {
                IDataReader dataReader = db.ExecuteReader(Config.con, CommandType.Text, "Select * from [User] where GUID='" + GUID + "'", null);
                while (dataReader.Read())
                {
                    entity            = new Entity.User();
                    entity.ID         = DataHelper.ParseToInt(dataReader["ID"].ToString());
                    entity.UserName   = dataReader["UserName"].ToString();
                    entity.PassWord   = dataReader["PassWord"].ToString();
                    entity.GUID       = dataReader["GUID"].ToString();
                    entity.Department = dataReader["Department"].ToString();
                    entity.RealName   = dataReader["RealName"].ToString();
                    entity.PwdChgDate = DataHelper.ParseToDate(dataReader["PwdChgDate"].ToString());
                    //entity.CreateUser = dataReader["CreateUser"].ToString();
                    //entity.CreateDate = DataHelper.ParseToDate(dataReader["CreateDate"].ToString());
                    //entity.UpdateUser = dataReader["UpdateUser"].ToString();
                    //entity.UpdateDate = DataHelper.ParseToDate(dataReader["UpdateDate"].ToString());
                    entity.IsStop = DataHelper.ParseToBoolean(dataReader["IsStop"].ToString());
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                db.Conn.Close();
            }
            return(entity);
        }
Beispiel #2
0
        public IList <Entity.User> select(Entity.User user)
        {
            //throw new NotImplementedException();
            IList <Entity.User> Luser;
            string sql;

            //条件:实体没有传过来参数
            if (user.UserID == null)
            {
                SqlParameter[] sqlparams = //new SqlParameter ("@userID",user.UserID ),
                {
                    new SqlParameter("@lever",  "管理员"),
                    new SqlParameter("@lever2", "操作员")
                };
                sql = "select * from user_info where level=@lever or level=@lever2 ";
                DataTable table = DAL.sqlhelper.GetDatable(sql, CommandType.Text, sqlparams);
                Luser = DAL.CovertHelper <Entity.User> .ConvertToModel(table);
            }
            //条件:实体传递过来参数的时候
            else
            {
                SqlParameter[] sqlparamsB = { new SqlParameter("@userID", user.UserID),
                                              new SqlParameter("@lever",  "管理员"),
                                              new SqlParameter("@lever2", "操作员") };
                sql = "select * from user_info where userID=@userID";
                DataTable table = DAL.sqlhelper.GetDatable(sql, CommandType.Text, sqlparamsB);
                Luser = DAL.CovertHelper <Entity.User> .ConvertToModel(table);
            }
            //DataTable table = DAL.sqlhelper.GetDatable(sql, CommandType.Text, sqlparams);
            //IList<Entity.User> Luser = DAL.CovertHelper<Entity.User>.ConvertToModel(table);
            return(Luser);
        }
Beispiel #3
0
        public bool IdelUser(Entity.User user)
        {
            //throw new NotImplementedException();
            SqlParameter[] para = { new SqlParameter("@userid", user.UserID) };
            string         sql  = "delete from user_info where userID =@userid";

            return(sqlhelper.ExecuteNonquery(sql, CommandType.Text, para));
        }
Beispiel #4
0
        public bool IaddUser(Entity.User user)
        {
            //throw new NotImplementedException();
            SqlParameter[] para = { new SqlParameter("@userid",   user.UserID),
                                    new SqlParameter("@username", user.UserName),
                                    new SqlParameter("@password", user.PassWord),
                                    new SqlParameter("@level",    user.Level),
                                    new SqlParameter("@head",     user.Head) };
            string         sql = "insert into user_info values(@userid,@username,@password,@level,@head)";

            return(sqlhelper.ExecuteNonquery(sql, CommandType.Text, para));
        }
Beispiel #5
0
        public IList <Entity.User> SelectUser(Entity.User UserInfo)
        {
            SqlParameter[] sqlParams = { new SqlParameter("@userID", UserInfo.UserID), new SqlParameter("@pwd", UserInfo.PassWord) };
            //SqlParameter[] sqlParams = { new SqlParameter("@userID", UserInfo.UserID) };
            string sql = "select * from User_info where UserID=@userID and PassWord=@pwd";
            //string sql = @"select * from User_info where UserID=@userID";
            DataTable           table = DAL.sqlhelper.GetDatable(sql, CommandType.Text, sqlParams);
            IList <Entity.User> user  = DAL.CovertHelper <Entity.User> .ConvertToModel(table);

            return(user);
            //return table;
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static List <Entity.User> GetAllUser()
        {
            List <Entity.User>    list      = new List <Entity.User>();
            DBOperatorBase        db        = new DataBase();
            IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory();

            try
            {
                IDbDataParameter[] prams =
                {
                };
                IDataReader dataReader = db.ExecuteReader(Config.con, CommandType.StoredProcedure, "proc_User_GetAll", prams);
                while (dataReader.Read())
                {
                    Entity.User entity = new Entity.User();
                    entity.ID       = DataHelper.ParseToInt(dataReader["ID"].ToString());
                    entity.UserName = dataReader["UserName"].ToString();
                    entity.PassWord = dataReader["PassWord"].ToString();
                    entity.GUID     = dataReader["GUID"].ToString();
                    //entity.AreaCode = dataReader["AreaCode"].ToString();
                    //entity.AreaInCharge = dataReader["AreaInCharge"].ToString();
                    entity.RealName   = dataReader["RealName"].ToString();
                    entity.PwdChgDate = DataHelper.ParseToDate(dataReader["PwdChgDate"].ToString());
                    //entity.CreateUser = dataReader["CreateUser"].ToString();
                    //entity.CreateDate = DataHelper.ParseToDate(dataReader["CreateDate"].ToString());
                    //entity.UpdateUser = dataReader["UpdateUser"].ToString();
                    //entity.UpdateDate = DataHelper.ParseToDate(dataReader["UpdateDate"].ToString());
                    entity.IsStop = DataHelper.ParseToBoolean(dataReader["IsStop"].ToString());
                    list.Add(entity);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                db.Conn.Close();
            }
            return(list);
        }