/// <summary> /// 更新一条数据 /// </summary> public bool Update(E_Model.Teacher model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update CMS_TEACHER set "); strSql.Append("CHNNAME=@CHNNAME,"); strSql.Append("ENGNAME=@ENGNAME,"); strSql.Append("RANK=@RANK,"); strSql.Append("TPICTURE=@TPICTURE,"); strSql.Append("DESCRIPTION=@DESCRIPTION"); strSql.Append(" where ID=@ID "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "CHNNAME", DbType.AnsiString, model.CHNNAME); db.AddInParameter(dbCommand, "ENGNAME", DbType.AnsiString, model.ENGNAME); db.AddInParameter(dbCommand, "RANK", DbType.AnsiString, model.RANK); db.AddInParameter(dbCommand, "TPICTURE", DbType.AnsiString, model.TPICTURE); 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 bool Add(E_Model.Teacher model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into CMS_TEACHER("); strSql.Append("ID,CHNNAME,ENGNAME,RANK,TPICTURE,STATUS,DESCRIPTION,CREATEDATE,CREATEUSER)"); strSql.Append(" values ("); strSql.Append("@ID,@CHNNAME,@ENGNAME,@RANK,@TPICTURE,@STATUS,@DESCRIPTION,@CREATEDATE,@CREATEUSER)"); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "ID", DbType.AnsiString, model.ID); db.AddInParameter(dbCommand, "CHNNAME", DbType.AnsiString, model.CHNNAME); db.AddInParameter(dbCommand, "ENGNAME", DbType.AnsiString, model.ENGNAME); db.AddInParameter(dbCommand, "RANK", DbType.AnsiString, model.RANK); db.AddInParameter(dbCommand, "TPICTURE", DbType.AnsiString, model.TPICTURE); db.AddInParameter(dbCommand, "STATUS", DbType.AnsiString, model.STATUS); db.AddInParameter(dbCommand, "DESCRIPTION", DbType.AnsiString, model.DESCRIPTION); 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 E_Model.Teacher DataRowToModel(DataRow row) { E_Model.Teacher model = new E_Model.Teacher(); if (row != null) { if (row["ID"] != null) { model.ID = row["ID"].ToString(); } if (row["CHNNAME"] != null) { model.CHNNAME = row["CHNNAME"].ToString(); } if (row["ENGNAME"] != null) { model.ENGNAME = row["ENGNAME"].ToString(); } if (row["RANK"] != null) { model.RANK = row["RANK"].ToString(); } if (row["TPICTURE"] != null) { model.TPICTURE = row["TPICTURE"].ToString(); } if (row["STATUS"] != null) { model.STATUS = row["STATUS"].ToString(); } if (row["DESCRIPTION"] != null) { model.DESCRIPTION = row["DESCRIPTION"].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.Teacher ReaderBind(IDataReader dataReader) { E_Model.Teacher model = new E_Model.Teacher(); object ojb; model.ID = dataReader["ID"].ToString(); model.CHNNAME = dataReader["CHNNAME"].ToString(); model.ENGNAME = dataReader["ENGNAME"].ToString(); model.RANK = dataReader["RANK"].ToString(); model.TPICTURE = dataReader["TPICTURE"].ToString(); model.STATUS = dataReader["STATUS"].ToString(); model.DESCRIPTION = dataReader["DESCRIPTION"].ToString(); ojb = dataReader["CREATEDATE"]; if (ojb != null && ojb != DBNull.Value) { model.CREATEDATE = (DateTime)ojb; } model.CREATEUSER = dataReader["CREATEUSER"].ToString(); return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public E_Model.Teacher GetModel(string ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID,CHNNAME,ENGNAME,RANK,TPICTURE,STATUS,DESCRIPTION,CREATEDATE,CREATEUSER from CMS_TEACHER "); strSql.Append(" where ID=@ID "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "ID", DbType.AnsiString, ID); E_Model.Teacher model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
public bool Update(E_Model.Teacher model) { return(dal.Update(model)); }
public bool Add(E_Model.Teacher model) { return(dal.Add(model)); }