private void txtRecherche_TextChanged(object sender, TextChangedEventArgs e)
 {
     try {
         TextBox         t      = (TextBox)sender;
         string          filter = t.Text;
         ICollectionView cv     = CollectionViewSource.GetDefaultView(FournDataGrid.ItemsSource);
         if (filter == "")
         {
             cv.Filter = null;
         }
         else
         {
             cv.Filter = o =>
             {
                 SVC.ProduitOrdonnance p = o as SVC.ProduitOrdonnance;
                 if (t.Name == "txtId")
                 {
                     return(p.Id == Convert.ToInt32(filter));
                 }
                 return(p.Design.ToUpper().StartsWith(filter.ToUpper()));
             };
         }
     }
     catch (Exception ex)
     {
         MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show(ex.Message, Medicus.Properties.Resources.SiteWeb, MessageBoxButton.OK, MessageBoxImage.Stop);
     }
 }
        private void btnImport_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (MemberUser.CréationDossierPatient == true)
                {
                    OpenFileDialog openfile = new OpenFileDialog();
                    openfile.DefaultExt = ".txt";
                    openfile.Filter     = "(.txt)|*.txt";

                    var browsefile = openfile.ShowDialog();

                    if (browsefile == true)
                    {
                        string[] lines = File.ReadAllLines(openfile.FileName);



                        List <SVC.ProduitOrdonnance> dt = new List <SVC.ProduitOrdonnance>();
                        for (int i = 0; i < lines.Length; i++)
                        {
                            string v1 = lines[i].Substring(0, 5);


                            string v2 = lines[i].Substring(5, 49);

                            string v3 = lines[i].Substring(55, 49);

                            string v4 = lines[i].Substring(105, 30);

                            string v5 = lines[i].Substring(135, 20);

                            string v6 = lines[i].Substring(155, 21);
                            SVC.ProduitOrdonnance dr = new SVC.ProduitOrdonnance
                            {
                                CodeCnas      = Convert.ToInt32(v1),
                                Design        = v2,
                                dci           = v3,
                                Dosage        = v4,
                                UnitéDeMesure = v5,
                                Colisage      = v6,
                                Remarques     = "Mise à jours automatique",
                            };
                            dt.Add(dr);
                        }

                        FournDataGrid.ItemsSource = dt;
                        FournDataGrid.DataContext = dt;
                    }
                }
            }
            catch //(Exception ex)
            {
                MessageBoxResult resul03 = Xceed.Wpf.Toolkit.MessageBox.Show(Medicus.Properties.Resources.OperationSuccées, Medicus.Properties.Resources.SiteWeb, MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
 private void FournDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     try {
         if (MemberUser.ModificationAchat == true && FournDataGrid.SelectedItem != null)
         {
             SVC.ProduitOrdonnance    selectproduit = FournDataGrid.SelectedItem as SVC.ProduitOrdonnance;
             AjouterProduitOrdonnance cl            = new AjouterProduitOrdonnance(proxy, selectproduit, MemberUser, callback);
             cl.Show();
         }
         else
         {
             MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show("Vous ne pouvez pas faire cette opération", "Medicus", MessageBoxButton.YesNo, MessageBoxImage.Question);
         }
     }
     catch (Exception ex)
     {
         MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show(ex.Message, Medicus.Properties.Resources.SiteWeb, MessageBoxButton.OK, MessageBoxImage.Stop);
     }
 }
 private void btnEdit_Click(object sender, RoutedEventArgs e)
 {
     try {
         if (MemberUser.ModificationAchat == true && FournDataGrid.SelectedItem != null)
         {
             SVC.ProduitOrdonnance    selectproduit = FournDataGrid.SelectedItem as SVC.ProduitOrdonnance;
             AjouterProduitOrdonnance cl            = new AjouterProduitOrdonnance(proxy, selectproduit, MemberUser, callback);
             cl.Show();
         }
         else
         {
             MessageBoxResult resul03 = Xceed.Wpf.Toolkit.MessageBox.Show(Medicus.Properties.Resources.Opérationéchouée, Medicus.Properties.Resources.SiteWeb, MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show(ex.Message, Medicus.Properties.Resources.SiteWeb, MessageBoxButton.OK, MessageBoxImage.Stop);
     }
 }
        public void AddRefresh(SVC.ProduitOrdonnance listmembership, int oper)
        {
            try
            {
                var LISTITEM11 = FournDataGrid.ItemsSource as IEnumerable <SVC.ProduitOrdonnance>;
                List <SVC.ProduitOrdonnance> LISTITEM0 = LISTITEM11.ToList();

                if (oper == 1)
                {
                    LISTITEM0.Add(listmembership);
                }
                else
                {
                    if (oper == 2)
                    {
                        var objectmodifed = LISTITEM0.Find(n => n.Id == listmembership.Id);
                        //objectmodifed = listmembership;
                        var index = LISTITEM0.IndexOf(objectmodifed);
                        if (index != -1)
                        {
                            LISTITEM0[index] = listmembership;
                        }
                    }
                    else
                    {
                        if (oper == 3)
                        {
                            //    MessageBoxResult resultc10 = Xceed.Wpf.Toolkit.MessageBox.Show("Supp rendezvous :"+ listmembership.Id.ToString(), Medicus.Properties.Resources.SiteWeb, MessageBoxButton.OK, MessageBoxImage.Error);
                            var deleterendez = LISTITEM0.Where(n => n.Id == listmembership.Id).First();
                            LISTITEM0.Remove(deleterendez);
                        }
                    }
                }



                FournDataGrid.ItemsSource = LISTITEM0;
            }catch (Exception ex)
            {
            }
        }
        public AjouterProduitOrdonnance(SVC.ServiceCliniqueClient proxyrecu, SVC.ProduitOrdonnance spécialtiérecu, SVC.Membership membershirecu, ICallback callbackrecu)
        {
            try
            {
                InitializeComponent();

                proxy      = proxyrecu;
                special    = spécialtiérecu;
                membership = membershirecu;
                callback   = callbackrecu;


                if (special != null)
                {
                    FournVousGrid.DataContext = special;
                    List <SVC.Dci> testmedecin = proxy.GetAllDci();
                    ListeDciCombo.ItemsSource = testmedecin;
                    List <SVC.Dci> tte = testmedecin.Where(n => n.Id == special.IdDci).OrderBy(n => n.Id).ToList();
                    ListeDciCombo.SelectedItem           = tte.First();
                    créationOrdonnace                    = 0;
                    callbackrecu.InsertDciCallbackevent += new ICallback.CallbackEventHandler33(callbackDci_Refresh);
                }
                else
                {
                    special = new SVC.ProduitOrdonnance();
                    FournVousGrid.DataContext            = special;
                    ListeDciCombo.ItemsSource            = proxy.GetAllDci().OrderBy(n => n.Id);
                    btnCreer.IsEnabled                   = false;
                    créationOrdonnace                    = 1;
                    callbackrecu.InsertDciCallbackevent += new ICallback.CallbackEventHandler33(callbackDci_Refresh);
                }
                proxy.InnerDuplexChannel.Closed  += new EventHandler(InnerDuplexChannel_Closed);
                proxy.InnerDuplexChannel.Faulted += new EventHandler(InnerDuplexChannel_Faulted);
            }
            catch (Exception ex)
            {
                MessageBoxResult resultc10 = Xceed.Wpf.Toolkit.MessageBox.Show(ex.Message, Medicus.Properties.Resources.SiteWeb, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 private void btnSupp_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (MemberUser.SuppressionDossierPatient == true && FournDataGrid.SelectedItem != null)
         {
             using (var ts = new TransactionScope(TransactionScopeOption.RequiresNew))
             {
                 SVC.ProduitOrdonnance SelectMedecin = FournDataGrid.SelectedItem as SVC.ProduitOrdonnance;
                 proxy.DeleteProduitOrdonnance(SelectMedecin);
                 ts.Complete();
             }
             proxy.AjouterProduitOrdonnaceRefresh();
         }
         else
         {
             MessageBoxResult resul03 = Xceed.Wpf.Toolkit.MessageBox.Show(Medicus.Properties.Resources.Opérationéchouée, Medicus.Properties.Resources.SiteWeb, MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show(ex.Message, Medicus.Properties.Resources.SiteWeb, MessageBoxButton.OK, MessageBoxImage.Stop);
     }
 }