Esempio n. 1
0
        /// <summary>
        /// Saves this instance.
        /// </summary>
        /// <returns></returns>
        private bool Save()
        {
            bool result = false;

            if (Verify())
            {
                using (var ctx = new EF6.RT2020Entities())
                {
                    var objReason = ctx.PriceManagementReason.Find(_ReasonId);
                    if (objReason == null)
                    {
                        objReason            = new EF6.PriceManagementReason();
                        objReason.ReasonId   = Guid.NewGuid();
                        objReason.ReasonCode = txtCode.Text;

                        ctx.PriceManagementReason.Add(objReason);
                    }
                    objReason.ReasonName     = txtName.Text;
                    objReason.ReasonName_Chs = txtNameAlt1.Text;
                    objReason.ReasonName_Cht = txtNameAlt2.Text;

                    ctx.SaveChanges();
                    result = true;

                    _ReasonId = objReason.ReasonId;
                }
            }
            return(result);
        }
 private static string GetFormatedText(EF6.PriceManagementReason 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);
 }
        /// <summary>
        /// Get a EF6.PriceManagementReason object from the database using the given ReasonId
        /// </summary>
        /// <param name="reasonId">The primary key value</param>
        /// <returns>A EF6.PriceManagementReason object</returns>
        public static EF6.PriceManagementReason Get(Guid reasonId)
        {
            EF6.PriceManagementReason result = null;

            using (var ctx = new EF6.RT2020Entities())
            {
                result = ctx.PriceManagementReason.Where(x => x.ReasonId == reasonId).AsNoTracking().FirstOrDefault();
            }

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

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

            return(result);
        }