Ejemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.users.user_oauth GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,user_id,user_name,oauth_name,oauth_access_token,oauth_openid,add_time from " + databaseprefix + "user_oauth ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Model.users.user_oauth model = new Model.users.user_oauth();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_id"] != null && ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_name"] != null && ds.Tables[0].Rows[0]["user_name"].ToString() != "")
                {
                    model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["oauth_name"] != null && ds.Tables[0].Rows[0]["oauth_name"].ToString() != "")
                {
                    model.oauth_name = ds.Tables[0].Rows[0]["oauth_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["oauth_access_token"] != null && ds.Tables[0].Rows[0]["oauth_access_token"].ToString() != "")
                {
                    model.oauth_access_token = ds.Tables[0].Rows[0]["oauth_access_token"].ToString();
                }
                if (ds.Tables[0].Rows[0]["oauth_openid"] != null && ds.Tables[0].Rows[0]["oauth_openid"].ToString() != "")
                {
                    model.oauth_openid = ds.Tables[0].Rows[0]["oauth_openid"].ToString();
                }
                if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.users.user_oauth model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + databaseprefix + "user_oauth set ");
            strSql.Append("user_id=@user_id,");
            strSql.Append("user_name=@user_name,");
            strSql.Append("oauth_name=@oauth_name,");
            strSql.Append("oauth_access_token=@oauth_access_token,");
            strSql.Append("oauth_openid=@oauth_openid,");
            strSql.Append("add_time=@add_time");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_id",            SqlDbType.Int,         4),
                new SqlParameter("@user_name",          SqlDbType.NVarChar,  100),
                new SqlParameter("@oauth_name",         SqlDbType.NVarChar,   50),
                new SqlParameter("@oauth_access_token", SqlDbType.NVarChar,  500),
                new SqlParameter("@oauth_openid",       SqlDbType.NVarChar,  255),
                new SqlParameter("@add_time",           SqlDbType.DateTime),
                new SqlParameter("@id",                 SqlDbType.Int, 4)
            };
            parameters[0].Value = model.user_id;
            parameters[1].Value = model.user_name;
            parameters[2].Value = model.oauth_name;
            parameters[3].Value = model.oauth_access_token;
            parameters[4].Value = model.oauth_openid;
            parameters[5].Value = model.add_time;
            parameters[6].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.users.user_oauth model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + databaseprefix + "user_oauth(");
            strSql.Append("user_id,user_name,oauth_name,oauth_access_token,oauth_openid,add_time)");
            strSql.Append(" values (");
            strSql.Append("@user_id,@user_name,@oauth_name,@oauth_access_token,@oauth_openid,@add_time)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_id",            SqlDbType.Int,        4),
                new SqlParameter("@user_name",          SqlDbType.NVarChar, 100),
                new SqlParameter("@oauth_name",         SqlDbType.NVarChar,  50),
                new SqlParameter("@oauth_access_token", SqlDbType.NVarChar, 500),
                new SqlParameter("@oauth_openid",       SqlDbType.NVarChar, 255),
                new SqlParameter("@add_time",           SqlDbType.DateTime)
            };
            parameters[0].Value = model.user_id;
            parameters[1].Value = model.user_name;
            parameters[2].Value = model.oauth_name;
            parameters[3].Value = model.oauth_access_token;
            parameters[4].Value = model.oauth_openid;
            parameters[5].Value = model.add_time;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public Model.users.user_oauth GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,user_id,user_name,oauth_name,oauth_access_token,oauth_openid,add_time from " + databaseprefix + "user_oauth ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            Model.users.user_oauth model = new Model.users.user_oauth();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_id"] != null && ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_name"] != null && ds.Tables[0].Rows[0]["user_name"].ToString() != "")
                {
                    model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["oauth_name"] != null && ds.Tables[0].Rows[0]["oauth_name"].ToString() != "")
                {
                    model.oauth_name = ds.Tables[0].Rows[0]["oauth_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["oauth_access_token"] != null && ds.Tables[0].Rows[0]["oauth_access_token"].ToString() != "")
                {
                    model.oauth_access_token = ds.Tables[0].Rows[0]["oauth_access_token"].ToString();
                }
                if (ds.Tables[0].Rows[0]["oauth_openid"] != null && ds.Tables[0].Rows[0]["oauth_openid"].ToString() != "")
                {
                    model.oauth_openid = ds.Tables[0].Rows[0]["oauth_openid"].ToString();
                }
                if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.users.user_oauth model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.users.user_oauth model)
 {
     return(dal.Add(model));
 }