private void CBX_Localisation_SelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBox CBX = sender as ComboBox; if (CBX != null) { T_E_PROSPECT_PRO prospect = (CBX.SelectedItem as T_E_PROSPECT_PRO); if (prospect != null) { List <T_E_CONTACT_CTC> listeContact = Database.MegeCastingDatabase.Current.T_E_CONTACT_CTC.list().Where(x => x.PRO_ID == prospect.PRO_ID).ToList(); this.CBX_Contact.ItemsSource = listeContact; if (Model.StoreObject.CTC_ID != 0) { List <T_E_CONTACT_CTC> Contacttest = listeContact.Where(x => x.CTC_ID == Model.StoreObject.CTC_ID).ToList(); if (Contacttest != null && Contacttest.Count > 0) { CBX_Contact.SelectedItem = Contacttest.First(); } else { Model.StoreObject.CTC_ID = 0; } } } } }
public ProspectEdit(T_E_PROSPECT_PRO _Prospect = null) { InitializeComponent(); Model = new ProspectEditModel(_Prospect); this.DataContext = Model; Model.Content = new RelatedListe <T_E_CONTACT_CTC>(Model.StoreObject.PRO_ID); GridContact.Children.Add(Model.Content); List <T_R_STATUT_JURIDIQUE_JUR> listestatut = Database.MegeCastingDatabase.Current.T_R_STATUT_JURIDIQUE_JUR.list(); this.CBX_Statut.ItemsSource = listestatut; NumberRule1.IsObligated = isClientSwitch.IsChecked.Value; NumberRule2.IsObligated = isClientSwitch.IsChecked.Value; TextRule3.IsObligated = isClientSwitch.IsChecked.Value; TextRule4.IsObligated = isClientSwitch.IsChecked.Value; TextRule5.IsObligated = isClientSwitch.IsChecked.Value; TextRule1.IsObligated = isPartenaireSwitch.IsChecked.Value; TextRule2.IsObligated = isPartenaireSwitch.IsChecked.Value; if (_Prospect.PAR_LOGIN != "" && _Prospect.PAR_LOGIN != null) { Model.partenaire = Database.MegeCastingDatabase.Current.T_H_PARTENAIRES_PAR.get(_Prospect.PRO_ID); TBX_PAR_LOGIN.Text = Model.partenaire.PAR_LOGIN; TBX_PAR_MDP.Text = Model.partenaire.PAR_MDP; } if (_Prospect.CLI_RNA != 0 && _Prospect.CLI_RNA != null) { Model.Client = Database.MegeCastingDatabase.Current.T_H_CLIENT_CLI.get(_Prospect.PRO_ID); Model.addresse = Database.MegeCastingDatabase.Current.T_E_ADRESSE_ADR.get(Model.Client.ADR_ID); TBX_CLI_RNA.Text = Model.Client.CLI_RNA.ToString(); TBX_CLI_SIRET.Text = Model.Client.CLI_SIRET.ToString(); CBX_Statut.SelectedItem = listestatut.Where(x => x.JUR_ID == Model.Client.JUR_ID); TBX_ADR_LIBELLE_RUE.Text = Model.addresse.ADR_LIBELLE_RUE; TBX_ADR_NUM_VOIE.Text = Model.addresse.ADR_NUM_VOIE; TBX_ADR_VILLE.Text = Model.addresse.ADR_NUM_VOIE; } }