protected void btnBuy_Click(object sender, EventArgs e) { try { BLL_Bookshelves bll = new BLL_Bookshelves(); DataTable dt = bll.GetList("ResourceFolder_Id='" + ResourceFolder_ID + "'").Tables[0]; if (dt.Rows.Count > 0) { BookPrice = dt.Rows[0]["BookPrice"].ToString(); } if (BookPrice == "0.00") { #region 用户购买资源表 Model_UserBuyResources buyModel = new Model_UserBuyResources(); buyModel.UserBuyResources_ID = Guid.NewGuid().ToString(); buyModel.UserId = FloginUser.UserId; buyModel.Book_id = ResourceFolder_ID; buyModel.BookPrice = 0; buyModel.BuyType = UserOrder_PaytoolEnum.FREE.ToString(); buyModel.CreateTime = DateTime.Now; buyModel.CreateUser = FloginUser.UserId; if (new BLL_UserBuyResources().Add(buyModel)) { new Rc.Cloud.BLL.BLL_clsAuth().AddLogFromBS(Request.Url.ToString(), string.Format("免费资源。购买资源成功,购买人:{0},资源标识:{1}" , FloginUser.UserId, ResourceFolder_ID)); ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('购买成功',{icon:1,time:1000},function(){window.location.href=window.location;});</script>"); } else { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('购买失败',{icon:2,time:2000});</script>"); return; } #endregion } else { if (Type == "1") { Response.Redirect("/student/Payment.aspx?orderType=2&rid=" + ResourceFolder_ID); } else { Response.Redirect("/teacher/Payment.aspx?orderType=1&rid=" + ResourceFolder_ID); } } } catch (Exception) { } }
protected void LaodData() { BLL_UserBuyResources bllubr = new BLL_UserBuyResources(); DataTable dtubr = bllubr.GetList(" Book_id='" + ResourceFolder_ID + "' and UserId='" + FloginUser.UserId + "'").Tables[0]; if (dtubr.Rows.Count > 0) { Vbtn = true; btnBuy.Visible = false; } BLL_Bookshelves bll = new BLL_Bookshelves(); DataTable dt = bll.GetList("ResourceFolder_Id='" + ResourceFolder_ID + "'").Tables[0]; if (dt.Rows.Count > 0) { #region 处理图片显示宽高 int imgHeight = 0; int imgWidth = 0; string imgFilePath = Server.MapPath(dt.Rows[0]["BookImg_Url"].ToString()); if (System.IO.File.Exists(imgFilePath)) { System.Drawing.Image img = System.Drawing.Image.FromFile(imgFilePath); imgHeight = img.Height; imgWidth = img.Width; if (imgHeight / 300.0 > imgWidth / 220.0) { imgWidth = 0; if (imgHeight > 300) { imgHeight = 300; } } else { imgHeight = 0; if (imgWidth > 220) { imgWidth = 220; } } img.Dispose(); } #endregion //ltlImg.Text = string.Format("<img src='{0}' {1} {2} onerror=\"this.src='../images/re_nopic.jpg'\" width='186' height='239' />" // , dt.Rows[0]["BookImg_Url"].ToString() // , imgHeight > 0 ? string.Format("height='{0}'", imgHeight) : "" // , imgWidth > 0 ? string.Format("width='{0}'", imgWidth) : ""); ltlImg.Text = string.Format("<img src='{0}' onerror=\"this.src='../images/re_nopic.jpg'\" width='175' height='240' />" , dt.Rows[0]["BookImg_Url"].ToString()); ltlMaskImg.Text = string.Format("<img class='blur-item-hook' src='{0}' />" , dt.Rows[0]["BookImg_Url"].ToString()); ltlBookName.Text = dt.Rows[0]["Book_Name"].ToString(); btnBuy.Text = "购买 ¥" + dt.Rows[0]["BookPrice"].ToString(); ltlBookBif.Text = dt.Rows[0]["BookBrief"].ToString(); } string strsql = @"select ResourceFolder_Id,ResourceFolder_Name,Resource_Type,Resource_Class,File_Suffix,ResourceFolder_Level,ResourceFolder_ParentId from VW_ResourceAndResourceFolder where Book_ID='" + ResourceFolder_ID + "' order by ResourceFolder_Order"; DataTable dtre = Rc.Common.DBUtility.DbHelperSQL.Query(strsql).Tables[0]; if (dtre.Rows.Count > 0) { DataView dvw = new DataView(); dvw.Table = dtre; litTree.Text = InitNavigationTree("0", dtre.Rows[0]["Resource_Class"].ToString(), dvw, 1).ToString(); } string sql = @" select c.comment_id,c.comment_content,create_time,comment_evaluate,ISNULL(u.TrueName,u.UserName)as Commenter,o.Book_Id from userorder_comment c left join F_User u on u.UserId=c.user_id left join UserOrder o on o.UserOrder_No=c.order_num where o.Book_Id='" + ResourceFolder_ID + "'"; DataTable dtC = Rc.Common.DBUtility.DbHelperSQL.Query(sql).Tables[0]; rptcourse_comment.DataSource = dtC; rptcourse_comment.DataBind(); }