public PersonGymGroupSearchView(PERSON_GYMGROUP personGymGroup)
 {
     this.PERSON_GYMGROUP_ID = personGymGroup.PERSON_GYMGROUP_ID;
     this.GYMGROUPNAME       = personGymGroup.GYMGROUP.GYMGROUPNAME;
     this.NUMBEROFHOURS      = personGymGroup.GYMGROUP.NUMBEROFHOURS;
     this.GYMGROUPYEAR       = personGymGroup.GYMGROUP.GYMGROUPYEAR;
     this.YEARPRICE          = personGymGroup.GYMGROUP.YEARPRICE;
 }
 public GymGroupPersonSearchView(PERSON_GYMGROUP gymGroupPerson)
 {
     this.PERSON_GYMGROUP_ID = gymGroupPerson.PERSON_GYMGROUP_ID;
     this.LASTNAME           = gymGroupPerson.PERSON.LASTNAME;
     this.FIRSTNAME          = gymGroupPerson.PERSON.FIRSTNAME;
     this.BIRTHDATE          = gymGroupPerson.PERSON.BIRTHDATE;
     this.HOURLYRATE         = gymGroupPerson.PERSON.HOURLYRATE;
     this.KINDNAME           = gymGroupPerson.KIND.KINDNAME;
 }
Ejemplo n.º 3
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (currentChildId == 0)
            {
                MessageBox.Show("Merci de choisir avant d'enregistrer");
                return;
            }
            if (comboBoxKind.SelectedItem == null)
            {
                MessageBox.Show("Merci de choisir un type avant d'enregistrer");
                return;
            }
            PERSON_GYMGROUP person_GymGroup;

            switch (type.Name)
            {
            case "GYMGROUP":
                person_GymGroup            = new PERSON_GYMGROUP();
                person_GymGroup.PERSONID   = Convert.ToInt32(Reflection.GetValue(masterObj, "PERSONID"));
                person_GymGroup.GYMGROUPID = currentChildId;
                person_GymGroup.KINDID     = ((ComboboxItem)comboBoxKind.SelectedItem).Value;

                egoEntities.PERSON_GYMGROUP.Add(person_GymGroup);
                break;

            case "PERSON":
                person_GymGroup            = new PERSON_GYMGROUP();
                person_GymGroup.PERSONID   = currentChildId;
                person_GymGroup.GYMGROUPID = Convert.ToInt32(Reflection.GetValue(masterObj, "GYMGROUPID"));
                person_GymGroup.KINDID     = ((ComboboxItem)comboBoxKind.SelectedItem).Value;

                egoEntities.PERSON_GYMGROUP.Add(person_GymGroup);
                break;

            default:
                break;
            }
            egoEntities.SaveChanges();
            this.Dispose();
            this.Close();
        }
