Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int    totalcount = 0;
                int    pagesize   = 10;
                int    pageindex  = HYRequest.GetQueryInt("p", 1);
                string kw         = Utils.SafeCheckSearchKw(HYRequest.GetQueryString("kw"));
                this.SearchKw = kw;
                string whereSql = string.Empty;

                //List<ProductModel> list;
                if (!string.IsNullOrEmpty(kw))
                {
                    whereSql       = string.Format(" where productname like '%{0}%' ", kw);
                    searchProducts = ProductFactory.GetList(pagesize, pageindex, whereSql, " order by productid desc ", out totalcount);
                }
                else
                {
                    searchProducts = ProductFactory.GetList(10, string.Empty);
                }

                PagerHtml = Utils.BuildProductListPager(totalcount, pagesize, pageindex, "search.aspx?p={0}&kw=" + kw);
            }
        }
Esempio n. 2
0
        private void UpLoadFile(HttpContext context)
        {
            //Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig();
            string         _delfile     = HYRequest.GetString("DelFilePath");
            HttpPostedFile _upfile      = context.Request.Files["Filedata"];
            bool           _iswater     = false; //默认不打水印
            bool           _isthumbnail = false; //默认不生成缩略图

            if (HYRequest.GetQueryString("IsWater") == "1")
            {
                _iswater = true;
            }
            if (HYRequest.GetQueryString("IsThumbnail") == "1")
            {
                _isthumbnail = true;
            }
            if (_upfile == null)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}");
                return;
            }
            UpLoad upFiles = new UpLoad();
            string msg     = upFiles.fileSaveAs(_upfile, _isthumbnail, _iswater);

            //删除已存在的旧文件,旧文件不为空且应是上传文件,防止跨目录删除
            if (!string.IsNullOrEmpty(_delfile) && _delfile.IndexOf("../") == -1 &&
                _delfile.ToLower().StartsWith(SiteConfig.Instance().FileUpLoadPath.ToLower()))
            {
                Utils.DeleteUpFile(_delfile);
            }
            //返回成功信息
            context.Response.Write(msg);
            context.Response.End();
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string action = HYRequest.GetQueryString("action");
                if (action == "cancelorder") //取消订单
                {
                    int orderid = HYRequest.GetQueryInt("orderid", 0);
                    OrderFactory.UpdateStatus(99, orderid);
                    Response.Redirect("user_order.aspx");
                }

                int s          = HYRequest.GetQueryInt("s", 0);
                int pageindex  = HYRequest.GetQueryInt("p", 1);
                int pagesize   = 5;
                int totalcount = 0;
                if (s == 0)
                {
                    OrderList = OrderFactory.GetOrderList(pagesize, pageindex, " where uid=" + this.LoginUser.uid + " and orderstatus>1 ", " order by orderid desc ", out totalcount);
                }
                else if (s == 1) //已下单未付款
                {
                    OrderList = OrderFactory.GetOrderList(pagesize, pageindex, " where uid=" + this.LoginUser.uid + " and (orderstatus=2 or orderstatus=3) ", " order by orderid desc ", out totalcount);
                }
                else if (s == 2) //已付款
                {
                    OrderList = OrderFactory.GetOrderList(pagesize, pageindex, " where uid=" + this.LoginUser.uid + " and orderstatus=5 ", " order by orderid desc ", out totalcount);
                }
            }
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                UserModel userInfo = this.LoginUser;
                string    orderno  = HYRequest.GetQueryString("orderno");

                CartOrder = OrderFactory.Get(orderno);

                //需要判断是否选中所有产品,如不是,则新增加一个订单作为购物车,保留未选中的产品;
                if (CartOrder != null && CartOrder.orderstatus == 1) //购物车订单
                {
                    if (!CartOrder.selectallproduct)
                    {
                        OrderModel om = new OrderModel();
                        om.orderstatus  = 1;                 //购物车
                        om.address      = userInfo.address;  //CartOrder.address;
                        om.createtime   = CartOrder.createtime;
                        om.customername = userInfo.fullname; //CartOrder.customername;
                        om.tel          = userInfo.tel;
                        om.uid          = CartOrder.uid;
                        om.orderno      = Utils.GenerateOutTradeNo(CartOrder.uid);

                        foreach (OrderProduct op in CartOrder.productlist)
                        {
                            if (!op.isselected)
                            {
                                om.productlist.Add(op);
                            }
                        }

                        foreach (OrderProduct op in om.productlist)
                        {
                            CartOrder.productlist.Remove(op);
                        }

                        CartOrder.orderstatus = 2; //更新为已下单
                        CartOrder.createtime  = DateTime.Now;
                        OrderFactory.Update(CartOrder);

                        OrderFactory.Add(om);
                    }
                }

                //if (CartOrder != null && CartOrder.orderstatus == 1) //购物车订单
                //    OrderFactory.UpdateStatus(2, CartOrder.orderid);//更新为已下单

                this.txtaddress.Value      = userInfo.address; //CartOrder.address;
                this.txtcustomername.Value = userInfo.fullname;
                this.txttel.Value          = userInfo.tel;
                this.txtordermessage.Value = CartOrder.ordermessage;

                //this.ltlPostAge.Text = vsconfig.PostAge.ToString();
            }
        }
