コード例 #1
0
        private bool Save()
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var currency = ctx.Currency.Find(_CurrencyId);

                if (currency == null)
                {
                    currency = new EF6.Currency();

                    currency.CurrencyId   = Guid.NewGuid();
                    currency.CurrencyCode = txtCurrencyCode.Text;
                    currency.CreatedBy    = ConfigHelper.CurrentUserId;
                    currency.CreatedOn    = DateTime.Now;

                    ctx.Currency.Add(currency);
                }
                currency.CountryName    = (Guid)cboCountryName.SelectedValue != Guid.Empty ? CountryEx.GetCountryCode((Guid)cboCountryName.SelectedValue) : "";
                currency.CurrencyName   = txtCurrencyName.Text;
                currency.UnicodeDecimal = Convert.ToInt32((txtUnicodeDecimal.Text == string.Empty) ? "0" : txtUnicodeDecimal.Text);
                currency.ExchangeRate   = Convert.ToDecimal((txtExchangeRate.Text == string.Empty) ? "0" : txtExchangeRate.Text);
                currency.ModifiedBy     = ConfigHelper.CurrentUserId;
                currency.ModifiedOn     = DateTime.Now;

                ctx.SaveChanges();
                result = true;
            }

            return(result);
        }
コード例 #2
0
ファイル: CurrencyEx.cs プロジェクト: paulusyeung/RT2020
 private static string GetFormatedText(EF6.Currency target, string[] textField, string textFormatString)
 {
     for (int i = 0; i < textField.Length; i++)
     {
         PropertyInfo pi = target.GetType().GetProperty(textField[i]);
         textFormatString = textFormatString.Replace("{" + i.ToString() + "}", pi != null ? pi.GetValue(target, null).ToString() : string.Empty);
     }
     return(textFormatString);
 }
コード例 #3
0
ファイル: CurrencyEx.cs プロジェクト: paulusyeung/RT2020
        /// <summary>
        /// Get a EF6.Currency object from the database using the given CurrencyId
        /// </summary>
        /// <param name="currencyId">The primary key value</param>
        /// <returns>A EF6.Currency object</returns>
        public static EF6.Currency Get(Guid currencyId)
        {
            EF6.Currency result = null;

            using (var ctx = new EF6.RT2020Entities())
            {
                result = ctx.Currency.Where(x => x.CurrencyId == currencyId).AsNoTracking().FirstOrDefault();
            }

            return(result);
        }
コード例 #4
0
ファイル: CurrencyEx.cs プロジェクト: paulusyeung/RT2020
        /// <summary>
        /// Get a EF6.Currency object from the database using the given QueryString
        /// </summary>
        /// <param name="currencyId">The primary key value</param>
        /// <returns>A EF6.Currency object</returns>
        public static EF6.Currency Get(string whereClause)
        {
            EF6.Currency result = null;

            using (var ctx = new EF6.RT2020Entities())
            {
                result = ctx.Currency
                         .SqlQuery(string.Format("Select * from Currency Where {0}", whereClause))
                         .AsNoTracking()
                         .FirstOrDefault();
            }

            return(result);
        }