Example #1
0
        void button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Construction du menu relatif à la fonction du UserConnecte
                Image b = sender as Image;
                //Button b = sender as Button;
                Module = b.Name;
                AuthentInitializeServiceClient client = new AuthentInitializeServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Initialisation"));
                // MessageBox.Show(Module);
                client.GetMenuDuRoleCompleted += (senders, arg) =>
                {
                    if (arg.Cancelled || arg.Error != null)
                    {
                        Message.Show("Error occurs while processing request ! ", Galatee.Silverlight.Resources.Langue.errorTitle);
                        return;
                        //
                    }

                    dico = arg.Result;

                    if (dico.Count == 0 || dico == null)
                    {
                        Message.Show("Aucun module trouvé " + " " + "Payement module", Galatee.Silverlight.Resources.Langue.errorTitle);
                        return;
                    }
                    else
                    {
                        if (Module == "Caisse")
                        {
                            /// appel menu galatee
                            ///
                            CaisseServiceClient clt = new CaisseServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Caisse"));
                            clt.VerifieEtatCaisseCompleted += (xx, args) =>
                            {
                                try
                                {
                                    if (args.Cancelled || args.Error != null)
                                    {
                                        Message.Show("Error occurs while processing request !", Galatee.Silverlight.Resources.Langue.errorTitle);
                                        return;
                                        //
                                    }
                                    EtatCaisse = args.Result;
                                    if (EtatCaisse == SessionObject.Enumere.EtatDeCaissePasCassier)
                                    {
                                        // Charger le controle de choix de la caisse
                                        FrmCreeCaisse frm = new FrmCreeCaisse();
                                        frm.success += new EventHandler(ConnexionSuccess);
                                        frm.Show();
                                    }
                                    else if (EtatCaisse == SessionObject.Enumere.EtatDeCaisseDejaCloture)
                                    {
                                        Message.Show(Galatee.Silverlight.Resources.Caisse.Langue.MsgCaisseDejaFerme, Galatee.Silverlight.Resources.Langue.errorTitle);
                                        return;
                                    }
                                    else if (EtatCaisse == SessionObject.Enumere.EtatDeCaisseAutreSessionOuvert)
                                    {
                                        Message.ShowWarning("Vous avez ouvert une caisse sur un autre poste " + "\n\r" + "Veuillez la clôturer", "Caisse");
                                        return;
                                    }

                                    else if (EtatCaisse == SessionObject.Enumere.EtatDeCaisseAutreUserSurCaisse)
                                    {
                                        Message.ShowWarning("Un autre utilisateur a une session en cours sur cette caisse " + "\n\r" + "Veuillez consulter l'administrateur", "Caisse");
                                        return;
                                    }

                                    else if (EtatCaisse == SessionObject.Enumere.EtatDeCaisseOuverteALaDemande)
                                    {
                                        Message.Show(Galatee.Silverlight.Resources.Caisse.Langue.MsgCaisseOuverteAlaDemande, Galatee.Silverlight.Resources.Langue.errorTitle);
                                    }

                                    //SessionObject.CaisseOverte = CaisseOverte;
                                    //if (!string.IsNullOrEmpty(CaisseOverte.Caissiere))
                                    //{
                                    //    DialogResult diag = new DialogResult("The day of  as been openned for you . \n Please correct the <<" + CaisseOverte.Raison + ">> and close that day", false, true, false);
                                    //    diag.Closed += new EventHandler(diag_Closed);
                                    //    diag.Show();

                                    //    // new DialogResult("Wrong parameters", false).Show();
                                    //    MessageBox.Show();//, "Payement modul");//, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    //    return;
                                    //}


                                    RefreshMenuBar();
                                    MenuViewModel viewModel = new MenuViewModel(_mainPage, dico, "Galatee.Silverlight." + Module, Module);
                                    viewModelG = viewModel;

                                    if (!IsRefreh)
                                    {
                                        _mainPage.DataContext = viewModelG;

                                        IsRefreh = true;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Message.Show(ex, "Module Caisse");
                                }
                            };
                            clt.VerifieEtatCaisseAsync(UserConnecte.matricule, SessionObject.LePosteCourant.FK_IDCAISSE.Value);
                        }

                        else // si le matricule ne correspond pas à celui d'une caissiere
                        {
                            /// Peupler les menus du module select
                            try
                            {
                                RefreshMenuBar();
                                MenuViewModel viewModel = new MenuViewModel(_mainPage, dico, "Galatee.Silverlight." + Module, Module);
                                viewModelG = viewModel;

                                if (!IsRefreh)
                                {
                                    _mainPage.DataContext = viewModelG;

                                    IsRefreh = true;
                                }
                            }
                            catch (Exception ex)
                            {
                                Message.Show(ex, "Module Caisse");
                            }
                        }
                    }
                };
                client.GetMenuDuRoleAsync(UserConnecte.FK_IDFONCTION, Module);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }