/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.SYS_UserForRole model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SYS_UserForRole set "); strSql.Append("Adn_Id=@Adn_Id,"); strSql.Append("Role_Id=@Role_Id"); strSql.Append(" where UFR_Id=@UFR_Id "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "UFR_Id", DbType.Int32, model.UFR_Id); db.AddInParameter(dbCommand, "Adn_Id", DbType.Int32, model.Adn_Id); db.AddInParameter(dbCommand, "Role_Id", DbType.Int32, model.Role_Id); int rows = db.ExecuteNonQuery(dbCommand); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.SYS_UserForRole DataRowToModel(DataRow row) { Model.SYS_UserForRole model = new Model.SYS_UserForRole(); if (row != null) { if (row["UFR_Id"] != null && row["UFR_Id"].ToString() != "") { model.UFR_Id = int.Parse(row["UFR_Id"].ToString()); } if (row["Adn_Id"] != null && row["Adn_Id"].ToString() != "") { model.Adn_Id = int.Parse(row["Adn_Id"].ToString()); } if (row["Role_Id"] != null && row["Role_Id"].ToString() != "") { model.Role_Id = int.Parse(row["Role_Id"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.SYS_UserForRole DataRowToModel(DataRow row) { Model.SYS_UserForRole model = new Model.SYS_UserForRole(); if (row != null) { if (row["UFR_Id"] != null && row["UFR_Id"].ToString() != "") { model.UFR_Id = int.Parse(row["UFR_Id"].ToString()); } if (row["Adn_Id"] != null && row["Adn_Id"].ToString() != "") { model.Adn_Id = int.Parse(row["Adn_Id"].ToString()); } if (row["Role_Id"] != null && row["Role_Id"].ToString() != "") { model.Role_Id = int.Parse(row["Role_Id"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.SYS_UserForRole GetModel(int UFR_Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select UFR_Id,Adn_Id,Role_Id from SYS_UserForRole "); strSql.Append(" where UFR_Id=@UFR_Id "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "UFR_Id", DbType.Int32, UFR_Id); Model.SYS_UserForRole model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 对象实体绑定数据 /// </summary> public Model.SYS_UserForRole ReaderBind(IDataReader dataReader) { Model.SYS_UserForRole model = new Model.SYS_UserForRole(); object ojb; ojb = dataReader["UFR_Id"]; if (ojb != null && ojb != DBNull.Value) { model.UFR_Id = (int)ojb; } ojb = dataReader["Adn_Id"]; if (ojb != null && ojb != DBNull.Value) { model.Adn_Id = (int)ojb; } ojb = dataReader["Role_Id"]; if (ojb != null && ojb != DBNull.Value) { model.Role_Id = (int)ojb; } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.SYS_UserForRole model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SYS_UserForRole("); strSql.Append("UId,Role_Id)"); strSql.Append(" values ("); strSql.Append("@Adn_Id,@Role_Id)"); strSql.Append(";select @@IDENTITY"); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "Adn_Id", DbType.Int32, model.Adn_Id); db.AddInParameter(dbCommand, "Role_Id", DbType.Int32, model.Role_Id); int result; object obj = db.ExecuteScalar(dbCommand); if (!int.TryParse(obj.ToString(), out result)) { return(0); } return(result); }
/// <summary> /// 对象实体绑定数据 /// </summary> public Model.SYS_UserForRole ReaderBind(IDataReader dataReader) { Model.SYS_UserForRole model = new Model.SYS_UserForRole(); object ojb; ojb = dataReader["UFR_Id"]; if (ojb != null && ojb != DBNull.Value) { model.UFR_Id = (int)ojb; } ojb = dataReader["Adn_Id"]; if (ojb != null && ojb != DBNull.Value) { model.Adn_Id = (int)ojb; } ojb = dataReader["Role_Id"]; if (ojb != null && ojb != DBNull.Value) { model.Role_Id = (int)ojb; } return model; }