示例#1
0
        public Contact NouveauContact()
        {
            if (this.contact == null)
            {
                this.contact = new Contact();
            }

            List <Donnee> donnees;

            contact.setIduser(template.getIduser());
            contact.setDtcreation(DateTime.Now);
            contact.setFavoris(false);
            contact.setActif(true);

            donnees = new List <Donnee>();

            foreach (Control ctrl in this.panel1.Controls)
            {
                if (ctrl.Tag != null && ctrl.Tag.GetType() == typeof(Champ))
                {
                    Champ c = (Champ)ctrl.Tag;

                    Donnee d = new Donnee();
                    d.setIdchamp(c.getIdchamp());

                    if (ctrl.GetType() == typeof(DateTimePicker))
                    {
                        if ((((DateTimePicker)ctrl).Value.ToShortDateString() != DateTime.Now.ToShortDateString()))
                        {
                            d.setValeur(((DateTimePicker)ctrl).Value.ToString("yyyy-MM-dd"));
                        }
                        else
                        {
                            d.setValeur(null);
                        }
                    }
                    else
                    {
                        d.setValeur(ctrl.Text);
                    }

                    donnees.Add(d);
                }
            }

            contact.setDonnees(donnees);
            return(contact);
        }