/// <summary> /// 更新一条数据 /// </summary> public bool Update(abc.Model.Model.Authority model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Authority set "); strSql.Append("RoleId=SQL2012RoleId,"); strSql.Append("SourceId=SQL2012SourceId,"); strSql.Append("Authority=SQL2012Authority"); strSql.Append(" where AuthorityId=SQL2012AuthorityId"); SqlParameter[] parameters = { new SqlParameter("SQL2012RoleId", SqlDbType.Int, 4), new SqlParameter("SQL2012SourceId", SqlDbType.Int, 4), new SqlParameter("SQL2012Authority", SqlDbType.VarChar, 1000), new SqlParameter("SQL2012AuthorityId", SqlDbType.Int, 4) }; parameters[0].Value = model.RoleId; parameters[1].Value = model.SourceId; parameters[2].Value = model.Authority; parameters[3].Value = model.AuthorityId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(abc.Model.Model.Authority model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Authority("); strSql.Append("RoleId,SourceId,Authority)"); strSql.Append(" values ("); strSql.Append("SQL2012RoleId,SQL2012SourceId,SQL2012Authority)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("SQL2012RoleId", SqlDbType.Int, 4), new SqlParameter("SQL2012SourceId", SqlDbType.Int, 4), new SqlParameter("SQL2012Authority", SqlDbType.VarChar, 1000) }; parameters[0].Value = model.RoleId; parameters[1].Value = model.SourceId; parameters[2].Value = model.Authority; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public abc.Model.Model.Authority DataRowToModel(DataRow row) { abc.Model.Model.Authority model = new abc.Model.Model.Authority(); if (row != null) { if (row["AuthorityId"] != null && row["AuthorityId"].ToString() != "") { model.AuthorityId = int.Parse(row["AuthorityId"].ToString()); } if (row["RoleId"] != null && row["RoleId"].ToString() != "") { model.RoleId = int.Parse(row["RoleId"].ToString()); } if (row["SourceId"] != null && row["SourceId"].ToString() != "") { model.SourceId = int.Parse(row["SourceId"].ToString()); } if (row["Authority"] != null) { model.Authority = row["Authority"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public abc.Model.Model.Authority GetModel(int AuthorityId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 AuthorityId,RoleId,SourceId,Authority from Authority "); strSql.Append(" where AuthorityId=SQL2012AuthorityId"); SqlParameter[] parameters = { new SqlParameter("SQL2012AuthorityId", SqlDbType.Int, 4) }; parameters[0].Value = AuthorityId; abc.Model.Model.Authority model = new abc.Model.Model.Authority(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }