/// <summary> /// 增加一条数据 /// </summary> public bool Add(E_Model.School model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into CMS_SCHOOL("); strSql.Append("ID,SCHOOLNAME,SCHOOLENAME,SCHOOLADRESS,SCHOOLIMAGE,SHOWPICTURE,DESCRIPTION,STATUS,CREATEDATE,CREATEUSER)"); strSql.Append(" values ("); strSql.Append("@ID,@SCHOOLNAME,@SCHOOLENAME,@SCHOOLADRESS,@SCHOOLIMAGE,@SHOWPICTURE,@DESCRIPTION,@STATUS,@CREATEDATE,@CREATEUSER)"); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "ID", DbType.AnsiString, model.ID); db.AddInParameter(dbCommand, "SCHOOLNAME", DbType.AnsiString, model.SCHOOLNAME); db.AddInParameter(dbCommand, "SCHOOLENAME", DbType.AnsiString, model.SCHOOLENAME); db.AddInParameter(dbCommand, "SCHOOLADRESS", DbType.AnsiString, model.SCHOOLADRESS); db.AddInParameter(dbCommand, "SCHOOLIMAGE", DbType.AnsiString, model.SCHOOLIMAGE); db.AddInParameter(dbCommand, "SHOWPICTURE", DbType.AnsiString, model.SHOWPICTURE); db.AddInParameter(dbCommand, "DESCRIPTION", DbType.AnsiString, model.DESCRIPTION); db.AddInParameter(dbCommand, "STATUS", DbType.AnsiString, model.STATUS); db.AddInParameter(dbCommand, "CREATEDATE", DbType.DateTime, model.CREATEDATE); db.AddInParameter(dbCommand, "CREATEUSER", DbType.AnsiString, model.CREATEUSER); int rows = db.ExecuteNonQuery(dbCommand); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(E_Model.School model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update CMS_SCHOOL set "); strSql.Append("SCHOOLNAME=@SCHOOLNAME,"); strSql.Append("SCHOOLENAME=@SCHOOLENAME,"); strSql.Append("SCHOOLADRESS=@SCHOOLADRESS,"); strSql.Append("SCHOOLIMAGE=@SCHOOLIMAGE,"); strSql.Append("SHOWPICTURE=@SHOWPICTURE,"); strSql.Append("DESCRIPTION=@DESCRIPTION"); strSql.Append(" where ID=@ID "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "SCHOOLNAME", DbType.AnsiString, model.SCHOOLNAME); db.AddInParameter(dbCommand, "SCHOOLENAME", DbType.AnsiString, model.SCHOOLENAME); db.AddInParameter(dbCommand, "SCHOOLADRESS", DbType.AnsiString, model.SCHOOLADRESS); db.AddInParameter(dbCommand, "SCHOOLIMAGE", DbType.AnsiString, model.SCHOOLIMAGE); db.AddInParameter(dbCommand, "SHOWPICTURE", DbType.AnsiString, model.SHOWPICTURE); db.AddInParameter(dbCommand, "DESCRIPTION", DbType.AnsiString, model.DESCRIPTION); db.AddInParameter(dbCommand, "ID", DbType.AnsiString, model.ID); int rows = db.ExecuteNonQuery(dbCommand); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public E_Model.School DataRowToModel(DataRow row) { E_Model.School model = new E_Model.School(); if (row != null) { if (row["ID"] != null) { model.ID = row["ID"].ToString(); } if (row["SCHOOLNAME"] != null) { model.SCHOOLNAME = row["SCHOOLNAME"].ToString(); } if (row["SCHOOLENAME"] != null) { model.SCHOOLENAME = row["SCHOOLENAME"].ToString(); } if (row["SCHOOLADRESS"] != null) { model.SCHOOLADRESS = row["SCHOOLADRESS"].ToString(); } if (row["SCHOOLIMAGE"] != null) { model.SCHOOLIMAGE = row["SCHOOLIMAGE"].ToString(); } if (row["SHOWPICTURE"] != null) { model.SHOWPICTURE = row["SHOWPICTURE"].ToString(); } if (row["DESCRIPTION"] != null) { model.DESCRIPTION = row["DESCRIPTION"].ToString(); } if (row["STATUS"] != null) { model.STATUS = row["STATUS"].ToString(); } if (row["CREATEDATE"] != null && row["CREATEDATE"].ToString() != "") { model.CREATEDATE = DateTime.Parse(row["CREATEDATE"].ToString()); } if (row["CREATEUSER"] != null) { model.CREATEUSER = row["CREATEUSER"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public E_Model.School GetModel(string ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID,SCHOOLNAME,SCHOOLENAME,SCHOOLADRESS,SCHOOLIMAGE,SHOWPICTURE,DESCRIPTION,STATUS,CREATEDATE,CREATEUSER from CMS_SCHOOL "); strSql.Append(" where ID=@ID "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "ID", DbType.AnsiString, ID); E_Model.School model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 对象实体绑定数据 /// </summary> public E_Model.School ReaderBind(IDataReader dataReader) { E_Model.School model = new E_Model.School(); object ojb; model.ID = dataReader["ID"].ToString(); model.SCHOOLNAME = dataReader["SCHOOLNAME"].ToString(); model.SCHOOLENAME = dataReader["SCHOOLENAME"].ToString(); model.SCHOOLADRESS = dataReader["SCHOOLADRESS"].ToString(); model.SCHOOLIMAGE = dataReader["SCHOOLIMAGE"].ToString(); model.SHOWPICTURE = dataReader["SHOWPICTURE"].ToString(); model.DESCRIPTION = dataReader["DESCRIPTION"].ToString(); model.STATUS = dataReader["STATUS"].ToString(); ojb = dataReader["CREATEDATE"]; if (ojb != null && ojb != DBNull.Value) { model.CREATEDATE = (DateTime)ojb; } model.CREATEUSER = dataReader["CREATEUSER"].ToString(); return(model); }
public bool Update(E_Model.School model) { return(dal.Update(model)); }
public bool Add(E_Model.School model) { return(dal.Add(model)); }