Esempio n. 1
0
        /// <summary>
        /// Gets the salute id.
        /// </summary>
        /// <param name="saluteCode">The salute code.</param>
        /// <returns></returns>
        public static Guid GetSaluteId(string saluteCode)
        {
            Guid result = Guid.Empty;

            using (var ctx = new EF6.RT2020Entities())
            {
                var objSalutationList = ctx.Salutation.Where(x => x.SalutationCode == saluteCode).FirstOrDefault();
                if (objSalutationList == null)
                {
                    var item = new EF6.Salutation();

                    item.SalutationId       = Guid.NewGuid();
                    item.SalutationCode     = saluteCode;
                    item.SalutationName     = saluteCode;
                    item.SalutationName_Chs = saluteCode;
                    item.SalutationName_Cht = saluteCode;

                    ctx.Salutation.Add(item);
                    ctx.SaveChanges();

                    result = item.SalutationId;
                }
                else
                {
                    result = objSalutationList.SalutationId;
                }
            }

            return(result);
        }
Esempio n. 2
0
        private bool Save()
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.Salutation.Find(_SalutationId);

                if (item == null)
                {
                    item = new EF6.Salutation();
                    item.SalutationId   = new Guid();
                    item.SalutationCode = txtSalutationCode.Text;

                    ctx.Salutation.Add(item);
                }
                item.SalutationName     = txtSalutationName.Text;
                item.SalutationName_Chs = txtSalutationNameAlt1.Text;
                item.SalutationName_Cht = txtSalutationNameAlt2.Text;
                if ((Guid)cboParentSalutation.SelectedValue == Guid.Empty)
                {
                    item.ParentSalutation = (Guid)cboParentSalutation.SelectedValue;
                }

                ctx.SaveChanges();
                result = true;
            }

            return(result);;
        }
Esempio n. 3
0
 private static string GetFormatedText(EF6.Salutation 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);
 }
Esempio n. 4
0
        /// <summary>
        /// Get a EF6.Salutation object from the database using the given SalutationId
        /// </summary>
        /// <param name="salutationId">The primary key value</param>
        /// <returns>A EF6.Salutation object</returns>
        public static EF6.Salutation Get(Guid salutationId)
        {
            EF6.Salutation result = null;

            using (var ctx = new EF6.RT2020Entities())
            {
                result = ctx.Salutation.Where(x => x.SalutationId == salutationId).AsNoTracking().FirstOrDefault();
            }

            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// Get a EF6.Salutation object from the database using the given QueryString
        /// </summary>
        /// <param name="salutationId">The primary key value</param>
        /// <returns>A EF6.Salutation object</returns>
        public static EF6.Salutation Get(string whereClause)
        {
            EF6.Salutation result = null;

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

            return(result);
        }
Esempio n. 6
0
        public static string GetParentName(EF6.Salutation target)
        {
            var result = "";

            if (target.ParentSalutation.HasValue)
            {
                using (var ctx = new EF6.RT2020Entities())
                {
                    var item = ctx.Salutation.Where(x => x.SalutationId == target.ParentSalutation.Value).AsNoTracking().FirstOrDefault();
                    if (item != null)
                    {
                        result = CookieHelper.CurrentLocaleId == LanguageHelper.AlternateLanguage2.Key ?
                                 item.SalutationName_Cht : CookieHelper.CurrentLocaleId == LanguageHelper.AlternateLanguage1.Key ?
                                 item.SalutationName_Chs :
                                 item.SalutationName;
                    }
                }
            }

            return(result);
        }