コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LingLong.Admin.Model.t_particulars model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_particulars set ");
            strSql.Append("Title=@Title,");
            strSql.Append("TextContent=@TextContent,");
            strSql.Append("CreateTime=@CreateTime");
            strSql.Append(" where ID=@ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@Title",       MySqlDbType.VarChar,   128),
                new MySqlParameter("@TextContent", MySqlDbType.Text),
                new MySqlParameter("@CreateTime",  MySqlDbType.DateTime),
                new MySqlParameter("@ID",          MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.Title;
            parameters[1].Value = model.TextContent;
            parameters[2].Value = model.CreateTime;
            parameters[3].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(LingLong.Admin.Model.t_particulars model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_particulars(");
            strSql.Append("Title,TextContent,CreateTime)");
            strSql.Append(" values (");
            strSql.Append("@Title,@TextContent,@CreateTime)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@Title",       MySqlDbType.VarChar, 128),
                new MySqlParameter("@TextContent", MySqlDbType.Text),
                new MySqlParameter("@CreateTime",  MySqlDbType.DateTime)
            };
            parameters[0].Value = model.Title;
            parameters[1].Value = model.TextContent;
            parameters[2].Value = model.CreateTime;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public LingLong.Admin.Model.t_particulars DataRowToModel(DataRow row)
 {
     LingLong.Admin.Model.t_particulars model = new LingLong.Admin.Model.t_particulars();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["Title"] != null)
         {
             model.Title = row["Title"].ToString();
         }
         if (row["TextContent"] != null)
         {
             model.TextContent = row["TextContent"].ToString();
         }
         if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
         {
             model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
         }
     }
     return(model);
 }
コード例 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LingLong.Admin.Model.t_particulars GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,Title,TextContent,CreateTime from t_particulars ");
            strSql.Append(" where ID=@ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ID", MySqlDbType.Int32)
            };
            parameters[0].Value = ID;

            LingLong.Admin.Model.t_particulars model = new LingLong.Admin.Model.t_particulars();
            DataSet ds = DbHelperMySql.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(LingLong.Admin.Model.t_particulars model)
 {
     return(dal.Update(model));
 }
コード例 #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(LingLong.Admin.Model.t_particulars model)
 {
     return(dal.Add(model));
 }