Ejemplo n.º 1
0
        // *************************** MONLOC **********************************
        // *********************************************************************
        public static int InsertOrUpdateWQX_MONLOC(global::System.Int32? mONLOC_IDX, global::System.String oRG_ID,  global::System.String mONLOC_ID, global::System.String mONLOC_NAME,
            global::System.String mONLOC_TYPE, global::System.String mONLOC_DESC, global::System.String hUC_EIGHT, global::System.String HUC_TWELVE, global::System.String tRIBAL_LAND_IND,
            global::System.String tRIBAL_LAND_NAME, global::System.String lATITUDE_MSR, global::System.String lONGITUDE_MSR, global::System.Int32? sOURCE_MAP_SCALE,
            global::System.String hORIZ_ACCURACY, global::System.String hORIZ_ACCURACY_UNIT, global::System.String hORIZ_COLL_METHOD, global::System.String hORIZ_REF_DATUM,
            global::System.String vERT_MEASURE, global::System.String vERT_MEASURE_UNIT, global::System.String vERT_COLL_METHOD, global::System.String vERT_REF_DATUM,
            global::System.String cOUNTRY_CODE, global::System.String sTATE_CODE, global::System.String cOUNTY_CODE, global::System.String wELL_TYPE, global::System.String aQUIFER_NAME,
            global::System.String fORMATION_TYPE, global::System.String wELLHOLE_DEPTH_MSR, global::System.String wELLHOLE_DEPTH_MSR_UNIT, global::System.String wQX_SUBMIT_STATUS,
            DateTime? wQXUpdateDate, Boolean? aCT_IND, Boolean? wQX_IND, String cREATE_USER = "******")
        {
            using (OpenEnvironmentEntities ctx = new OpenEnvironmentEntities())
            {
                Boolean insInd = false;
                try
                {
                    T_WQX_MONLOC a = new T_WQX_MONLOC();

                    if (mONLOC_IDX != null)
                        a = (from c in ctx.T_WQX_MONLOC
                             where c.MONLOC_IDX == mONLOC_IDX
                             select c).FirstOrDefault();
                    else
                        insInd = true;

                    if (a == null) //insert case
                    {
                        a = new T_WQX_MONLOC();
                        insInd = true;
                    }

                    if (oRG_ID != null) a.ORG_ID = oRG_ID;
                    if (mONLOC_ID != null) a.MONLOC_ID = mONLOC_ID;
                    if (mONLOC_NAME != null) a.MONLOC_NAME = mONLOC_NAME;
                    if (mONLOC_TYPE != null) a.MONLOC_TYPE = mONLOC_TYPE;
                    if (mONLOC_DESC != null) a.MONLOC_DESC = mONLOC_DESC;
                    if (hUC_EIGHT != null) a.HUC_EIGHT = hUC_EIGHT;
                    if (HUC_TWELVE != null) a.HUC_TWELVE = HUC_TWELVE;
                    if (tRIBAL_LAND_IND  != null) a.TRIBAL_LAND_IND = tRIBAL_LAND_IND;
                    if (tRIBAL_LAND_NAME != null) a.TRIBAL_LAND_NAME = tRIBAL_LAND_NAME;
                    if (lATITUDE_MSR != null) a.LATITUDE_MSR = lATITUDE_MSR;
                    if (lONGITUDE_MSR != null) a.LONGITUDE_MSR = lONGITUDE_MSR;
                    if (sOURCE_MAP_SCALE != null) a.SOURCE_MAP_SCALE = sOURCE_MAP_SCALE;
                    if (hORIZ_ACCURACY != null) a.HORIZ_ACCURACY = hORIZ_ACCURACY;
                    if (hORIZ_ACCURACY_UNIT != null) a.HORIZ_ACCURACY_UNIT = hORIZ_ACCURACY_UNIT;
                    if (hORIZ_COLL_METHOD != null) a.HORIZ_COLL_METHOD = hORIZ_COLL_METHOD;
                    if (hORIZ_REF_DATUM != null) a.HORIZ_REF_DATUM = hORIZ_REF_DATUM;
                    if (vERT_MEASURE != null) a.VERT_MEASURE= vERT_MEASURE;
                    if (vERT_MEASURE_UNIT != null) a.VERT_MEASURE_UNIT = vERT_MEASURE_UNIT;
                    if (vERT_COLL_METHOD != null) a.VERT_COLL_METHOD = vERT_COLL_METHOD;
                    if (vERT_REF_DATUM != null) a.VERT_REF_DATUM = vERT_REF_DATUM;
                    if (cOUNTRY_CODE != null) a.COUNTRY_CODE = cOUNTRY_CODE;
                    if (sTATE_CODE != null) a.STATE_CODE = sTATE_CODE;
                    if (cOUNTY_CODE != null) a.COUNTY_CODE = cOUNTY_CODE;

                    if (wELL_TYPE != null) a.WELL_TYPE = wELL_TYPE;
                    if (aQUIFER_NAME != null) a.AQUIFER_NAME = aQUIFER_NAME;
                    if (fORMATION_TYPE != null) a.FORMATION_TYPE = fORMATION_TYPE;
                    if (wELLHOLE_DEPTH_MSR != null) a.WELLHOLE_DEPTH_MSR = wELLHOLE_DEPTH_MSR;
                    if (wELLHOLE_DEPTH_MSR_UNIT != null) a.WELLHOLE_DEPTH_MSR_UNIT = wELLHOLE_DEPTH_MSR_UNIT;
                    if (wQX_SUBMIT_STATUS != null) a.WQX_SUBMIT_STATUS = wQX_SUBMIT_STATUS;
                    if (aCT_IND != null) a.ACT_IND = aCT_IND;
                    if (wQX_IND != null) a.WQX_IND = wQX_IND;

                    if (insInd) //insert case
                    {
                        a.CREATE_USERID = cREATE_USER.ToUpper();
                        a.CREATE_DT = System.DateTime.Now;
                        ctx.AddToT_WQX_MONLOC(a);
                    }
                    else
                    {
                        a.UPDATE_USERID = cREATE_USER.ToUpper();
                        a.UPDATE_DT = System.DateTime.Now;
                    }

                    ctx.SaveChanges();

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