public bool Attended(Person aPerson, Event anEvent)
 {
     if (this.Retrieve(aPerson, anEvent) != null)
         return true;
     else
         return false;
 }
        public void RemoveAllAttendancesOfPerson(Person aPerson)
        {
            SqlBuilder sb = new SqlBuilder(StatementType.Delete, typeof(Attendance));
            sb.AddConstraint(Operator.Equals, "id_person", aPerson.Id);

            SqlStatement stmt = sb.GetStatement(true);
            stmt.Execute();
        }
        public void RemoveAttendance(Person aPerson, Event anEvent)
        {
            Attendance at = Retrieve(aPerson, anEvent);

            if (at == null)
                throw new Exception("La asistencia que se intenta eliminar no existe en la base de datos.");

            at.Remove();
        }
        public Attendance AddAttendance(Person aPerson, Event anEvent)
        {
            if (Retrieve(aPerson, anEvent) == null) {
                Attendance newAttendance = new Attendance(aPerson.Id, anEvent.Id);
                newAttendance.Persist();

                return newAttendance;
            }

            throw new AttendanceExistsException("Se está intentando ingresar una asistencia que" +
                    " ya existe en la base de datos.");
        }
        // Add person with basic data
        //        public Person AddPerson(int dni, string surname, string name, bool is_man,
        //                                       bool data_is_complete)
        //        {
        //            
        //            return this.AddPerson(dni, surname, name, is_man
        //            
        //            // Check if exists another person with the same dni.
        //            try {
        //                Retrieve(dni);
        //            }
        //            catch (PersonDoesNotExistException) {
        //                Person newPerson = new Person(dni, surname, name, is_man, data_is_complete);
        //                newPerson.Persist();
        //                
        //                return newPerson;
        //            }
        //            
        //            throw new Exception("Se está intentando ingresar una persona que " +
        //                                            "ya existe en la base de datos: El DNI ingresado " +
        //                                            "pertenece a una persona previamente agregada.");
        //        }
        // Add person with complete data
        public Person AddPerson(int dni, string surname, string name, bool is_man,
		                        DateTime birthday_date, string address, string city,
		                        string land_phone_number, string mobile_number, string email,
		                        string comunity, bool is_active, bool is_data_complete)
        {
            // Check if exists another person with the same dni.
            //			try {
            //				RetrieveByDNI(dni);
            //			}
            //			catch (PersonDoesNotExistException) {
                Person newPerson = new Person(dni, surname, name, is_man,
                                              birthday_date, address, city,
                                              land_phone_number, mobile_number, email,
                                              comunity, is_active, is_data_complete);
                newPerson.Persist();

                return newPerson;
            //			}

            //			throw new Exception("Se está intentando ingresar una persona que " +
            //			                    "ya existe en la base de datos: El DNI ingresado " +
            //			                    "pertenece a una persona previamente agregada.");
        }
Example #6
0
        public ModifyPerson(Gtk.Window parent, ListStore personsModel,
		                    Person aPerson, TreeIter personIter)
            : base(parent, personsModel)
        {
            this.personIter = personIter;

            this.dlgAddPerson.Title = "Modificar persona";

            this.dialogButtons.Remove(this.btnOkClose);
            this.btnOkAdd.Label = "Guardar";

            // Person data
            this.entryName.Text = aPerson.Name;
            this.entrySurname.Text = aPerson.Surname;
            this.entryDNI.Text = aPerson.Dni == 0 ? "" : aPerson.Dni.ToString();

            this.cmbSex.Active = aPerson.IsMan ? 0 : 1;

            this.entryAddress.Text = aPerson.Address;
            this.entryCity.Text = aPerson.City;
            this.entryLandPhone.Text = aPerson.LandPhoneNumber;
            this.entryMobilePhone.Text = aPerson.MobileNumber;
            this.entryEMail.Text = aPerson.EMail;

            this.entryCommunity.Text = aPerson.Community;
            this.chkIsActive.Active = aPerson.IsActive;

            if (!aPerson.BirthdayDate.Equals(DateTime.MinValue)) {
                this.spbtnDay.Value = aPerson.BirthdayDate.Day;
                this.cmbMonth.Active = aPerson.BirthdayDate.Month - 1;
            }

            this.chkIsDataComplete.Active = aPerson.IsDataComplete;

            this.person = aPerson;
        }
Example #7
0
        public void AddPersonToList(Person p)
        {
            // Add to persons list
            this.persons.AppendValues(p);

            /* First load last events. If this fuction returns true, it means
             * that an update to the last events was necessary, and the persons
             * have been added, so it's not necessary to add this person
             * again. */
            this.LoadAttendancesListData();

            // If persons in attendances list is updated, quit
            if (this.treeItersOnAttendancesList.ContainsKey(p))
                return;

            // If there are no last events, we quit.
            if (this.lastEventsOnAttendancesList.Count == 0)
                return;

            AttendancesManager am = AttendancesManager.Instance;
            ArrayList data = new ArrayList();

            // Person's data
            data.Add(p);

            // Events
            foreach (Event anEvent in this.lastEventsOnAttendancesList)
                data.Add(am.Attended(p, anEvent));

            // ... and the person object itself. We'll need it.
            //			data.Add(p);

            TreeIter iter = this.attendances.AppendValues(data.ToArray());

            if (!this.treeItersOnAttendancesList.ContainsKey(p))
                    this.treeItersOnAttendancesList.Add(p, iter);
        }
        public IList<Attendance> RetrieveLastEventsAttended(Person aPerson, int numberOfEvents)
        {
            SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(Attendance));
            sb.SetRowLimit(numberOfEvents);
            sb.AddOrderByField(false, "date");

            SqlStatement stmt = sb.GetStatement(true);

            Attendance[] attendances =
                (Attendance[])ObjectFactory.GetCollection(typeof(Attendance), stmt.Execute());

            return attendances;
        }
        private Attendance Retrieve(Person aPerson, Event anEvent)
        {
            Key key = new Key(true);
            key.Add("id_person", aPerson.Id);
            key.Add("id_event", anEvent.Id);

            Attendance anAttendance =
                Broker.SessionBroker.TryRetrieveInstance(typeof(Attendance), key) as Attendance;

            // If found, return it
            if (anAttendance != null)
                return anAttendance;

            return null;
        }
Example #10
0
 public Attendance(int id_person, int id_event)
 {
     this.aPerson = PersonsManager.Instance.RetrieveById(id_person);
     this.anEvent = EventsManager.Instance.Retrieve(id_event);
 }