예제 #1
0
        /// <summary> 通貨コードを使ってCurrencyIdを取得する</summary>
        /// <param name="currencyCode"> 通貨コード </param>
        private async Task LoadCurrencyCode(string currencyCode)
        {
            Currency currency = null;
            await ServiceProxyFactory.LifeTime(async factory =>
            {
                var service             = factory.Create <CurrencyMasterClient>();
                CurrenciesResult result = await service.GetByCodeAsync(SessionKey, CompanyId, new string[] { currencyCode });
                if (result.ProcessResult.Result)
                {
                    currency = result.Currencies?.FirstOrDefault();
                }
            });

            if (currency != null)
            {
                CurrencyId = currency.Id;
                Precision  = currency.Precision;
                InitializeGrid();
                await SetDataWithCurrencyId();
            }
            else
            {
                grid.Rows.Clear();
                grid.DataSource = null;
            }
        }
예제 #2
0
        /// <summary>Set Currency Info</summary>
        private async Task SetCurrencyInfo()
        {
            Currency = null;
            var currencyPreFlg = true;

            if (string.IsNullOrWhiteSpace(txtCurrencyCode.Text))
            {
                txtCurrencyCode.Text = "JPY";
                currencyPreFlg       = false;
            }

            CurrenciesResult result = null;

            await ServiceProxyFactory.LifeTime(async factory =>
            {
                var service = factory.Create <CurrencyMasterClient>();
                result      = await service.GetByCodeAsync(SessionKey, CompanyId, new string[] { txtCurrencyCode.Text });

                if (result.ProcessResult.Result && result.Currencies.Any() && result.Currencies[0] != null)
                {
                    if (currencyPreFlg)
                    {
                        Precision = result.Currencies[0].Precision;
                    }
                    Currency   = result.Currencies[0];
                    CurrencyId = result.Currencies[0].Id;
                }
                else
                {
                    CurrencyId = 0;
                }
            });
        }
예제 #3
0
        public async Task <IEnumerable <Currency> > SearchInfo()
        {
            List <Currency> list = null;
            await ServiceProxyFactory.LifeTime(async factory =>
            {
                var service             = factory.Create <CurrencyMasterClient>();
                CurrenciesResult result = await service.GetItemsAsync(
                    Application.Login.SessionKey, Application.Login.CompanyId, new CurrencySearch());

                if (result.ProcessResult.Result)
                {
                    list = result.Currencies;
                }
            });

            return(list);
        }
예제 #4
0
        private async Task <List <Currency> > LoadListAsync()
        {
            List <Currency>  list   = null;
            CurrenciesResult result = null;

            await ServiceProxyFactory.LifeTime(async factory =>
            {
                var service = factory.Create <CurrencyMasterClient>();
                result      = await service.GetItemsAsync(SessionKey, CompanyId, new CurrencySearch());

                if (result.ProcessResult.Result)
                {
                    list = result.Currencies.OrderBy(b => b.DisplayOrder)
                           .ThenBy(b => b.Code).ToList();
                }
            });

            return(list ?? new List <Currency>());
        }
예제 #5
0
        /// <summary> 通貨データを取得 </summary>
        /// <param name="code"> 通貨コード </param>
        /// <returns> Currency List</returns>
        private List <Currency> GetCurrencyData(string[] code)
        {
            List <Currency>  currency = null;
            CurrenciesResult result   = null;
            var task = ServiceProxyFactory.LifeTime(async factory =>
            {
                var service = factory.Create <CurrencyMasterClient>();
                result      = await service.GetByCodeAsync(SessionKey, CompanyId, code);

                if (result.ProcessResult.Result)
                {
                    currency = result.Currencies;
                }
            });

            ProgressDialog.Start(ParentForm, task, false, SessionKey);

            return(currency);
        }
예제 #6
0
        private void txtCurrencyCode_Validated(object sender, EventArgs e)
        {
            try
            {
                CurrenciesResult result = null;

                if (txtCurrencyCode.Text != string.Empty)
                {
                    var task = ServiceProxyFactory.LifeTime(async factory =>
                    {
                        var service = factory.Create <CurrencyMasterClient>();

                        result = await service.GetByCodeAsync(
                            SessionKey, CompanyId,
                            new string[] { txtCurrencyCode.Text });
                    });
                    ProgressDialog.Start(ParentForm, task, false, SessionKey);

                    if (result.ProcessResult.Result && result.Currencies.Any())
                    {
                        SetCurrencyData(result.Currencies[0]);
                        Modified = false;
                    }
                    else
                    {
                        SetCurrencyData(null);
                    }
                }
                else
                {
                    ClearStatusMessage();
                    txtCurrencyCode.Clear();
                    CurrencyID = 0;
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
            }
        }