private void DeleteCompteur(CsCompteurBta listForCompteur)
        {
            try
            {
                var service = new IScelleServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Scelles"));

                if (listForCompteur != null)
                {
                    service.DeleteCompteurCompleted += (snder, UpdateR) =>
                    {
                        if (UpdateR.Cancelled ||
                            UpdateR.Error != null)
                        {
                            Message.ShowError(UpdateR.Error.Message, Languages.EtatDuCompteur);
                            return;
                        }
                        if (UpdateR.Result == false)
                        {
                            Message.ShowError(Languages.ErreurMiseAJourDonnees, Languages.EtatDuCompteur);
                            return;
                        }
                        else
                        {
                        }
                    };
                    service.DeleteCompteurAsync(listForCompteur);
                }
            }

            catch (Exception ex)
            {
                Message.Show(ex.Message, Languages.Commune);
            }
        }
Exemplo n.º 2
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (DonnesDatagrid.Count == 0)
                {
                    throw new Exception(Languages.AucuneDonneeASupprimer);
                }
                if (dtgrdParametre.SelectedItems.Count > 0)
                {
                    var messageBox = new MessageBoxControl.MessageBoxChildWindow(Languages.LibelleReceptionScelle, Languages.QuestionSuppressionDonnees, MessageBoxControl.MessageBoxButtons.YesNo, MessageBoxControl.MessageBoxIcon.Question);
                    messageBox.OnMessageBoxClosed += (_, result) =>
                    {
                        if (messageBox.Result == MessageBoxResult.OK)
                        {
                            if (dtgrdParametre.SelectedItem != null)
                            {
                                var selected = dtgrdParametre.SelectedItem as CsCompteurBta;

                                if (selected != null)
                                {
                                    IScelleServiceClient delete = new IScelleServiceClient(Utility.Protocole(),
                                                                                           Utility.EndPoint("Scelles"));
                                    delete.DeleteCompteurCompleted += (del, argDel) =>
                                    {
                                        if (argDel.Cancelled || argDel.Error != null)
                                        {
                                            Message.ShowError(argDel.Error.Message, Languages.LibelleReceptionScelle);
                                            return;
                                        }

                                        if (argDel.Result == false)
                                        {
                                            Message.ShowError(Languages.ErreurSuppressionDonnees, Languages.LibelleReceptionScelle);
                                            return;
                                        }
                                        DonnesDatagrid.Remove(selected);
                                    };
                                    delete.DeleteCompteurAsync(selected);
                                }
                            }
                        }
                        else
                        {
                            return;
                        }
                    };
                    messageBox.Show();
                }
                else
                {
                    throw new Exception(Languages.SelectionnerUnElement);
                }
            }
            catch (Exception ex)
            {
                Message.ShowError(ex.Message, Languages.LibelleCodeDepart);
            }
        }
        private void DeleteCompteur(CsCompteurBta listForCompteur)
        {
            try
            {
                var service = new IScelleServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Scelles"));

                if (listForCompteur != null)
                {
                    service.DeleteCompteurCompleted += (snder, UpdateR) =>
                    {
                        if (UpdateR.Cancelled ||
                            UpdateR.Error != null)
                        {
                            Message.ShowError(UpdateR.Error.Message, Languages.EtatDuCompteur);
                            return;
                        }
                        if (UpdateR.Result == false)
                        {
                            Message.ShowError(Languages.ErreurMiseAJourDonnees, Languages.EtatDuCompteur);
                            return;
                        }
                        else
                        {
                            //Message.ShowInformation("Compteur modifié avec succès", Languages.EtatDuCompteur);
                            //RazEcran();
                            //SelectAllCompteurNonAffecte();
                            //return;
                        }
                        //OnEvent(null);
                        //DialogResult = true;
                    };
                    service.DeleteCompteurAsync(listForCompteur);
                }
            }

            catch (Exception ex)
            {
                Message.Show(ex.Message, Languages.Commune);
            }
        }