//******************REF DATA**************************************** public static int InsertOrUpdateT_WQX_REF_DATA(global::System.String tABLE, global::System.String vALUE, global::System.String tEXT, global::System.Boolean? UsedInd) { using (OpenEnvironmentEntities ctx = new OpenEnvironmentEntities()) { try { Boolean insInd = true; T_WQX_REF_DATA a = new T_WQX_REF_DATA(); if (ctx.T_WQX_REF_DATA.Any(o => o.VALUE == vALUE && o.TABLE == tABLE)) { //update case a = (from c in ctx.T_WQX_REF_DATA where c.VALUE == vALUE && c.TABLE == tABLE select c).FirstOrDefault(); insInd = false; } a.TABLE = tABLE; a.VALUE = vALUE; a.TEXT = Utils.SubStringPlus(tEXT, 0,200); if (UsedInd != null) a.USED_IND = UsedInd; a.UPDATE_DT = System.DateTime.Now; a.ACT_IND = true; if (insInd) //insert case { if (UsedInd == null) a.USED_IND = true; ctx.AddToT_WQX_REF_DATA(a); } ctx.SaveChanges(); return 1; } catch (Exception ex) { return 0; } } }