/// <summary> /// 更新一条数据 /// </summary> public bool Update(E_Model.Notice model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SYS_NOTICE set "); strSql.Append("TITLE=:TITLE,"); strSql.Append("KEYWORD=:KEYWORD,"); strSql.Append("DESCRIPTION=:DESCRIPTION"); strSql.Append(" where ID=:ID "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "TITLE", DbType.String, model.TITLE); db.AddInParameter(dbCommand, "KEYWORD", DbType.String, model.KEYWORD); db.AddInParameter(dbCommand, "DESCRIPTION", DbType.String, model.DESCRIPTION); db.AddInParameter(dbCommand, "ID", DbType.String, model.ID); int rows = db.ExecuteNonQuery(dbCommand); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(E_Model.Notice model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SYS_NOTICE("); strSql.Append("ID,TITLE,KEYWORD,DESCRIPTION,STATUS,ANNEXGROUP,CREATEDATE,CREATEUSER)"); strSql.Append(" values ("); strSql.Append(":ID,:TITLE,:KEYWORD,:DESCRIPTION,:STATUS,:ANNEXGROUP,:CREATEDATE,:CREATEUSER)"); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "ID", DbType.String, model.ID); db.AddInParameter(dbCommand, "TITLE", DbType.String, model.TITLE); db.AddInParameter(dbCommand, "KEYWORD", DbType.String, model.KEYWORD); db.AddInParameter(dbCommand, "DESCRIPTION", DbType.String, model.DESCRIPTION); db.AddInParameter(dbCommand, "STATUS", DbType.String, model.STATUS); db.AddInParameter(dbCommand, "ANNEXGROUP", DbType.String, model.ANNEXGROUP); db.AddInParameter(dbCommand, "CREATEDATE", DbType.DateTime, model.CREATEDATE); db.AddInParameter(dbCommand, "CREATEUSER", DbType.String, model.CREATEUSER); int rows = db.ExecuteNonQuery(dbCommand); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public E_Model.Notice GetModel(string ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from SYS_NOTICE "); strSql.Append(" where ID='" + ID + "' "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); DataSet DS = db.ExecuteDataSet(CommandType.Text, strSql.ToString()); E_Model.Notice model = new E_Model.Notice(); if (DS.Tables[0].Rows.Count == 1) { model.ID = DS.Tables[0].Rows[0]["ID"].ToString(); model.TITLE = DS.Tables[0].Rows[0]["TITLE"].ToString(); model.KEYWORD = DS.Tables[0].Rows[0]["KEYWORD"].ToString(); model.DESCRIPTION = DS.Tables[0].Rows[0]["DESCRIPTION"].ToString(); model.ANNEXGROUP = DS.Tables[0].Rows[0]["ANNEXGROUP"].ToString(); model.STATUS = DS.Tables[0].Rows[0]["STATUS"].ToString(); if (model.CREATEDATE != null) { model.CREATEDATE = DateTime.Parse(DS.Tables[0].Rows[0]["CREATEDATE"].ToString()); } model.CREATEUSER = DS.Tables[0].Rows[0]["CREATEUSER"].ToString(); } return(model); }
/// <summary> /// 对象实体绑定数据 /// </summary> public E_Model.Notice ReaderBind(IDataReader dataReader) { E_Model.Notice model = new E_Model.Notice(); object ojb; model.ID = dataReader["ID"].ToString(); model.TITLE = dataReader["TITLE"].ToString(); model.KEYWORD = dataReader["KEYWORD"].ToString(); model.DESCRIPTION = dataReader["DESCRIPTION"].ToString(); model.STATUS = dataReader["STATUS"].ToString(); model.ANNEXGROUP = dataReader["ANNEXGROUP"].ToString(); ojb = dataReader["CREATEDATE"]; if (ojb != null && ojb != DBNull.Value) { model.CREATEDATE = (DateTime)ojb; } model.CREATEUSER = dataReader["CREATEUSER"].ToString(); return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(E_Model.Notice model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(E_Model.Notice model) { return(dal.Add(model)); }