コード例 #1
0
        private async Task <BankAccount> GetBankAccountAsync(BankAccount bankAccount)
        {
            BankAccount product = null;
            await ServiceProxyFactory.LifeTime(async factory =>
            {
                var service = factory.Create <BankAccountMasterClient>();
                BankAccountResult result = await service.GetByCodeAsync(
                    Login.SessionKey,
                    Login.CompanyId,
                    bankAccount.BankCode,
                    bankAccount.BranchCode,
                    bankAccount.AccountTypeId,
                    bankAccount.AccountNumber);

                if (result.ProcessResult.Result)
                {
                    product = result.BankAccount;
                }
            });

            return(product);
        }
コード例 #2
0
        private void Save()
        {
            try
            {
                if (!ValidateChildren())
                {
                    return;
                }

                if (!ValidateInput())
                {
                    return;
                }

                ZeroLeftPaddingWithoutValidated();

                if (!ShowConfirmDialog(MsgQstConfirmSave))
                {
                    DispStatusMessage(MsgInfProcessCanceled);
                    return;
                }

                var bankAccount = BankAccountInfo();
                bankAccount.Id = 0;

                BankAccountResult  result  = null;
                List <BankAccount> newList = null;
                ProgressDialog.Start(ParentForm, Task.Run(async() =>
                {
                    var org = await GetBankAccountAsync(bankAccount);
                    if (org != null)
                    {
                        bankAccount.Id = org.Id;
                    }

                    await ServiceProxyFactory.LifeTime(async factory =>
                    {
                        var service = factory.Create <BankAccountMasterClient>();
                        result      = await service.SaveAsync(
                            Login.SessionKey,
                            bankAccount);
                        if (result.ProcessResult.Result && result.BankAccount != null)
                        {
                            newList = await LoadListAsync();
                        }
                    });
                }), false, SessionKey);

                if (result.BankAccount != null)
                {
                    BankAccountList.Clear();
                    BankAccountList.AddRange(newList);
                    grdBankAccount.DataSource = new BindingSource(BankAccountList, null);
                    ClearAll();
                    DispStatusMessage(MsgInfSaveSuccess);
                }
                else
                {
                    ShowWarningDialog(MsgErrSaveError);
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
            }
        }