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

            using (var ctx = new EF6.RT2020Entities())
            {
                var item = ctx.SmartTag4Workplace.Find(_TagId);

                if (item == null)
                {
                    item         = new EF6.SmartTag4Workplace();
                    item.TagId   = Guid.NewGuid();
                    item.TagCode = txtTagCode.Text;

                    ctx.SmartTag4Workplace.Add(item);
                }
                item.TagName     = txtTagName.Text;
                item.TagName_Chs = txtTagNameAlt1.Text;
                item.TagName_Cht = txtTagNameAlt2.Text;
                item.Priority    = Convert.ToInt32(txtPriority.Text);

                ctx.SaveChanges();
                result = true;
            }

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

            using (var ctx = new EF6.RT2020Entities())
            {
                result = ctx.SmartTag4Workplace.Where(x => x.TagId == tagId).AsNoTracking().FirstOrDefault();
            }

            return(result);
        }
示例#4
0
        public static EF6.SmartTag4Workplace GetByTagCode(string code)
        {
            EF6.SmartTag4Workplace result = null;

            using (var ctx = new EF6.RT2020Entities())
            {
                result = ctx.SmartTag4Workplace.Where(x => x.TagCode == code).FirstOrDefault();
            }

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

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

            return(result);
        }