示例#1
0
        private void AplicarValorButton_Click(object sender, RoutedEventArgs e)
        {
            float monto   = float.Parse(ValoraAplicarTextBox.Text);
            float residuo = monto;

            if (ValoraAplicarTextBox.Text.Length > 0)
            {
                foreach (PagosDetalle item in listado)
                {
                    if (residuo > 0)
                    {
                        if (item.Balance >= monto)
                        {
                            item.Total   = monto;
                            item.Balance = item.Balance - monto;
                            residuo      = 0;

                            if (residuo > 0)
                            {
                                monto = residuo;
                            }
                            continue;
                        }

                        if (item.Balance < monto)
                        {
                            item.Total   = item.Balance;
                            residuo      = monto - item.Balance;
                            item.Balance = 0;

                            if (residuo > 0)
                            {
                                monto = residuo;
                            }
                            continue;
                        }
                    }
                }

                DetalleDataGrid.ItemsSource = null;
                DetalleDataGrid.ItemsSource = listado;

                MontoTextBox.Text = ValoraAplicarTextBox.Text;
                DescuentoTextBox.Focus();
            }
        }
        private bool Validar()
        {
            bool paso = true;

            if (string.IsNullOrEmpty(UsuarioIdTextBox.Text))
            {
                paso = false;
                UsuarioIdTextBox.Focus();
            }

            if (string.IsNullOrEmpty(TotalTextBox.Text))
            {
                paso = false;
                TotalTextBox.Focus();
            }

            if (string.IsNullOrEmpty(SubTotalTextBox.Text))
            {
                paso = false;
                SubTotalTextBox.Focus();
            }


            if (string.IsNullOrEmpty(DescuentoTextBox.Text))
            {
                paso = false;
                DescuentoTextBox.Focus();
            }

            if (string.IsNullOrEmpty(ITBISTextBox.Text))
            {
                paso = false;
                ITBISTextBox.Focus();
            }

            if (string.IsNullOrEmpty(SubTotalTextBox.Text))
            {
                paso = false;
                SubTotalTextBox.Focus();
            }

            if (string.IsNullOrEmpty(FechaDeCompraTimePicker.Text))
            {
                paso = false;
                FechaDeCompraTimePicker.Focus();
            }


            if (string.IsNullOrEmpty(SuplidorIdTextbox.Text))
            {
                paso = false;
                SuplidorIdTextbox.Focus();
            }

            if (string.IsNullOrEmpty(CompraIDTextBox.Text))
            {
                paso = false;
                CompraIDTextBox.Focus();
            }

            if (this.Detalle.Count == 0)
            {
                MessageBox.Show("La Compra debe tener un producto", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                paso = false;
            }
            return(paso);
        }