private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                List <CsHabilitationCaisse> listeCaisseAReverser = new List <CsHabilitationCaisse>();
                CsHabilitationCaisse        laCaisse             = new CsHabilitationCaisse();
                if (laCaisseARevereser == null)
                {
                    SessionObject.LaCaisseCourante.IsCAISSECOURANTE = true;
                    listeCaisseAReverser.Add(SessionObject.LaCaisseCourante);
                }
                else
                {
                    listeCaisseAReverser.Add(laCaisseARevereser);
                }


                if (leCaisseHabilNonReverse != null && leCaisseHabilNonReverse.Count != 0)
                {
                    listeCaisseAReverser.AddRange(leCaisseHabilNonReverse);
                }

                ValidationReversementCaisse(listeCaisseAReverser);
                this.DialogResult = true;
            }
            catch (Exception ex)
            {
                Message.ShowError(ex, Langue.errorTitle);
            }
        }
 private void RetourneCaisseNonReverser(CsHabilitationCaisse laCaisse)
 {
     try
     {
         CaisseServiceClient service = new CaisseServiceClient(Utility.ProtocoleIndex(), Utility.EndPoint("Caisse"));
         service.RetourneHabileCaisseNonReversementAsync(laCaisse);
         service.RetourneHabileCaisseNonReversementCompleted += (s, args) =>
         {
             if (args.Cancelled || args.Error != null)
             {
                 Message.ShowError("Un problème est survenu lors de la fermeture de caisse", "Information");
             }
             leCaisseHabilNonReverse = args.Result;
             if (leCaisseHabilNonReverse != null && leCaisseHabilNonReverse.Count != 0)
             {
                 this.btn_Detail.IsEnabled  = true;
                 Txt_MontantNonReverse.Text = leCaisseHabilNonReverse.Sum(t => t.ECART).Value.ToString(SessionObject.FormatMontant);
             }
             else
             {
                 this.Txt_MontantNonReverse.Text = initValue.ToString(SessionObject.FormatMontant);
             }
             RetourneReversement(laCaisse);
         };
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private void ListeDesTransactions(CsHabilitationCaisse laCaisse)
        {
            int handler = LoadingManager.BeginLoading("Traitement en cours ...");

            try
            {
                if (!string.IsNullOrWhiteSpace(TxtDateCaisse.Text))
                {
                    DateTime debut = DateTime.Today;
                    DateTime fin   = (DateTime.Today.AddDays(1));

                    CaisseServiceClient proxy = new CaisseServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Caisse"));
                    proxy.LitseDesTransactionAsync(laCaisse);
                    proxy.LitseDesTransactionCompleted += (senders, results) =>
                    {
                        if (results.Cancelled || results.Error != null)
                        {
                            string error = results.Error.Message;
                            MessageBox.Show("errror occurs while calling remote method", "ReportListeEncaissements", MessageBoxButton.OK);
                            return;
                        }
                        if (results.Result == null || results.Result.Count == 0)
                        {
                            Message.ShowInformation("Aucune donnée trouvée", "Caisse");
                            return;
                        }

                        List <ServiceCaisse.CsLclient> dataTable = new List <ServiceCaisse.CsLclient>();
                        List <ServiceCaisse.CsLclient> tri       = new List <ServiceCaisse.CsLclient>();
                        dataTable.AddRange(results.Result);

                        tri   = results.Result.OrderBy(t => t.DTRANS).ToList();
                        debut = tri[0].DTRANS.Value;
                        fin   = tri[tri.Count - 1].DTRANS.Value;


                        Dictionary <string, string> param = new Dictionary <string, string>();
                        param.Add("pUser", !string.IsNullOrWhiteSpace(SessionObject.LaCaisseCourante.MATRICULE) ? "Matricule : " + SessionObject.LaCaisseCourante.NOMCAISSE  : "Matricule :Aucun");
                        param.Add("pDateDebut", "Date debut : " + debut);
                        param.Add("pDateFin", "Date fin : " + fin);

                        string key = Utility.getKey();
                        Utility.ActionDirectOrientation <ServicePrintings.CsLclient, ServiceCaisse.CsLclient>(dataTable, param, SessionObject.CheminImpression, "ListeDesTransactions".Trim(), "Caisse".Trim(), true);
                        LoadingManager.EndLoading(handler);
                    };
                }
                else
                {
                    Message.Show("Veuillez choisir un utilisateur et réessayer svp! ", "Information");
                    LoadingManager.EndLoading(handler);
                }
            }
            catch (Exception ex)
            {
                LoadingManager.EndLoading(handler);
            }
            finally
            {
            }
        }
        private void ChargerHabilitationCaisse()
        {
            CaisseServiceClient service = new CaisseServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Caisse"));

            service.RetouneLaCaisseCouranteAsync(UserConnecte.matricule);
            service.RetouneLaCaisseCouranteCompleted += (sender, es) =>
            {
                try
                {
                    if (es.Cancelled || es.Error != null)
                    {
                        Message.ShowError("Erreur d'invocation du service . Veuillez réssayer svp!", Galatee.Silverlight.Resources.Langue.errorTitle);
                        this.DialogResult = true;
                    }

                    if (es.Result == null)
                    {
                        Message.ShowError("Aucune données trouvées", Langue.errorTitle);
                        return;
                    }

                    laCaisse = es.Result;
                    SessionObject.LaCaisseCourante = laCaisse;
                    ChargerControl();
                }
                catch (Exception ex)
                {
                    Message.ShowError(ex, Langue.errorTitle);
                }
            };
        }
 private void ValiderDemandeReversement(CsHabilitationCaisse laCaisse)
 {
     try
     {
         CsDemandeReversement laDemande = new CsDemandeReversement()
         {
             FK_IDHABILCAISSE = laCaisse.PK_ID,
             USERCREATION     = UserConnecte.matricule,
             DATECREATION     = System.DateTime.Now,
             DATEMODIFICATION = System.DateTime.Now,
             RAISONDEMANDE    = this.txt_RaisonDemande.Text,
             STATUT           = SessionObject.Enumere.EvenementCree
         };
         Galatee.Silverlight.ServiceCaisse.CaisseServiceClient service = new Galatee.Silverlight.ServiceCaisse.CaisseServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Caisse"));
         service.MiseAJourDemandeReversementCompleted += (s, args) =>
         {
             if (args != null && args.Cancelled)
             {
                 return;
             }
             if (args.Result == true)
             {
                 Message.ShowInformation("Demande initiée", Langue.LibelleModule);
             }
         };
         service.MiseAJourDemandeReversementAsync(laDemande, 1);
         service.CloseAsync();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private void HabiliterCaisse(CsCaisse csCaisse)
        {
            try
            {
                CsHabilitationCaisse habilitationCaisse = new CsHabilitationCaisse
                {
                    CENTRE         = csCaisse.CENTRE,
                    DATE_DEBUT     = DateTime.Now,
                    FK_IDCENTRE    = csCaisse.FK_IDCENTRE,
                    FK_IDCAISSE    = csCaisse.PK_ID,
                    MATRICULE      = UserConnecte.matricule,
                    NUMCAISSE      = csCaisse.NUMCAISSE,
                    POSTE          = SessionObject.LePosteCourant.NOMPOSTE,
                    FK_IDCAISSIERE = UserConnecte.PK_ID
                };

                //Galatee.Silverlight.ServiceCaisse.CaisseServiceClient service = new Galatee.Silverlight.ServiceCaisse.CaisseServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Caisse"));
                //service.HabiliterCaisseCompleted += (s, args) =>
                //{
                //    if (args != null && args.Cancelled)
                //        return;

                //        if (args.Result != 0)
                //            habilitationCaisse.PK_ID = args.Result;
                //     SessionObject.LaCaisseCourante  = habilitationCaisse;
                //};
                //service.HabiliterCaisseAsync(habilitationCaisse);
                //service.CloseAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void ValidationFermetureCaisse(CsHabilitationCaisse laCaisse)
        {
            CaisseServiceClient service = new CaisseServiceClient(Utility.ProtocoleIndex(), Utility.EndPoint("Caisse"));

            service.FermetureCaisseCompleted += (s, args) =>
            {
                if (args.Cancelled || args.Error != null || args.Result == null)
                {
                    Message.ShowError("Un problème est survenu lors de la fermeture de caisse", "Information");
                }
                else
                {
                    // log out current user
                    if (args.Result.Value == true)
                    {
                        //Message.ShowInformation("La caisse est fermée, vous allez devoir vous reconnecter","Information");// "Information", MessageBoxButton.OK) == MessageBoxResult.OK)
                        HtmlPage.Document.Submit();
                    }
                    else
                    {
                        Message.ShowError("Impossible de fermer la caisse. Veuillez réessayer", "Information");
                    }
                }
            };
            service.FermetureCaisseAsync(laCaisse);
        }
        private void RetourneReversement(CsHabilitationCaisse laCaisse)
        {
            try
            {
                CaisseServiceClient service = new CaisseServiceClient(Utility.ProtocoleIndex(), Utility.EndPoint("Caisse"));
                service.RetourneHabileCaisseReversementCompleted += (s, args) =>
                {
                    CsHabilitationCaisse leCaisseHabil = new CsHabilitationCaisse();
                    if (args.Cancelled || args.Error != null)
                    {
                        Message.ShowError("Un problème est survenu lors de la fermeture de caisse", "Information");
                    }
                    leCaisseHabil = args.Result;


                    if (leCaisseHabil.MONTANTENCAISSE != null)
                    {
                        this.txt_MontantEncaisse.Text = leCaisseHabil.MONTANTENCAISSE.Value.ToString(SessionObject.FormatMontant);
                    }
                    else
                    {
                        this.txt_MontantEncaisse.Text = initValue.ToString(SessionObject.FormatMontant);
                    }

                    if (leCaisseHabil.MONTANTREVERSER != null)
                    {
                        this.Txt_MontantReverse.Text = leCaisseHabil.MONTANTREVERSER.Value.ToString(SessionObject.FormatMontant);
                    }
                    else
                    {
                        this.Txt_MontantReverse.Text = initValue.ToString(SessionObject.FormatMontant);
                    }


                    if (leCaisseHabil.MONTANTREVERSER != null)
                    {
                        this.Txt_MontantAReverser.Text = ((Convert.ToDecimal(this.txt_MontantEncaisse.Text) - Convert.ToDecimal(this.Txt_MontantReverse.Text)) + Convert.ToDecimal(this.Txt_MontantNonReverse.Text)).ToString(SessionObject.FormatMontant);
                        SessionObject.LaCaisseCourante.MONTANTENCAISSE = (Convert.ToDecimal(this.txt_MontantEncaisse.Text) - Convert.ToDecimal(this.Txt_MontantReverse.Text));
                    }
                    else
                    {
                        this.Txt_MontantAReverser.Text = (Convert.ToDecimal(this.txt_MontantEncaisse.Text) + Convert.ToDecimal(this.Txt_MontantNonReverse.Text)).ToString(SessionObject.FormatMontant);
                        SessionObject.LaCaisseCourante.MONTANTENCAISSE = Convert.ToDecimal(this.txt_MontantEncaisse.Text);
                    }
                };
                service.RetourneHabileCaisseReversementAsync(laCaisse);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public frmEtatCaisse(CsHabilitationCaisse LaCaisse)
        {
            InitializeComponent();

            try
            {
                laCaisse = LaCaisse;
                translate();
            }
            catch (Exception ex)
            {
                Message.ShowError(ex, Langue.errorTitle);
            }
        }
 void galatee_OkClickedCaissiere(object sender, EventArgs e)
 {
     try
     {
         CsHabilitationCaisse _LeCaisseSelect = new CsHabilitationCaisse();
         Galatee.Silverlight.MainView.UcListeGenerique ctrs = sender as Galatee.Silverlight.MainView.UcListeGenerique;
         if (ctrs.MyObject != null)
         {
             _LeCaisseSelect       = (CsHabilitationCaisse)ctrs.MyObject;
             this.TxtCaissier.Text = _LeCaisseSelect.NOMCAISSE;
             this.TxtCaissier.Tag  = _LeCaisseSelect;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 void galatee_OkClickedCaissiere(object sender, EventArgs e)
 {
     try
     {
         CsHabilitationCaisse _LeCaisseSelect = new CsHabilitationCaisse();
         Galatee.Silverlight.MainView.UcListeGenerique ctrs = sender as Galatee.Silverlight.MainView.UcListeGenerique;
         if (ctrs.MyObject != null)
         {
             _LeCaisseSelect = (CsHabilitationCaisse)ctrs.MyObject;
             this.txtMatriculeCaissier.Text = _LeCaisseSelect.MATRICULE;
             this.txt_CashierName.Text      = _LeCaisseSelect.NOMCAISSE;
             this.txtMatriculeCaissier.Tag  = _LeCaisseSelect;
             Btn_Update.IsEnabled           = true;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 void galatee_OkClickedCaissiere(object sender, EventArgs e)
 {
     try
     {
         CsHabilitationCaisse _LeCaisseSelect = new CsHabilitationCaisse();
         Galatee.Silverlight.MainView.UcListeGenerique ctrs = sender as Galatee.Silverlight.MainView.UcListeGenerique;
         if (ctrs.MyObject != null)
         {
             _LeCaisseSelect         = (CsHabilitationCaisse)ctrs.MyObject;
             this.txt_Caissiere.Text = _LeCaisseSelect.MATRICULE;
             if (ListeDesReglementADupliquer != null && ListeDesReglementADupliquer.Count != 0)
             {
                 ListeDesReglementADupliquer.Clear();
             }
             RemplireDataGrid(_ListeDesReglementDuRecu.Where(p => p.MATRICULE == _LeCaisseSelect.MATRICULE).ToList());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public FrmReversement(CsHabilitationCaisse _laCaisseARevereser)
 {
     InitializeComponent();
     laCaisseARevereser = new CsHabilitationCaisse();
     laCaisseARevereser = _laCaisseARevereser;
 }
        private void ChargerControl()
        {
            if (string.IsNullOrEmpty(laCaisse.CENTRE))
            {
                laCaisse = SessionObject.LaCaisseCourante;
            }

            CaisseServiceClient service = new CaisseServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Caisse"));

            service.RetourneEtatDeCaisseAsync(laCaisse);
            service.RetourneEtatDeCaisseCompleted += (sender, es) =>
            {
                try
                {
                    if (es.Cancelled || es.Error != null)
                    {
                        Message.ShowError("Erreur d'invocation du service . Veuillez réssayer svp!", Galatee.Silverlight.Resources.Langue.errorTitle);
                        this.DialogResult = true;
                    }

                    if (es.Result == null || es.Result.Count == 0)
                    {
                        Message.ShowError("Aucune données trouvées", Langue.errorTitle);
                        return;
                    }
                    this.Txt_NumCaissiere.Text = laCaisse.NUMCAISSE;
                    List <CsLclient> _LstReglement = new List <CsLclient>();
                    _LstReglement.AddRange(es.Result);

                    if (_LstReglement.Count > 0)
                    {
                        this.dtg_EtatCaisse.ItemsSource = null;
                        this.dtg_EtatCaisse.ItemsSource = _LstReglement;

                        decimal?TotalEncaisse = _LstReglement.FirstOrDefault(t => t.MODEREG == "1") == null  ? 0 : _LstReglement.FirstOrDefault(t => t.MODEREG == "1").MONTANT;
                        decimal?TotalDecaisse = _LstReglement.FirstOrDefault(t => t.MODEREG == "A") == null ? 0 : _LstReglement.FirstOrDefault(t => t.MODEREG == "A").MONTANT;
                        this.Txt_TotalEnCaise.Text = (TotalEncaisse - TotalDecaisse).Value.ToString(SessionObject.FormatMontant);

                        //List<CsLclient> _LstDeReglementNonAnnule =_LstReglement.Where(t => string.IsNullOrEmpty(t.TOPANNUL) && t.DC == SessionObject.Enumere.Debit ).ToList();
                        //RetourneGridModePaiement(_LstDeReglementNonAnnule);
                        //this.Txt_MontantEncaisse.Text = _LstDeReglementNonAnnule.Sum(p => p.MONTANT).Value.ToString(SessionObject.FormatMontant);

                        //var NbreRecu = _LstDeReglementNonAnnule.Select(l => new { l.ACQUIT }).Distinct().ToList();
                        //var NbreRecuDecaisse = _LstReglement.Where(t => string.IsNullOrEmpty(t.TOPANNUL) && t.DC == SessionObject.Enumere.Credit).Select(l => new { l.ACQUIT }).Distinct().ToList();
                        //var NbreRecuAnnuler = _LstReglement.Where(t => !string.IsNullOrEmpty(t.TOPANNUL)).Select(l => new { l.ACQUIT }).Distinct().ToList();


                        //this.Txt_MontantDecaisse.Text = _LstReglement.Where(t => string.IsNullOrEmpty(t.TOPANNUL) && t.DC == SessionObject.Enumere.Credit ).Sum(t => t.MONTANT).Value.ToString(SessionObject.FormatMontant);
                        //this.Txt_FondDeCaisse.Text = (laCaisse.FONDCAISSE == null) ? "0" : laCaisse.FONDCAISSE.Value.ToString(SessionObject.FormatMontant);
                        //this.Txt_Annulation.Text = _LstReglement.Where(t => !string.IsNullOrEmpty(t.TOPANNUL)).Sum(p => p.MONTANT).Value.ToString(SessionObject.FormatMontant);
                        //this.Txt_nbreRecu.Text = (NbreRecu != null && NbreRecu.Count != 0) ? NbreRecu.Count().ToString() : "0";
                        //this.Txt_nbreRecuDecaisse.Text = (NbreRecuDecaisse != null && NbreRecuDecaisse.Count != 0) ? NbreRecuDecaisse.Count().ToString() : "0";
                        //this.Txt_nbreRecuAnnule.Text = (NbreRecuAnnuler != null && NbreRecuAnnuler.Count != 0) ? NbreRecuAnnuler.Count().ToString() : "0";

                        //decimal TotalEncaisse = string.IsNullOrEmpty(this.Txt_MontantEncaisse.Text)? 0 :Convert.ToDecimal(this.Txt_MontantEncaisse.Text);
                        //decimal TotalDecaisse = string.IsNullOrEmpty(this.Txt_MontantDecaisse.Text)? 0 :Convert.ToDecimal(this.Txt_MontantDecaisse.Text);
                        //this.txt_totalGeneral.Text = (TotalEncaisse - TotalDecaisse).ToString();
                    }
                }
                catch (Exception ex)
                {
                    Message.ShowError(ex, Langue.errorTitle);
                }
            };
        }