Ejemplo n.º 4
0
        protected object GetObjectById(int _id, bool _master, string _slaveType, string _masterType)
        {
            switch (typeof(T).Name)
            {
            case "FAMILY":
                FAMILY family = null;
                if (_id == 0)
                {
                    family = egoEntities.FAMILY.FirstOrDefault();
                }
                else
                {
                    family = egoEntities.FAMILY.FirstOrDefault(x => x.FAMILYID == _id);
                }
                return(family == null ? new FAMILY() : family);

            case "PERSON":
                PERSON person = null;
                if (_master)
                {
                    person = _id == 0 ? egoEntities.PERSON.FirstOrDefault() : egoEntities.PERSON.FirstOrDefault(x => x.PERSONID == _id);
                }
                else
                {
                    if (_masterType == "GYMGROUP")
                    {
                        PERSON_GYMGROUP person_gymGroup = new PERSON_GYMGROUP();
                        person_gymGroup = _id == 0 ? egoEntities.PERSON_GYMGROUP.FirstOrDefault() : egoEntities.PERSON_GYMGROUP.FirstOrDefault(x => x.PERSON_GYMGROUP_ID == _id);
                        return(person_gymGroup == null ? new PERSON_GYMGROUP() : person_gymGroup);
                    }
                    else if (_masterType == "FAMILY")
                    {
                        person = _id == 0 ? egoEntities.PERSON.FirstOrDefault() : egoEntities.PERSON.FirstOrDefault(x => x.PERSONID == _id);
                    }
                }
                return(person == null ? new PERSON() : person);

            case "PHONE":
                PHONE Phone = null;
                Phone = _id == 0 ? egoEntities.PHONE.FirstOrDefault() : egoEntities.PHONE.FirstOrDefault(x => x.PHONEID == _id);
                return(Phone == null ? new PHONE() : Phone);

            case "DISCOUNT":
                DISCOUNT Discount = null;
                Discount = _id == 0 ? egoEntities.DISCOUNT.FirstOrDefault() : egoEntities.DISCOUNT.FirstOrDefault(x => x.DISCOUNTID == _id);
                return(Discount == null ? new DISCOUNT() : Discount);

            case "PAYMENT":
                PAYMENT Payment = null;
                Payment = _id == 0 ? egoEntities.PAYMENT.FirstOrDefault() : egoEntities.PAYMENT.FirstOrDefault(x => x.PAYMENTID == _id);
                return(Payment == null ? new PAYMENT() : Payment);

            case "DOCUMENT":
                DOCUMENT Document = null;
                Document = _id == 0 ? egoEntities.DOCUMENT.FirstOrDefault() : egoEntities.DOCUMENT.FirstOrDefault(x => x.DOCUMENTID == _id);
                return(Document == null ? new DOCUMENT() : Document);

            case "GYMGROUP":
                if (_master)
                {
                    GYMGROUP GymGroup = null;
                    GymGroup = _id == 0 ? egoEntities.GYMGROUP.FirstOrDefault() : egoEntities.GYMGROUP.FirstOrDefault(x => x.GYMGROUPID == _id);
                    return(GymGroup == null ? new GYMGROUP() : GymGroup);
                }
                else
                {
                    PERSON_GYMGROUP Person_GymGroup = new PERSON_GYMGROUP();
                    Person_GymGroup = _id == 0 ? egoEntities.PERSON_GYMGROUP.FirstOrDefault() : egoEntities.PERSON_GYMGROUP.First(x => x.PERSON_GYMGROUP_ID == _id);
                    return(Person_GymGroup == null ? new PERSON_GYMGROUP() : Person_GymGroup);
                }
            }

            return(null);
        }
