Ejemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public S_UserInfoModel GetModel(Guid UserID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 UserID,UserName,UserAccount,UserPwd,UserSalt,UserPhone,UserEmail,SendEmailTime,CreateTime,UserNick,UserStatus,UserLogin,UpdateTime,RoleID,UserImg,UserNote,DepartmentID,UserClass,UserGroupID from S_UserInfo ");
            strSql.Append(" where UserID=@UserID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserID", SqlDbType.UniqueIdentifier, 16)
            };
            parameters[0].Value = UserID;

            S_UserInfoModel model = new S_UserInfoModel();
            DataSet         ds    = db.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public S_UserInfoModel DataRowToModel(DataRow row)
        {
            S_UserInfoModel model = new S_UserInfoModel();

            if (row != null)
            {
                if (row["UserID"] != null && row["UserID"].ToString() != "")
                {
                    model.UserID = new Guid(row["UserID"].ToString());
                }
                if (row["UserName"] != null)
                {
                    model.UserName = row["UserName"].ToString();
                }
                if (row["UserAccount"] != null)
                {
                    model.UserAccount = row["UserAccount"].ToString();
                }
                if (row["UserPwd"] != null)
                {
                    model.UserPwd = row["UserPwd"].ToString();
                }
                if (row["UserSalt"] != null)
                {
                    model.UserSalt = row["UserSalt"].ToString();
                }
                if (row["UserPhone"] != null)
                {
                    model.UserPhone = row["UserPhone"].ToString();
                }
                if (row["UserEmail"] != null)
                {
                    model.UserEmail = row["UserEmail"].ToString();
                }
                if (row["SendEmailTime"] != null && row["SendEmailTime"].ToString() != "")
                {
                    model.SendEmailTime = DateTime.Parse(row["SendEmailTime"].ToString());
                }
                if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
                }
                if (row["UserNick"] != null)
                {
                    model.UserNick = row["UserNick"].ToString();
                }
                if (row["UserStatus"] != null && row["UserStatus"].ToString() != "")
                {
                    model.UserStatus = int.Parse(row["UserStatus"].ToString());
                }
                if (row["UserLogin"] != null && row["UserLogin"].ToString() != "")
                {
                    model.UserLogin = int.Parse(row["UserLogin"].ToString());
                }
                if (row["UpdateTime"] != null && row["UpdateTime"].ToString() != "")
                {
                    model.UpdateTime = DateTime.Parse(row["UpdateTime"].ToString());
                }
                if (row["RoleID"] != null && row["RoleID"].ToString() != "")
                {
                    model.RoleID = int.Parse(row["RoleID"].ToString());
                }
                if (row["UserImg"] != null)
                {
                    model.UserImg = row["UserImg"].ToString();
                }
                if (row["UserNote"] != null)
                {
                    model.UserNote = row["UserNote"].ToString();
                }
                if (row["DepartmentID"] != null && row["DepartmentID"].ToString() != "")
                {
                    model.DepartmentID = int.Parse(row["DepartmentID"].ToString());
                }
                if (row["UserClass"] != null)
                {
                    model.UserClass = row["UserClass"].ToString();
                }
                if (row["UserGroupID"] != null && row["UserGroupID"].ToString() != "")
                {
                    model.UserGroupID = int.Parse(row["UserGroupID"].ToString());
                }
            }
            return(model);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(S_UserInfoModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into S_UserInfo(");
            strSql.Append("UserID,UserName,UserAccount,UserPwd,UserSalt,UserPhone,UserEmail,SendEmailTime,CreateTime,UserNick,UserStatus,UserLogin,UpdateTime,RoleID,UserImg,UserNote,DepartmentID,UserClass,UserGroupID)");
            strSql.Append(" values (");
            strSql.Append("@UserID,@UserName,@UserAccount,@UserPwd,@UserSalt,@UserPhone,@UserEmail,@SendEmailTime,@CreateTime,@UserNick,@UserStatus,@UserLogin,@UpdateTime,@RoleID,@UserImg,@UserNote,@DepartmentID,@UserClass,@UserGroupID)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserID",        SqlDbType.UniqueIdentifier,           16),
                new SqlParameter("@UserName",      SqlDbType.NVarChar,                   50),
                new SqlParameter("@UserAccount",   SqlDbType.NVarChar,                   50),
                new SqlParameter("@UserPwd",       SqlDbType.NVarChar,                  200),
                new SqlParameter("@UserSalt",      SqlDbType.NVarChar,                   50),
                new SqlParameter("@UserPhone",     SqlDbType.NVarChar,                   50),
                new SqlParameter("@UserEmail",     SqlDbType.NVarChar,                   50),
                new SqlParameter("@SendEmailTime", SqlDbType.DateTime),
                new SqlParameter("@CreateTime",    SqlDbType.DateTime),
                new SqlParameter("@UserNick",      SqlDbType.NVarChar,                   50),
                new SqlParameter("@UserStatus",    SqlDbType.Int,                         4),
                new SqlParameter("@UserLogin",     SqlDbType.Int,                         4),
                new SqlParameter("@UpdateTime",    SqlDbType.DateTime),
                new SqlParameter("@RoleID",        SqlDbType.Int,                         4),
                new SqlParameter("@UserImg",       SqlDbType.NVarChar,         int.MaxValue),
                new SqlParameter("@UserNote",      SqlDbType.NVarChar,                  500),
                new SqlParameter("@DepartmentID",  SqlDbType.Int,                         4),
                new SqlParameter("@UserClass",     SqlDbType.NVarChar,                   50),
                new SqlParameter("@UserGroupID",   SqlDbType.Int, 4)
            };
            parameters[0].Value  = Guid.NewGuid();
            parameters[1].Value  = model.UserName;
            parameters[2].Value  = model.UserAccount;
            parameters[3].Value  = model.UserPwd;
            parameters[4].Value  = model.UserSalt;
            parameters[5].Value  = model.UserPhone;
            parameters[6].Value  = model.UserEmail;
            parameters[7].Value  = model.SendEmailTime;
            parameters[8].Value  = model.CreateTime;
            parameters[9].Value  = model.UserNick;
            parameters[10].Value = model.UserStatus;
            parameters[11].Value = model.UserLogin;
            parameters[12].Value = model.UpdateTime;
            parameters[13].Value = model.RoleID;
            parameters[14].Value = model.UserImg;
            parameters[15].Value = model.UserNote;
            parameters[16].Value = model.DepartmentID;
            parameters[17].Value = model.UserClass;
            parameters[18].Value = 0; //model.UserGroupID;

            int rows = db.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }