public DataTable SelBy(M_Favorite model) { string strsql = "SELECT * FROM ZL_Favorite WHERE [Owner]=@Owner AND [InfoID]=@InfoID AND [FavoriType]=@FavoriType"; SqlParameter[] sp = model.GetParameters(); return(SqlHelper.ExecuteTable(CommandType.Text, strsql, sp)); }
void ID_Favorite.AddFavorite(M_Favorite favorite) { string strSql = "PR_Favorite_Add"; SqlParameter[] cmdParams = GetParameters(favorite); SqlHelper.ExecuteProc(strSql, cmdParams); }
public int insertQues(M_Favorite model) { if (CheckFavoData(model.Owner, model.FavoriType, model.InfoID))//判断是否存在 { return(insert(model)); } return(0); }
public int insertQues(M_Favorite model) { DataTable dt = SelBy(model); if (dt.Rows.Count <= 0)//判断是否存在 { return(insert(model)); } return(0); }
private static M_Favorite GetInfoFromReader(SqlDataReader rdr) { M_Favorite info = new M_Favorite(); info.FavoriteID = DataConverter.CLng(rdr["FavoriteID"]); info.Owner = DataConverter.CLng(rdr["Owner"]); info.InfoID = DataConverter.CLng(rdr["InfoID"]); info.AddDate = DataConverter.CDate(rdr["FavoriteDate"]); rdr.Close(); return(info); }
private static SqlParameter[] GetParameters(M_Favorite Info) { SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@FavoriteID", SqlDbType.Int), new SqlParameter("@Owner", SqlDbType.Int), new SqlParameter("@InfoID", SqlDbType.Int), new SqlParameter("@FavoriteDate", SqlDbType.DateTime) }; parameter[0].Value = Info.FavoriteID; parameter[1].Value = Info.Owner; parameter[2].Value = Info.InfoID; parameter[3].Value = Info.AddDate; return(parameter); }
public bool GetFavByUserIDAndFriendID(int Owner, int InfoID) { string sql = @"SELECT * FROM ZL_Favorite Where ZL_Favorite.Owner=@Owner and ZL_Favorite.InfoID=@InfoID"; SqlParameter[] parameter = { new SqlParameter("Owner", Owner), new SqlParameter("InfoID", InfoID) }; M_Favorite mf = new M_Favorite(); using (DbDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, parameter)) { if (dr.Read()) { return(true); } else { return(false); } } }
//批量添加问题收藏 private void AddLikeQues(string qids) { DataTable userDt = JsonHelper.JsonToDT(CurUser_Hid.Value); string[] qidattr = qids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (DataRow item in userDt.Rows) { for (int i = 0; i < qidattr.Length; i++) { int userid = Convert.ToInt32(item["UserID"]); int qid = Convert.ToInt32(qidattr[i]); M_Favorite favMod = new M_Favorite(); favMod.InfoID = qid; favMod.Owner = userid; favMod.Title = askBll.SelReturnModel(qid).Qcontent; favMod.FavoriType = 4; favMod.FavUrl = "/Guest/Ask/SearchDetails.aspx?soure=manager&ID=" + qid; favMod.AddDate = DateTime.Now; favBll.insertQues(favMod); } } }
protected void Page_Load(object sender, EventArgs e) { if (!this.Page.IsPostBack) { buser.CheckIsLogin(); string uname = HttpContext.Current.Request.Cookies["UserState"]["LoginName"]; this.UserInfo = buser.GetUserByName(uname); if (string.IsNullOrEmpty(base.Request.QueryString["InfoID"])) { function.WriteErrMsg("没有指定要添加到收藏夹的内容ID!"); } else { int InfoID = DataConverter.CLng(base.Request.QueryString["InfoID"]); M_Favorite fav = new M_Favorite(); fav.FavoriteID = 0; fav.InfoID = InfoID; fav.Owner = this.UserInfo.UserID; fav.AddDate = DateTime.Now; this.bfav.AddFavorite(fav); function.WriteSuccessMsg("该内容成功添加到你的收藏夹了!<br/> 10秒后该页自动关闭...也可手工【<a href=\"javascript:window.close();\">关闭</a>】"); } } }
public bool UpdateByID(M_Favorite model) { return(DBCenter.UpdateByID(model, model.FavoriteID)); }
/// <summary> /// 添加收藏信息到收藏夹 /// </summary> /// <param name="favorite">收藏信息实例</param> public int AddFavorite(M_Favorite model) { return(DBCenter.Insert(model)); }
public ActionResult AddToFav() { M_Favorite favMod = new M_Favorite(); favMod.InfoID = DataConvert.CLng(Request["infoID"]); favMod.Owner = mu.UserID; favMod.AddDate = DateTime.Now; favMod.FavoriType = DataConvert.CLng(Request.Form["type"], 1); //--------------------------- favMod.FavItemID = ""; favMod.Title = HttpUtility.HtmlEncode(Request["title"]); favMod.FavUrl = Request.Form["url"]; switch (favMod.FavoriType) { case 1: case 3: { M_CommonData conMod = conBll.SelReturnModel(favMod.InfoID); if (conMod == null) { err = "内容ID[" + favMod.InfoID + "]不存在"; break; } if (string.IsNullOrEmpty(favMod.Title)) { favMod.Title = conMod.Title; } } break; case 2: { M_Product proMod = proBll.GetproductByid(favMod.InfoID); if (proMod == null) { err = "商品不存在"; break; } if (string.IsNullOrEmpty(favMod.Title)) { favMod.Title = proMod.Proname; } } break; case 4: { B_Ask askBll = new B_Ask(); M_Ask askMod = askBll.SelReturnModel(favMod.InfoID); if (askMod == null) { err = "问题不存在"; break; } if (string.IsNullOrEmpty(favMod.Title)) { favMod.Title = StringHelper.SubStr(askMod.Qcontent); } } break; case 5: { B_Baike bkBll = new B_Baike(); M_Baike bkMod = bkBll.SelReturnModel(favMod.InfoID); if (bkMod == null) { err = "百科不存在"; break; } if (string.IsNullOrEmpty(favMod.Title)) { favMod.Title = bkMod.Tittle; } } break; } if (string.IsNullOrEmpty(favMod.Title)) { favMod.Title = "无标题"; } if (favMod.InfoID < 1) { err = "未指定内容ID"; } else if (favMod.Owner < 1) { err = "用户未登录"; } else { favBll.insert(favMod); } ViewBag.err = err; return(View()); }
public int insert(M_Favorite model) { return(Sql.insertID(TbName, model.GetParameters(), BLLCommon.GetParas(model), BLLCommon.GetFields(model))); }
public bool UpdateByID(M_Favorite model) { return(Sql.UpdateByIDs(TbName, PK, model.FavoriteID.ToString(), BLLCommon.GetFieldAndPara(model), model.GetParameters())); }
/// <summary> /// 添加收藏信息到收藏夹 /// </summary> /// <param name="favorite">收藏信息实例</param> public void AddFavorite(M_Favorite model) { Sql.insertID(TbName, model.GetParameters(), BLLCommon.GetParas(model), BLLCommon.GetFields(model)); }
/// <summary> /// 添加收藏信息到收藏夹 /// </summary> /// <param name="favorite">收藏信息实例</param> public void AddFavorite(M_Favorite favorite) { dal.AddFavorite(favorite); }