Ejemplo n.º 5
0
        private static void CreatePerson(List <ExcelModel> _ExcelModel, EGOEntities _EGOEntities, FrmSetting _FrmSetting)
        {
            _FrmSetting.progressBar.Value   = 0;
            _FrmSetting.progressBar.Maximum = _ExcelModel.Count;
            int i = 0;

            try
            {
                foreach (var ExcelModel in _ExcelModel)
                {
                    i++;
                    _FrmSetting.label1.Text = "Création de l'adhérent:" + ExcelModel.NOM + " " + ExcelModel.PRENOM + i + "/" + _ExcelModel.Count;
                    _FrmSetting.label1.Refresh();
                    _FrmSetting.progressBar.Value = i;
                    _FrmSetting.progressBar.Refresh();

                    FAMILY Family;
                    if (!_EGOEntities.FAMILY.Any(x => x.LASTNAME == ExcelModel.NOM && x.ZIPCODE == ExcelModel.CP))
                    {
                        Family = CreateFamily(ExcelModel, _EGOEntities);
                    }
                    else
                    {
                        Family = _EGOEntities.FAMILY.First(x => x.LASTNAME == ExcelModel.NOM && x.ZIPCODE == ExcelModel.CP);
                    }

                    PERSON Person = new PERSON();
                    Person.FAMILYID   = Family.FAMILYID;
                    Person.LASTNAME   = ExcelModel.NOM.ToUpper();
                    Person.FIRSTNAME  = ExcelModel.PRENOM.ToUpper();
                    Person.BIRTHDATE  = ExcelModel.NEELE;
                    Person.HOURLYRATE = 0;

                    _EGOEntities.PERSON.Add(Person);

                    GYMGROUP GymGroup;
                    if (!_EGOEntities.GYMGROUP.Any(x => x.GYMGROUPNAME == ExcelModel.GROUPE))
                    {
                        GymGroup = CreateGymGroup(ExcelModel, _EGOEntities);
                    }
                    else
                    {
                        GymGroup = _EGOEntities.GYMGROUP.First(x => x.GYMGROUPNAME == ExcelModel.GROUPE);
                    }

                    PERSON_GYMGROUP Person_GymGroup = new PERSON_GYMGROUP();
                    Person_GymGroup.GYMGROUPID = GymGroup.GYMGROUPID;
                    Person_GymGroup.PERSONID   = Person.PERSONID;
                    Person_GymGroup.KINDID     = 1;

                    _EGOEntities.PERSON_GYMGROUP.Add(Person_GymGroup);

                    if (!_EGOEntities.PHONE.Any(x => x.FAMILYID == Family.FAMILYID && x.PHONENUMBER == ExcelModel.TELEPHONE))
                    {
                        PHONE Phone = new PHONE();
                        Phone.FAMILYID    = Family.FAMILYID;
                        Phone.PHONENUMBER = ExcelModel.TELEPHONE;
                        _EGOEntities.PHONE.Add(Phone);
                    }

                    if (!_EGOEntities.PHONE.Any(x => x.FAMILYID == Family.FAMILYID && x.PHONENUMBER == ExcelModel.PORTABLE))
                    {
                        PHONE Phone = new PHONE();
                        Phone.FAMILYID    = Family.FAMILYID;
                        Phone.PHONENUMBER = ExcelModel.PORTABLE;
                        _EGOEntities.PHONE.Add(Phone);
                    }

                    DOCUMENT Document;
                    if (ExcelModel.FICHE)
                    {
                        Document = new DOCUMENT();
                        Document.DOCUMENTTYPEID = 1;
                        Document.PERSONID       = Person.PERSONID;
                        Document.DOCUMENTYEAR   = Common.CurrentStartYear();
                        _EGOEntities.DOCUMENT.Add(Document);
                    }
                    if (ExcelModel.AUTPAR)
                    {
                        Document = new DOCUMENT();
                        Document.DOCUMENTTYPEID = 2;
                        Document.PERSONID       = Person.PERSONID;
                        Document.DOCUMENTYEAR   = Common.CurrentStartYear();
                        _EGOEntities.DOCUMENT.Add(Document);
                    }
                    if (ExcelModel.PHOTO)
                    {
                        Document = new DOCUMENT();
                        Document.DOCUMENTTYPEID = 3;
                        Document.PERSONID       = Person.PERSONID;
                        Document.DOCUMENTYEAR   = Common.CurrentStartYear();
                        _EGOEntities.DOCUMENT.Add(Document);
                    }
                    if (ExcelModel.CM)
                    {
                        Document = new DOCUMENT();
                        Document.DOCUMENTTYPEID = 4;
                        Document.PERSONID       = Person.PERSONID;
                        Document.DOCUMENTYEAR   = Common.CurrentStartYear();
                        _EGOEntities.DOCUMENT.Add(Document);
                    }

                    PAYMENT Payment;
                    if (ExcelModel.ECH1MONTANT != 0)
                    {
                        Payment = new PAYMENT();
                        if (ExcelModel.ECH1NUMCHEQUE != 0)
                        {
                            Payment.PAYMENTTYPEID = 2;
                        }
                        else
                        {
                            Payment.PAYMENTTYPEID = 1;
                        }
                        Payment.FAMILYID    = Family.FAMILYID;
                        Payment.GYMYEAR     = Common.CurrentStartYear();
                        Payment.PAYMENTDATE = DateTime.ParseExact("30/09/2020", "dd/MM/yyyy", CultureInfo.InvariantCulture);
                        Payment.CHECKNUMBER = ExcelModel.ECH1NUMCHEQUE;
                        Payment.AMOUNT      = ExcelModel.ECH1MONTANT;
                        _EGOEntities.PAYMENT.Add(Payment);
                    }
                    if (ExcelModel.ECH2MONTANT != 0)
                    {
                        Payment = new PAYMENT();
                        if (ExcelModel.ECH2NUMCHEQUE != 0)
                        {
                            Payment.PAYMENTTYPEID = 2;
                        }
                        else
                        {
                            Payment.PAYMENTTYPEID = 1;
                        }
                        Payment.FAMILYID    = Family.FAMILYID;
                        Payment.GYMYEAR     = Common.CurrentStartYear();
                        Payment.PAYMENTDATE = DateTime.ParseExact("30/11/2020", "dd/MM/yyyy", CultureInfo.InvariantCulture);
                        Payment.CHECKNUMBER = ExcelModel.ECH2NUMCHEQUE;
                        Payment.AMOUNT      = ExcelModel.ECH2MONTANT;
                        _EGOEntities.PAYMENT.Add(Payment);
                    }
                    if (ExcelModel.ECH3MONTANT != 0)
                    {
                        Payment = new PAYMENT();
                        if (ExcelModel.ECH3NUMCHEQUE != 0)
                        {
                            Payment.PAYMENTTYPEID = 2;
                        }
                        else
                        {
                            Payment.PAYMENTTYPEID = 1;
                        }
                        Payment.FAMILYID    = Family.FAMILYID;
                        Payment.GYMYEAR     = Common.CurrentStartYear();
                        Payment.PAYMENTDATE = DateTime.ParseExact("28/02/2021", "dd/MM/yyyy", CultureInfo.InvariantCulture);
                        Payment.CHECKNUMBER = ExcelModel.ECH3NUMCHEQUE;
                        Payment.AMOUNT      = ExcelModel.ECH3MONTANT;
                        _EGOEntities.PAYMENT.Add(Payment);
                    }
                    if (ExcelModel.ECH4MONTANT != 0)
                    {
                        Payment = new PAYMENT();
                        if (ExcelModel.ECH4NUMCHEQUE != 0)
                        {
                            Payment.PAYMENTTYPEID = 2;
                        }
                        else
                        {
                            Payment.PAYMENTTYPEID = 1;
                        }
                        Payment.FAMILYID    = Family.FAMILYID;
                        Payment.GYMYEAR     = Common.CurrentStartYear();
                        Payment.PAYMENTDATE = DateTime.ParseExact("30/04/2021", "dd/MM/yyyy", CultureInfo.InvariantCulture);
                        Payment.CHECKNUMBER = ExcelModel.ECH4NUMCHEQUE;
                        Payment.AMOUNT      = ExcelModel.ECH4MONTANT;
                        _EGOEntities.PAYMENT.Add(Payment);
                    }
                    if (ExcelModel.COTISLICENCE != 0)
                    {
                        Payment = new PAYMENT();

                        Payment.PAYMENTTYPEID = 2;
                        Payment.FAMILYID      = Family.FAMILYID;
                        Payment.GYMYEAR       = Common.CurrentStartYear();
                        Payment.PAYMENTDATE   = DateTime.ParseExact("28/09/2020", "dd/MM/yyyy", CultureInfo.InvariantCulture);
                        Payment.CHECKNUMBER   = ExcelModel.ECH4NUMCHEQUE;
                        Payment.AMOUNT        = ExcelModel.COTISLICENCE;
                        _EGOEntities.PAYMENT.Add(Payment);
                    }

                    if (!ExcelModel.Nouvelle)
                    {
                        DISCOUNT Discount = new DISCOUNT();
                        Discount.FAMILYID     = Family.FAMILYID;
                        Discount.DISCOUNTYEAR = Common.CurrentStartYear();
                        Discount.DESCRIPTION  = "Cotisation";
                        Discount.AMOUNT       = 35;

                        _EGOEntities.DISCOUNT.Add(Discount);

                        Discount              = new DISCOUNT();
                        Discount.FAMILYID     = Family.FAMILYID;
                        Discount.DISCOUNTYEAR = Common.CurrentStartYear();
                        Discount.DESCRIPTION  = "Ancienneté";
                        Discount.AMOUNT       = ExcelModel.REDUCANCIEN;

                        _EGOEntities.DISCOUNT.Add(Discount);
                    }

                    _EGOEntities.SaveChanges();
                }

                _FrmSetting.label1.Text = "Création des réductions familiales";
                CreateFamilyDiscount(_EGOEntities);
                _EGOEntities.SaveChanges();
                _FrmSetting.label1.Text       = "Fin";
                _FrmSetting.progressBar.Value = 0;
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }