/// <summary> /// 增加一条数据 /// </summary> public int Add(IPSP.Model.T_Role model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_Role("); strSql.Append("s_RoleName,s_Notes,s_RoleCode)"); strSql.Append(" values ("); strSql.Append("@s_RoleName,@s_Notes,@s_RoleCode)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@s_RoleName", SqlDbType.NVarChar, 50), new SqlParameter("@s_Notes", SqlDbType.NVarChar, 500), new SqlParameter("@s_RoleCode", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.s_RoleName; parameters[1].Value = model.s_Notes; parameters[2].Value = model.s_RoleCode; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(IPSP.Model.T_Role model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_Role set "); strSql.Append("s_RoleName=@s_RoleName,"); strSql.Append("s_Notes=@s_Notes,"); strSql.Append("s_RoleCode=@s_RoleCode"); strSql.Append(" where n_RoleID=@n_RoleID"); SqlParameter[] parameters = { new SqlParameter("@s_RoleName", SqlDbType.NVarChar, 50), new SqlParameter("@s_Notes", SqlDbType.NVarChar, 500), new SqlParameter("@s_RoleCode", SqlDbType.NVarChar, 50), new SqlParameter("@n_RoleID", SqlDbType.Int, 4) }; parameters[0].Value = model.s_RoleName; parameters[1].Value = model.s_Notes; parameters[2].Value = model.s_RoleCode; parameters[3].Value = model.n_RoleID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public IPSP.Model.T_Role DataRowToModel(DataRow row) { IPSP.Model.T_Role model = new IPSP.Model.T_Role(); if (row != null) { if (row["n_RoleID"] != null && row["n_RoleID"].ToString() != "") { model.n_RoleID = int.Parse(row["n_RoleID"].ToString()); } if (row["s_RoleName"] != null) { model.s_RoleName = row["s_RoleName"].ToString(); } if (row["s_Notes"] != null) { model.s_Notes = row["s_Notes"].ToString(); } if (row["s_RoleCode"] != null) { model.s_RoleCode = row["s_RoleCode"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public IPSP.Model.T_Role GetModel(int n_RoleID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 n_RoleID,s_RoleName,s_Notes,s_RoleCode from T_Role "); strSql.Append(" where n_RoleID=@n_RoleID"); SqlParameter[] parameters = { new SqlParameter("@n_RoleID", SqlDbType.Int, 4) }; parameters[0].Value = n_RoleID; IPSP.Model.T_Role model = new IPSP.Model.T_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); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(IPSP.Model.T_Role model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(IPSP.Model.T_Role model) { return(dal.Add(model)); }