/// <summary> /// 增加一条数据 /// </summary> public int Add(ZQUSR.Model.sr_SciResSort model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into sr_SciResSort("); strSql.Append("BigSort,SmallSort)"); strSql.Append(" values ("); strSql.Append("@BigSort,@SmallSort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@BigSort", SqlDbType.NVarChar, 10), new SqlParameter("@SmallSort", SqlDbType.NVarChar, 10) }; parameters[0].Value = model.BigSort; parameters[1].Value = model.SmallSort; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ZQUSR.Model.sr_SciResSort GetModel(int PK_SID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 PK_SID,BigSort,SmallSort from sr_SciResSort "); strSql.Append(" where PK_SID=@PK_SID "); SqlParameter[] parameters = { new SqlParameter("@PK_SID", SqlDbType.Int, 4) }; parameters[0].Value = PK_SID; ZQUSR.Model.sr_SciResSort model = new ZQUSR.Model.sr_SciResSort(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["PK_SID"].ToString() != "") { model.PK_SID = int.Parse(ds.Tables[0].Rows[0]["PK_SID"].ToString()); } model.BigSort = ds.Tables[0].Rows[0]["BigSort"].ToString(); model.SmallSort = ds.Tables[0].Rows[0]["SmallSort"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(ZQUSR.Model.sr_SciResSort model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update sr_SciResSort set "); strSql.Append("BigSort=@BigSort,"); strSql.Append("SmallSort=@SmallSort"); strSql.Append(" where PK_SID=@PK_SID "); SqlParameter[] parameters = { new SqlParameter("@PK_SID", SqlDbType.Int, 4), new SqlParameter("@BigSort", SqlDbType.NVarChar, 10), new SqlParameter("@SmallSort", SqlDbType.NVarChar, 10) }; parameters[0].Value = model.PK_SID; parameters[1].Value = model.BigSort; parameters[2].Value = model.SmallSort; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }