Пример #1
0
        public static int InsertOrUpdateT_WQX_RESULT(global::System.Int32? rESULT_IDX, global::System.Int32 aCTIVITY_IDX, global::System.String rESULT_DETECT_CONDITION,            
            global::System.String cHAR_NAME, global::System.String rESULT_SAMP_FRACTION, global::System.String rESULT_MSR, global::System.String rESULT_MSR_UNIT,
            global::System.String rESULT_STATUS, global::System.String rESULT_VALUE_TYPE, global::System.String rESULT_COMMENT,
            global::System.String bIO_INTENT_NAME, global::System.String bIO_INDIVIDUAL_ID, global::System.String bIO_TAXONOMY, global::System.String bIO_SAMPLE_TISSUE_ANATOMY,
            global::System.Int32? aNALYTIC_METHOD_IDX, int? lAB_IDX, DateTime? lAB_ANALYSIS_START_DT, global::System.String dETECTION_LIMIT, global::System.String pQL,
            global::System.String lOWER_QUANT_LIMIT, global::System.String uPPER_QUANT_LIMIT, int? lAB_SAMP_PREP_IDX, DateTime? lAB_SAMP_PREP_START_DT, string dILUTION_FACTOR,
            string fREQ_CLASS_CODE, string fREQ_CLASS_UNIT,
            String cREATE_USER = "******")
        {
            using (OpenEnvironmentEntities ctx = new OpenEnvironmentEntities())
            {
                Boolean insInd = false;
                try
                {
                    T_WQX_RESULT a = new T_WQX_RESULT();

                    if (rESULT_IDX != null)
                        a = (from c in ctx.T_WQX_RESULT
                            where c.RESULT_IDX == rESULT_IDX
                            select c).FirstOrDefault();

                    if (a == null)
                        a = new T_WQX_RESULT();

                    if (a.RESULT_IDX == 0) //insert case
                        insInd = true;

                    a.ACTIVITY_IDX = aCTIVITY_IDX;

                    if (rESULT_DETECT_CONDITION != null) a.RESULT_DETECT_CONDITION = rESULT_DETECT_CONDITION;
                    if (cHAR_NAME != null) a.CHAR_NAME = cHAR_NAME;

                    if (rESULT_SAMP_FRACTION != null) a.RESULT_SAMP_FRACTION = rESULT_SAMP_FRACTION;
                    if (rESULT_MSR != null) a.RESULT_MSR = rESULT_MSR;
                    if (rESULT_MSR_UNIT != null) a.RESULT_MSR_UNIT = rESULT_MSR_UNIT;
                    if (rESULT_STATUS != null) a.RESULT_STATUS = rESULT_STATUS;
                    if (rESULT_VALUE_TYPE != null) a.RESULT_VALUE_TYPE = rESULT_VALUE_TYPE;
                    if (rESULT_COMMENT != null) a.RESULT_COMMENT = rESULT_COMMENT;
                    if (bIO_INTENT_NAME != null) a.BIO_INTENT_NAME = bIO_INTENT_NAME;
                    if (bIO_INDIVIDUAL_ID != null) a.BIO_INDIVIDUAL_ID = bIO_INDIVIDUAL_ID;
                    if (bIO_TAXONOMY != null) a.BIO_SUBJECT_TAXONOMY = bIO_TAXONOMY;
                    if (bIO_SAMPLE_TISSUE_ANATOMY != null) a.BIO_SAMPLE_TISSUE_ANATOMY = bIO_SAMPLE_TISSUE_ANATOMY;
                    if (aNALYTIC_METHOD_IDX != null) a.ANALYTIC_METHOD_IDX = aNALYTIC_METHOD_IDX;
                    if (lAB_IDX != null) a.LAB_IDX = lAB_IDX;
                    if (lAB_ANALYSIS_START_DT != null) a.LAB_ANALYSIS_START_DT = lAB_ANALYSIS_START_DT;
                    if (dETECTION_LIMIT != null) a.DETECTION_LIMIT = dETECTION_LIMIT;
                    if (pQL != null) a.PQL = pQL;
                    if (lOWER_QUANT_LIMIT != null) a.LOWER_QUANT_LIMIT = lOWER_QUANT_LIMIT;
                    if (uPPER_QUANT_LIMIT != null) a.UPPER_QUANT_LIMIT = uPPER_QUANT_LIMIT;
                    if (lAB_SAMP_PREP_IDX != null) a.LAB_SAMP_PREP_IDX = lAB_SAMP_PREP_IDX;
                    if (lAB_SAMP_PREP_START_DT != null) a.LAB_SAMP_PREP_START_DT = lAB_SAMP_PREP_START_DT;
                    if (dILUTION_FACTOR != null) a.DILUTION_FACTOR = dILUTION_FACTOR;
                    if (fREQ_CLASS_CODE != null) a.FREQ_CLASS_CODE = fREQ_CLASS_CODE;
                    if (fREQ_CLASS_UNIT != null) a.FREQ_CLASS_UNIT = fREQ_CLASS_UNIT;
                    //set freq class unit to count if not provided
                    if (fREQ_CLASS_UNIT == null && fREQ_CLASS_CODE != null) fREQ_CLASS_UNIT = "count";

                    if (insInd) //insert case
                        ctx.AddToT_WQX_RESULT(a);

                    ctx.SaveChanges();

                    return a.RESULT_IDX;
                }
                catch (Exception ex)
                {
                    return 0;
                }
            }
        }