Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.weixin_msg model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update weixin_msg set ");
            strSql.Append("openid=@openid,");
            strSql.Append("mesg=@mesg,");
            strSql.Append("beizhu=@beizhu,");
            strSql.Append("beizhu2=@beizhu2,");
            strSql.Append("style=@style,");
            strSql.Append("time=@time");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@openid",  SqlDbType.NChar,     50),
                new SqlParameter("@mesg",    SqlDbType.Text),
                new SqlParameter("@beizhu",  SqlDbType.NChar,     50),
                new SqlParameter("@beizhu2", SqlDbType.NChar,     10),
                new SqlParameter("@style",   SqlDbType.NChar,     10),
                new SqlParameter("@time",    SqlDbType.DateTime),
                new SqlParameter("@id",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.openid;
            parameters[1].Value = model.mesg;
            parameters[2].Value = model.beizhu;
            parameters[3].Value = model.beizhu2;
            parameters[4].Value = model.style;
            parameters[5].Value = model.time;
            parameters[6].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.weixin_msg DataRowToModel(DataRow row)
 {
     Maticsoft.Model.weixin_msg model = new Maticsoft.Model.weixin_msg();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["openid"] != null)
         {
             model.openid = row["openid"].ToString();
         }
         if (row["mesg"] != null)
         {
             model.mesg = row["mesg"].ToString();
         }
         if (row["beizhu"] != null)
         {
             model.beizhu = row["beizhu"].ToString();
         }
         if (row["beizhu2"] != null)
         {
             model.beizhu2 = row["beizhu2"].ToString();
         }
         if (row["style"] != null)
         {
             model.style = row["style"].ToString();
         }
         if (row["time"] != null && row["time"].ToString() != "")
         {
             model.time = DateTime.Parse(row["time"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.weixin_msg model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into weixin_msg(");
            strSql.Append("openid,mesg,beizhu,beizhu2,style,time)");
            strSql.Append(" values (");
            strSql.Append("@openid,@mesg,@beizhu,@beizhu2,@style,@time)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@openid",  SqlDbType.NChar, 50),
                new SqlParameter("@mesg",    SqlDbType.Text),
                new SqlParameter("@beizhu",  SqlDbType.NChar, 50),
                new SqlParameter("@beizhu2", SqlDbType.NChar, 10),
                new SqlParameter("@style",   SqlDbType.NChar, 10),
                new SqlParameter("@time",    SqlDbType.DateTime)
            };
            parameters[0].Value = model.openid;
            parameters[1].Value = model.mesg;
            parameters[2].Value = model.beizhu;
            parameters[3].Value = model.beizhu2;
            parameters[4].Value = model.style;
            parameters[5].Value = model.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 Maticsoft.Model.weixin_msg GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,openid,mesg,beizhu,beizhu2,style,time from weixin_msg ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }