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

            strSql.Append("update wx_ucard_notice set ");
            strSql.Append("wid=@wid,");
            strSql.Append("nName=@nName,");
            strSql.Append("nContent=@nContent,");
            strSql.Append("userDegree=@userDegree,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("sId=@sId");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",        SqlDbType.Int,          4),
                new SqlParameter("@nName",      SqlDbType.VarChar,    100),
                new SqlParameter("@nContent",   SqlDbType.VarChar,   1500),
                new SqlParameter("@userDegree", SqlDbType.VarChar,    500),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@sId",        SqlDbType.Int,          4),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.wid;
            parameters[1].Value = model.nName;
            parameters[2].Value = model.nContent;
            parameters[3].Value = model.userDegree;
            parameters[4].Value = model.createDate;
            parameters[5].Value = model.sId;
            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 WeiXinPF.Model.wx_ucard_notice DataRowToModel(DataRow row)
 {
     WeiXinPF.Model.wx_ucard_notice model = new WeiXinPF.Model.wx_ucard_notice();
     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["nName"] != null)
         {
             model.nName = row["nName"].ToString();
         }
         if (row["nContent"] != null)
         {
             model.nContent = row["nContent"].ToString();
         }
         if (row["userDegree"] != null)
         {
             model.userDegree = row["userDegree"].ToString();
         }
         if (row["createDate"] != null && row["createDate"].ToString() != "")
         {
             model.createDate = DateTime.Parse(row["createDate"].ToString());
         }
         if (row["sId"] != null && row["sId"].ToString() != "")
         {
             model.sId = int.Parse(row["sId"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WeiXinPF.Model.wx_ucard_notice model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_ucard_notice(");
            strSql.Append("wid,nName,nContent,userDegree,createDate,sId)");
            strSql.Append(" values (");
            strSql.Append("@wid,@nName,@nContent,@userDegree,@createDate,@sId)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",        SqlDbType.Int,          4),
                new SqlParameter("@nName",      SqlDbType.VarChar,    100),
                new SqlParameter("@nContent",   SqlDbType.VarChar,   1500),
                new SqlParameter("@userDegree", SqlDbType.VarChar,    500),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@sId",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.wid;
            parameters[1].Value = model.nName;
            parameters[2].Value = model.nContent;
            parameters[3].Value = model.userDegree;
            parameters[4].Value = model.createDate;
            parameters[5].Value = model.sId;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WeiXinPF.Model.wx_ucard_notice GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,wid,nName,nContent,userDegree,createDate,sId from wx_ucard_notice ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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