示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MxWeiXinPF.Model.wx_sjb_users model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_sjb_users set ");
            strSql.Append("wid=@wid,");
            strSql.Append("openid=@openid,");
            strSql.Append("uName=@uName,");
            strSql.Append("tel=@tel,");
            strSql.Append("succTimes=@succTimes,");
            strSql.Append("failTimes=@failTimes");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",       SqlDbType.Int,       4),
                new SqlParameter("@openid",    SqlDbType.VarChar, 300),
                new SqlParameter("@uName",     SqlDbType.VarChar, 100),
                new SqlParameter("@tel",       SqlDbType.VarChar,  30),
                new SqlParameter("@succTimes", SqlDbType.Int,       4),
                new SqlParameter("@failTimes", SqlDbType.Int,       4),
                new SqlParameter("@id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.wid;
            parameters[1].Value = model.openid;
            parameters[2].Value = model.uName;
            parameters[3].Value = model.tel;
            parameters[4].Value = model.succTimes;
            parameters[5].Value = model.failTimes;
            parameters[6].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MxWeiXinPF.Model.wx_sjb_users DataRowToModel(DataRow row)
 {
     MxWeiXinPF.Model.wx_sjb_users model=new MxWeiXinPF.Model.wx_sjb_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["uName"]!=null)
         {
             model.uName=row["uName"].ToString();
         }
         if(row["tel"]!=null)
         {
             model.tel=row["tel"].ToString();
         }
         if(row["succTimes"]!=null && row["succTimes"].ToString()!="")
         {
             model.succTimes=int.Parse(row["succTimes"].ToString());
         }
         if(row["failTimes"]!=null && row["failTimes"].ToString()!="")
         {
             model.failTimes=int.Parse(row["failTimes"].ToString());
         }
     }
     return model;
 }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MxWeiXinPF.Model.wx_sjb_users model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_sjb_users(");
            strSql.Append("wid,openid,uName,tel,succTimes,failTimes)");
            strSql.Append(" values (");
            strSql.Append("@wid,@openid,@uName,@tel,@succTimes,@failTimes)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",       SqlDbType.Int,       4),
                new SqlParameter("@openid",    SqlDbType.VarChar, 300),
                new SqlParameter("@uName",     SqlDbType.VarChar, 100),
                new SqlParameter("@tel",       SqlDbType.VarChar,  30),
                new SqlParameter("@succTimes", SqlDbType.Int,       4),
                new SqlParameter("@failTimes", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.wid;
            parameters[1].Value = model.openid;
            parameters[2].Value = model.uName;
            parameters[3].Value = model.tel;
            parameters[4].Value = model.succTimes;
            parameters[5].Value = model.failTimes;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MxWeiXinPF.Model.wx_sjb_users DataRowToModel(DataRow row)
 {
     MxWeiXinPF.Model.wx_sjb_users model = new MxWeiXinPF.Model.wx_sjb_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["uName"] != null)
         {
             model.uName = row["uName"].ToString();
         }
         if (row["tel"] != null)
         {
             model.tel = row["tel"].ToString();
         }
         if (row["succTimes"] != null && row["succTimes"].ToString() != "")
         {
             model.succTimes = int.Parse(row["succTimes"].ToString());
         }
         if (row["failTimes"] != null && row["failTimes"].ToString() != "")
         {
             model.failTimes = int.Parse(row["failTimes"].ToString());
         }
     }
     return(model);
 }
示例#5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MxWeiXinPF.Model.wx_sjb_users GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,wid,openid,uName,tel,succTimes,failTimes from wx_sjb_users ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            MxWeiXinPF.Model.wx_sjb_users model = new MxWeiXinPF.Model.wx_sjb_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);
            }
        }
示例#6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MxWeiXinPF.Model.wx_sjb_users GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 id,wid,openid,uName,tel,succTimes,failTimes from wx_sjb_users ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

            MxWeiXinPF.Model.wx_sjb_users model=new MxWeiXinPF.Model.wx_sjb_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;
            }
        }