/// <summary> /// 对象实体绑定数据 /// </summary> public Mxm.Model.feed_back ReaderBind(IDataReader dataReader) { Mxm.Model.feed_back model = new Mxm.Model.feed_back(); object ojb; ojb = dataReader["feed_id"]; if (ojb != null && ojb != DBNull.Value) { model.feed_id = (int)ojb; } model.title = dataReader["title"].ToString(); model.linkman = dataReader["linkman"].ToString(); model.corperation = dataReader["corperation"].ToString(); model.link_address = dataReader["link_address"].ToString(); ojb = dataReader["postcode"]; if (ojb != null && ojb != DBNull.Value) { model.postcode = (decimal)ojb; } model.link_tel = dataReader["link_tel"].ToString(); model.fax = dataReader["fax"].ToString(); ojb = dataReader["mobile"]; if (ojb != null && ojb != DBNull.Value) { model.mobile = (decimal)ojb; } model.email = dataReader["email"].ToString(); model.msg_content = dataReader["msg_content"].ToString(); return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Mxm.Model.feed_back GetModel(int feed_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select feed_id,title,linkman,corperation,link_address,postcode,link_tel,fax,mobile,email,msg_content from feed_back "); strSql.Append(" where feed_id=@feed_id "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "feed_id", DbType.Int32, feed_id); Mxm.Model.feed_back model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(Mxm.Model.feed_back model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into feed_back("); strSql.Append("title,linkman,corperation,link_address,postcode,link_tel,fax,mobile,email,msg_content)"); strSql.Append(" values ("); strSql.Append("@title,@linkman,@corperation,@link_address,@postcode,@link_tel,@fax,@mobile,@email,@msg_content)"); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "title", DbType.String, model.title); db.AddInParameter(dbCommand, "linkman", DbType.String, model.linkman); db.AddInParameter(dbCommand, "corperation", DbType.String, model.corperation); db.AddInParameter(dbCommand, "link_address", DbType.String, model.link_address); db.AddInParameter(dbCommand, "postcode", DbType.Decimal, model.postcode); db.AddInParameter(dbCommand, "link_tel", DbType.String, model.link_tel); db.AddInParameter(dbCommand, "fax", DbType.String, model.fax); db.AddInParameter(dbCommand, "mobile", DbType.Decimal, model.mobile); db.AddInParameter(dbCommand, "email", DbType.String, model.email); db.AddInParameter(dbCommand, "msg_content", DbType.String, model.msg_content); db.ExecuteNonQuery(dbCommand); }
/// <summary> /// 对象实体绑定数据 /// </summary> public Mxm.Model.feed_back ReaderBind(IDataReader dataReader) { Mxm.Model.feed_back model = new Mxm.Model.feed_back(); object ojb; ojb = dataReader["feed_id"]; if (ojb != null && ojb != DBNull.Value) { model.feed_id = (int)ojb; } model.title = dataReader["title"].ToString(); model.linkman = dataReader["linkman"].ToString(); model.corperation = dataReader["corperation"].ToString(); model.link_address = dataReader["link_address"].ToString(); ojb = dataReader["postcode"]; if (ojb != null && ojb != DBNull.Value) { model.postcode = (decimal)ojb; } model.link_tel = dataReader["link_tel"].ToString(); model.fax = dataReader["fax"].ToString(); ojb = dataReader["mobile"]; if (ojb != null && ojb != DBNull.Value) { model.mobile = (decimal)ojb; } model.email = dataReader["email"].ToString(); model.msg_content = dataReader["msg_content"].ToString(); return model; }