Ejemplo n.º 1
0
    protected void gvStoreOrder_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string[] args       = e.CommandArgument.ToString().Split(':');
        string   orderId    = args[0];
        string   storeId    = args[1];
        string   isCheckOut = args[2];
        double   totalMoney = Convert.ToDouble(args[3]);
        string   payWay     = args[4];

        if (e.CommandName == "OK")
        {
            //判断选中正确否(判断金额)
            int count    = 0;
            int paycount = 0;
            IList <StoreOrderModel> orders = new List <StoreOrderModel>();
            string[] storeMoney            = CheckOutOrdersBLL.GetStoreTotalOrderGoodsMoney(storeId);
            double   ordermoney            = double.Parse(storeMoney[0]); //订货款
            double   turnmonty             = double.Parse(storeMoney[1]); //周转款

            StoreOrderModel order = new StoreOrderModel();
            order.StoreorderId = orderId;
            if (payWay == "0")
            {
                order.OrderType = 0;
                if (totalMoney > ordermoney)
                {
                    msg = "<script>alert('" + GetTran("000957", "订货款不足!") + "');</script>";
                    return;
                }
            }
            else if (payWay == "1")
            {
                order.OrderType = 1;
                if (totalMoney > turnmonty)
                {
                    msg = "<script>alert('" + GetTran("000965", "周转款不足!") + "');</script>";
                    return;
                }
            }
            order.TotalMoney = Convert.ToDecimal(totalMoney);
            orders.Add(order);

            //if (!CheckOutOrdersBLL.CheckLogicProductInventory(orders))
            //{
            //    msg = "<script>alert('" + GetTran("000974", "公司库存不足,请通知公司及时进货!") + "')</script>";
            //    return;
            //}
            if (AddOrderDataDAL.OrderPayment(storeId, orderId, CommonDataBLL.OperateIP, 2, 1, 10, "管理员", "", 2, -1, 1, 1, "", 0, "") == 0)
            {
                msg = "<script>alert('" + GetTran("000978", "支付成功!") + "')</script>";
                Bind();
            }
            else
            {
                msg = "<script>alert('" + GetTran("000979", "支付失败请重新支付!") + "')</script>";
            }
            //if (payWay == "3")//支付宝支付
            //{
            //    msg = "<script>window.open('../Store/payment/default.aspx?zongMoney=" + totalMoney + "&TotalMoney=" + totalMoney + "&TotalComm=0 &OrderID =" + orderId + "&OnlineOrder=1');</script>";

            //    return;
            //}
            //else
            //{

            //}
        }
        else if (e.CommandName == "D")
        {
            //验证订单
            if (OrdersBrowseBLL.GetOrderIsExist(orderId))
            {
                msg = "<script>alert('" + GetTran("005993", "对不起,订单已被删除!") + "');</script>";
                Bind();
                return;
            }
            else if (OrdersBrowseBLL.GetOrderCheckState(orderId))
            {
                msg = "<script>alert('" + GetTran("005994", "对不起,该订单已支付,不能删除!") + "');</script>";
                Bind();
                return;
            }

            if (OrdersBrowseBLL.DelStoreOrderItem(orderId))
            {
                msg = "<script>alert('" + GetTran("000749", "删除成功!") + "');</script>";
            }
            else
            {
                msg = "<script>alert('" + GetTran("000417", "删除失败!") + "');</script>";
            }
            Bind();
        }
    }