CY_ECommercePlatform/CY.WebForm/Pages/financial/OrderMoneyBatchReceive.aspx.cs
@@ -47,9 +47,12 @@
        protected void Page_Load(object sender, EventArgs e)
        {
            _eC_OrderBasicBLL = new EC_OrderBasicBLL();
            btnSubmit.ServerClick += new EventHandler(btnSubmit_ServerClick);
            LoadOrder();
            //btnSubmit.ServerClick += new EventHandler(btnSubmit_ServerClick);
            if (!IsPostBack)
            {
                LoadOrder();
            }
            if (IsPostBack || IsCallback)
                return;
            InitPage();
@@ -61,62 +64,106 @@
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnSubmit_ServerClick(object sender, EventArgs e)
        protected void btn_Submit_form(object sender, EventArgs e)
        {
            string[] orderIds = Request["ids"].Split(',');
            var ids = Request["ids"];
            //string[] orderIds = Request["ids"].Split(',');
            string receiveWay = Request["rdoReceiveWay"];
            bool isWin = false;
            using (var scope = new TransactionScope())
                using (var scope = new TransactionScope(TransactionScopeOption.Required,
     new TransactionOptions
     {
         IsolationLevel = IsolationLevel.ReadCommitted,
         Timeout = TransactionManager.MaximumTimeout
     }
 ))
            {
                foreach (string orderId in orderIds)
                try
                {
                    EC_OrderBasic _orderBasic = _eC_OrderBasicBLL.SelectModelById(orderId.ToInt32().Value);
                    OA_CorporateClients m_OA_CorporateClients = bll_OA_CorporateClientsBLL.SelectModelByFirmIdandMemberId(CurrentUser.MemberId, _orderBasic.BuyerId);
                    if (receiveWay == "0" && m_OA_CorporateClients != null)
                    {
                        if (this.txtReceiveMoney.Value.ToInt32() > (m_OA_CorporateClients.Prepayments + m_OA_CorporateClients.Credit))
                        {
                            JavaScript.MessageBox("预付款不足!", this, "window.location='/Pages/financial/OrderMoneyBatchReceive.aspx?id=" + Request["ids"] + "'");
                            //Response.Redirect("/Pages/financial/OrderMoneyReceive.aspx?id=" + orderId);
                            return;
                        }
                    }
                    if (string.IsNullOrEmpty(orderId) || string.IsNullOrEmpty(receiveWay))
                    var _orderBasicmodes = _eC_OrderBasicBLL.GetOrderByIds(ids);
                    if (string.IsNullOrEmpty(ids) || string.IsNullOrEmpty(receiveWay))
                    {
                        JavaScript.MessageBox("传入参数错误!", this);
                        return;
                    }
                    if (null == _orderBasic)
                    if (null == _orderBasicmodes)
                    {
                        JavaScript.MessageBox("订单不存在或已删除!", this);
                        return;
                    }
                    isWin = "0".Equals(receiveWay) ? UsePrepare(_orderBasic) : ToAccount(_orderBasic.Keyid.Value, _orderBasic.BuyerName, _orderBasic.UnPayedMoney);
                    if (!isWin)
                    {
                        break;
                    }
                    int i = 0;
                    foreach (var _orderBasic in _orderBasicmodes)
                    {
                        //EC_OrderBasic _orderBasic = _eC_OrderBasicBLL.SelectModelById(orderId.ToInt32().Value);
                        if (receiveWay == "0" && i == 0)
                        {
                            OA_CorporateClients m_OA_CorporateClients = bll_OA_CorporateClientsBLL.SelectModelByFirmIdandMemberId(CurrentUser.MemberId, _orderBasic.BuyerId);
                            if (m_OA_CorporateClients != null)
                            {
                                if (this.txtReceiveMoney.Value.ToInt32() > (m_OA_CorporateClients.Prepayments + m_OA_CorporateClients.Credit))
                                {
                                    JavaScript.MessageBox("预付款不足!", this, "window.location='/Pages/financial/OrderMoneyBatchReceive.aspx?id=" + Request["ids"] + "'");
                                    //Response.Redirect("/Pages/financial/OrderMoneyReceive.aspx?id=" + orderId);
                                    return;
                                }
                            }
                            else
                            {
                                JavaScript.MessageBox("预付款不足!", this, "window.location='/Pages/financial/OrderMoneyBatchReceive.aspx?id=" + Request["ids"] + "'");
                            }
                        }
                        i = i + 1;
                        isWin = "0".Equals(receiveWay) ? UsePrepare(_orderBasic) : ToAccount(_orderBasic.Keyid.Value, _orderBasic.BuyerName, _orderBasic.UnPayedMoney);
                        if (!isWin)
                        {
                            break;
                        }
                    }
                    scope.Complete();
                }
                scope.Complete();
                catch (Exception ex)
                {
                    // 回滚事务
                }
                finally
                {
                    // 释放资源
                    scope.Dispose();
                }
            }
             
            if (isWin)
            {
                JavaScript.MessageBox("操作成功", this, true, true);
                JavaScript.MessageBox("操作成功", this);
                JavaScript.RefreshDIVOpener(this);
            }
            else
            {
                JavaScript.MessageBox("操作失败", this);
            }
            //JavaScript.MessageBox(isWin ? "收款成功!" : "收款失败!", this, "top.frmright.ReLoad();top.Dialog.close();");
            Request.RequestContext.RouteData.DataTokens.Add("IsWin", isWin ? "1" : "");
            if (!isWin)
                InitPage();
            else
                ;
            //Request.RequestContext.RouteData.DataTokens.Add("IsWin", isWin ? "1" : "");
            //if (!isWin)
            //    InitPage();
            //else
            //    ;
        }
@@ -178,7 +225,7 @@
        {
            string[] orderIds = Request["id"].Split(',');
            this.ids.Value = Request["id"];
            List<EC_OrderBasic> eC_OrderBasics = new List<EC_OrderBasic>();
            //List<EC_OrderBasic> eC_OrderBasics = new List<EC_OrderBasic>();
            decimal shoukuanmoney = 0;
            if (orderIds==null || orderIds.Length==0)
            {
@@ -187,25 +234,26 @@
            try
            {
                foreach (string orderId in orderIds)
                var _orderBasicmodes = _eC_OrderBasicBLL.GetOrderByIds(this.ids.Value);
                foreach (var _orderBasicmode in _orderBasicmodes)
                {
                    EC_OrderBasic _orderBasicmode = _eC_OrderBasicBLL.SelectModelById(orderId.ToInt32().Value);
                    OA_CorporateClients m_OA_CorporateClients = bll_OA_CorporateClientsBLL.SelectModelByFirmIdandMemberId(CurrentUser.MemberId, _orderBasicmode.BuyerId);
                    if (m_OA_CorporateClients != null)
                    {
                        _orderBasicmode.nowCustomMoney = "¥" + (m_OA_CorporateClients.Prepayments ?? 0).ToString("0.00");
                        _orderBasicmode.nowCredit = "¥" + (m_OA_CorporateClients.Credit ?? 0).ToString("0.00");
                    }
                    else
                    {
                        _orderBasicmode.nowCustomMoney = "¥0";
                        _orderBasicmode.nowCredit = "¥0";
                    }
                   // EC_OrderBasic _orderBasicmode = _eC_OrderBasicBLL.SelectModelById(orderId.ToInt32().Value);
                    //OA_CorporateClients m_OA_CorporateClients = bll_OA_CorporateClientsBLL.SelectModelByFirmIdandMemberId(CurrentUser.MemberId, _orderBasicmode.BuyerId);
                    //if (m_OA_CorporateClients != null)
                    //{
                    //    _orderBasicmode.nowCustomMoney = "¥" + (m_OA_CorporateClients.Prepayments ?? 0).ToString("0.00");
                    //    _orderBasicmode.nowCredit = "¥" + (m_OA_CorporateClients.Credit ?? 0).ToString("0.00");
                    //}
                    //else
                    //{
                    //    _orderBasicmode.nowCustomMoney = "¥0";
                    //    _orderBasicmode.nowCredit = "¥0";
                    //}
                    shoukuanmoney += _orderBasicmode.UnPayedMoney;
                    eC_OrderBasics.Add(_orderBasicmode);
                   // eC_OrderBasics.Add(_orderBasicmode);
                }
                this.txtReceiveMoney.Value = String.Format("{0:F}", shoukuanmoney);
                //rptOrderInfo.DataSource = eC_OrderBasics;