Exemplo n.º 1
0
        private void ContribucionTextBox_TextChanged(object sender, EventArgs e)
        {
            Colectas colecta;
            double   contribucion;

            if (IdNumericUpDown.Value == 0)
            {
                colecta      = ColectasBLL.Buscar(Convert.ToInt32(MetaComboBox.SelectedValue));
                contribucion = 0;
            }
            else
            {
                var aporte = AportesBLL.Buscar((int)IdNumericUpDown.Value);
                colecta      = ColectasBLL.Buscar(aporte.ColectaId);
                contribucion = 0;
            }

            if (!string.IsNullOrWhiteSpace(ContribucionTextBox.Text))
            {
                contribucion = Convert.ToDouble(ContribucionTextBox.Text);
            }

            if (colecta != null)
            {
                RestaTextBox.Text = (colecta.Meta - contribucion).ToString();
            }
        }
Exemplo n.º 2
0
        private void GuardarButton_Click(object sender, EventArgs e)
        {
            bool    paso = false;
            Aportes aportes;

            if (!Validar())
            {
                return;
            }
            aportes = LLenaClase();

            if (IdNumericUpDown.Value == 0)
            {
                paso = AportesBLL.Guardar(aportes);
            }
            else
            {
                if (!ExisteEnLaBaseDeDatos())
                {
                    MessageBox.Show("No se puede modificar un Aporte ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                paso = AportesBLL.Modificar(aportes);
            }

            if (paso)
            {
                Limpiar();
                MessageBox.Show("Guardado!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("No se pudo guardar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        private void ConsultarButton_Click(object sender, EventArgs e)
        {
            //Si el filtro de la fecha se encuentra marcado, va a tomar en cuenta le rango de fecha
            if (FechaCheckBox.Checked)
            {
                if (!String.IsNullOrWhiteSpace(CriterioTextBox.Text))
                {
                    switch (FiltroComboBox.SelectedIndex)
                    {
                    case 0:     //Aportes
                        lista = AportesBLL.GetList(r => r.AportesId == Utilidades.ToInt(CriterioTextBox.Text) && (r.Fecha >= DesdeDateTimePicker.Value && r.Fecha <= HastaDateTimePicker.Value));
                        break;

                    case 1:     //Persona
                        lista = AportesBLL.GetList(r => r.Persona == Utilidades.ToInt(CriterioTextBox.Text));
                        break;
                    }
                }
                else
                {
                    lista = AportesBLL.GetList(r => (r.Fecha >= DesdeDateTimePicker.Value && r.Fecha <= HastaDateTimePicker.Value));
                }
            }
            else
            {
                if (!String.IsNullOrWhiteSpace(CriterioTextBox.Text))
                {
                    switch (FiltroComboBox.SelectedIndex)
                    {
                    case 0:     //Aportes
                        lista = AportesBLL.GetList(r => r.AportesId == Utilidades.ToInt(CriterioTextBox.Text));
                        break;

                    case 1:     //Persona
                        lista = AportesBLL.GetList(r => r.Persona == Utilidades.ToInt(CriterioTextBox.Text));
                        break;
                    }
                }
                //En caso de que no haya nada en el textBo
                else
                {
                    lista = AportesBLL.GetList(r => true);
                }
            }


            ConsultaDataGridView.DataSource = null;
            ConsultaDataGridView.DataSource = lista;
        }
Exemplo n.º 4
0
        private void ElimarButton_Click(object sender, EventArgs e)
        {
            int id;

            int.TryParse(IdNumericUpDown.Text, out id);

            Limpiar();
            if (AportesBLL.Buscar(id) != null)
            {
                if (AportesBLL.Eliminar(id))
                {
                    MessageBox.Show("Eliminado!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("No se puede eliminar la colecta que no existe", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 5
0
        private void BuscarButton_Click(object sender, EventArgs e)
        {
            Aportes aportes = new Aportes();
            int     id;

            int.TryParse(IdNumericUpDown.Text, out id);

            Limpiar();
            aportes = AportesBLL.Buscar(id);

            if (aportes != null)
            {
                LLenaCampo(aportes);
                MetaComboBox.SelectedItem = aportes.ColectaId;
            }
            else
            {
                MessageBox.Show("Aportes no encontrado", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 6
0
        private bool ExisteEnLaBaseDeDatos()
        {
            Aportes aportes = AportesBLL.Buscar((int)IdNumericUpDown.Value);

            return(aportes != null);
        }