Esempio n. 5
0
        }                                        //H5调起JS API参数
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //string openid = Request.QueryString["openid"];
                string     orderno   = HYRequest.GetQueryString("orderno");
                OrderModel orderinfo = OrderFactory.Get(orderno);

                int total_fee = HYRequest.GetQueryInt("total_fee", 0); //单位为分

                //若传递了相关参数,则调统一下单接口,获得后续相关接口的入口参数
                JsApiPay jsApiPay = new JsApiPay(this);

                if (orderinfo != null && orderinfo.productlist.Count > 0)
                {
                    jsApiPay.body_desc = orderinfo.productlist[0].productinfo.productname + "等";
                }
                else
                {
                    jsApiPay.body_desc = shopconfig.ShopName + "购物";
                }

                //单独测试,先微信登陆一下,整合后,有openid了,就无需重复获取授权了。
                //jsApiPay.GetOpenidAndAccessToken();
                jsApiPay.openid = this.LoginUser.openid;

                jsApiPay.total_fee    = total_fee;
                jsApiPay.out_trade_no = orderno; //WxPayApi.GenerateOutTradeNo(321);  //此处订单号,整合到系统后,从订单产生开始就确立,无需在支付页面生成

                //JSAPI支付预处理
                try
                {
                    WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult();
                    wxJsApiParam = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数
                    //在页面上显示订单信息
                    //Response.Write("<span style='color:#00CD00;font-size:20px'>订单详情:</span><br/>");
                    //Response.Write("<span style='color:#00CD00;font-size:20px'>" + unifiedOrderResult.ToPrintStr() + "</span>");
                    //Response.Write(string.Format("<span style='color:#00CD00;font-size:20px'>订单号:{0}</span><br/>", orderinfo.orderno));
                    //Response.Write(string.Format("<span style='color:#00CD00;font-size:20px'>支付额:{0}</span><br/>", orderinfo.totalyfprice));

                    System.Text.StringBuilder sbtips = new System.Text.StringBuilder();
                    sbtips.Append("<span style='color:#00CD00;font-size:20px'>订单详情:</span><br/>");
                    sbtips.Append(string.Format("<span style='color:#00CD00;font-size:16px'>订单编号:{0}</span><br/>", orderinfo.orderno));
                    sbtips.Append(string.Format("<span style='color:#00CD00;font-size:16px'>支付总额:{0}</span><br/>", orderinfo.totalyfprice));

                    this.ltlTips.Text = sbtips.ToString();
                }
                catch
                {
                    this.ltlTips.Text = "<span style='color:#FF0000;font-size:20px'>" + "下单失败,请返回重试" + "</span>";
                }
            }
        }
Esempio n. 6
0
        public void ProcessRequest(HttpContext context)
        {
            Security.CheckAdministerAndCloseReq();

            //取得处事类型
            string action = HYRequest.GetQueryString("action");

            switch (action)
            {
            default:     //普通上传
                UpLoadFile(context);
                break;
            }
        }
