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