Пример #1
0
        // *************************** IMPORT_TEMPLATE    ******************************
        // *****************************************************************************
        public static int InsertOrUpdateWQX_IMPORT_TEMPLATE(global::System.Int32? tEMPLATE_ID, global::System.String oRG_ID, string tYPE_CD, string tEMPLATE_NAME, String cREATE_USER = "******")
        {
            using (OpenEnvironmentEntities ctx = new OpenEnvironmentEntities())
            {
                Boolean insInd = false;
                try
                {
                    T_WQX_IMPORT_TEMPLATE a = new T_WQX_IMPORT_TEMPLATE();

                    if (tEMPLATE_ID != null)
                        a = (from c in ctx.T_WQX_IMPORT_TEMPLATE
                             where c.TEMPLATE_ID == tEMPLATE_ID
                             select c).FirstOrDefault();

                    if (tEMPLATE_ID == null) //insert case
                        insInd = true;

                    if (oRG_ID != null) a.ORG_ID = oRG_ID;
                    if (tYPE_CD != null) a.TYPE_CD = tYPE_CD;
                    if (tEMPLATE_NAME != null) a.TEMPLATE_NAME = tEMPLATE_NAME;

                    if (insInd) //insert case
                    {
                        a.CREATE_DT = System.DateTime.Now;
                        a.CREATE_USERID = cREATE_USER;
                        ctx.AddToT_WQX_IMPORT_TEMPLATE(a);
                    }

                    ctx.SaveChanges();

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