private bool Save() { bool result = false; using (var ctx = new EF6.RT2020Entities()) { int priority = 0; if (int.TryParse(txtPriority.Text, out priority)) { var item = ctx.SmartTag4Supplier.Find(_TagId); if (item == null) { item = new EF6.SmartTag4Supplier(); item.TagId = Guid.NewGuid(); item.TagCode = txtTagCode.Text; ctx.SmartTag4Supplier.Add(item); _TagId = item.TagId; } item.TagName = txtTagName.Text; item.TagName_Chs = txtTagNameAlt1.Text; item.TagName_Cht = txtTagNameAlt2.Text; item.Priority = priority; ctx.SaveChanges(); result = true; } } return(result); }
private static string GetFormatedText(EF6.SmartTag4Supplier 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.SmartTag4Supplier object from the database using the given TagId /// </summary> /// <param name="tagId">The primary key value</param> /// <returns>A EF6.SmartTag4Supplier object</returns> public static EF6.SmartTag4Supplier Get(Guid tagId) { EF6.SmartTag4Supplier result = null; using (var ctx = new EF6.RT2020Entities()) { result = ctx.SmartTag4Supplier.Where(x => x.TagId == tagId).AsNoTracking().FirstOrDefault(); } return(result); }
public static EF6.SmartTag4Supplier GetByTagCode(string code) { EF6.SmartTag4Supplier result = null; using (var ctx = new EF6.RT2020Entities()) { result = ctx.SmartTag4Supplier.Where(x => x.TagCode == code).FirstOrDefault(); } return(result); }
/// <summary> /// Get a EF6.SmartTag4Supplier object from the database using the given QueryString /// </summary> /// <param name="tagId">The primary key value</param> /// <returns>A EF6.SmartTag4Supplier object</returns> public static EF6.SmartTag4Supplier Get(string whereClause) { EF6.SmartTag4Supplier result = null; using (var ctx = new EF6.RT2020Entities()) { result = ctx.SmartTag4Supplier .SqlQuery(string.Format("Select * from SmartTag4Supplier Where {0}", whereClause)) .AsNoTracking() .FirstOrDefault(); } return(result); }