/// <summary> /// 更新一条数据 /// </summary> public bool Update(university.Model.CCOM.Proposal model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Proposal set "); strSql.Append("Topic_relation_id=@Topic_relation_id,"); strSql.Append("Review=@Review,"); strSql.Append("Score=@Score,"); strSql.Append("Result=@Result"); strSql.Append(" where Proposal_id=@Proposal_id"); SqlParameter[] parameters = { new SqlParameter("@Topic_relation_id", SqlDbType.BigInt, 8), new SqlParameter("@Review", SqlDbType.Text), new SqlParameter("@Score", SqlDbType.Int, 4), new SqlParameter("@Result", SqlDbType.Int, 4), new SqlParameter("@Proposal_id", SqlDbType.BigInt, 8) }; parameters[0].Value = model.Topic_relation_id; parameters[1].Value = model.Review; parameters[2].Value = model.Score; parameters[3].Value = model.Result; parameters[4].Value = model.Proposal_id; int rows = DBSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public long Add(university.Model.CCOM.Proposal model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Proposal("); strSql.Append("Topic_relation_id,Review,Score,Result)"); strSql.Append(" values ("); strSql.Append("@Topic_relation_id,@Review,@Score,@Result)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Topic_relation_id", SqlDbType.BigInt, 8), new SqlParameter("@Review", SqlDbType.Text), new SqlParameter("@Score", SqlDbType.Int, 4), new SqlParameter("@Result", SqlDbType.Int, 4) }; parameters[0].Value = model.Topic_relation_id; parameters[1].Value = model.Review; parameters[2].Value = model.Score; parameters[3].Value = model.Result; object obj = DBSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt64(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public university.Model.CCOM.Proposal DataRowToModel(DataRow row) { university.Model.CCOM.Proposal model = new university.Model.CCOM.Proposal(); if (row != null) { if (row["Proposal_id"] != null && row["Proposal_id"].ToString() != "") { model.Proposal_id = long.Parse(row["Proposal_id"].ToString()); } if (row["Topic_relation_id"] != null && row["Topic_relation_id"].ToString() != "") { model.Topic_relation_id = long.Parse(row["Topic_relation_id"].ToString()); } if (row["Review"] != null) { model.Review = row["Review"].ToString(); } if (row["Score"] != null && row["Score"].ToString() != "") { model.Score = int.Parse(row["Score"].ToString()); } if (row["Result"] != null && row["Result"].ToString() != "") { model.Result = int.Parse(row["Result"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public university.Model.CCOM.Proposal GetModel(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Proposal_id,Topic_relation_id,Review,Score,Result "); strSql.Append(" from Proposal "); strSql.Append(" where " + strWhere); university.Model.CCOM.Proposal model = new university.Model.CCOM.Proposal(); DataSet ds = DBSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Proposal_id"] != null && ds.Tables[0].Rows[0]["Proposal_id"].ToString() != "") { model.Proposal_id = long.Parse(ds.Tables[0].Rows[0]["Proposal_id"].ToString()); } if (ds.Tables[0].Rows[0]["Topic_relation_id"] != null && ds.Tables[0].Rows[0]["Topic_relation_id"].ToString() != "") { model.Topic_relation_id = long.Parse(ds.Tables[0].Rows[0]["Topic_relation_id"].ToString()); } if (ds.Tables[0].Rows[0]["Review"] != null) { model.Review = ds.Tables[0].Rows[0]["Review"].ToString(); } if (ds.Tables[0].Rows[0]["Score"] != null && ds.Tables[0].Rows[0]["Score"].ToString() != "") { model.Score = int.Parse(ds.Tables[0].Rows[0]["Score"].ToString()); } if (ds.Tables[0].Rows[0]["Result"] != null && ds.Tables[0].Rows[0]["Result"].ToString() != "") { model.Result = int.Parse(ds.Tables[0].Rows[0]["Result"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public university.Model.CCOM.Proposal GetModel(long Proposal_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Proposal_id,Topic_relation_id,Review,Score,Result from Proposal "); strSql.Append(" where Proposal_id=@Proposal_id"); SqlParameter[] parameters = { new SqlParameter("@Proposal_id", SqlDbType.BigInt) }; parameters[0].Value = Proposal_id; university.Model.CCOM.Proposal model = new university.Model.CCOM.Proposal(); DataSet ds = DBSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }