コード例 #1
0
        /// <summary>
        /// Editar premezcla detalle
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnEditar_Click(object sender, RoutedEventArgs e)
        {
            var botonEditar = (Button)e.Source;

            try
            {
                var premezclaDetalleInfo = (PremezclaDetalleInfo)Extensor.ClonarInfo(botonEditar.CommandParameter);
                BtnAgregar.Content = Properties.Resources.OtrosCostos_MensajeCosto;
                if (premezclaDetalleInfo == null)
                {
                    return;
                }
                skAyudaProducto.Clave         = premezclaDetalleInfo.Producto.ProductoId.ToString(CultureInfo.InvariantCulture);
                skAyudaProducto.Descripcion   = premezclaDetalleInfo.Producto.Descripcion;
                skAyudaProducto.IsEnabled     = false;
                skAyudaOrganizacion.IsEnabled = false;
                skAyudaPremezcla.IsEnabled    = false;
                TxtPorcentajeAjuste.Value     = premezclaDetalleInfo.Porcentaje;
                BtnAgregar.Content            = Properties.Resources.DiferenciasDeInventario_LblActualizar;
                TxtPorcentajeAjuste.Focus();
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.DiferenciasDeInventario_MensajeErrorObtenerDatosEditar, MessageBoxButton.OK,
                                  MessageImage.Error);
            }
        }
コード例 #2
0
        /// <summary>
        /// Validacion antes de agregar el ajuste al grid
        /// </summary>
        /// <returns></returns>
        private ResultadoValidacion ValidarAgregar(bool actualizar)
        {
            var resultado = new ResultadoValidacion();

            if (String.IsNullOrEmpty(skAyudaOrganizacion.Clave.Trim()) && String.IsNullOrEmpty(skAyudaOrganizacion.Descripcion.Trim()))
            {
                skAyudaOrganizacion.AsignarFoco();
                resultado.Mensaje   = Properties.Resources.ConfiguracionDePremezclas_MensajeValidacionAgregarOrganizacion;
                resultado.Resultado = false;
                return(resultado);
            }

            if (String.IsNullOrEmpty(skAyudaPremezcla.Clave.Trim()) && String.IsNullOrEmpty(skAyudaPremezcla.Descripcion.Trim()))
            {
                skAyudaPremezcla.AsignarFoco();
                resultado.Mensaje   = Properties.Resources.ConfiguracionDePremezclas_MensajeValidacionAgregarPremezcla;
                resultado.Resultado = false;
                return(resultado);
            }

            if (String.IsNullOrEmpty(skAyudaProducto.Clave.Trim()) && String.IsNullOrEmpty(skAyudaProducto.Descripcion.Trim()))
            {
                skAyudaProducto.AsignarFoco();
                resultado.Mensaje   = Properties.Resources.ConfiguracionDePremezclas_MensajeValidacionAgregarProducto;
                resultado.Resultado = false;
                return(resultado);
            }

            if (String.IsNullOrEmpty(TxtPorcentajeAjuste.Text) || TxtPorcentajeAjuste.Value == 0)
            {
                TxtPorcentajeAjuste.Focus();
                resultado.Resultado = false;
                resultado.Mensaje   = Properties.Resources.ConfiguracionDePremezclas_MensajeValidacionAgregarPorcentaje;
                return(resultado);
            }

            //Verificar si el producto ya esta agregado
            if (!actualizar)
            {
                if (listaPremezclaDetalle != null)
                {
                    if ((from premezclaDetalle in listaPremezclaDetalle
                         where premezclaDetalle.Producto.ProductoId == Convert.ToInt32(skAyudaProducto.Clave)
                         select premezclaDetalle).Any())
                    {
                        skAyudaProducto.AsignarFoco();
                        resultado.Resultado = false;
                        resultado.Mensaje   = Properties.Resources.ConfiguracionDePremezclas_MensajeValidacionProductoAgregado;
                        return(resultado);
                    }
                }
            }

            resultado.Resultado = true;
            return(resultado);
        }