Esempio n. 7
0
        protected void lnkBuy_Click(object sender, EventArgs e)
        {
            bool      iswxpay  = true; //this.payment_2.Checked; //是否微信支付
            string    orderno  = HYRequest.GetQueryString("orderno");
            UserModel userInfo = this.LoginUser;

            CartOrder              = OrderFactory.Get(orderno);
            CartOrder.address      = this.txtaddress.Value;
            CartOrder.customername = this.txtcustomername.Value;
            CartOrder.tel          = this.txttel.Value;
            CartOrder.shippingdesc = "快递"; //this.shipping_1.Checked ? "市内" : "市外";
            CartOrder.paymentdesc  = iswxpay ? "微信支付" : "货到付款";
            CartOrder.ordermessage = this.txtordermessage.Value;
            //CartOrder.ordersysdesc = userInfo.usertypedesc;
            CartOrder.orderpostage = CartOrder.postage.ToString();

            //如果用户信息不全,则补充完整
            if (string.IsNullOrEmpty(userInfo.fullname) || string.IsNullOrEmpty(userInfo.tel) || string.IsNullOrEmpty(userInfo.address))
            {
                userInfo.fullname = (string.IsNullOrEmpty(userInfo.fullname) ? CartOrder.customername : userInfo.fullname);
                userInfo.tel      = (string.IsNullOrEmpty(userInfo.tel) ? CartOrder.tel : userInfo.tel);
                userInfo.address  = (string.IsNullOrEmpty(userInfo.address) ? CartOrder.address : userInfo.address);

                UserFactory.Update(userInfo);
            }

            if (iswxpay)
            {
                CartOrder.totalprice   = CartOrder.productprice;
                CartOrder.totalyfprice = CartOrder.productprice + CartOrder.postage;
                CartOrder.orderstatus  = 3;
                //CartOrder.totalyfprice = getyifuprice(CartOrder.totalprice);

                OrderFactory.Update(CartOrder);

                //前往微信支付JS API接口页面
                string url = "pay/wxpay.aspx?orderno=" + CartOrder.orderno + "&total_fee=" + (CartOrder.totalyfprice * 100).ToString("0");
                Response.Redirect(url);
            }
        }
