示例#1
0
        public void SaveRates(List <ExchangeRate> rates)
        {
            var currentDate = new ExchangeDate()
            {
                exDate = DateTime.Parse(rates.First().ExchangeDate)
            };

            SaveDateInDb(currentDate);
            var dataOfRates = GetCurrencyDatas();

            if (dataOfRates == null || dataOfRates.Count <= 0)
            {
                dataOfRates = SaveCurrencyData(rates.Select(rate => new CurrencyData()
                {
                    cc   = rate.ShortName,
                    r030 = rate.Indetifier,
                    txt  = rate.FullName
                })).ToList();
            }

            SaveCurrencyRates(rates.Select(rate => new CurrencyRate()
            {
                Rate   = rate.Rate,
                CurId  = dataOfRates.Where(data => data.r030 == rate.Indetifier).Select(data => data.ID).FirstOrDefault(),
                DateId = currentDate.ID
            }));
        }
示例#2
0
 private void ReportedDate_Leave(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(this.txtCurrencyCode.Text.Trim()) && ExchangeDate.Value != null)
     {
         BaseExchangeTable exchange = new BaseExchangeTable();
         exchange = bExchange.GetModel(CConvert.ToDateTime(ExchangeDate.Value.ToString("yyyy-MM")), txtCurrencyCode.Text);
         if (exchange != null)
         {
             ExchangeDate.Value   = DateTime.Now;
             txtCurrencyCode.Text = "";
             ExchangeDate.Focus();
             MessageBox.Show("当月此货币汇率已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
示例#3
0
        private void txtCurrencyCode_Leave(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtCurrencyCode.Text.Trim()))
            {
                BaseMaster baseMaster = bCommon.GetBaseMaster("CURRENCY", txtCurrencyCode.Text.Trim());
                if (baseMaster != null)
                {
                    txtCurrencyCode.Text = baseMaster.Code;
                    txtCurrencyName.Text = baseMaster.Name;
                }
                else
                {
                    MessageBox.Show("货币不存在.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtCurrencyCode.Text = "";
                    txtCurrencyName.Text = "";
                    txtCurrencyCode.Focus();
                }
            }
            else
            {
                txtCurrencyName.Text = "";
            }

            if (!string.IsNullOrEmpty(this.txtCurrencyCode.Text.Trim()) && ExchangeDate.Value != null)
            {
                BaseExchangeTable exchange = new BaseExchangeTable();
                exchange = bExchange.GetModel(CConvert.ToDateTime(ExchangeDate.Value.ToString("yyyy-MM")), txtCurrencyCode.Text);
                if (exchange != null)
                {
                    ExchangeDate.Value   = DateTime.Now;
                    txtCurrencyCode.Text = "";
                    ExchangeDate.Focus();
                    MessageBox.Show("当月此货币汇率已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
示例#4
0
 private void SaveDateInDb(ExchangeDate currentDate)
 {
     Session.Save(currentDate);
 }