username@email.com
昨天 529d8cb61421eb65d86559d3d2636ad405b87b41
CY_ECommercePlatform/CY.WebForm/Pages/financial/CaigouPayEdit.aspx.cs
@@ -29,6 +29,10 @@
        OA_FirmAccountBLL bll_OA_FirmAccountBLL = null;
        OA_SuppliersBLL bll_OA_SuppliersBLL = null;
        OA_FukuanshenqingBLL _fukuanshenqingBLL = null;
        OA_SubjectSetBLL _OA_SubjectSetBLL = null;
        Sys_DictionaryBLL _Sys_DictionaryBLL = null;
        OA_StaffBLL staffBLL = null;
        OA_BaozhengjinBLL oA_BaozhengjinBLL = null;
        decimal? AllMoney = 0;
        decimal? ReceiveMoney = 0;
        //初始化
@@ -43,6 +47,10 @@
            bll_OA_FirmAccountBLL = new OA_FirmAccountBLL();
            bll_OA_SuppliersBLL = new OA_SuppliersBLL();
            _fukuanshenqingBLL = new OA_FukuanshenqingBLL();
            _Sys_DictionaryBLL = new Sys_DictionaryBLL();
            staffBLL = new OA_StaffBLL();
            oA_BaozhengjinBLL = new OA_BaozhengjinBLL();
            _OA_SubjectSetBLL = new OA_SubjectSetBLL();
        }
        //页面加载
@@ -88,10 +96,11 @@
                }
                this.spanAllMoney.InnerHtml = "¥" + (AllMoney ?? 0).ToString("0.00");
                this.spanReceiveMoney.InnerHtml = "¥" + ReceiveMoney.Value.ToString("0.00");
                this.hidReceiveMoney.Value =  ReceiveMoney.Value.ToString();
                this.spanCountRe.InnerHtml = Keys.Count().ToString2() + " 单";
                this.txtReciveMoney.Enabled = false;
                this.txtReciveMoney.Text = (ReceiveMoney ?? 0).ToString("0.00");
                this.txtReciveMoney.Value = (ReceiveMoney ?? 0).ToString("0.00");
                this.txtReciveMoney.Attributes.Add("max", (ReceiveMoney ?? 0).ToString("0.00"));
            }
               
@@ -111,14 +120,12 @@
                    JavaScript.MessageBox("请选择账户", this);
                    return;
                }
                ReceiveMoney = this.txtReciveMoney.Text.ToDecimal2();
                var werwerwerwerwe = Request["txtReciveMoney"];
                ReceiveMoney = this.txtReciveMoney.Value.ToDecimal2();
                int? SubjectId = this.selSubject.Value.ToInt32();
                var molingmoney = this.txtMolingMoney.Value.ToDecimal2();
                decimal? money = ReceiveMoney;
                if (Request["amount"].ToString2() == "one")
                {
                    money = this.txtReciveMoney.Text.ToDecimal2();
                }
                int? AccountIdOut = Request["selAccountNameOut"].ToInt32();