Esempio n. 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int    totalcount = 0;
                int    pagesize   = 12;
                int    cid        = HYRequest.GetQueryInt("cid", 0);
                int    pageindex  = HYRequest.GetQueryInt("p", 1);
                int    od         = HYRequest.GetQueryInt("od", 0);
                string whereSql   = " where productcode=1 ";

                string orderby = " order by productid desc ";
                string url     = "productlist.aspx?p={0}";


                if (cid > 0)
                {
                    whereSql = " where productcode=1 and categoryid=" + cid;
                    url     += "&cid=" + cid;
                }

                if (od == 1)
                {
                    orderby = " order by salecount desc ";
                }
                else if (od == 2)
                {
                    orderby = " order by price desc ";
                }

                listProducts = ProductFactory.GetList(pagesize, pageindex, whereSql, orderby, out totalcount);

                //this.rptProducts.DataSource = list;
                //this.rptProducts.DataBind();

                //this.rptAddToCarPopWin.DataSource = list;
                //this.rptAddToCarPopWin.DataBind();

                pagerHtml = Utils.BuildProductListPager(totalcount, pagesize, pageindex, url);

                if (cid == 0)
                {
                    this.CategoryName = "全部商品";
                }
                else
                {
                    ProductCategoryModel pcm = ProductCategoryFactory.Get(cid);
                    if (pcm != null)
                    {
                        this.CategoryName = pcm.categoryname;
                    }
                }
            }

            string action = HYRequest.GetQueryString("action");

            if (action == "ajaxloadlist")
            {
                int cid        = HYRequest.GetInt("cid", 0);
                int pageindex  = HYRequest.GetInt("p", 1);
                int pagesize   = 12;
                int totalcount = 0;

                string wheresql = " where productcode=1 ";
                if (cid > 0)
                {
                    wheresql = string.Format(" where productcode=1 and categoryid={0} ", cid.ToString());
                }

                List <ProductModel> list   = ProductFactory.GetList(pagesize, pageindex, wheresql, string.Empty, out totalcount);
                StringBuilder       sbhtml = new StringBuilder();
                foreach (ProductModel pm in list)
                {
                    sbhtml.AppendLine("<li class=\"item\">");
                    sbhtml.AppendLine(string.Format("<a href=\"productshow.aspx?id={0}\"><img src=\"{1}\" alt=\"item\" /></a>", pm.productid, pm.includepicpath));
                    sbhtml.AppendLine(string.Format("<h4><a href=\"productshow.aspx?id={0}\">{1}</a></h4>", pm.productid, pm.productname));
                    sbhtml.AppendLine(string.Format("<span>&yen;{0}</span><del style=\"display:none\">&yen;{0}</del><em>库存:{1} &nbsp; 销量:{2}</em>", pm.price.ToString(), pm.productcount, pm.salecount));
                    sbhtml.AppendLine(string.Format("<p class=\"add-to-cart\" onClick=\"toshare({0})\"><span>添加到购物车</span></p>", pm.productid));

                    sbhtml.AppendLine("</li>");
                }
                Response.Write(sbhtml.ToString());
                Response.Flush();
                Response.End();
            }
        }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                UserModel  userInfo = this.LoginUser;
                OrderModel myorder  = OrderFactory.GetCartOrder(userInfo.uid);

                int    pid      = HYRequest.GetQueryInt("pid", 0);
                int    itemflag = HYRequest.GetQueryInt("itemflag", 0);
                string action   = HYRequest.GetQueryString("action");

                if (action == "add") //添加商品
                {
                    OrderModel myof = myorder;
                    if (myof == null)
                    {
                        myof              = new OrderModel();
                        myof.orderno      = Utils.GenerateOutTradeNo(userInfo.uid); //Utils.GetRandomOrderNo();
                        myof.uid          = userInfo.uid;
                        myof.customername = userInfo.fullname;
                        myof.tel          = userInfo.tel;
                        myof.address      = userInfo.address;
                    }

                    ProductModel p  = ProductFactory.Get(pid);
                    OrderProduct op = new OrderProduct();
                    op.count       = 1;
                    op.productinfo = p;
                    op.price       = p.price;

                    //判断是否有属性
                    if (itemflag > 0)
                    {
                        int tmpflag = 1;
                        foreach (KeyValuePair <string, decimal> kvp in p.itempricelist)
                        {
                            if (itemflag == tmpflag)
                            {
                                op.item  = kvp.Key;
                                op.price = kvp.Value;
                                break;
                            }
                            tmpflag++;
                        }
                    }

                    CheckIsAdd(myof.productlist, op);

                    if (myorder == null)
                    {
                        OrderFactory.Add(myof);
                    }
                    else
                    {
                        OrderFactory.Update(myof);
                    }

                    Response.Redirect("cart.aspx");
                }
                else if (action == "del")
                {
                    OrderModel   myof = myorder;
                    ProductModel p    = ProductFactory.Get(pid);

                    OrderProduct op = new OrderProduct();
                    op.productinfo = p;
                    op.item        = HYRequest.GetQueryString("item");

                    CheckIsDel(myof.productlist, op);

                    OrderFactory.Update(myof);
                    Response.Redirect("cart.aspx");
                }
                else if (action == "ajaxupdate")   //更新数量
                {
                    int    goods_selected = HYRequest.GetInt("goods_selected", 1);
                    int    goods_number   = HYRequest.GetInt("goods_number", 1);
                    int    rec_id         = HYRequest.GetInt("rec_id", 0);
                    string item           = HYRequest.GetString("item");

                    OrderModel   myof = myorder;
                    ProductModel p    = ProductFactory.Get(rec_id);
                    OrderProduct op   = new OrderProduct();
                    op.isselected  = (goods_selected == 1) ? true : false;
                    op.count       = goods_number;
                    op.item        = item;
                    op.productinfo = p;
                    CheckIsUpdate(myof.productlist, op);

                    OrderFactory.Update(myof);

                    string json = "{\"rec_id\":" + rec_id + ",\"goods_number\":" + goods_number + ",\"total_number\":" + myof.productcount + ",\"total_desc\":" + myof.productprice.ToString() + ",\"postage\":" + myof.postage.ToString() + ",\"error\":0}";
                    Response.Write(json);
                    Response.Flush();
                    Response.End();
                    return;
                }
                else if (action == "ajaxupdateall")  //全选状态处理
                {
                    int        goods_selected = HYRequest.GetInt("goods_selected", 1);
                    int        rec_id         = HYRequest.GetInt("rec_id", 0);
                    OrderModel myof           = myorder;
                    foreach (OrderProduct o in myof.productlist)
                    {
                        o.isselected = (goods_selected == 1) ? true : false;
                    }

                    OrderFactory.Update(myof);

                    string json = "{\"rec_id\":" + rec_id + ",\"total_number\":" + myof.productcount + ",\"total_desc\":" + myof.productprice.ToString() + ",\"postage\":" + myof.postage.ToString() + ",\"error\":0}";
                    Response.Write(json);
                    Response.Flush();
                    Response.End();
                    return;
                }

                if (myorder != null && myorder.productcount > 0)
                {
                    this.phNoProduct.Visible = false;
                    CartOrder = myorder;
                }
                else
                {
                    this.phNoProduct.Visible = true;
                }
            }
        }
