protected goodsInfo info = null; // 产品 //protected SellerInfo sInfo = null; // 商家 protected void bind() { if (id <= 0) { Response.Write("<script>alert('参数错误');history.go(-1);</script>"); return; } info = BLL.goodsBLL.GetModel(id); if (info == null || info.GoodsId != id) { Response.Write("<script>alert('无对应的商品');history.go(-1);</script>"); return; } name = info.GoodsName; price = Common.Utils.decimalObjectToStr(info.Price); if (info.sellerid <= 0) { Response.Write("<script>alert('无对应的商家信息');history.go(-1);</script>"); return; } //sInfo = BLL.SellerBLL.GetModel(info.sellerid); //if (sInfo == null || sInfo.sellerid != info.sellerid) //{ // Response.Write("<script>alert('无对应的商家信息');history.go(-1);</script>"); // return; //} }
protected SellerInfo sInfo = null; // 商家 protected void bind() { if (id <= 0) { Response.Write("<script>alert('参数错误');history.go(-1);</script>"); Response.End(); } info = BLL.goodsBLL.GetModel(id); if (info == null || info.GoodsId != id) { Response.Write("<script>alert('无对应的商品');history.go(-1);</script>"); Response.End(); } name = info.GoodsName; if (info.sellerid <= 0) { Response.Write("<script>alert('无对应的商家信息');history.go(-1);</script>"); Response.End(); } sInfo = BLL.SellerBLL.GetModel(info.sellerid); if (sInfo == null || sInfo.sellerid != info.sellerid) { Response.Write("<script>alert('无对应的商家信息');history.go(-1);</script>"); Response.End(); } }
/// <summary> /// 用户兑换 /// </summary> /// <param name="ExchId"></param> /// <param name="sellerid">当前商家</param> /// <param name="resultMsg"></param> /// <returns></returns> public static int exch(int ExchId, int sellerid, ref string resultMsg) { try { if (ExchId <= 0) { resultMsg = "兑换ID错误"; return(0); } if (sellerid <= 0) { resultMsg = "商家ID错误"; return(0); } DateTime now = DateTime.Now; goodsExchInfo info = GetModel(ExchId); if (info == null || info.ExchId != ExchId) { resultMsg = "不存在对应的兑换信息"; return(0); } g_orderInfo g_orderinfo = BLL.g_orderBLL.GetModel(info.orderid); if (g_orderinfo == null || g_orderinfo.orderid != info.orderid) { resultMsg = "不存在对应的订单信息"; return(0); } goodsInfo goodsinfo = BLL.goodsBLL.GetModel(info.goodsid); if (goodsinfo == null || goodsinfo.GoodsId != info.goodsid) { resultMsg = "不存在对应的商品信息"; return(0); } if (goodsinfo.sellerid != sellerid) { resultMsg = "此兑换单不属于当前商家"; return(0); } if (now > goodsinfo.EndDate) { resultMsg = "此活动已到期"; return(0); } //info.status = 1; //info.ExchName = ""; //info.ExchTel = ""; //info.ExchZipCode = ""; //info.ExchAddress = ""; //return Update(info); int result = new goodsExchDAL().exch(ExchId, info.goodsid, ref resultMsg); return(result); } catch (Exception exc) { resultMsg = exc.Message; } return(0); }
/// <summary> /// 绑定列表 /// </summary> /// <param name="typeid"></param> /// <param name="PageIndex"></param> /// <param name="PageSize"></param> /// <returns></returns> ///// protected string bindgoods( int companyid, int PageIndex, int PageSize) protected string bindgoods(int PageIndex, int PageSize) { int TotalRows = 0; goodsInfo goodsinfo = new goodsInfo(); //string where = BLL.DataPermissionBLL.getclientsql(companyid, ""); string where = ""; DataTable dt = goodsBLL.GetPager(PageSize, PageIndex, where, "GoodsId desc" , "GoodsId,GoodsName,Img,Price,TotalCount,ExchCount,Status,description" , ref TotalRows); string json = MyJSONHelper.GetJson_Pager(dt, TotalRows); //string json = "[{\"TotalRows\":" + TotalRows + ",\"rows\":["; //if (dt != null && dt.Rows.Count > 0) //{ // decimal price; // string imgurl; // foreach (DataRow dr in dt.Rows) // { // price = (decimal)Common.Utils.ChinaRound(Convert.ToDouble(dr["Price"]), 2); // //market = (decimal)Common.Utils.ChinaRound(Convert.ToDouble(dr["market"]), 2); // imgurl = dr["Img"].ToString(); // json += "{" + // "\"GoodsId\":\"" + dr["GoodsId"].ToString() + "\"" + // ",\"GoodsName\":\"" + Common.Utils.jsonReplace(dr["GoodsName"].ToString()) + "\"" + // ",\"img\":\"" + dr["Img"].ToString() + "\"" + // ",\"TotalCount\":\"" + dr["TotalCount"].ToString() + "\"" + // ",\"ExchCount\":\"" + Common.Utils.jsonReplace(dr["ExchCount"].ToString()) + "\"" + // ",\"Status\":\"" + dr["Status"].ToString() + "\"" + // ",\"Price\":\"" + price + "\"" + // //",\"StartDate\":\"" + dr["StartDate"].ToString() +"\"" + // //",\"EndDate\":\"" + dr["EndDate"].ToString() + "\"" + // ",\"description\":\"" + dr["description"].ToString() + "\"" + // "},"; // } //} //if (json.Trim().Length > 0 && json.Trim().EndsWith(",")) // json = json.Remove(json.Length - 1); //json += "]}]"; return(json); }
protected void Repeater1bind() { int PageSize = Pagination1.PageSize; int CurrentPage = Pagination1.CurrentPage; int total = 0; goodsInfo goodsinfo = new goodsInfo(); //string where = BLL.DataPermissionBLL.getclientsql(companyid, "") + " and sellerid=" + sellerid; string where = GetCondition() + " and sellerid=" + sellerid; DataTable dt = goodsBLL.GetPager(PageSize, CurrentPage, where, "GoodsId desc" , "GoodsId,GoodsName,GoodsType,Img,Price,TotalCount,ExchCount,Status,StartDate,EndDate,purchase" , ref total); Repeater1.DataSource = dt; Repeater1.DataBind(); Pagination1.TotalRecords = total; }
/// <summary> /// 删除 /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "del") { int id = Convert.ToInt32(e.CommandArgument); goodsInfo info = BLL.goodsBLL.GetModel(id); if (info == null || info.GoodsId != id) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), DateTime.Now.ToString(), "alert('无对应的信息!');", true); return; } int b = BLL.goodsBLL.Delete(id, "GoodsId"); if (b > 0) { Repeater1bind(); } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), DateTime.Now.ToString(), "alert('删除失败!');", true); } } }
/// <summary> /// 添加订单 /// </summary> public void addorder() { BLL.g_orderBLL gorderbll = new BLL.g_orderBLL(); Model.g_orderInfo gorder = new Model.g_orderInfo(); int overwritegoodsid = Common.Utils.ObjectToint(Request.Form["hidoosid"]); if (overwritegoodsid <= 0) { Response.Write("<script>parent.successful('商品ID错误');</script>"); return; } goodsInfo goodsinfo = BLL.goodsBLL.GetModel(overwritegoodsid); if (goodsinfo == null || goodsinfo.GoodsId != overwritegoodsid) { Response.Write("<script>parent.successful('不存在对应的商品');</script>"); return; } int count = Common.Utils.ObjectToint(Request.Form["inputcount"]); if (count <= 0) { Response.Write("<script>parent.successful('至少要购买1份');</script>"); return; } gorder.goodsid = overwritegoodsid; gorder.ordertype = goodsinfo.GoodsType; //gorder.pay_price = Common.Utils.ObjectTodecimal(Request.Form["h_moneysum"], 2); //gorder.totalprice = Common.Utils.ObjectTodecimal(Request.Form["h_moneysum"], 2); gorder.goods_count = count; gorder.uid = base.uid; decimal orderprice = goodsinfo.Price * gorder.goods_count; gorder.totalprice = orderprice; gorder.pay_price = orderprice; string resultMeg = ""; int result = gorderbll.add(gorder, ref resultMeg); if (result > 0) { if (gorder.ordertype == (int)Common.enum_goodstype.goodstype_2) { Response.Write("<script>parent.successful('" + result + "');</script>"); } else { Response.Write("<script>parent.successful2('" + result + "');</script>"); } return; } else { Response.Write("<script>parent.fail('" + resultMeg.Replace("'", "").Replace("\n", "").Replace("\r", "") + "');</script>"); return; } }