@@ -138,12 +145,35 @@
                    {
                        var id = this.Keyid.Value.ToInt32().Value;
                        var fukuanshenqing = _fukuanshenqingBLL.GetModelByKeyid(id);
                        if (fukuanshenqing.FukuanStatus == 2 && money>0)
                        {
                            JavaScript.MessageBox("该申请已经付款结束!", this);
                            return;
                        }
                        if (money > (fukuanshenqing.Fukuanmoney - fukuanshenqing.Yishoumoney))
                        {
                            JavaScript.MessageBox("操作金额大于剩余应付金额!", this);
                            return;
                        }
                        var Youwufapiao = Request["rdoReceiveQuannbu"];
                        if (fukuanshenqing.Youwufapiao == 2 && Youwufapiao == "1")
                        {
                            JavaScript.MessageBox("已经保存为有发票,无法修改为无发票!", this);
                            return;
                        }
                        if (molingmoney.HasValue)
                        {
                            if ((money + molingmoney.Value) != (fukuanshenqing.Fukuanmoney - fukuanshenqing.Yishoumoney))
                            {
                                JavaScript.MessageBox("操作金额加抹零金额必须等于剩余应付金额!", this);
                                return;
                            }
                        }
                        string[] Keys = fukuanshenqing.DindanId.Trim(',').Split(',');
                        var ssss = false;
                        using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required,
@@ -161,32 +191,35 @@
                                {
                                    fukuanshenqing.FukuanStatus = 2;
                                }
                                if (molingmoney.HasValue)
                                {
                                    if ((money + molingmoney.Value) >= (fukuanshenqing.Fukuanmoney - fukuanshenqing.Yishoumoney))
                                    {
                                        fukuanshenqing.FukuanStatus = 2;
                                    }
                                }
                                fukuanshenqing.Yishoumoney = yishoumoney + money;
                                fukuanshenqing.Updater = CurrentUser.ShortName;
                                fukuanshenqing.LastUpdateTime = DateTime.Now;
                                fukuanshenqing.Youwufapiao = Youwufapiao.ToInt32();
                                ssss = _fukuanshenqingBLL.UpdateModel(fukuanshenqing);
                                if (this.txtReciveMoney.Text.ToDecimal2() > 0)
                                if (this.txtReciveMoney.Value.ToDecimal2() > 0)
                                {
                                    List<OA_Procurement> m_OA_ProcurementList = new List<OA_Procurement>();
                                    List<OA_FirmAccountRecord> m_OA_FirmAccountRecordList = new List<OA_FirmAccountRecord>();
                                    m_OA_FirmAccountOut.Balance -= money;
                                    m_OA_FirmAccountOut.AllExpenses += money;
                                    decimal molingmoneyvalue = 0;
                                    if (molingmoney.HasValue)
                                    {
                                        molingmoneyvalue = molingmoney.Value;
                                    }
                                    foreach (var item in Keys)
                                    {
                                        OA_Procurement m_OA_Procurement = bll_OA_ProcurementBLL.SelectSingleModel(item);
                                        if (m_OA_Procurement != null)
                                        {
                                            if (Request["amount"].ToString2() == "one")
                                                m_OA_Procurement.ReceiveMoney += money;
                                            else
                                                m_OA_Procurement.ReceiveMoney = m_OA_Procurement.AllMoney;
                                            if (m_OA_Procurement.ReceiveMoney == m_OA_Procurement.AllMoney)
                                                m_OA_Procurement.ClearingStatusId = bll_Sys_DictionaryBLL.GetKeyIdByKeyid(1, "结账状态");
                                            m_OA_Procurement.Operator = CurrentUser.ShortName;
                                            m_OA_Procurement.LastUpdateTime = DateTime.Now;
                                            OA_Suppliers m_OA_Suppliers = bll_OA_SuppliersBLL.getSingleSupplier(m_OA_Procurement.SuppliersId.ToString2());
@@ -194,10 +227,24 @@
                                            m_OA_FirmAccountRecordOut.AccountId = m_OA_FirmAccountOut.Keyid;
                                            m_OA_FirmAccountRecordOut.RecordTypeId = 2;//支出
                                            if (Request["amount"].ToString2() == "one")
                                                m_OA_FirmAccountRecordOut.Money = money;
                                            else
                                                m_OA_FirmAccountRecordOut.Money = (m_OA_Procurement.AllMoney - m_OA_Procurement.ReceiveMoney);
                                            m_OA_FirmAccountRecordOut.Money = m_OA_Procurement.AllMoney.Value;
                                            m_OA_Procurement.ReceiveMoney = m_OA_Procurement.AllMoney.Value ;
                                            if (molingmoneyvalue > 0)
                                            {
                                                if (m_OA_Procurement.AllMoney.Value >= molingmoneyvalue)
                                                {
                                                    m_OA_Procurement.ReceiveMoney = m_OA_Procurement.AllMoney.Value  - molingmoneyvalue;
                                                    m_OA_FirmAccountRecordOut.Money = m_OA_Procurement.AllMoney.Value  - molingmoneyvalue;
                                                    molingmoneyvalue = 0;
                                                }
                                                else
                                                {
                                                    m_OA_Procurement.ReceiveMoney = 0;
                                                    m_OA_FirmAccountRecordOut.Money = 0;
                                                    molingmoneyvalue = molingmoneyvalue - m_OA_Procurement.AllMoney.Value;
                                                }
                                            }
                                            m_OA_FirmAccountRecordOut.SubjectId = m_OA_SubjectSet.Keyid;
                                            m_OA_FirmAccountRecordOut.OperationalMatters = "采购付款";
@@ -208,6 +255,21 @@
                                            m_OA_FirmAccountRecordOut.ResidualAmount = m_OA_FirmAccountOut.Balance;
                                            m_OA_FirmAccountRecordList.Add(m_OA_FirmAccountRecordOut);
                                            m_OA_ProcurementList.Add(m_OA_Procurement);
                                            if (m_OA_Procurement.ReceiveMoney == m_OA_Procurement.AllMoney)
                                                m_OA_Procurement.ClearingStatusId = bll_Sys_DictionaryBLL.GetKeyIdByKeyid(1, "结账状态");
                                            if (fukuanshenqing.FukuanStatus == 2)
                                                m_OA_Procurement.ClearingStatusId = bll_Sys_DictionaryBLL.GetKeyIdByKeyid(1, "结账状态");
                                            m_OA_Procurement.Operator = CurrentUser.ShortName;
                                            m_OA_Procurement.LastUpdateTime = DateTime.Now;
                                        }
                                    }
@@ -215,7 +277,47 @@
                                    if (m_OA_ProcurementList.Count > 0)
                                    {
                                        ssss = bll_OA_FirmAccountBLL.PurchasePayList(m_OA_FirmAccountRecordList, m_OA_ProcurementList, m_OA_FirmAccountOut);
                                        if (!string.IsNullOrEmpty(this.selSubject.Value))
                                        {
                                            var oA_SubjectSet = _OA_SubjectSetBLL.getSingleSubject(m_OA_FirmAccountRecordList[0].SubjectId);
                                            if (oA_SubjectSet.SubjectName.IndexOf("投标保证金") >= 0 || oA_SubjectSet.SubjectName.IndexOf("履约保证金") >= 0)
                                            {
                                                //如果选择科目是保证金,插入以条保证金数据
                                                OA_Baozhengjin oA_Baozhengjin = new OA_Baozhengjin();
                                                oA_Baozhengjin.FirmId = CurrentUser.MemberId;
                                                oA_Baozhengjin.FukuanTime = DateTime.Now;
                                                oA_Baozhengjin.Zhanghuleixing = this.selAcoountTypeOut.Value;
                                                var ss = _Sys_DictionaryBLL.GetDataByType("账户类型").FirstOrDefault(x => x.Name == oA_Baozhengjin.Zhanghuleixing);
                                                if (ss != null)
                                                {
                                                    oA_Baozhengjin.ReceiveWay = ss.Keyid;
                                                }
                                                oA_Baozhengjin.Account = Request["selAccountName"].ToInt32();
                                                oA_Baozhengjin.Fukuanzhanghu = m_OA_FirmAccountOut.AccountName + "-" + m_OA_FirmAccountOut.UserName;
                                                oA_Baozhengjin.Subject = m_OA_FirmAccountRecordList[0].SubjectId;
                                                oA_Baozhengjin.Fukuankemu = oA_SubjectSet.SubjectName;
                                                oA_Baozhengjin.Fukuanmoney = money;
                                                oA_Baozhengjin.Shoukuandanwei = m_OA_FirmAccountRecordList[0].PaymentUnit;
                                                oA_Baozhengjin.remark = m_OA_FirmAccountRecordList[0].OperationalMatters;
                                                oA_Baozhengjin.TuikuanTime = null;
                                                oA_Baozhengjin.TuikuanStatus = 1;
                                                oA_Baozhengjin.Creater = CurrentUser.ShortName;
                                                oA_Baozhengjin.CreateTime = oA_Baozhengjin.FukuanTime;
                                                oA_Baozhengjin.Updater = CurrentUser.ShortName;
                                                oA_Baozhengjin.LastUpdateTime = oA_Baozhengjin.FukuanTime;
                                                oA_Baozhengjin.MemberName = fukuanshenqing.Creater;
                                                var oA_Staff = staffBLL.SelectListByFirmId(CurrentUser.MemberId, false, false).Where(x => x.Name == oA_Baozhengjin.MemberName).FirstOrDefault();
                                                oA_Baozhengjin.MemberId = oA_Staff.Keyid;
                                                var sss = oA_BaozhengjinBLL.InsertModel(oA_Baozhengjin);
                                            }
                                        }
                                    }
                                }