/// <summary> /// 增加一条数据 /// </summary> public long Add(JY.Model.Review model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.BigInt, 8), new SqlParameter("@MemberId", SqlDbType.BigInt, 8), new SqlParameter("@ProductId", SqlDbType.Int, 4), new SqlParameter("@ProductName", SqlDbType.NVarChar, 50), new SqlParameter("@ReviewContent", SqlDbType.NText), new SqlParameter("@ReplyContent", SqlDbType.NText), new SqlParameter("@ReviewName", SqlDbType.NVarChar, 50), new SqlParameter("@ReviewDate", SqlDbType.DateTime), new SqlParameter("@Sort", SqlDbType.Int, 4), new SqlParameter("@IsDelete", SqlDbType.Bit, 1) }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.MemberId; parameters[2].Value = model.ProductId; parameters[3].Value = model.ProductName; parameters[4].Value = model.ReviewContent; parameters[5].Value = model.ReplyContent; parameters[6].Value = model.ReviewName; parameters[7].Value = model.ReviewDate; parameters[8].Value = model.Sort; parameters[9].Value = model.IsDelete; DbHelperSQL.RunProcedure("Review_ADD", parameters, out rowsAffected); return((long)parameters[0].Value); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JY.Model.Review model) { int rowsAffected = 0; SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.BigInt, 8), new SqlParameter("@MemberId", SqlDbType.BigInt, 8), new SqlParameter("@ProductId", SqlDbType.Int, 4), new SqlParameter("@ProductName", SqlDbType.NVarChar, 50), new SqlParameter("@ReviewContent", SqlDbType.NText), new SqlParameter("@ReplyContent", SqlDbType.NText), new SqlParameter("@ReviewName", SqlDbType.NVarChar, 50), new SqlParameter("@ReviewDate", SqlDbType.DateTime), new SqlParameter("@Sort", SqlDbType.Int, 4), new SqlParameter("@IsDelete", SqlDbType.Bit, 1) }; parameters[0].Value = model.ID; parameters[1].Value = model.MemberId; parameters[2].Value = model.ProductId; parameters[3].Value = model.ProductName; parameters[4].Value = model.ReviewContent; parameters[5].Value = model.ReplyContent; parameters[6].Value = model.ReviewName; parameters[7].Value = model.ReviewDate; parameters[8].Value = model.Sort; parameters[9].Value = model.IsDelete; DbHelperSQL.RunProcedure("Review_Update", parameters, out rowsAffected); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public JY.Model.Review GetModel(long ID) { SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.BigInt) }; parameters[0].Value = ID; JY.Model.Review model = new JY.Model.Review(); DataSet ds = DbHelperSQL.RunProcedure("Review_GetModel", parameters, "ds"); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["MemberId"] != null && ds.Tables[0].Rows[0]["MemberId"].ToString() != "") { model.MemberId = long.Parse(ds.Tables[0].Rows[0]["MemberId"].ToString()); } if (ds.Tables[0].Rows[0]["ProductId"] != null && ds.Tables[0].Rows[0]["ProductId"].ToString() != "") { model.ProductId = int.Parse(ds.Tables[0].Rows[0]["ProductId"].ToString()); } if (ds.Tables[0].Rows[0]["ProductName"] != null && ds.Tables[0].Rows[0]["ProductName"].ToString() != "") { model.ProductName = ds.Tables[0].Rows[0]["ProductName"].ToString(); } if (ds.Tables[0].Rows[0]["ReviewContent"] != null && ds.Tables[0].Rows[0]["ReviewContent"].ToString() != "") { model.ReviewContent = ds.Tables[0].Rows[0]["ReviewContent"].ToString(); } if (ds.Tables[0].Rows[0]["ReplyContent"] != null && ds.Tables[0].Rows[0]["ReplyContent"].ToString() != "") { model.ReplyContent = ds.Tables[0].Rows[0]["ReplyContent"].ToString(); } if (ds.Tables[0].Rows[0]["ReviewName"] != null && ds.Tables[0].Rows[0]["ReviewName"].ToString() != "") { model.ReviewName = ds.Tables[0].Rows[0]["ReviewName"].ToString(); } if (ds.Tables[0].Rows[0]["ReviewDate"] != null && ds.Tables[0].Rows[0]["ReviewDate"].ToString() != "") { model.ReviewDate = DateTime.Parse(ds.Tables[0].Rows[0]["ReviewDate"].ToString()); } if (ds.Tables[0].Rows[0]["Sort"] != null && ds.Tables[0].Rows[0]["Sort"].ToString() != "") { model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString()); } if (ds.Tables[0].Rows[0]["IsDelete"] != null && ds.Tables[0].Rows[0]["IsDelete"].ToString() != "") { if ((ds.Tables[0].Rows[0]["IsDelete"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsDelete"].ToString().ToLower() == "true")) { model.IsDelete = true; } else { model.IsDelete = false; } } return(model); } else { return(null); } }