// *************************** IMPORT: PROJECT ****************************** // ***************************************************************************** public static int InsertOrUpdateWQX_IMPORT_TEMP_PROJECT(global::System.Int32? tEMP_PROJECT_IDX, string uSER_ID, global::System.Int32? pROJECT_IDX, global::System.String oRG_ID, global::System.String pROJECT_ID, global::System.String pROJECT_NAME, global::System.String pROJECT_DESC, global::System.String sAMP_DESIGN_TYPE_CD, global::System.Boolean? qAPP_APPROVAL_IND, global::System.String qAPP_APPROVAL_AGENCY, string sTATUS_CD, string sTATUS_DESC) { using (OpenEnvironmentEntities ctx = new OpenEnvironmentEntities()) { Boolean insInd = false; try { T_WQX_IMPORT_TEMP_PROJECT a = new T_WQX_IMPORT_TEMP_PROJECT(); if (tEMP_PROJECT_IDX != null) a = (from c in ctx.T_WQX_IMPORT_TEMP_PROJECT where c.TEMP_PROJECT_IDX == tEMP_PROJECT_IDX select c).FirstOrDefault(); else insInd = true; if (uSER_ID != null) { a.USER_ID = uSER_ID; if (uSER_ID.Length > 25) { sTATUS_CD = "F"; sTATUS_DESC += "User ID length exceeded. "; } } if (pROJECT_IDX != null) a.PROJECT_IDX = pROJECT_IDX; if (oRG_ID != null) a.ORG_ID = oRG_ID; if (pROJECT_ID != null) { a.PROJECT_ID = pROJECT_ID.SubStringPlus(0, 35).Trim(); if (pROJECT_ID.Length > 35) { sTATUS_CD = "F"; sTATUS_DESC += "Project ID length exceeded. "; } T_WQX_PROJECT ptemp = db_WQX.GetWQX_PROJECT_ByIDString(pROJECT_ID, oRG_ID); if (ptemp != null) { sTATUS_CD = "F"; sTATUS_DESC += "Project ID already exists. "; } } if (!string.IsNullOrEmpty(pROJECT_NAME)) { a.PROJECT_NAME = pROJECT_NAME.SubStringPlus(0, 120).Trim(); if (pROJECT_NAME.Length > 120) { sTATUS_CD = "F"; sTATUS_DESC += "Project Name length exceeded. "; } } if (!string.IsNullOrEmpty(pROJECT_DESC)) { a.PROJECT_DESC = pROJECT_DESC.SubStringPlus(0, 1999); if (pROJECT_DESC.Length > 1999) { sTATUS_CD = "F"; sTATUS_DESC += "Project Description length exceeded. "; } } if (!string.IsNullOrEmpty(sAMP_DESIGN_TYPE_CD)) { a.SAMP_DESIGN_TYPE_CD = sAMP_DESIGN_TYPE_CD.Trim().SubStringPlus(0, 20); if (sAMP_DESIGN_TYPE_CD.Length > 20) { sTATUS_CD = "F"; sTATUS_DESC += "Sample Design Type Code length exceeded. "; } } if (qAPP_APPROVAL_IND != null) { a.QAPP_APPROVAL_IND = qAPP_APPROVAL_IND; } if (!string.IsNullOrEmpty(qAPP_APPROVAL_AGENCY)) { a.QAPP_APPROVAL_AGENCY = qAPP_APPROVAL_AGENCY.SubStringPlus(0, 50); if (qAPP_APPROVAL_AGENCY.Length > 50) { sTATUS_CD = "F"; sTATUS_DESC += "QAPP Approval Agency length exceeded. "; } } if (sTATUS_CD != null) a.IMPORT_STATUS_CD = sTATUS_CD; if (sTATUS_DESC != null) a.IMPORT_STATUS_DESC = sTATUS_DESC.SubStringPlus(0, 100); if (insInd) //insert case ctx.AddToT_WQX_IMPORT_TEMP_PROJECT(a); ctx.SaveChanges(); return a.TEMP_PROJECT_IDX; } catch (Exception ex) { sTATUS_CD = "F"; sTATUS_DESC += "Unspecified error. "; return 0; } } }