Ejemplo n.º 1
0
        public List <Models.AccionRecursosPT> Catalogo(Models.AccionRecursosPT oAccionRecursos)
        {
            OpenDbConn();

            DAL.AccionRecursosPT           cAccionRecursos = new DAL.AccionRecursosPT(cDblib);
            List <Models.AccionRecursosPT> oLista          = cAccionRecursos.Catalogo(oAccionRecursos);

            return(oLista);
        }
Ejemplo n.º 2
0
        public int grabar(Models.AccionPT DatosGenerales, List <Models.AccionRecursosPT> Integrantes, List <Models.AccionTareasPT> Tareas)
        {
            int  idReferencia;
            bool bConTransaccion = false;
            Guid methodOwnerID   = new Guid("5590F1B4-7073-4B5F-A4DB-9F301648D151");

            OpenDbConn();
            if (cDblib.Transaction.ownerID.Equals(new Guid()))
            {
                bConTransaccion = true;
            }
            if (bConTransaccion)
            {
                cDblib.beginTransaction(methodOwnerID);
            }
            try
            {
                DAL.AccionPT         oAccion     = new DAL.AccionPT(cDblib);
                DAL.AccionRecursosPT oRecursoDAL = new DAL.AccionRecursosPT(cDblib);
                DAL.AccionTareasPT   oTareaDAL   = new DAL.AccionTareasPT(cDblib);

                if (DatosGenerales.T410_idaccion == -1)
                {
                    DatosGenerales.T410_fcreacion = System.DateTime.Now;
                    idReferencia = oAccion.Insert(DatosGenerales);
                }
                else
                {
                    oAccion.Update(DatosGenerales);
                    idReferencia = DatosGenerales.T410_idaccion;
                }

                foreach (Models.AccionRecursosPT oRecurso in Integrantes)
                {
                    switch (oRecurso.accionBD)
                    {
                    case "I":
                        //Inserción
                        oRecurso.t410_idaccion = idReferencia;
                        oRecursoDAL.Insert(oRecurso);
                        break;

                    case "D":
                        //delete
                        oRecursoDAL.Delete(oRecurso);
                        break;

                    case "U":
                        //update
                        oRecursoDAL.Update(oRecurso);
                        break;
                    }
                }

                foreach (Models.AccionTareasPT oTarea in Tareas)
                {
                    switch (oTarea.accionBD)
                    {
                    case "I":
                        //Inserción
                        oTareaDAL.Insert(oTarea);
                        break;

                    case "D":
                        //delete
                        oTareaDAL.Delete(oTarea);
                        break;
                    }
                }

                if (bConTransaccion)
                {
                    cDblib.commitTransaction(methodOwnerID);
                }

                return(idReferencia);
            }
            catch (Exception ex)
            {
                //rollback
                if (cDblib.Transaction.ownerID.Equals(methodOwnerID))
                {
                    cDblib.rollbackTransaction(methodOwnerID);
                }
                throw new Exception(ex.Message);
            }
            finally
            {
                //nota.Dispose();
            }
        }