private void MethodLoadDetail() { try { if (ESGR_AperturaCierreCaja.Opcion != "I") { var vrListDetalle = new BSGR_VentaDetalle().GetCollectionVentaDetalle(0, ESGR_AperturaCierreCaja.ESGR_Caja.IdCaja.ToString()).ToList(); var vrCollection_AperturaCierreCajaDetalle = new BSGR_AperturaCierreCaja().CollectionESGR_AperturaCierreCajaDetalle(ESGR_AperturaCierreCaja).ToList(); Application.Current.Dispatcher.Invoke(() => { ColletionMDSGR_AperturaCajaDetalle.Clear(); var CollectionESGR_Moneda = new CmpObservableCollection <ESGR_Moneda>(new BSGR_Moneda().GetCollectionMoneda()); var CollectionESGR_MedioPago = new CmpObservableCollection <ESGR_MedioPago>(new BSGR_MedioPago().GetCollectionMedioPago()); vrCollection_AperturaCierreCajaDetalle.ForEach(x => { var vrSelectMoneda = CollectionESGR_Moneda.FirstOrDefault(y => y.CodMoneda == x.ESGR_Moneda.CodMoneda); var vrSelectMedioPago = CollectionESGR_MedioPago.FirstOrDefault(y => y.IdMedioPago == x.ESGR_MedioPago.IdMedioPago); var vrDetalle = vrListDetalle.Where(z => z.ESGR_VentaCuenta.ESGR_MedioPago.IdMedioPago == x.ESGR_MedioPago.IdMedioPago && z.ESGR_VentaCuenta.ESGR_Moneda.CodMoneda == x.ESGR_Moneda.CodMoneda); ColletionMDSGR_AperturaCajaDetalle.Add(new MDSGR_AperturaCierreCajaDetalle() { Item = x.Item, CollectionESGR_Moneda = CollectionESGR_Moneda, CollectionESGR_MedioPago = CollectionESGR_MedioPago, SelectedESGR_Moneda = vrSelectMoneda, SelectedESGR_MedioPago = vrSelectMedioPago, ESGR_Moneda = x.ESGR_Moneda, Monto_Inicio = x.Monto_Inicio, Monto_Sistema = vrDetalle.Sum(y => y.Importe) - x.Monto_Inicio + vrDetalle.Sum(y => y.ESGR_VentaCuenta.Adicional) - vrDetalle.Sum(y => y.ESGR_VentaCuenta.Descuento), Monto_Cierre = x.Monto_Cierre, DiferExceso = x.DiferExceso }); }); }); } } catch (Exception ex) { CmpMessageBox.Show(SGRMessage.AdministracionAperturaCierreCaja, ex.Message, CmpButton.Aceptar); } }
private async void MethodLoadCaja() { await Task.Factory.StartNew(() => { try { var CollectionCajaAperturada = new BSGR_AperturaCierreCaja().CollectionESGR_AperturaCierreCaja().Where(x => x.ESGR_Estado.CodEstado == "APTCJ").ToList(); Application.Current.Dispatcher.Invoke(() => { CollectionESGR_Caja.Clear(); CollectionCajaAperturada.ForEach(x => { CollectionESGR_Caja.Add(x.ESGR_Caja); }); }); } catch (Exception ex) { CmpMessageBox.Show(SGRMessage.AdministracionCaja, ex.Message, CmpButton.Aceptar); } }); }