예제 #1
0
        private void btnCreer_CheckedChanged(object sender, EventArgs e)
        {
            //CreatekoloUsersBindingSource.DataSource = new KoloUser();
            //CreatekoloUsersBindingSource.ResetBindings(false);

            try
            {
                var newUser = CreatekoloUsersBindingSource.Current as KoloUser;



                if (newUser == null)
                {
                    MessageBox.Show("veuillez remplir tous les case");
                    CreatekoloUsersBindingSource.DataSource = new KoloUser();
                    CreatekoloUsersBindingSource.ResetBindings(true);
                }
                else
                {
                    KoloContextHelper.Context.AddToKoloUsers(newUser);
                    KoloContextHelper.Context.SaveChanges();
                    CreatekoloUsersBindingSource.ResetBindings(false);
                    MessageBox.Show("Created");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        private void KoloUserForm_Load(object sender, EventArgs e)
        {
            var koloUser = new KoloUser()
            {
                Person = new Person()
            };

            var koloUser1 = new KoloUser();

            koloUser1.Person = new Person();


            koloUsersBindingSource.DataSource = koloUser;
            koloUsersBindingSource.ResetBindings(false);

            CreatekoloUsersBindingSource.DataSource = koloUser1;
            CreatekoloUsersBindingSource.ResetBindings(false);

            countriesBindingSource.DataSource = new Country();
            var UserCountry = Context.Countries.ToList();

            countriesBindingSource.DataSource = UserCountry;
            countriesBindingSource.ResetBindings(false);

            citiesBindingSource.DataSource = new City();
            var UserCity = Context.Cities.ToList();

            citiesBindingSource.DataSource = UserCity;
            citiesBindingSource.ResetBindings(false);

            refGendersBindingSource.DataSource = new RefGender();
            var UserGender = Context.RefGenders.ToList();

            refGendersBindingSource.DataSource = UserGender;
            refGendersBindingSource.ResetBindings(false);

            refMaritalStatusBindingSource.DataSource = new RefMaritalStatu();
            var UserMaritalStatus = Context.RefMaritalStatus.ToList();

            refMaritalStatusBindingSource.DataSource = UserMaritalStatus;
            refMaritalStatusBindingSource.ResetBindings(false);


            KoloContextHelper.Context = new KoloGateway.KoloEntities(KoloUri);
        }