示例#1
0
        private bool Save()
        {
            bool result = false;

            using (var ctx = new EF6.RT2020Entities())
            {
                var jt = ctx.StaffJobTitle.Find(this.JobTitleId);

                if (jt == null)
                {
                    jt            = new EF6.StaffJobTitle();
                    jt.JobTitleId = new Guid();

                    ctx.StaffJobTitle.Add(jt);
                    jt.JobTitleCode = txtJobTitleCode.Text;
                }
                jt.JobTitleName     = txtJobTitleName.Text;
                jt.JobTitleName_Chs = txtJobTitleNameAlt1.Text;
                jt.JobTitleName_Cht = txtJobTitleNameAlt2.Text;

                ctx.SaveChanges();
                result = true;
            }

            return(result);
        }
示例#2
0
 private static string GetFormatedText(EF6.StaffJobTitle 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
        /// <summary>
        /// Get a EF6.StaffJobTitle object from the database using the given JobTitleId
        /// </summary>
        /// <param name="jobTitleId">The primary key value</param>
        /// <returns>A EF6.StaffJobTitle object</returns>
        public static EF6.StaffJobTitle Get(Guid jobTitleId)
        {
            EF6.StaffJobTitle result = null;

            using (var ctx = new EF6.RT2020Entities())
            {
                result = ctx.StaffJobTitle.Where(x => x.JobTitleId == jobTitleId).AsNoTracking().FirstOrDefault();
            }

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

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

            return(result);
        }