public async Task <IActionResult> PutCurrencyEx(long id, CurrencyEx currencyEx)
        {
            if (id != currencyEx.Id)
            {
                return(BadRequest());
            }

            _context.Entry(currencyEx).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CurrencyExExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <CurrencyEx> > PostCurrencyEx(CurrencyEx currencyEx)
        {
            _context.CurrencyEx.Add(currencyEx);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCurrencyEx", new { id = currencyEx.Id }, currencyEx));
        }
        private void lvPosTenderTypeList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvPosTenderTypeList.SelectedItem != null)
            {
                Guid id = Guid.Empty;
                if (Guid.TryParse(lvPosTenderTypeList.SelectedItem.Text, out id))
                {
                    using (var ctx = new EF6.RT2020Entities())
                    {
                        var oPosTenderType = ctx.PosTenderType.Find(id);
                        if (oPosTenderType != null)
                        {
                            txtTypeCode.Text                = oPosTenderType.TypeCode;
                            txtTypeName.Text                = oPosTenderType.TypeName;
                            txtTypeNameAlt1.Text            = oPosTenderType.TypeName_Chs;
                            txtTypeNameAlt2.Text            = oPosTenderType.TypeName_Cht;
                            cboCurrency.SelectedValue       = CurrencyEx.GetCurrencyIdByCode(oPosTenderType.CurrencyCode);
                            txtExchangeRate.Text            = oPosTenderType.ExchangeRate.Value.ToString("n4");
                            chkDownloadToPoS.Checked        = true;
                            txtChargeRate.Text              = oPosTenderType.ChargeRate.ToString("n2");
                            txtChargeAmount.Text            = oPosTenderType.ChargeAmount.ToString("n2");
                            txtAdditionalMonthlyCharge.Text = oPosTenderType.AdditionalMonthlyCharge.ToString("n2");
                            txtMinimumMonthlyCharge.Text    = oPosTenderType.MinimumMonthlyCharge.ToString("n2");

                            _TenderTypeId = oPosTenderType.TypeId;

                            SetCtrlEditable();
                            SetToolBar();
                        }
                    }
                }
            }
        }
Beispiel #4
0
        private void cboCurrency_SelectedIndexChanged(object sender, EventArgs e)
        {
            Guid id = Guid.Empty;

            if (Guid.TryParse(cboCurrency.SelectedValue.ToString(), out id))
            {
                txtExchangeRate.Text = CurrencyEx.GetExchangeRateById(id).ToString("n4");
                updateCurrency(new System.Guid(cboCurrency.SelectedValue.ToString()));
            }
        }
Beispiel #5
0
        private void FillCurrencyList()
        {
            cboCurrency.Items.Clear();

            CurrencyEx.LoadCombo(ref cboCurrency, "CurrencyCode", false);

            if (cboCurrency.Items.Count > 0)
            {
                cboCurrency.Text = SystemInfoEx.CurrentInfo.Default.SysInfo.BasicCurrency;

                updateCurrency(cboCurrency.Text);
            }
        }
        private void cboCurrency_SelectedIndexChanged(object sender, EventArgs e)
        {
            var id = Guid.Empty;

            if (cboCurrency.SelectedValue != null)
            {
                if (Guid.TryParse(cboCurrency.SelectedValue.ToString(), out id))
                {
                    if (id != Guid.Empty)
                    {
                        txtExchangeRate.Text = CurrencyEx.GetExchangeRateById(id).ToString("n4");
                    }
                }
            }
        }
 // Verify Vendor Currency and Price exist or not.
 // If verify failed, can not post the import.
 private void VerifyVendorCurrencyPrice(int iCount, DataRow row)
 {
     if (!string.IsNullOrEmpty(row[colVendorCurrency].ToString()))
     {
         //string sql = "CurrencyCode = '" + row[colVendorCurrency].ToString() + "'";
         //Currency oCurr = Currency.LoadWhere(sql);
         //if (oCurr != null)
         if (CurrencyEx.IsCurrencyCodeInUse(row[colVendorCurrency].ToString()))
         {
             // TODO:Set the cell style of DataGridView
         }
     }
     else // Without Vendor Currency, Vendor Price should be ZERO
     {
         // TODO:Set the cell style of DataGridView
     }
 }
Beispiel #8
0
        private bool IsValid()
        {
            bool result = true; decimal numeric = 0;

            errorProvider.SetError(txtCurrencyCode, string.Empty);
            errorProvider.SetError(txtUnicodeDecimal, string.Empty);
            errorProvider.SetError(txtExchangeRate, string.Empty);

            #region CountryCode 唔可以吉
            if (txtCurrencyCode.Text.Length == 0)
            {
                errorProvider.SetError(txtCurrencyCode, "Cannot be blank!");
                errorProvider.SetIconAlignment(txtCurrencyCode, ErrorIconAlignment.TopLeft);
                result = false;
            }
            #endregion

            #region 新增,要 check CountryCode 係咪 in use
            if (_CurrencyId == Guid.Empty)
            {
                if (CurrencyEx.IsCurrencyCodeInUse(txtCurrencyCode.Text.Trim()))
                {
                    errorProvider.SetError(txtCurrencyCode, "Currency Code in use");
                    errorProvider.SetIconAlignment(txtCurrencyCode, ErrorIconAlignment.TopLeft);
                    result = false;
                }
            }
            #endregion

            if (!decimal.TryParse(txtUnicodeDecimal.Text, out numeric))
            {
                errorProvider.SetError(txtUnicodeDecimal, Resources.Common.DigitalNeeded);
                errorProvider.SetIconAlignment(txtUnicodeDecimal, ErrorIconAlignment.TopLeft);
                result = false;
            }
            if (!decimal.TryParse(txtExchangeRate.Text, out numeric))
            {
                errorProvider.SetError(txtExchangeRate, Resources.Common.DigitalNeeded);
                errorProvider.SetIconAlignment(txtExchangeRate, ErrorIconAlignment.TopLeft);
                result = false;
            }

            return(result);
        }
Beispiel #9
0
        private async Task <CurrencyEx> GetCurrencyRates()
        {
            var currencyEx = new CurrencyEx();

            try
            {
                var httpClient = new HttpClient();
                var response   = await httpClient.GetAsync("https://api.exchangeratesapi.io/latest?symbols=INR").Result.Content.ReadAsStringAsync();

                //"{\"rates\":{\"INR\":81.8765},\"base\":\"EUR\",\"date\":\"2020-03-13\"}"

                Regex pattern = new Regex("[}{]");
                response = pattern.Replace(response, "");
                var split = response.Split(",").ToList();
                split.ForEach(x =>
                {
                    if (x.Contains("INR"))
                    {
                        currencyEx.TargetCurrency = x.Split(":")[2].ToString();
                    }
                    else if (x.Contains("date"))
                    {
                        currencyEx.LastUpdated = x.Split(":")[1].Replace("\\", "").ToString();
                    }
                    else if (x.Contains("base"))
                    {
                        currencyEx.BaseCurrency = x.Split(":")[1].Replace("\\", "").ToString();
                    }
                });
            }
            catch
            {
                currencyEx.BaseCurrency   = "EUR";
                currencyEx.LastUpdated    = DateTime.Now.ToString();
                currencyEx.TargetCurrency = "00.0";
            }
            return(currencyEx);
        }
 private void FillCurrencyList()
 {
     CurrencyEx.LoadCombo(ref cboCurrency, "CurrencyCode", false, true, String.Empty, String.Empty);
 }
Beispiel #11
0
 private void FillCurrencyList()
 {
     CurrencyEx.LoadCombo(ref cboCurrency, "CurrencyCode", false);
 }