예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.t_index_announce model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_index_announce set ");
            strSql.Append("sTitle=@sTitle,");
            strSql.Append("sCover=@sCover,");
            strSql.Append("sSynopsis=@sSynopsis,");
            strSql.Append("iView=@iView,");
            strSql.Append("iUserID=@iUserID,");
            strSql.Append("iCreateTime=@iCreateTime,");
            strSql.Append("iCreateID=@iCreateID");
            strSql.Append(" where iAutoID=@iAutoID ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@sTitle",      MySqlDbType.VarChar, 255),
                new MySqlParameter("@sCover",      MySqlDbType.VarChar, 500),
                new MySqlParameter("@sSynopsis",   MySqlDbType.VarChar, 255),
                new MySqlParameter("@iView",       MySqlDbType.Int32,    10),
                new MySqlParameter("@iUserID",     MySqlDbType.Int32,    10),
                new MySqlParameter("@iCreateTime", MySqlDbType.Int32,    10),
                new MySqlParameter("@iCreateID",   MySqlDbType.Int32,    10),
                new MySqlParameter("@iAutoID",     MySqlDbType.Int32, 10)
            };
            parameters[0].Value = model.sTitle;
            parameters[1].Value = model.sCover;
            parameters[2].Value = model.sSynopsis;
            parameters[3].Value = model.iView;
            parameters[4].Value = model.iUserID;
            parameters[5].Value = model.iCreateTime;
            parameters[6].Value = model.iCreateID;
            parameters[7].Value = model.iAutoID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.t_index_announce DataRowToModel(DataRow row)
 {
     Maticsoft.Model.t_index_announce model = new Maticsoft.Model.t_index_announce();
     if (row != null)
     {
         if (row["iAutoID"] != null && row["iAutoID"].ToString() != "")
         {
             model.iAutoID = int.Parse(row["iAutoID"].ToString());
         }
         if (row["sTitle"] != null)
         {
             model.sTitle = row["sTitle"].ToString();
         }
         if (row["sCover"] != null)
         {
             model.sCover = row["sCover"].ToString();
         }
         if (row["sSynopsis"] != null)
         {
             model.sSynopsis = row["sSynopsis"].ToString();
         }
         if (row["iView"] != null && row["iView"].ToString() != "")
         {
             model.iView = int.Parse(row["iView"].ToString());
         }
         if (row["iUserID"] != null && row["iUserID"].ToString() != "")
         {
             model.iUserID = int.Parse(row["iUserID"].ToString());
         }
         if (row["iCreateTime"] != null && row["iCreateTime"].ToString() != "")
         {
             model.iCreateTime = int.Parse(row["iCreateTime"].ToString());
         }
         if (row["iCreateID"] != null && row["iCreateID"].ToString() != "")
         {
             model.iCreateID = int.Parse(row["iCreateID"].ToString());
         }
     }
     return(model);
 }
예제 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.t_index_announce model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_index_announce(");
            strSql.Append("iAutoID,sTitle,sCover,sSynopsis,iView,iUserID,iCreateTime,iCreateID)");
            strSql.Append(" values (");
            strSql.Append("@iAutoID,@sTitle,@sCover,@sSynopsis,@iView,@iUserID,@iCreateTime,@iCreateID)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@iAutoID",     MySqlDbType.Int32,    10),
                new MySqlParameter("@sTitle",      MySqlDbType.VarChar, 255),
                new MySqlParameter("@sCover",      MySqlDbType.VarChar, 500),
                new MySqlParameter("@sSynopsis",   MySqlDbType.VarChar, 255),
                new MySqlParameter("@iView",       MySqlDbType.Int32,    10),
                new MySqlParameter("@iUserID",     MySqlDbType.Int32,    10),
                new MySqlParameter("@iCreateTime", MySqlDbType.Int32,    10),
                new MySqlParameter("@iCreateID",   MySqlDbType.Int32, 10)
            };
            parameters[0].Value = model.iAutoID;
            parameters[1].Value = model.sTitle;
            parameters[2].Value = model.sCover;
            parameters[3].Value = model.sSynopsis;
            parameters[4].Value = model.iView;
            parameters[5].Value = model.iUserID;
            parameters[6].Value = model.iCreateTime;
            parameters[7].Value = model.iCreateID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.t_index_announce GetModel(int iAutoID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select iAutoID,sTitle,sCover,sSynopsis,iView,iUserID,iCreateTime,iCreateID from t_index_announce ");
            strSql.Append(" where iAutoID=@iAutoID ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@iAutoID", MySqlDbType.Int32, 10)
            };
            parameters[0].Value = iAutoID;

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

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