private void LoadEtatCaisse() { string centre = string.Empty; int fkidcentre = 0; string matricule = string.Empty; List <CsHabilitationCaisse> lstCaisseAEditer = new List <CsHabilitationCaisse>(); Galatee.Silverlight.ServiceCaisse.CsHabilitationCaisse laCaisseSelect = this.TxtCaissier.Tag != null ? (Galatee.Silverlight.ServiceCaisse.CsHabilitationCaisse)TxtCaissier.Tag : null; Galatee.Silverlight.ServiceAccueil.CsCentre leCentreSelect = Txt_CodeCentre.Tag != null ? (Galatee.Silverlight.ServiceAccueil.CsCentre)Txt_CodeCentre.Tag : null; Galatee.Silverlight.ServiceAccueil.CsSite leSiteSelect = Txt_CodeSite.Tag != null ? (Galatee.Silverlight.ServiceAccueil.CsSite)Txt_CodeSite.Tag : null; DateTime datedebut = dtp_debut.SelectedDate != null ? dtp_debut.SelectedDate.Value : new DateTime(); DateTime datefin = dtp_fin.SelectedDate != null ? dtp_fin.SelectedDate.Value : new DateTime(); if (leSiteSelect != null && !string.IsNullOrEmpty(leSiteSelect.CODE) && leCentreSelect == null) { List <int> LstidCentre = new List <int>(); foreach (var item in _lesCentre.Where(t => t.FK_IDCODESITE == leSiteSelect.PK_ID).ToList()) { LstidCentre.Add(item.PK_ID); } if (datedebut == new DateTime() && datefin == new DateTime()) { lstCaisseAEditer = _listDesCaisseOuverte.Where(t => LstidCentre.Contains(t.FK_IDCENTRE)).ToList(); } if (datedebut != new DateTime() && datefin == new DateTime()) { lstCaisseAEditer = _listDesCaisseOuverte.Where(t => LstidCentre.Contains(t.FK_IDCENTRE) && t.DATE_DEBUT >= datedebut).ToList(); } if (datedebut != new DateTime() && datefin != new DateTime()) { lstCaisseAEditer = _listDesCaisseOuverte.Where(t => LstidCentre.Contains(t.FK_IDCENTRE) && t.DATE_DEBUT >= datedebut && t.DATE_DEBUT <= datefin).ToList(); } if (datedebut == new DateTime() && datefin != new DateTime()) { lstCaisseAEditer = _listDesCaisseOuverte.Where(t => LstidCentre.Contains(t.FK_IDCENTRE) && t.DATE_DEBUT <= datefin).ToList(); } } if (leCentreSelect != null && !string.IsNullOrEmpty(leCentreSelect.CODE) && laCaisseSelect == null) { centre = leCentreSelect.CODE; fkidcentre = leCentreSelect.PK_ID; if (datedebut == new DateTime() && datefin == new DateTime()) { lstCaisseAEditer = _listDesCaisseOuverte.Where(t => t.FK_IDCENTRE == laCaisseSelect.FK_IDCENTRE).ToList(); } if (datedebut != new DateTime() && datefin == new DateTime()) { lstCaisseAEditer = _listDesCaisseOuverte.Where(t => t.FK_IDCENTRE == laCaisseSelect.FK_IDCENTRE && t.DATE_DEBUT >= datedebut).ToList(); } if (datedebut != new DateTime() && datefin != new DateTime()) { lstCaisseAEditer = _listDesCaisseOuverte.Where(t => t.FK_IDCENTRE == laCaisseSelect.FK_IDCENTRE && t.DATE_DEBUT >= datedebut && t.DATE_DEBUT <= datefin).ToList(); } if (datedebut == new DateTime() && datefin != new DateTime()) { lstCaisseAEditer = _listDesCaisseOuverte.Where(t => t.FK_IDCENTRE == laCaisseSelect.FK_IDCENTRE && t.DATE_DEBUT <= datefin).ToList(); } } if (laCaisseSelect != null && !string.IsNullOrEmpty(laCaisseSelect.MATRICULE)) { centre = laCaisseSelect.CENTRE; fkidcentre = leCentreSelect.PK_ID; matricule = laCaisseSelect.MATRICULE; if (datedebut == new DateTime() && datefin == new DateTime()) { lstCaisseAEditer = _listDesCaisseOuverte.Where(t => t.FK_IDCENTRE == fkidcentre && t.MATRICULE == laCaisseSelect.MATRICULE).ToList(); } if (datedebut != new DateTime() && datefin == new DateTime()) { lstCaisseAEditer = _listDesCaisseOuverte.Where(t => t.FK_IDCENTRE == fkidcentre && t.MATRICULE == laCaisseSelect.MATRICULE && t.DATE_DEBUT >= datedebut).ToList(); } if (datedebut != new DateTime() && datefin != new DateTime()) { lstCaisseAEditer = _listDesCaisseOuverte.Where(t => t.FK_IDCENTRE == fkidcentre && t.MATRICULE == laCaisseSelect.MATRICULE && t.DATE_DEBUT >= datedebut && t.DATE_DEBUT <= datefin).ToList(); } if (datedebut == new DateTime() && datefin != new DateTime()) { lstCaisseAEditer = _listDesCaisseOuverte.Where(t => t.FK_IDCENTRE == fkidcentre && t.MATRICULE == laCaisseSelect.MATRICULE && t.DATE_DEBUT <= datefin).ToList(); } } if (lstCaisseAEditer.Count == 0) { Message.ShowInformation("Aucune caisse trouvée pour les critères saisis", Langue.LibelleModule); return; } CaisseServiceClient proxy = new CaisseServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Caisse")); proxy.ListeDesReversementCaisseAsync(lstCaisseAEditer); proxy.ListeDesReversementCaisseCompleted += (senders, results) => { if (results.Cancelled || results.Error != null) { string error = results.Error.Message; MessageBox.Show("errror occurs while calling remote method", "ReversementCaisse", MessageBoxButton.OK); return; } if (results.Result == null || results.Result.Count == 0) { Message.ShowInformation("Aucune donnée trouvée", "Caisse"); return; } List <ServiceCaisse.CsHabilitationCaisse> dataTable = new List <ServiceCaisse.CsHabilitationCaisse>(); dataTable.AddRange(results.Result); //impression du recu de la liste of cut-off Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("pcentre", !string.IsNullOrWhiteSpace(this.Txt_LibelleCentre.Text) ? "Centre : " + this.Txt_LibelleCentre.Text : "Centre : Aucun"); param.Add("pmatricule", !string.IsNullOrWhiteSpace(this.TxtCaissier.Text) ? "Matricule : " + TxtCaissier.Text : "Matricule :Aucun"); param.Add("pdatedebut", dtp_debut.SelectedDate != null ? "Date de début : " + dtp_debut.SelectedDate.Value.ToShortDateString() : "Date de début : Aucune"); param.Add("pdatefin", dtp_fin.SelectedDate != null ? "Date de fin : " + dtp_fin.SelectedDate.Value.ToShortDateString() : "Date de fin : Aucune"); Utility.ActionDirectOrientation <ServicePrintings.CsHabilitationCaisse, ServiceCaisse.CsHabilitationCaisse>(dataTable, param, SessionObject.CheminImpression, "ReversementCaisse", "Caisse", true); }; }