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

            using (var ctx = new EF6.RT2020Entities())
            {
                var jt = ctx.JobTitle.Find(_JobTitleId);

                if (jt == null)
                {
                    jt              = new EF6.JobTitle();
                    jt.JobTitleId   = Guid.NewGuid();
                    jt.JobTitleCode = txtJobTitleCode.Text;

                    ctx.JobTitle.Add(jt);
                    _JobTitleId = jt.JobTitleId;
                }
                jt.JobTitleName     = txtJobTitleName.Text;
                jt.JobTitleName_Chs = txtJobTitleNameAlt1.Text;
                jt.JobTitleName_Cht = txtJobTitleNameAlt2.Text;
                if ((Guid)cboParentJobTitle.SelectedValue != Guid.Empty)
                {
                    jt.ParentJobTitle = (Guid)cboParentJobTitle.SelectedValue;
                }

                ctx.SaveChanges();
                result = true;
            }

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

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

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

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

            return(result);
        }