public void CalcularCotizacion(Material material, double metros, Espesor espesor, Cliente cliente) { var Cotizacion = new ItemCotizacion(); Cotizacion.Cantidad = metros; Cotizacion.Material = material; Cotizacion.Espesor = espesor; Cotizacion.Cliente = cliente; double rendimientoBolsas = CalculoBolsas(metros, espesor); presupuesto = Cotizacion.Material.precio * Cotizacion.Espesor.precio * rendimientoBolsas; System.Console.WriteLine("\n--------------------------\n" + "Pedido de presupuesto: "); System.Console.WriteLine(FechaInicial = DateTime.Now); System.Console.WriteLine("Su presupuesto es: $" + presupuesto); System.Console.WriteLine("Necesitará: " + rendimientoBolsas + " bolsas"); System.Console.WriteLine("A nombre de: " + Cotizacion.Cliente.nombre + " " + Cotizacion.Cliente.apellido); System.Console.WriteLine("Su presupuesto tendrá validez hasta el: "); System.Console.WriteLine(FechaFinal = FechaInicial.AddDays(30)); System.Console.WriteLine("--------------------------\n"); Cotizacion cotizacion1 = new Cotizacion(FechaInicial, presupuesto, rendimientoBolsas, cliente, FechaFinal); cotizaciones.Add(cotizacion1); }
public async void Search() { try { if (Customer == null) { await dialogService.ShowMessage("Validacion", "Debes seleccionar un cliente antes de ejecutar la busqueda."); return; } CashHeaders.Clear(); TotalLineas = 0; if (FiltroFechas || FiltroPeriodo) { HayFiltro = true; } if (HayFiltro) { if (FiltroFechas && FiltroPeriodo) { await dialogService.ShowMessage("Validacion", "No es posible filtrar por rango de fechas y periodo a la vez."); return; } //Si se filtro x rango de fechas... if (FiltroFechas == true && FiltroPeriodo == false) { var pagosxfecha = dataService .Get <CashHeader>(true) .Where(s => s.CustId == Customer.CustId && Convert.ToDateTime(s.TranDate.ToString("yyyy/MM/dd")) >= Convert.ToDateTime(FechaInicial.ToString("yyyy/MM/dd")) && Convert.ToDateTime(s.TranDate.ToString("yyyy/MM/dd")) <= Convert.ToDateTime(FechaFinal.ToString("yyyy/MM/dd"))) .ToList(); if (pagosxfecha == null || pagosxfecha.Count == 0) { await dialogService.ShowMessage("Informacion", "El cliente, no registra pagos en el rango de fechas seleccionado."); return; } CashHeaders = new ObservableCollection <CashHeader>(pagosxfecha); TotalLineas = CashHeaders.Sum(god => god.TranAmt); } //Si se filtro x periodo... if (FiltroPeriodo == true && FiltroFechas == false) { if (Calendar == null) { await dialogService.ShowMessage("Informacion", "Debes seleccionar un periodo."); return; } var pagosxperiodo = dataService .Get <CashHeader>(true) .Where(s => s.CustId == Customer.CustId && Convert.ToDateTime(s.TranDate.ToString("yyyy/MM/dd")) >= Convert.ToDateTime(Calendar.StartDate.ToString("yyyy/MM/dd")) && Convert.ToDateTime(s.TranDate.ToString("yyyy/MM/dd")) <= Convert.ToDateTime(Calendar.EndDate.ToString("yyyy/MM/dd"))) .ToList(); if (pagosxperiodo == null || pagosxperiodo.Count == 0) { await dialogService.ShowMessage("Informacion", "El cliente, no registra pagos en el periodo seleccionado."); return; } CashHeaders = new ObservableCollection <CashHeader>(pagosxperiodo); TotalLineas = CashHeaders.Sum(god => god.TranAmt); } } var pagos = dataService .Get <CashHeader>(true) .Where(s => s.CustId == Customer.CustId) .ToList(); if (pagos == null || pagos.Count == 0) { await dialogService.ShowMessage("Informacion", "El cliente, no registra pagos."); return; } CashHeaders = new ObservableCollection <CashHeader>(pagos); TotalLineas = CashHeaders.Sum(god => god.TranAmt); } catch (Exception ex) { await dialogService.ShowMessage("Error", ex.Message); } }
public async void Search() { try { if (Customer == null) { await dialogService.ShowMessage("Validacion", "Debes seleccionar un cliente antes de ejecutar la busqueda."); return; } InvoiceHeaders.Clear(); TotalLineas = 0; if (FiltroFechas || FiltroPeriodo || FacturaConSaldo) { HayFiltro = true; } if (HayFiltro) { if (FiltroFechas && FiltroPeriodo) { await dialogService.ShowMessage("Validacion", "No es posible filtrar por rango de fechas y periodo a la vez."); return; } //filtro x fact saldo if (FacturaConSaldo == true && FiltroPeriodo == false && FiltroFechas == false) { var facturasconsaldo = dataService .Get <InvoiceHeader>(true) .Where(s => s.CustNum == Customer.CustNum && s.InvoiceBal > 0) .ToList(); if (facturasconsaldo == null || facturasconsaldo.Count == 0) { await dialogService.ShowMessage("Informacion", "El cliente, no registra facturas con saldo."); return; } InvoiceHeaders = new ObservableCollection <InvoiceHeader>(facturasconsaldo); TotalLineas = InvoiceHeaders.Sum(god => god.InvoiceAmt); TotalSaldo = InvoiceHeaders.Sum(god => god.InvoiceBal); MontoMenosSaldo = (TotalLineas - TotalSaldo); } //filtro x fechas if (FiltroFechas == true && FiltroPeriodo == false && FacturaConSaldo == false) { var invoicesxfechas = dataService .Get <InvoiceHeader>(true) .Where(s => s.CustNum == Customer.CustNum && Convert.ToDateTime(s.InvoiceDate.ToString("yyyy/MM/dd")) >= Convert.ToDateTime(FechaInicial.ToString("yyyy/MM/dd")) && Convert.ToDateTime(s.InvoiceDate.ToString("yyyy/MM/dd")) <= Convert.ToDateTime(FechaFinal.ToString("yyyy/MM/dd"))) .ToList(); if (invoicesxfechas == null || invoicesxfechas.Count == 0) { await dialogService.ShowMessage("Informacion", "El cliente, no registra facturas en el rango de fechas seleccionado."); return; } InvoiceHeaders = new ObservableCollection <InvoiceHeader>(invoicesxfechas); TotalLineas = InvoiceHeaders.Sum(god => god.InvoiceAmt); TotalSaldo = InvoiceHeaders.Sum(god => god.InvoiceBal); MontoMenosSaldo = (TotalLineas - TotalSaldo); } //filtro x fechas y fact. con saldo if (FiltroFechas == true && FacturaConSaldo == true && FiltroPeriodo == false) { var invoicesxfechas = dataService .Get <InvoiceHeader>(true) .Where(s => s.CustNum == Customer.CustNum && Convert.ToDateTime(s.InvoiceDate.ToString("yyyy/MM/dd")) >= Convert.ToDateTime(FechaInicial.ToString("yyyy/MM/dd")) && Convert.ToDateTime(s.InvoiceDate.ToString("yyyy/MM/dd")) <= Convert.ToDateTime(FechaFinal.ToString("yyyy/MM/dd")) && s.InvoiceBal > 0) .ToList(); if (invoicesxfechas == null || invoicesxfechas.Count == 0) { await dialogService.ShowMessage("Informacion", "El cliente, no registra facturas con saldo en el rango de fechas seleccionado."); return; } InvoiceHeaders = new ObservableCollection <InvoiceHeader>(invoicesxfechas); TotalLineas = InvoiceHeaders.Sum(god => god.InvoiceAmt); TotalSaldo = InvoiceHeaders.Sum(god => god.InvoiceBal); MontoMenosSaldo = (TotalLineas - TotalSaldo); } //filtro x periodo if (FiltroPeriodo == true && FiltroFechas == false && FacturaConSaldo == false) { if (Calendar == null) { await dialogService.ShowMessage("Informacion", "Debes seleccionar un periodo."); return; } var facturasxperiodo = dataService .Get <InvoiceHeader>(true) .Where(s => s.CustNum == Customer.CustNum && Convert.ToDateTime(s.InvoiceDate.ToString("yyyy/MM/dd")) >= Convert.ToDateTime(Calendar.StartDate.ToString("yyyy/MM/dd")) && Convert.ToDateTime(s.InvoiceDate.ToString("yyyy/MM/dd")) <= Convert.ToDateTime(Calendar.EndDate.ToString("yyyy/MM/dd"))) .ToList(); if (facturasxperiodo == null || facturasxperiodo.Count == 0) { await dialogService.ShowMessage("Informacion", "El cliente, no registra facturas en el periodo seleccionado."); return; } InvoiceHeaders = new ObservableCollection <InvoiceHeader>(facturasxperiodo); TotalLineas = InvoiceHeaders.Sum(god => god.InvoiceAmt); TotalSaldo = InvoiceHeaders.Sum(god => god.InvoiceBal); MontoMenosSaldo = (TotalLineas - TotalSaldo); } //filtro x periodo y fact. con saldo if (FiltroPeriodo == true && FacturaConSaldo == true && FiltroFechas == false) { if (Calendar == null) { await dialogService.ShowMessage("Informacion", "Debes seleccionar un periodo."); return; } var facturasxpreiodo = dataService .Get <InvoiceHeader>(true) .Where(s => s.CustNum == Customer.CustNum && Convert.ToDateTime(s.InvoiceDate.ToString("yyyy/MM/dd")) >= Convert.ToDateTime(Calendar.StartDate.ToString("yyyy/MM/dd")) && Convert.ToDateTime(s.InvoiceDate.ToString("yyyy/MM/dd")) <= Convert.ToDateTime(Calendar.EndDate.ToString("yyyy/MM/dd"))) .ToList(); if (facturasxpreiodo == null || facturasxpreiodo.Count == 0) { await dialogService.ShowMessage("Informacion", "El cliente, no registra facturas en el periodo seleccionado."); return; } InvoiceHeaders = new ObservableCollection <InvoiceHeader>(facturasxpreiodo); TotalLineas = InvoiceHeaders.Sum(god => god.InvoiceAmt); TotalSaldo = InvoiceHeaders.Sum(god => god.InvoiceBal); MontoMenosSaldo = (TotalLineas - TotalSaldo); } } else { var facturas = dataService .Get <InvoiceHeader>(true) .Where(s => s.CustNum == Customer.CustNum) .ToList(); if (facturas == null || facturas.Count == 0) { await dialogService.ShowMessage("Informacion", "El cliente, no registra facturas."); return; } InvoiceHeaders = new ObservableCollection <InvoiceHeader>(facturas); TotalLineas = InvoiceHeaders.Sum(god => god.InvoiceAmt); TotalSaldo = InvoiceHeaders.Sum(god => god.InvoiceBal); MontoMenosSaldo = (TotalLineas - TotalSaldo); } await navigationService.Navigate("InvoicesListPage"); } catch (Exception ex) { await dialogService.ShowMessage("Error", ex.Message); } }