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