示例#1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WeiXinPF.Model.wx_crm_users GetModel(int wid, string openid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,wid,openid,nickname,sex,city,country,province,language,headimgurl,subscribe_time,unionid,createDate,groupId,updateDate,uStatus  from wx_crm_users ");
            strSql.Append(" where wid=@wid and openid=@openid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",    SqlDbType.Int,     4),
                new SqlParameter("@openid", SqlDbType.VarChar, 300)
            };

            parameters[0].Value = wid;
            parameters[1].Value = openid;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WeiXinPF.Model.wx_crm_users model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_crm_users(");
            strSql.Append("wid,openid,nickname,sex,city,country,province,language,headimgurl,subscribe_time,unionid,createDate,groupId,updateDate,uStatus)");
            strSql.Append(" values (");
            strSql.Append("@wid,@openid,@nickname,@sex,@city,@country,@province,@language,@headimgurl,@subscribe_time,@unionid,@createDate,@groupId,@updateDate,@uStatus)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",            SqlDbType.Int,          4),
                new SqlParameter("@openid",         SqlDbType.VarChar,    300),
                new SqlParameter("@nickname",       SqlDbType.VarChar,    200),
                new SqlParameter("@sex",            SqlDbType.VarChar,     10),
                new SqlParameter("@city",           SqlDbType.VarChar,    200),
                new SqlParameter("@country",        SqlDbType.VarChar,    200),
                new SqlParameter("@province",       SqlDbType.VarChar,    200),
                new SqlParameter("@language",       SqlDbType.VarChar,     30),
                new SqlParameter("@headimgurl",     SqlDbType.VarChar,   1000),
                new SqlParameter("@subscribe_time", SqlDbType.VarChar,     30),
                new SqlParameter("@unionid",        SqlDbType.VarChar,    200),
                new SqlParameter("@createDate",     SqlDbType.DateTime),
                new SqlParameter("@groupId",        SqlDbType.Int,          4),
                new SqlParameter("@updateDate",     SqlDbType.DateTime),
                new SqlParameter("@uStatus",        SqlDbType.SmallInt, 2)
            };
            parameters[0].Value  = model.wid;
            parameters[1].Value  = model.openid;
            parameters[2].Value  = model.nickname;
            parameters[3].Value  = model.sex;
            parameters[4].Value  = model.city;
            parameters[5].Value  = model.country;
            parameters[6].Value  = model.province;
            parameters[7].Value  = model.language;
            parameters[8].Value  = model.headimgurl;
            parameters[9].Value  = model.subscribe_time;
            parameters[10].Value = model.unionid;
            parameters[11].Value = model.createDate;
            parameters[12].Value = model.groupId;
            parameters[13].Value = model.updateDate;
            parameters[14].Value = model.uStatus;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WeiXinPF.Model.wx_crm_users DataRowToModel(DataRow row)
        {
            WeiXinPF.Model.wx_crm_users model = new WeiXinPF.Model.wx_crm_users();
            if (row != null)
            {
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.id = int.Parse(row["id"].ToString());
                }
                if (row["wid"] != null && row["wid"].ToString() != "")
                {
                    model.wid = int.Parse(row["wid"].ToString());
                }
                if (row["openid"] != null)
                {
                    model.openid = row["openid"].ToString();
                }
                if (row["nickname"] != null)
                {
                    model.nickname = row["nickname"].ToString();
                }
                if (row["sex"] != null)
                {
                    model.sex = row["sex"].ToString();
                }
                if (row["city"] != null)
                {
                    model.city = row["city"].ToString();
                }
                if (row["country"] != null)
                {
                    model.country = row["country"].ToString();
                }
                if (row["province"] != null)
                {
                    model.province = row["province"].ToString();
                }
                if (row["language"] != null)
                {
                    model.language = row["language"].ToString();
                }
                if (row["headimgurl"] != null)
                {
                    model.headimgurl = row["headimgurl"].ToString();
                }
                if (row["subscribe_time"] != null)
                {
                    model.subscribe_time = row["subscribe_time"].ToString();
                }
                if (row["unionid"] != null)
                {
                    model.unionid = row["unionid"].ToString();
                }
                if (row["createDate"] != null && row["createDate"].ToString() != "")
                {
                    model.createDate = DateTime.Parse(row["createDate"].ToString());
                }
                if (row["groupId"] != null && row["groupId"].ToString() != "")
                {
                    model.groupId = int.Parse(row["groupId"].ToString());
                }

                if (row["updateDate"] != null && row["updateDate"].ToString() != "")
                {
                    model.updateDate = DateTime.Parse(row["updateDate"].ToString());
                }
                if (row["uStatus"] != null && row["uStatus"].ToString() != "")
                {
                    model.uStatus = int.Parse(row["uStatus"].ToString());
                }
            }
            return(model);
        }
示例#4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WeiXinPF.Model.wx_crm_users model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_crm_users set ");
            strSql.Append("wid=@wid,");
            strSql.Append("openid=@openid,");
            strSql.Append("nickname=@nickname,");
            strSql.Append("sex=@sex,");
            strSql.Append("city=@city,");
            strSql.Append("country=@country,");
            strSql.Append("province=@province,");
            strSql.Append("language=@language,");
            strSql.Append("headimgurl=@headimgurl,");
            strSql.Append("subscribe_time=@subscribe_time,");
            strSql.Append("unionid=@unionid,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("groupId=@groupId,");
            strSql.Append("updateDate=@updateDate,");
            strSql.Append("uStatus=@uStatus");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",            SqlDbType.Int,          4),
                new SqlParameter("@openid",         SqlDbType.VarChar,    300),
                new SqlParameter("@nickname",       SqlDbType.VarChar,    200),
                new SqlParameter("@sex",            SqlDbType.VarChar,     10),
                new SqlParameter("@city",           SqlDbType.VarChar,    200),
                new SqlParameter("@country",        SqlDbType.VarChar,    200),
                new SqlParameter("@province",       SqlDbType.VarChar,    200),
                new SqlParameter("@language",       SqlDbType.VarChar,     30),
                new SqlParameter("@headimgurl",     SqlDbType.VarChar,   1000),
                new SqlParameter("@subscribe_time", SqlDbType.VarChar,     30),
                new SqlParameter("@unionid",        SqlDbType.VarChar,    200),
                new SqlParameter("@createDate",     SqlDbType.DateTime),
                new SqlParameter("@groupId",        SqlDbType.Int,          4),
                new SqlParameter("@updateDate",     SqlDbType.DateTime),
                new SqlParameter("@uStatus",        SqlDbType.SmallInt,     2),
                new SqlParameter("@id",             SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.wid;
            parameters[1].Value  = model.openid;
            parameters[2].Value  = model.nickname;
            parameters[3].Value  = model.sex;
            parameters[4].Value  = model.city;
            parameters[5].Value  = model.country;
            parameters[6].Value  = model.province;
            parameters[7].Value  = model.language;
            parameters[8].Value  = model.headimgurl;
            parameters[9].Value  = model.subscribe_time;
            parameters[10].Value = model.unionid;
            parameters[11].Value = model.createDate;
            parameters[12].Value = model.groupId;
            parameters[13].Value = model.updateDate;
            parameters[14].Value = model.uStatus;
            parameters[15].Value = model.id;

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

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