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