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 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); }