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) { } }
public static string SetBookShelvesState(string id) { try { BLL_Bookshelves bll = new BLL_Bookshelves(); Model_Bookshelves model = bll.GetModel(id); model.BookShelvesState = "0"; model.PutDownTime = DateTime.Now; bool inum = bll.Update(model); if (inum) { Model_VSysUserRole loginUser = (Model_VSysUserRole)HttpContext.Current.Session["LoginUser"]; Model_BookshelvesLog modelLog = new Model_BookshelvesLog(); modelLog.BookshelvesLog_Id = Guid.NewGuid().ToString(); modelLog.BookId = model.ResourceFolder_Id; modelLog.LogTypeEnum = "2"; modelLog.CreateUser = loginUser.SysUser_ID; modelLog.CreateTime = DateTime.Now; new BLL_BookshelvesLog().Add(modelLog); return(JsonConvert.SerializeObject(new { err = "null" })); } else { return(JsonConvert.SerializeObject(new { err = "" })); } } catch (Exception) { return(JsonConvert.SerializeObject(new { err = "error"//ex.Message.ToString() })); } }
private void LoadData() { Model_Bookshelves modelBook = new BLL_Bookshelves().GetModel(rid); BLL_UserOrder bll = new BLL_UserOrder(); Model_UserOrder model = new Model_UserOrder(); try { //if (bll.GetRecordCount("UserId='" + userId + "' and Book_Id='" + rid + "' and UserOrder_Status='" + (int)UOrderStatus.完成 + "' ") > 0) //{ // ClientScript.RegisterStartupScript(this.GetType(), "temp1", string.Format(strTips, "您已购买此教材,无需重复购买.")); // return; //} decimal amount = Convert.ToDecimal(modelBook.BookPrice); ltlAmount.Text = amount.ToString(); if (amount <= 0) { ClientScript.RegisterStartupScript(this.GetType(), "temp1", string.Format(strTips, "订单提交失败,请重新提交订单.")); return; } if (string.IsNullOrEmpty(orderNo)) { string userId = FloginUser.UserId; DataTable dt = bll.GetList("UserId='" + userId + "' and Book_Id='" + rid + "'").Tables[0]; if (dt.Rows.Count > 0) { DataRow[] dr = dt.Select("UserOrder_Status='" + (int)UOrderStatus.完成 + "'"); if (dr.Length > 0) { ClientScript.RegisterStartupScript(this.GetType(), "temp1", string.Format(strTips, "您已购买此教材,无需重复购买.")); return; } DataRow[] dr1 = dt.Select("UserOrder_Status='" + (int)UOrderStatus.待付款 + "'"); if (dr1.Length > 0) { orderNo = dr1[0]["UserOrder_No"].ToString(); enOrderNo = Rc.Common.DBUtility.DESEncrypt.Encrypt(orderNo); ltlUserOrder_No.Text = orderNo; } else { DataRow[] dr2 = dt.Select("UserOrder_Status='" + (int)UOrderStatus.已取消 + "'"); if (dr2.Length > 0) { orderNo = GenerateUMOrderNo(); //if (bll.GetRecordCount("UserOrder_No='" + orderNo + "'") > 0) //{ // ClientScript.RegisterStartupScript(this.GetType(), "temp1", string.Format(strTips, "订单提交失败,请重新提交订单.")); // return; //} enOrderNo = Rc.Common.DBUtility.DESEncrypt.Encrypt(orderNo); ltlUserOrder_No.Text = orderNo; model.UserOrder_Id = Guid.NewGuid().ToString(); model.UserId = userId; model.UserOrder_No = orderNo; model.UserOrder_Time = DateTime.Now; model.UserOrder_Paytool = ""; model.UsreOrder_Buyeremail = ""; model.UserOrder_Type = orderType; model.UserOrder_Amount = amount; model.UserOrder_Status = (int)Rc.Model.Resources.UOrderStatus.待付款; model.Book_Id = modelBook.ResourceFolder_Id; model.Book_Name = modelBook.Book_Name; model.Book_Price = Convert.ToDecimal(modelBook.BookPrice); model.BookImg_Url = modelBook.BookImg_Url; if (!bll.Add(model)) { ClientScript.RegisterStartupScript(this.GetType(), "temp1", string.Format(strTips, "订单提交失败,请重新提交订单...")); return; } else { #region 0元资源,自动购买,暂不启用 //model.UserOrder_Status = (int)UOrderStatus.完成; //model.UserOrder_FinishTime = DateTime.Now; //#region 用户购买资源表 //Model_UserBuyResources buyModel = new Model_UserBuyResources(); //buyModel.UserBuyResources_ID = Guid.NewGuid().ToString(); //buyModel.UserId = model.UserId; //buyModel.Book_id = model.Book_Id; //buyModel.BookPrice = model.Book_Price; //buyModel.BuyType = UserOrder_PaytoolEnum.FREE.ToString(); //buyModel.CreateTime = DateTime.Now; //#endregion //bll.UpdateAndAddUserBuyResources(model, buyModel); #endregion } } } } else { orderNo = GenerateUMOrderNo(); if (bll.GetRecordCount("UserOrder_No='" + orderNo + "'") > 0) { ClientScript.RegisterStartupScript(this.GetType(), "temp1", string.Format(strTips, "订单提交失败,请重新提交订单.")); return; } enOrderNo = Rc.Common.DBUtility.DESEncrypt.Encrypt(orderNo); ltlUserOrder_No.Text = orderNo; model.UserOrder_Id = Guid.NewGuid().ToString(); model.UserId = userId; model.UserOrder_No = orderNo; model.UserOrder_Time = DateTime.Now; model.UserOrder_Paytool = ""; model.UsreOrder_Buyeremail = ""; model.UserOrder_Type = orderType; model.UserOrder_Amount = amount; model.UserOrder_Status = (int)Rc.Model.Resources.UOrderStatus.待付款; model.Book_Id = modelBook.ResourceFolder_Id; model.Book_Name = modelBook.Book_Name; model.Book_Price = Convert.ToDecimal(modelBook.BookPrice); model.BookImg_Url = modelBook.BookImg_Url; if (!bll.Add(model)) { ClientScript.RegisterStartupScript(this.GetType(), "temp1", string.Format(strTips, "订单提交失败,请重新提交订单...")); return; } else { #region 0元资源,自动购买,暂不启用 //model.UserOrder_Status = (int)UOrderStatus.完成; //model.UserOrder_FinishTime = DateTime.Now; //#region 用户购买资源表 //Model_UserBuyResources buyModel = new Model_UserBuyResources(); //buyModel.UserBuyResources_ID = Guid.NewGuid().ToString(); //buyModel.UserId = model.UserId; //buyModel.Book_id = model.Book_Id; //buyModel.BookPrice = model.Book_Price; //buyModel.BuyType = UserOrder_PaytoolEnum.FREE.ToString(); //buyModel.CreateTime = DateTime.Now; //#endregion //bll.UpdateAndAddUserBuyResources(model, buyModel); #endregion } } } else { enOrderNo = Rc.Common.DBUtility.DESEncrypt.Encrypt(orderNo); ltlUserOrder_No.Text = orderNo; } } catch (Exception) { ClientScript.RegisterStartupScript(this.GetType(), "temp1", string.Format(strTips, "订单提交失败,请重新提交订单....")); return; } }
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(); }