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