internal void Update(RevisionMaterial parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            OidRevision = parent.Oid;

            try
            {
                ValidationRules.CheckRules();

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

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

            MarkOld();
        }
        internal void DeleteSelf(RevisionMaterial 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
            {
                parent.Session().Delete(parent.Session().Get <Material_PlanRecord>(Oid));
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkNew();
        }
示例#3
0
        internal void Update(RevisionMaterial parent)
        {
            this.RaiseListChangedEvents = false;

            // update (thus deleting) any deleted child objects
            foreach (Material_Plan obj in DeletedList)
            {
                obj.DeleteSelf(parent);
            }

            // now that they are deleted, remove them from memory too
            DeletedList.Clear();

            // AddItem/update any current child objects
            foreach (Material_Plan obj in this)
            {
                if (obj.IsNew)
                {
                    obj.Insert(parent);
                }
                else
                {
                    obj.Update(parent);
                }
            }

            this.RaiseListChangedEvents = true;
        }
示例#4
0
        private void Fetch(int session_code, IDataReader source)
        {
            try
            {
                _base.CopyValues(source);

                if (Childs)
                {
                    RevisionMaterial.DoLOCK(Session(session_code));

                    string      query  = RevisionMaterials.SELECT_BY_MATERIAL(this.Oid);
                    IDataReader reader = nHManager.Instance.SQLNativeSelect(query, Session(session_code));
                    _revisiones = RevisionMaterials.GetChildList(session_code, reader);

                    Material_Plan.DoLOCK(Session(session_code));

                    query   = Material_Plans.SELECT(GetInfo(false));
                    reader  = nHManager.Instance.SQLNativeSelect(query, Session(session_code));
                    _planes = Material_Plans.GetChildList(reader);

                    Material_Alumno.DoLOCK(Session(session_code));

                    query    = Material_Alumnos.SELECT_BY_MATERIAL(this.Oid);
                    reader   = nHManager.Instance.SQLNativeSelect(query, Session(session_code));
                    _alumnos = Material_Alumnos.GetChildList(reader);
                }
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkOld();
        }
示例#5
0
        private void Fetch(MaterialDocente source)
        {
            try
            {
                SessionCode = source.SessionCode;

                _base.CopyValues(source);

                CriteriaEx criteria = RevisionMaterial.GetCriteria(Session());
                criteria.AddEq("OidMaterial", this.Oid);
                _revisiones = RevisionMaterials.GetChildList(criteria.List <RevisionMaterial>());

                criteria = Material_Plan.GetCriteria(Session());
                criteria.AddEq("OidMaterial", this.Oid);
                _planes = Material_Plans.GetChildList(criteria.List <Material_Plan>());

                criteria = Material_Alumno.GetCriteria(Session());
                criteria.AddEq("OidMaterial", this.Oid);
                _alumnos = Material_Alumnos.GetChildList(criteria.List <Material_Alumno>());
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkOld();
        }
示例#6
0
        public void CopyValues(RevisionMaterial source)
        {
            if (source == null)
            {
                return;
            }

            _record.CopyValues(source.Base.Record);
        }
        public static Material_Plan NewChild(RevisionMaterial parent)
        {
            if (!CanAddObject())
            {
                throw new System.Security.SecurityException(
                          moleQule.Library.Resources.Messages.USER_NOT_ALLOWED);
            }

            Material_Plan obj = new Material_Plan();

            obj.OidRevision = parent.Oid;
            return(obj);
        }
        //  private RevisionMaterialList() { }

        /// <summary>
        /// Retrieve the complete list from db
        /// </summary>
        /// <returns>RevisionMaterialList</returns>
        public static RevisionMaterialList GetList(bool childs)
        {
            CriteriaEx criteria = RevisionMaterial.GetCriteria(RevisionMaterial.OpenSession());

            criteria.Childs = true;
            criteria.Query  = RevisionMaterialList.SELECT();

            //No criteria. Retrieve all de List
            RevisionMaterialList list = DataPortal.Fetch <RevisionMaterialList>(criteria);

            CloseSession(criteria.SessionCode);

            return(list);
        }
示例#9
0
 public void CopyFrom(RevisionMaterial source)
 {
     _base.CopyValues(source);
 }
 public static string SELECT()
 {
     return(RevisionMaterial.SELECT(new QueryConditions(), false));
 }
示例#11
0
 public Material_Plan NewItem(RevisionMaterial parent)
 {
     this.AddItem(Material_Plan.NewChild(parent));
     return(this[Count - 1]);
 }
示例#12
0
        // called to retrieve data from the database
        private void DataPortal_Fetch(CriteriaEx criteria)
        {
            try
            {
                SessionCode = criteria.SessionCode;

                Childs = criteria.Childs;

                if (nHMng.UseDirectSQL)
                {
                    MaterialDocente.DoLOCK(Session());

                    IDataReader reader = nHMng.SQLNativeSelect(criteria.Query, Session());

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

                    if (Childs)
                    {
                        RevisionMaterial.DoLOCK(Session());

                        string query = RevisionMaterials.SELECT_BY_MATERIAL(this.Oid);
                        reader      = nHManager.Instance.SQLNativeSelect(query, Session());
                        _revisiones = RevisionMaterials.GetChildList(criteria.SessionCode, reader);

                        Material_Plan.DoLOCK(Session());

                        query   = Material_Plans.SELECT(GetInfo(false));
                        reader  = nHManager.Instance.SQLNativeSelect(query, Session());
                        _planes = Material_Plans.GetChildList(reader);

                        Material_Alumno.DoLOCK(Session());

                        query    = Material_Alumnos.SELECT_BY_MATERIAL(this.Oid);
                        reader   = nHManager.Instance.SQLNativeSelect(query, Session());
                        _alumnos = Material_Alumnos.GetChildList(reader);
                    }
                }
                else
                {
                    _base.Record.CopyValues((MaterialDocenteRecord)(criteria.UniqueResult()));

                    //Session().Lock(Session().Get<MaterialDocenteRecord>(Oid), LockMode.UpgradeNoWait);

                    if (Childs)
                    {
                        criteria = RevisionMaterial.GetCriteria(Session());
                        criteria.AddEq("OidMaterial", this.Oid);
                        _revisiones = RevisionMaterials.GetChildList(criteria.List <RevisionMaterial>());

                        criteria = Material_Plan.GetCriteria(Session());
                        criteria.AddEq("OidMaterial", this.Oid);
                        _planes = Material_Plans.GetChildList(criteria.List <Material_Plan>());

                        criteria = Material_Alumno.GetCriteria(Session());
                        criteria.AddEq("OidMaterial", this.Oid);
                        _alumnos = Material_Alumnos.GetChildList(criteria.List <Material_Alumno>());
                    }
                }
            }
            catch (NHibernate.ADOException)
            {
                if (Transaction() != null)
                {
                    Transaction().Rollback();
                }
                throw new iQLockException(moleQule.Library.Resources.Messages.LOCK_ERROR);
            }
            catch (Exception ex)
            {
                if (Transaction() != null)
                {
                    Transaction().Rollback();
                }
                iQExceptionHandler.TreatException(ex);
            }
        }