private void Decharger_Click(object sender, RoutedEventArgs e)
 {
     if (Rdb_RmScelle.IsChecked == true)
     {
         ObjetSelectionneScelle = dgRemis.SelectedItem as CsScelle;
         if (txtNombredeScelle.Text != "" && ObjetSelectionneScelle != null)
         {
             int lot = int.Parse(txtNombredeScelle.Text.Trim());
             lot = lot - 1;
             txtNombredeScelle.Text = lot.ToString();
         }
         Galatee.Silverlight.Shared.CommonMethode.TransfertDataGrid <CsScelle>(dgRemis, dgScelle);
     }
     else
     {
         ObjetSelectionneLot = dgRemiselot.SelectedItem as CsTbLot;
         if (txtNombredeScelle.Text != "" && ObjetSelectionneLot != null)
         {
             int lot       = int.Parse(txtNombredeScelle.Text);
             int nomscelle = (int)ObjetSelectionneLot.Nombre_scelles_reçu;
             lot = nomscelle - lot;
             txtNombredeScelle.Text = lot.ToString();
         }
         Galatee.Silverlight.Shared.CommonMethode.TransfertDataGrid <CsTbLot>(dgRemiselot, dgLotScelle);
     }
 }
 public bool UpdateScelleStatut(CsScelle sScelle)
 {
     try
     {
         return(new DBScelle().Update(sScelle));
     }
     catch (Exception ex)
     {
         ErrorManager.LogException(this, ex);
         return(false);
     }
 }
 private void chargerTout_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (Rdb_RmScelle.IsChecked == true)
         {
             dgRemis.ItemsSource    = null;
             dgRemis.ItemsSource    = donnesDatagridScelle.OrderBy(c => c.NUM_SCELLE).ToList();
             dgScelle.ItemsSource   = null;
             ObjetSelectionneScelle = dgLotScelle.SelectedItem as CsScelle;
             foreach (CsScelle item in donnesDatagridScelle)
             {
                 if (txtNombredeScelle.Text != "")
                 {
                     int lot = int.Parse(txtNombredeScelle.Text.Trim());
                     lot = lot + 1;
                     txtNombredeScelle.Text = lot.ToString();
                 }
                 else
                 {
                     txtNombredeScelle.Text = "1";
                 }
             }
         }
         else
         {
             dgRemis.ItemsSource     = null;
             dgRemiselot.ItemsSource = DonnesDatagridLot.OrderBy(c => c.Numero_depart).ToList();
             dgLotScelle.ItemsSource = null;
             foreach (CsTbLot item in DonnesDatagridLot)
             {
                 if (txtNombredeScelle.Text != "")
                 {
                     int lot = int.Parse(txtNombredeScelle.Text.Trim()) != 0?int.Parse(txtNombredeScelle.Text.Trim()):0;
                     lot = (int)item.Nombre_scelles_reçu + lot;
                     txtNombredeScelle.Text = lot.ToString();
                 }
                 else
                 {
                     txtNombredeScelle.Text = "0";
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private void Charger_Click(object sender, RoutedEventArgs e)
        {
            if (Rdb_RmScelle.IsChecked == true)
            {
                ObjetSelectionneScelle = dgScelle.SelectedItem as CsScelle;
                if (dgRemiselot.Visibility == System.Windows.Visibility.Visible)
                {
                    if (dgRemiselot.ItemsSource != null)
                    {
                        txtNombredeScelle.Text = ((List <CsTbLot>)dgRemiselot.ItemsSource).Count.ToString();
                    }
                }
                else if (dgRemis.Visibility == System.Windows.Visibility.Visible)
                {
                    if (dgRemis.ItemsSource != null)
                    {
                        txtNombredeScelle.Text = ((List <CsScelle>)dgRemis.ItemsSource).Count.ToString();
                    }
                }
                if (chb_SaisiNombreScelleSouhaite.IsChecked == true)
                {
                    if (!string.IsNullOrWhiteSpace(txt_NombreScellesSouhaite.Text))
                    {
                        //on recupere le nmbre selectionné ,soit x
                        int NombreDeScelleSouhaiter = 0;
                        if (int.TryParse(txt_NombreScellesSouhaite.Text, out NombreDeScelleSouhaiter))
                        {
                            if (NombreDeScelleSouhaiter > 0)
                            {
                                var DataSourcedgScelle = ((List <CsScelle>)dgScelle.ItemsSource);
                                var DataSourcedgRemis  = ((List <CsScelle>)dgRemis.ItemsSource);

                                var ElementAAffecter     = DataSourcedgScelle.Take(NombreDeScelleSouhaiter);
                                var ListElementAAffecter = ElementAAffecter != null?ElementAAffecter.ToList() : null;

                                ListElementAAffecter.AddRange(DataSourcedgRemis != null?DataSourcedgRemis.ToList():new List <CsScelle>());

                                if (ListElementAAffecter != null)
                                {
                                    dgRemis.ItemsSource = null;
                                    dgRemis.ItemsSource = ListElementAAffecter.OrderBy(c => c.NUM_SCELLE).ToList();

                                    var ElementRestantAAffecter = DataSourcedgScelle.Where(s => !ListElementAAffecter.Contains(s));
                                    dgScelle.ItemsSource = null;
                                    dgScelle.ItemsSource = ElementRestantAAffecter.OrderBy(c => c.NUM_SCELLE).ToList();
                                    return;
                                }
                                else
                                {
                                    Message.ShowWarning("Aucun éléments affecté", "Information");
                                    return;
                                }
                            }
                            else
                            {
                                Message.ShowWarning("Veuillez saisir une valeur supperieur à 0", "Information");
                                return;
                            }
                        }
                        else
                        {
                            Message.ShowWarning("Veuillez saisir une valeur numérique", "Information");
                            return;
                        }
                    }
                    else
                    {
                        Message.ShowWarning("Veuillez saisir le nombre de scelles souhaité", "Information");
                        return;
                    }
                }
                Galatee.Silverlight.Shared.CommonMethode.TransfertDataGrid <CsScelle>(dgScelle, dgRemis);
            }
            else
            {
                ObjetSelectionneLot = dgLotScelle.SelectedItem as CsTbLot;
                if (ObjetSelectionneLot != null)
                {
                    if (txtNombredeScelle.Text != "")
                    {
                        int lot = int.Parse(txtNombredeScelle.Text);
                        lot = (int)ObjetSelectionneLot.Nombre_scelles_reçu + lot;
                        txtNombredeScelle.Text = lot.ToString();
                    }
                    else
                    {
                        txtNombredeScelle.Text = ObjetSelectionneLot.Nombre_scelles_reçu.ToString();
                    }
                }
                Galatee.Silverlight.Shared.CommonMethode.TransfertDataGrid <CsTbLot>(dgLotScelle, dgRemiselot);
            }
        }