示例#1
0
        /// <summary>
        /// Borra el registro de la base de datos
        /// </summary>
        /// <param name="parent">Lista padre</param>
        /// <remarks>La utiliza la BusinessListBaseEx correspondiente para borrar elementos<remarks/>
        internal void DeleteSelf(BudgetLines parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            // if we're new then don't update the database
            if (this.IsNew)
            {
                return;
            }

            try
            {
                SessionCode = parent.SessionCode;
                Session().Delete(Session().Get <BudgetLineRecord>(Oid));
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkNew();
        }
示例#2
0
        /// <summary>
        /// Actualiza el registro en la base de datos
        /// </summary>
        /// <param name="parent">Lista padre</param>
        /// <remarks>La utiliza la BusinessListBaseEx correspondiente para actualizar elementos<remarks/>
        internal void Update(BudgetLines parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            try
            {
                ValidationRules.CheckRules();

                if (!IsValid)
                {
                    throw new iQValidationException(
                              Library.Resources.Messages.GENERIC_VALIDATION_ERROR);
                }

                SessionCode = parent.SessionCode;
                BudgetLineRecord obj = Session().Get <BudgetLineRecord>(Oid);
                obj.CopyValues(Base.Record);
                Session().Update(obj);
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkOld();
        }
示例#3
0
        private void DataPortal_Create(CriteriaCs criteria)
        {
            _base.Record.Oid = (long)(new Random()).Next();
            GetNewCode();
            Fecha      = DateTime.Now;
            OidUsuario = (AppContext.User != null) ? (int)AppContext.User.Oid : 0;
            Usuario    = (AppContext.User != null) ? AppContext.User.Name : string.Empty;

            _conceptos = BudgetLines.NewChildList();
        }
示例#4
0
        /// <summary>
        /// Construye el objeto y se encarga de obtener los
        /// hijos si los tiene y se solicitan
        /// </summary>
        /// <param name="source">DataReader fuente</param>
        private void Fetch(IDataReader source)
        {
            try
            {
                _base.CopyValues(source);

                if (Childs)
                {
                    if (nHMng.UseDirectSQL)
                    {
                        BudgetLine.DoLOCK(Session());
                        string      query  = BudgetLines.SELECT(this);
                        IDataReader reader = nHMng.SQLNativeSelect(query, Session());
                        _conceptos = BudgetLines.GetChildList(reader, false);
                    }
                }
            }
            catch (Exception ex) { throw ex; }

            MarkOld();
        }
示例#5
0
        /// <summary>
        /// Obtiene un registro de la base de datos
        /// </summary>
        /// <param name="criteria">Criterios de consulta</param>
        /// <remarks>Lo llama el DataPortal tras generar el objeto</remarks>
        private void DataPortal_Fetch(CriteriaEx criteria)
        {
            try
            {
                _base.Record.Oid = 0;
                SessionCode      = criteria.SessionCode;
                Childs           = criteria.Childs;

                if (nHMng.UseDirectSQL)
                {
                    Budget.DoLOCK(Session());
                    IDataReader reader = nHMng.SQLNativeSelect(criteria.Query, Session());

                    if (reader.Read())
                    {
                        _base.CopyValues(reader);
                    }

                    if (Childs)
                    {
                        string query = string.Empty;

                        BudgetLine.DoLOCK(Session());
                        query      = BudgetLines.SELECT(this);
                        reader     = nHMng.SQLNativeSelect(query, Session());
                        _conceptos = BudgetLines.GetChildList(reader);
                    }
                }

                MarkOld();
            }
            catch (Exception ex)
            {
                if (!SharedTransaction && Transaction() != null)
                {
                    Transaction().Rollback();
                }
                iQExceptionHandler.TreatException(ex);
            }
        }
示例#6
0
        /// <summary>
        /// Inserta el registro en la base de datos
        /// </summary>
        /// <param name="parent">Lista padre</param>
        /// <remarks>La utiliza la BusinessListBaseEx correspondiente para insertar elementos<remarks/>
        internal void Insert(BudgetLines parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            try
            {
                ValidationRules.CheckRules();

                if (!IsValid)
                {
                    throw new iQValidationException(
                              Library.Resources.Messages.GENERIC_VALIDATION_ERROR);
                }

                parent.Session().Save(Base.Record);
            }
            catch (Exception ex) { throw ex; }

            MarkOld();
        }