private async Task <bool> SaveAccountTitleData() { var accountTitle = new AccountTitle(); accountTitle.ContraAccountCode = txtContraAccountCode.Text ?? string.Empty; accountTitle.ContraAccountName = txtContraAccountName.Text.Trim() ?? string.Empty; accountTitle.ContraAccountSubCode = txtContraAccountSubCode.Text ?? string.Empty; accountTitle.CompanyId = CompanyId; accountTitle.UpdateBy = Login.UserId; accountTitle.CreateBy = Login.UserId; accountTitle.Code = txtCode.Text; accountTitle.Name = txtName.Text.Trim(); var success = false; await ServiceProxyFactory.LifeTime(async factory => { var service = factory.Create <AccountTitleMasterClient>(); AccountTitleResult saveResult = null; saveResult = await service.SaveAsync(SessionKey, accountTitle); success = saveResult?.ProcessResult.Result ?? false; var syncResult = true; if (SavePostProcessor != null && success) { syncResult = SavePostProcessor.Invoke(new IMasterData[] { saveResult.AccountTitle as IMasterData }); } success &= syncResult; if (success) { await LoadGrid(); } }); return(success); }
public Task <AccountTitle> AddAsync(AccountTitle account, CancellationToken token = default(CancellationToken)) { string query = @" MERGE INTO AccountTitle AS Account USING ( SELECT @CompanyId AS CompanyId ,@Code AS Code ) AS Target ON ( Account.CompanyId = @CompanyId AND Account.Code = @Code ) WHEN MATCHED THEN UPDATE SET Name = @Name ,ContraAccountCode = (CASE WHEN @ContraAccountCode IS NOT NULL THEN @ContraAccountCode ELSE '' END ) ,ContraAccountName = (CASE WHEN @ContraAccountName IS NOT NULL THEN @ContraAccountName ELSE '' END ) ,ContraAccountSubCode = (CASE WHEN @ContraAccountSubCode IS NOT NULL THEN @ContraAccountSubCode ELSE '' END ) ,UpdateBy = @UpdateBy ,UpdateAt = GETDATE() WHEN NOT MATCHED THEN INSERT (CompanyId, Code, Name,ContraAccountCode,ContraAccountName,ContraAccountSubCode, CreateBy, CreateAt, UpdateBy, UpdateAt) VALUES (@CompanyId, @Code, @Name, (CASE WHEN @ContraAccountCode IS NOT NULL THEN @ContraAccountCode ELSE '' END ), (CASE WHEN @ContraAccountName IS NOT NULL THEN @ContraAccountName ELSE '' END ), (CASE WHEN @ContraAccountSubCode IS NOT NULL THEN @ContraAccountSubCode ELSE '' END ), @UpdateBy, GETDATE(), @UpdateBy, GETDATE()) OUTPUT inserted.*; "; return(dbHelper.ExecuteAsync <AccountTitle>(query, account, token)); }
private async Task <AccountTitle> RetrieveData() { AccountTitle accountTitleResult = null; await ServiceProxyFactory.LifeTime(async factory => { var service = factory.Create <AccountTitleMasterClient>(); AccountTitlesResult result = await service.GetByCodeAsync( SessionKey, CompanyId, new string[] { txtCode.Text }); if (result.ProcessResult.Result) { accountTitleResult = result.AccountTitles.FirstOrDefault(); if (accountTitleResult == null) { Modified = true; } else { txtName.Text = accountTitleResult.Name; txtContraAccountCode.Text = accountTitleResult.ContraAccountCode; txtContraAccountName.Text = accountTitleResult.ContraAccountName; txtContraAccountSubCode.Text = accountTitleResult.ContraAccountSubCode; AccountTitleId = accountTitleResult.Id; txtCode.Enabled = false; BaseContext.SetFunction03Enabled(true); Modified = false; } } }); return(accountTitleResult); }
private bool ExistAccountTitleCode() { AccountTitle accountTitleResult = null; AccountTitlesResult result = null; var task = ServiceProxyFactory.LifeTime(async factory => { var service = factory.Create <AccountTitleMasterClient>(); result = await service.GetByCodeAsync(SessionKey, CompanyId, new string[] { txtValue.Text }); }); ProgressDialog.Start(ParentForm, task, false, SessionKey); if (result.ProcessResult.Result) { accountTitleResult = result.AccountTitles.FirstOrDefault(); } if (accountTitleResult != null) { return(true); } ShowWarningDialog(MsgWngMasterNotExist, "科目", txtValue.Text); txtValue.Focus(); return(false); }
public async Task <AccountTitleResult> SaveAsync(string SessionKey, AccountTitle AccountTitle) { return(await authorizationProcessor.DoAuthorizeAsync(SessionKey, async token => { var result = await accountTitleProcessor.SaveAsync(AccountTitle, token); return new AccountTitleResult { ProcessResult = new ProcessResult { Result = true }, AccountTitle = result, }; }, logger)); }
public Task <AccountTitle> SaveAsync(AccountTitle AccountTitle, CancellationToken token = default(CancellationToken)) => addAccountTitleQueryProcessor.AddAsync(AccountTitle, token);
public async Task <ActionResult <int> > Delete(AccountTitle accountTitle, CancellationToken token) => await accountTitleProcessor.DeleteAsync(accountTitle.Id, token);
public async Task <ActionResult <AccountTitle> > Save(AccountTitle accountTitle, CancellationToken token) => await accountTitleProcessor.SaveAsync(accountTitle, token);