bool ValidarFormulario() { bool estaValidado = true; LimpiarErrores(); if (!codigoDocumentoPago.HasValue || cbbCodigoTipoDocumentoPago.SelectedIndex == 0) { if (cbbCodigoTipoDocumentoPago.SelectedIndex == 0) { estaValidado = false; lblErrorCodigoTipoDocumentoPago.Text = "Debe seleccionar tipo de documento de pago"; SetToolTipError(lblErrorCodigoTipoDocumentoPago); } if (!codigoDocumentoPago.HasValue) { estaValidado = false; lblErrorDocumentoPago.Text = "Debe seleccionar documento de pago"; SetToolTipError(lblErrorDocumentoPago); } } else { bool existeDocumentoPago = ListaDetalleActual.Exists(x => x.CodigoTipoDocumentoPago == int.Parse(cbbCodigoTipoDocumentoPago.SelectedValue.ToString()) && x.CodigoDocumentoPago == codigoDocumentoPago && (x.CodigoComprobantePagoDetalle != (_Detalle ?? new ComprobantePagoDetalleBe()).CodigoComprobantePagoDetalle)); if (existeDocumentoPago) { estaValidado = false; lblErrorDocumentoPago.Text = $"El documento de pago seleccionado ya existe"; SetToolTipError(lblErrorDocumentoPago); } } decimal monto = 0; if (string.IsNullOrEmpty(txtMonto.Text.Trim())) { estaValidado = false; lblErrorMonto.Text = "Debe ingresar monto"; SetToolTipError(lblErrorMonto); } else { if (!decimal.TryParse(txtMonto.Text.Trim(), out monto)) { estaValidado = false; lblErrorMonto.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorMonto); } } decimal montoPagar = 0; if (string.IsNullOrEmpty(txtMontoPagar.Text.Trim())) { estaValidado = false; lblErrorMontoPagar.Text = "Debe ingresar monto a pagar"; SetToolTipError(lblErrorMontoPagar); } else { if (!decimal.TryParse(txtMontoPagar.Text.Trim(), out montoPagar)) { estaValidado = false; lblErrorMontoPagar.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorMontoPagar); } else { if (montoPagar > monto) { estaValidado = false; lblErrorMontoPagar.Text = "El monto a pagar no puede ser mayor al monto"; SetToolTipError(lblErrorMontoPagar); } } } decimal mora = 0; if (string.IsNullOrEmpty(txtMora.Text.Trim())) { estaValidado = false; lblErrorMora.Text = "Debe ingresar mora"; SetToolTipError(lblErrorMora); } else { if (!decimal.TryParse(txtMora.Text.Trim(), out mora)) { estaValidado = false; lblErrorMora.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorMora); } } decimal moraPagar = 0; if (string.IsNullOrEmpty(txtMoraPagar.Text.Trim())) { estaValidado = false; lblErrorMoraPagar.Text = "Debe ingresar mora a pagar"; SetToolTipError(lblErrorMoraPagar); } else { if (!decimal.TryParse(txtMoraPagar.Text.Trim(), out moraPagar)) { estaValidado = false; lblErrorMoraPagar.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorMoraPagar); } else { if (moraPagar > mora) { estaValidado = false; lblErrorMoraPagar.Text = "El mora a pagar no puede ser mayor a la mora"; SetToolTipError(lblErrorMoraPagar); } } } decimal protesto = 0; if (string.IsNullOrEmpty(txtProtesto.Text.Trim())) { estaValidado = false; lblErrorProtesto.Text = "Debe ingresar protesto"; SetToolTipError(lblErrorProtesto); } else { if (!decimal.TryParse(txtProtesto.Text.Trim(), out protesto)) { estaValidado = false; lblErrorProtesto.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorProtesto); } } decimal protestoPagar = 0; if (string.IsNullOrEmpty(txtProtestoPagar.Text.Trim())) { estaValidado = false; lblErrorProtestoPagar.Text = "Debe ingresar protesto a pagar"; SetToolTipError(lblErrorProtestoPagar); } else { if (!decimal.TryParse(txtProtestoPagar.Text.Trim(), out protestoPagar)) { estaValidado = false; lblErrorProtestoPagar.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorProtestoPagar); } else { if (protestoPagar > protesto) { estaValidado = false; lblErrorProtestoPagar.Text = "El protesto a pagar no puede ser mayor al protesto"; SetToolTipError(lblErrorProtestoPagar); } } } decimal total = 0; if (string.IsNullOrEmpty(txtTotal.Text.Trim())) { estaValidado = false; lblErrorTotal.Text = "Debe ingresar total"; SetToolTipError(lblErrorTotal); } else { if (!decimal.TryParse(txtTotal.Text.Trim(), out total)) { estaValidado = false; lblErrorTotal.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorTotal); } } decimal importePagar = 0; if (string.IsNullOrEmpty(txtImportePagar.Text.Trim())) { estaValidado = false; lblErrorImportePagar.Text = "Debe ingresar importe a pagar"; SetToolTipError(lblErrorImportePagar); } else { if (!decimal.TryParse(txtImportePagar.Text.Trim(), out importePagar)) { estaValidado = false; lblErrorImportePagar.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorImportePagar); } else { if (importePagar > total) { estaValidado = false; lblErrorImportePagar.Text = "El importe a pagar no puede ser mayor al importe total"; SetToolTipError(lblErrorImportePagar); } } } return(estaValidado); }
bool ValidarFormulario() { bool estaValidado = true; LimpiarErrores(); if (codigoProducto == null) { estaValidado = false; lblErrorProducto.Text = "Debe seleccionar producto"; SetToolTipError(lblErrorProducto); } if (codigoProductoIndividual == null) { estaValidado = false; lblErrorProductoIndividual.Text = "Debe seleccionar producto individual"; SetToolTipError(lblErrorProductoIndividual); } else { ListaDetalleActual = ListaDetalleActual ?? new List <NotaDebitoDetalleBe>(); int?codigoNotaDebitoDetalle = Detalle == null ? null : (int?)Detalle.CodigoNotaDebitoDetalle; bool existeProductoIndividual = ListaDetalleActual.Count(x => x.CodigoProductoIndividual == codigoProductoIndividual && x.CodigoNotaDebitoDetalle != codigoNotaDebitoDetalle) > 0; if (existeProductoIndividual) { estaValidado = false; lblErrorProductoIndividual.Text = $"El producto individual seleccionado ya existe"; SetToolTipError(lblErrorProductoIndividual); } } if (cbbCodigoUnidadMedida.SelectedIndex == 0) { estaValidado = false; lblErrorUnidadMedida.Text = "Debe seleccionar una unidad medida"; SetToolTipError(lblErrorUnidadMedida); } if (string.IsNullOrEmpty(txtCantidad.Text.Trim())) { estaValidado = false; lblErrorCantidad.Text = "Debe ingresar cantidad"; SetToolTipError(lblErrorCantidad); } else { decimal cantidad = 0; if (!decimal.TryParse(txtCantidad.Text.Trim(), out cantidad)) { estaValidado = false; lblErrorCantidad.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorCantidad); } } if (tipoCalculo == TipoCalculo.ValorUnitario) { if (string.IsNullOrEmpty(txtValorUnitario.Text.Trim())) { estaValidado = false; lblErrorValorUnitario.Text = "Debe ingresar valor unitario"; SetToolTipError(lblErrorValorUnitario); } else { decimal valorUnitario = 0; if (!decimal.TryParse(txtValorUnitario.Text.Trim(), out valorUnitario)) { estaValidado = false; lblErrorValorUnitario.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorValorUnitario); } } } else if (tipoCalculo == TipoCalculo.PrecioUnitario) { if (string.IsNullOrEmpty(txtPrecioUnitario.Text.Trim())) { estaValidado = false; lblErrorPrecioUnitario.Text = "Debe ingresar precio unitario"; SetToolTipError(lblErrorPrecioUnitario); } else { decimal precioUnitario = 0; if (!decimal.TryParse(txtPrecioUnitario.Text.Trim(), out precioUnitario)) { estaValidado = false; lblErrorPrecioUnitario.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorPrecioUnitario); } } } if (tipoDescuento == TipoDescuento.Porcentaje) { if (string.IsNullOrEmpty(txtPorcentajeDescuento.Text.Trim())) { estaValidado = false; lblErrorPorcentajeDescuento.Text = "Debe ingresar valor porcentaje descuento"; SetToolTipError(lblErrorPorcentajeDescuento); } else { decimal porcentajeDescuento = 0; if (!decimal.TryParse(txtPorcentajeDescuento.Text.Trim(), out porcentajeDescuento)) { estaValidado = false; lblErrorPorcentajeDescuento.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorPorcentajeDescuento); } } } return(estaValidado); }
bool ValidarFormulario() { bool estaValidado = true; LimpiarErrores(); if (!codigoProducto.HasValue) { estaValidado = false; lblErrorProducto.Text = "Debe seleccionar producto"; SetToolTipError(lblErrorProducto); } else { bool existeProducto = ListaDetalleActual.Exists(x => x.CodigoProducto == codigoProducto && (x.CodigoComprobanteCompraDetalle != (_Detalle ?? new ComprobanteCompraDetalleBe()).CodigoComprobanteCompraDetalle)); if (existeProducto) { estaValidado = false; lblErrorProducto.Text = $"El producto seleccionado ya existe"; SetToolTipError(lblErrorProducto); } } if (string.IsNullOrEmpty(txtCantidad.Text.Trim())) { estaValidado = false; lblErrorCantidad.Text = "Debe ingresar cantidad"; SetToolTipError(lblErrorCantidad); } else { int cantidad = 0; if (!int.TryParse(txtCantidad.Text.Trim(), out cantidad)) { estaValidado = false; lblErrorCantidad.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorCantidad); } else { if (cantidadUnidadesRegistradas.HasValue) { if (cantidadUnidadesRegistradas > 0 && cantidad > cantidadUnidadesRegistradas) { estaValidado = false; lblErrorCantidad.Text = $"Ya existen {cantidadUnidadesRegistradas} unidades registradas"; SetToolTipError(lblErrorCantidad); } } } } if (string.IsNullOrEmpty(txtPrecioUnitario.Text.Trim())) { estaValidado = false; lblErrorPrecioUnitario.Text = "Debe ingresar precio unitario"; SetToolTipError(lblErrorPrecioUnitario); } else { decimal precioUnitario = 0; if (!decimal.TryParse(txtPrecioUnitario.Text.Trim(), out precioUnitario)) { estaValidado = false; lblErrorPrecioUnitario.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorPrecioUnitario); } } if (string.IsNullOrEmpty(txtImporteTotal.Text.Trim())) { estaValidado = false; lblErrorImporteTotal.Text = "Debe ingresar importe total"; SetToolTipError(lblErrorImporteTotal); } else { decimal importeTotal = 0; if (!decimal.TryParse(txtImporteTotal.Text.Trim(), out importeTotal)) { estaValidado = false; lblErrorImporteTotal.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorImporteTotal); } } return(estaValidado); }
bool ValidarFormulario() { bool estaValidado = true; LimpiarErrores(); if (codigoProducto == null) { estaValidado = false; lblErrorProducto.Text = "Debe seleccionar producto"; SetToolTipError(lblErrorProducto); } if (codigoProductoIndividual == null) { estaValidado = false; lblErrorProductoIndividual.Text = "Debe seleccionar producto individual"; SetToolTipError(lblErrorProductoIndividual); } else { ListaDetalleActual = ListaDetalleActual ?? new List <CotizacionDetalleBe>(); int?codigoCotizacionDetalle = Detalle == null ? null : (int?)Detalle.CodigoCotizacionDetalle; bool existeProductoIndividual = ListaDetalleActual.Count(x => x.CodigoProductoIndividual == codigoProductoIndividual && x.CodigoCotizacionDetalle != codigoCotizacionDetalle) > 0; if (existeProductoIndividual) { estaValidado = false; lblErrorProductoIndividual.Text = $"El producto individual seleccionado ya existe"; SetToolTipError(lblErrorProductoIndividual); } } if (string.IsNullOrEmpty(txtCantidad.Text.Trim())) { estaValidado = false; lblErrorCantidad.Text = "Debe ingresar cantidad"; SetToolTipError(lblErrorCantidad); } else { decimal cantidad = 0; if (!decimal.TryParse(txtCantidad.Text.Trim(), out cantidad)) { estaValidado = false; lblErrorCantidad.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorCantidad); } } if (string.IsNullOrEmpty(txtPrecioUnitario.Text.Trim())) { estaValidado = false; lblErrorPrecioUnitario.Text = "Debe ingresar precio unitario"; SetToolTipError(lblErrorPrecioUnitario); } else { decimal precioUnitario = 0; if (!decimal.TryParse(txtPrecioUnitario.Text.Trim(), out precioUnitario)) { estaValidado = false; lblErrorPrecioUnitario.Text = "Debe ingresar un valor numérico"; SetToolTipError(lblErrorPrecioUnitario); } } return(estaValidado); }