public void RgdGridDeleteCommand(object sender, GridCommandEventArgs e)
        {
            var editedItem = e.Item as GridEditableItem;

            if (editedItem != null)
            {
                var bankAccountsid = new Guid(editedItem.GetDataKeyValue("BankAccountsId").ToString());
                var filialeId      = new Guid(editedItem.GetDataKeyValue("FilialeId").ToString());
                var branchId       = new Guid(editedItem.GetDataKeyValue("BranchId").ToString());
                var positionId     = new Guid(editedItem.GetDataKeyValue("PositionId").ToString());
                _bankAccountsWrite.DeleteBankPersion(bankAccountsid, filialeId, branchId, positionId);
            }
        }
예제 #2
0
        protected void BankAccountsGrid_DeleteCommand(object sender, GridCommandEventArgs e)
        {
            var dataItem = e.Item as GridDataItem;

            if (dataItem != null)
            {
                var bankAccountsId = new Guid(dataItem.GetDataKeyValue("BankAccountsId").ToString());
                try
                {
                    //判断“费用账户”是否已绑定 CostCompany
                    ICostCussent            costCussentDao  = new CostCussent(GlobalConfig.DB.FromType.Read);
                    IList <CostCussentInfo> costCussentList = costCussentDao.GetCompanyCussentList();
                    var list = costCussentList.Where(w => w.InvoiceAccountsId == bankAccountsId || w.VoucherAccountsId == bankAccountsId ||
                                                     w.CashAccountsId == bankAccountsId || w.NoVoucherAccountsId == bankAccountsId).ToList();
                    string message = list.Aggregate("", (current, info) => current + (info.CompanyName + "\n"));
                    if (list.Count > 0)
                    {
                        RAM.Alert("该资金账户已经绑定到费用账户:\n" + message + "\n不允许删除");
                    }
                    else
                    {
                        //判断“往来单位资料”是否已绑定 CompanyBankAccounts
                        IList <FilialeInfo> filialeList = GlobalConfig.IsTestWebSite ?
                                                          CacheCollection.Filiale.GetHeadList().Where(ent => ent.FilialeTypes.Contains((int)FilialeType.SaleCompany) && ent.ID.Equals(new Guid("7AE62AF0-EB1F-49C6-8FD1-128D77C84698"))).ToList() :
                                                          CacheCollection.Filiale.GetHeadList().Where(ent => ent.FilialeTypes.Contains((int)FilialeType.SaleCompany) && !ent.ID.Equals(new Guid("ED58311F-FE6B-4CD9-85E9-FDA26EA209A0"))).ToList();
                        foreach (var filialeInfo in filialeList)
                        {
                            //删除B2C中的资金账户
                            B2CSao.BankAccountsDelete(filialeInfo.ID, bankAccountsId);
                        }
                        //删除本地资金账户
                        _bankAccountsWrite.DeleteBankPersion(bankAccountsId);
                        BankAccountManager.WriteInstance.Delete(bankAccountsId);
                    }
                }
                catch (Exception exp)
                {
                    RAM.Alert("资金账户删除失败!\\n\\n错误提示:" + exp.Message);
                }
            }
        }