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