Ejemplo n.º 1
0
        /// <summary>
        /// 更新一个用户
        /// </summary>
        /// <param name="entity">用户实体</param>
        public bool Update(SmartCampus.Entity.BASE_USER model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BASE_USER set ");

            strSql.Append(" USERID = @USERID , ");
            strSql.Append(" STATUS = @STATUS , ");
            strSql.Append(" ICON = @ICON , ");
            strSql.Append(" ROLEID = @ROLEID , ");
            strSql.Append(" USERNAME = @USERNAME , ");
            strSql.Append(" PWD = @PWD , ");
            strSql.Append(" SEX = @SEX , ");
            strSql.Append(" EMAIL = @EMAIL , ");
            strSql.Append(" TEL = @TEL , ");
            strSql.Append(" SDATE = @SDATE , ");
            strSql.Append(" EDATE = @EDATE , ");
            strSql.Append(" VERSION = @VERSION  ");
            strSql.Append(" where USERID=@USERID  ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@USERID",   SqlDbType.Int,         4),
                new SqlParameter("@STATUS",   SqlDbType.Int,         4),
                new SqlParameter("@ICON",     SqlDbType.VarChar,   200),
                new SqlParameter("@ROLEID",   SqlDbType.VarChar,   200),
                new SqlParameter("@USERNAME", SqlDbType.VarChar,    12),
                new SqlParameter("@PWD",      SqlDbType.VarChar,    32),
                new SqlParameter("@SEX",      SqlDbType.VarChar,     2),
                new SqlParameter("@EMAIL",    SqlDbType.VarChar,    50),
                new SqlParameter("@TEL",      SqlDbType.VarChar,    11),
                new SqlParameter("@SDATE",    SqlDbType.DateTime),
                new SqlParameter("@EDATE",    SqlDbType.DateTime),
                new SqlParameter("@VERSION",  SqlDbType.VarChar, 10)
            };

            parameters[12].Value = model.USERID;
            parameters[13].Value = model.STATUS;
            parameters[14].Value = model.ICON;
            parameters[15].Value = model.ROLEID;
            parameters[16].Value = model.USERNAME;
            parameters[17].Value = model.PWD;
            parameters[18].Value = model.SEX;
            parameters[19].Value = model.EMAIL;
            parameters[20].Value = model.TEL;
            parameters[21].Value = model.SDATE;
            parameters[22].Value = model.EDATE;
            parameters[23].Value = model.VERSION;
            int rows = SqlServerHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取一个实体
        /// </summary>
        /// <param name="userid">用户编号</param>
        public SmartCampus.Entity.BASE_USER GetEntity(int userid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select USERID, STATUS, ICON, ROLEID, USERNAME, PWD, SEX, EMAIL, TEL, SDATE, EDATE, VERSION  ");
            strSql.Append("  from BASE_USER ");
            strSql.Append(" where USERID=@USERID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@USERID", SqlDbType.Int, 4)
            };
            parameters[0].Value = userid;


            SmartCampus.Entity.BASE_USER model = new SmartCampus.Entity.BASE_USER();
            DataSet ds = SqlServerHelper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["USERID"].ToString() != "")
                {
                    model.USERID = int.Parse(ds.Tables[0].Rows[0]["USERID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["STATUS"].ToString() != "")
                {
                    model.STATUS = int.Parse(ds.Tables[0].Rows[0]["STATUS"].ToString());
                }
                model.ICON     = ds.Tables[0].Rows[0]["ICON"].ToString();
                model.ROLEID   = ds.Tables[0].Rows[0]["ROLEID"].ToString();
                model.USERNAME = ds.Tables[0].Rows[0]["USERNAME"].ToString();
                model.PWD      = ds.Tables[0].Rows[0]["PWD"].ToString();
                model.SEX      = ds.Tables[0].Rows[0]["SEX"].ToString();
                model.EMAIL    = ds.Tables[0].Rows[0]["EMAIL"].ToString();
                model.TEL      = ds.Tables[0].Rows[0]["TEL"].ToString();
                if (ds.Tables[0].Rows[0]["SDATE"].ToString() != "")
                {
                    model.SDATE = DateTime.Parse(ds.Tables[0].Rows[0]["SDATE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EDATE"].ToString() != "")
                {
                    model.EDATE = DateTime.Parse(ds.Tables[0].Rows[0]["EDATE"].ToString());
                }
                model.VERSION = ds.Tables[0].Rows[0]["VERSION"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加一个用户
        /// </summary>
        /// <remarks>用户实体对象userid不必赋值。</remarks>
        /// <param name="entity">用户实体</param>
        public void Add(SmartCampus.Entity.BASE_USER model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into BASE_USER(");
            strSql.Append("USERID,STATUS,ICON,ROLEID,USERNAME,PWD,SEX,EMAIL,TEL,SDATE,EDATE,VERSION");
            strSql.Append(") values (");
            strSql.Append("@USERID,@STATUS,@ICON,@ROLEID,@USERNAME,@PWD,@SEX,@EMAIL,@TEL,@SDATE,@EDATE,@VERSION");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@USERID",   SqlDbType.Int,         4),
                new SqlParameter("@STATUS",   SqlDbType.Int,         4),
                new SqlParameter("@ICON",     SqlDbType.VarChar,   200),
                new SqlParameter("@ROLEID",   SqlDbType.VarChar,   200),
                new SqlParameter("@USERNAME", SqlDbType.VarChar,    12),
                new SqlParameter("@PWD",      SqlDbType.VarChar,    32),
                new SqlParameter("@SEX",      SqlDbType.VarChar,     2),
                new SqlParameter("@EMAIL",    SqlDbType.VarChar,    50),
                new SqlParameter("@TEL",      SqlDbType.VarChar,    11),
                new SqlParameter("@SDATE",    SqlDbType.DateTime),
                new SqlParameter("@EDATE",    SqlDbType.DateTime),
                new SqlParameter("@VERSION",  SqlDbType.VarChar, 10)
            };

            parameters[0].Value  = model.USERID;
            parameters[1].Value  = model.STATUS;
            parameters[2].Value  = model.ICON;
            parameters[3].Value  = model.ROLEID;
            parameters[4].Value  = model.USERNAME;
            parameters[5].Value  = model.PWD;
            parameters[6].Value  = model.SEX;
            parameters[7].Value  = model.EMAIL;
            parameters[8].Value  = model.TEL;
            parameters[9].Value  = model.SDATE;
            parameters[10].Value = model.EDATE;
            parameters[11].Value = model.VERSION;
            SqlServerHelper.ExecuteSql(strSql.ToString(), parameters);
        }