/// <summary> /// 更新一条数据 /// </summary> public bool Update(Mall.Model.role_menu model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_role_menu set "); strSql.Append("MENUID=@MENUID,"); strSql.Append("ROLEID=@ROLEID"); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@MENUID", SqlDbType.NVarChar, 32), new SqlParameter("@ROLEID", SqlDbType.NVarChar, 32), new SqlParameter("@ID", SqlDbType.NVarChar, 32) }; parameters[0].Value = model.MENUID; parameters[1].Value = model.ROLEID; parameters[2].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Mall.Model.role_menu model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_role_menu("); strSql.Append("MENUID,ROLEID,ID)"); strSql.Append(" values ("); strSql.Append("@MENUID,@ROLEID,@ID)"); SqlParameter[] parameters = { new SqlParameter("@MENUID", SqlDbType.NVarChar, 32), new SqlParameter("@ROLEID", SqlDbType.NVarChar, 32), new SqlParameter("@ID", SqlDbType.NVarChar, 32) }; parameters[0].Value = model.MENUID; parameters[1].Value = model.ROLEID; parameters[2].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Mall.Model.role_menu DataRowToModel(DataRow row) { Mall.Model.role_menu model = new Mall.Model.role_menu(); if (row != null) { if (row["MENUID"] != null) { model.MENUID = row["MENUID"].ToString(); } if (row["ROLEID"] != null) { model.ROLEID = row["ROLEID"].ToString(); } if (row["ID"] != null) { model.ID = row["ID"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Mall.Model.role_menu GetModel(string ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 MENUID,ROLEID,ID from tb_role_menu "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.NVarChar, 32) }; parameters[0].Value = ID; Mall.Model.role_menu model = new Mall.Model.role_menu(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }