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