private void GuardarButton_Click_1(object sender, EventArgs e) { bool paso = false; Colectas colectas; if (!Validar()) { return; } colectas = LLenaClase(); if (IdNumericUpDown.Value == 0) { paso = ColectasBLL.Guardar(colectas); } else { if (!ExisteEnLaBaseDeDatos()) { MessageBox.Show("No se puede modificar un usuario ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } paso = ColectasBLL.Modificar(colectas); } if (paso) { Limpiar(); MessageBox.Show("Guardado!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No se pudo guardar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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(); } }
private void LLenarComboMeta() { var ListaColectas = ColectasBLL.GetList(p => true); MetaComboBox.DataSource = ListaColectas; MetaComboBox.ValueMember = "ColectasId"; MetaComboBox.DisplayMember = "Descripcion"; }
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 = ColectasBLL.GetList(r => r.ColectasId == Utilidades.ToInt(CriterioTextBox.Text) && (r.Vence >= DesdeDateTimePicker.Value && r.Vence <= HastaDateTimePicker.Value)); break; case 1: //Persona lista = ColectasBLL.GetList(r => r.Descripcion.Contains(CriterioTextBox.Text) && (r.Vence >= DesdeDateTimePicker.Value && r.Vence <= HastaDateTimePicker.Value)); break; } } else { lista = ColectasBLL.GetList(r => (r.Vence >= DesdeDateTimePicker.Value && r.Vence <= HastaDateTimePicker.Value)); } } else { if (!String.IsNullOrWhiteSpace(CriterioTextBox.Text)) { switch (FiltroComboBox.SelectedIndex) { case 0: //Aportes lista = ColectasBLL.GetList(r => r.ColectasId == Utilidades.ToInt(CriterioTextBox.Text)); break; case 1: //Persona lista = ColectasBLL.GetList(r => r.Descripcion.Contains(CriterioTextBox.Text) && (r.Vence >= DesdeDateTimePicker.Value && r.Vence <= HastaDateTimePicker.Value)); break; } } //En caso de que no haya nada en el textBo else { lista = ColectasBLL.GetList(r => true); } } ConsultaDataGridView.DataSource = null; ConsultaDataGridView.DataSource = lista; }
private void BuscarButton_Click(object sender, EventArgs e) { Colectas colectas = new Colectas(); int id; int.TryParse(IdNumericUpDown.Text, out id); Limpiar(); colectas = ColectasBLL.Buscar(id); if (colectas != null) { LLenaCampo(colectas); } else { MessageBox.Show("Colectas no encontrado", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void EliminarButton_Click_1(object sender, EventArgs e) { int id; int.TryParse(IdNumericUpDown.Text, out id); Limpiar(); if (ColectasBLL.Buscar(id) != null) { if (ColectasBLL.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); } }
private bool Validar() { bool paso = true; var colecta = ColectasBLL.Buscar(Convert.ToInt32(MetaComboBox.SelectedValue)); if (Convert.ToDouble(ContribucionTextBox.Text) + colecta.Logrado > colecta.Meta) { MyErrorProvider.SetError(ContribucionTextBox, "La contribucion excede la cantiadad faltante"); ContribucionTextBox.Focus(); paso = false; } if (string.IsNullOrWhiteSpace(PersonaComboBox.Text)) { MyErrorProvider.SetError(PersonaComboBox, "El campo Descripcion no puede estar vacio"); PersonaComboBox.Focus(); paso = false; } return(paso); }
private bool ExisteEnLaBaseDeDatos() { Colectas colectas = ColectasBLL.Buscar((int)IdNumericUpDown.Value); return(colectas != null); }