Esempio n. 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string action = HYRequest.GetQueryString("action");

                UserModel  userInfo = this.LoginUser;
                OrderModel myorder  = OrderFactory.GetCartOrder(userInfo.uid);



                if (action == "addtocart")       //添加到购物车
                {
                    #region ==addtocart==
                    int pid      = HYRequest.GetFormInt("pid", 0);
                    int buycount = HYRequest.GetFormInt("buycount", 0);
                    int itemflag = HYRequest.GetFormInt("itemflag", 0);

                    OrderModel myof = myorder;
                    if (myof == null)
                    {
                        myof              = new OrderModel();
                        myof.orderno      = Utils.GenerateOutTradeNo(this.LoginUser.uid);
                        myof.uid          = userInfo.uid;
                        myof.customername = userInfo.fullname;
                        myof.tel          = userInfo.tel;
                        myof.address      = userInfo.address;
                    }

                    ProductModel p  = ProductFactory.Get(pid);
                    OrderProduct op = new OrderProduct();
                    op.count       = buycount;
                    op.productinfo = p;
                    op.price       = p.price;

                    //判断是否有属性
                    if (itemflag > 0)
                    {
                        int tmpflag = 1;
                        foreach (KeyValuePair <string, decimal> kvp in p.itempricelist)
                        {
                            if (itemflag == tmpflag)
                            {
                                op.item  = kvp.Key;
                                op.price = kvp.Value;
                                break;
                            }
                            tmpflag++;
                        }
                    }

                    CheckIsAdd(myof.productlist, op);

                    if (myorder == null)
                    {
                        OrderFactory.Add(myof);
                    }
                    else
                    {
                        OrderFactory.Update(myof);
                    }

                    string json = "{\"shopcount\":" + myof.productlist.Count + ",\"error\":0}";
                    Response.Write(json);
                    Response.Flush();
                    Response.End();
                    return;

                    #endregion
                }
                else if (action == "addtofav")   //添加到收藏夹
                {
                    #region ==addtofav==
                    int  pid   = HYRequest.GetFormInt("pid", 0);
                    bool isfav = FavoriteFactory.IsFavorite(this.LoginUser.uid, pid);
                    if (!isfav)
                    {
                        FavoriteModel fm = new FavoriteModel();
                        fm.product   = ProductFactory.Get(pid);
                        fm.uid       = this.LoginUser.uid;
                        fm.productid = pid;

                        FavoriteFactory.Add(fm);
                    }
                    string json = "{\"favtip\":\"已收藏\",\"error\":0}";
                    Response.Write(json);
                    Response.Flush();
                    Response.End();
                    return;

                    #endregion
                }
                else if (action == "delfav")     //删除收藏夹
                {
                    int fid = HYRequest.GetFormInt("fid", 0);
                    FavoriteFactory.Delete(fid);
                }
            }
        }