/// <summary> /// 更新一条数据 /// </summary> public bool Update(E_Model.Brand model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update CMS_BRAND set "); strSql.Append("BRANDNAME=@BRANDNAME,"); strSql.Append("BRANDENAME=@BRANDENAME,"); strSql.Append("SHOWPICTURE=@SHOWPICTURE,"); strSql.Append("SLOGAN=@SLOGAN,"); strSql.Append("DESCRIPTION=@DESCRIPTION"); strSql.Append(" where ID=@ID "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "BRANDNAME", DbType.AnsiString, model.BRANDNAME); db.AddInParameter(dbCommand, "BRANDENAME", DbType.AnsiString, model.BRANDENAME); db.AddInParameter(dbCommand, "SHOWPICTURE", DbType.AnsiString, model.SHOWPICTURE); db.AddInParameter(dbCommand, "SLOGAN", DbType.AnsiString, model.SLOGAN); 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.Brand model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into CMS_BRAND("); strSql.Append("ID,BRANDNAME,BRANDENAME,SHOWPICTURE,SLOGAN,STATUS,DESCRIPTION,CREATEDATE,CREATEUSER)"); strSql.Append(" values ("); strSql.Append("@ID,@BRANDNAME,@BRANDENAME,@SHOWPICTURE,@SLOGAN,@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, "BRANDNAME", DbType.AnsiString, model.BRANDNAME); db.AddInParameter(dbCommand, "BRANDENAME", DbType.AnsiString, model.BRANDENAME); db.AddInParameter(dbCommand, "SHOWPICTURE", DbType.AnsiString, model.SHOWPICTURE); db.AddInParameter(dbCommand, "SLOGAN", DbType.AnsiString, model.SLOGAN); 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.Brand DataRowToModel(DataRow row) { E_Model.Brand model = new E_Model.Brand(); if (row != null) { if (row["ID"] != null) { model.ID = row["ID"].ToString(); } if (row["BRANDNAME"] != null) { model.BRANDNAME = row["BRANDNAME"].ToString(); } if (row["BRANDENAME"] != null) { model.BRANDENAME = row["BRANDENAME"].ToString(); } if (row["SHOWPICTURE"] != null) { model.SHOWPICTURE = row["SHOWPICTURE"].ToString(); } if (row["SLOGAN"] != null) { model.SLOGAN = row["SLOGAN"].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.Brand ReaderBind(IDataReader dataReader) { E_Model.Brand model = new E_Model.Brand(); object ojb; model.ID = dataReader["ID"].ToString(); model.BRANDNAME = dataReader["BRANDNAME"].ToString(); model.BRANDENAME = dataReader["BRANDENAME"].ToString(); model.SHOWPICTURE = dataReader["SHOWPICTURE"].ToString(); model.SLOGAN = dataReader["SLOGAN"].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.Brand GetModel(string ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID,BRANDNAME,BRANDENAME,SHOWPICTURE,SLOGAN,STATUS,DESCRIPTION,CREATEDATE,CREATEUSER from CMS_BRAND "); strSql.Append(" where ID=@ID "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "ID", DbType.AnsiString, ID); E_Model.Brand model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
public bool Update(E_Model.Brand model) { return(dal.Update(model)); }
public bool Add(E_Model.Brand model) { return(dal.Add(model)); }