public static int InsertOrUpdateWQX_IMPORT_TEMPLATE_DTL(global::System.Int32? tEMPLATE_DTL_ID, global::System.Int32? tEMPLATE_ID, global::System.Int32? cOL_NUM, global::System.String fIELD_MAP, string cHAR_NAME, string cHAR_DEFAULT_UNIT, String cREATE_USER = "******", string cHAR_DEFAULT_SAMP_FRACTION = null) { using (OpenEnvironmentEntities ctx = new OpenEnvironmentEntities()) { Boolean insInd = false; try { T_WQX_IMPORT_TEMPLATE_DTL a = new T_WQX_IMPORT_TEMPLATE_DTL(); if (tEMPLATE_ID != null) a = (from c in ctx.T_WQX_IMPORT_TEMPLATE_DTL where c.TEMPLATE_DTL_ID == tEMPLATE_DTL_ID select c).FirstOrDefault(); if (a == null) //insert case { insInd = true; a = new T_WQX_IMPORT_TEMPLATE_DTL(); } if (tEMPLATE_ID != null) a.TEMPLATE_ID = tEMPLATE_ID.ConvertOrDefault<int>(); if (cOL_NUM != null) a.COL_NUM = cOL_NUM.ConvertOrDefault<int>(); if (fIELD_MAP != null) a.FIELD_MAP = fIELD_MAP; if (cHAR_NAME != null) a.CHAR_NAME = cHAR_NAME; if (cHAR_DEFAULT_UNIT != null) a.CHAR_DEFAULT_UNIT = cHAR_DEFAULT_UNIT; if (cHAR_DEFAULT_SAMP_FRACTION != null) a.CHAR_DEFAULT_SAMP_FRACTION = cHAR_DEFAULT_SAMP_FRACTION; if (insInd) //insert case { a.CREATE_DT = System.DateTime.Now; a.CREATE_USERID = cREATE_USER; ctx.AddToT_WQX_IMPORT_TEMPLATE_DTL(a); } ctx.SaveChanges(); return a.TEMPLATE_DTL_ID; } catch (Exception ex) { return 0; } } }