private bool Validar() { bool paso = true; if (string.IsNullOrWhiteSpace(DescripciontextBox.Text)) { ErrorProvider.SetError(DescripciontextBox, "Este campo no puede estar vacío"); DescripciontextBox.Focus(); paso = false; } if (ProyectosBLL.ExisteProyecto(DescripciontextBox.Text, (int)IdnumericUpDown.Value)) { ErrorProvider.SetError(DescripciontextBox, "Este Proyecto ya existe"); DescripciontextBox.Focus(); paso = false; } if (string.IsNullOrWhiteSpace(TareacomboBox.Text)) { ErrorProvider.SetError(TareacomboBox, "Debe seleccionar una Tarea"); TareacomboBox.Focus(); paso = false; } if (this.Detalle.Count == 0) { ErrorProvider.SetError(DetallesdataGridView, "Debe agregar una Tarea"); DetallesdataGridView.Focus(); paso = false; } return(paso); }
private void Agregarbutton_Click(object sender, EventArgs e) { if (!ValidarDetalle()) { return; } if (DetallesdataGridView.DataSource != null) { this.Detalle = (List <ProyectosDetalle>)DetallesdataGridView.DataSource; } Tareas tareas = BuscarId(TareacomboBox.Text); this.Detalle.Add(new ProyectosDetalle() { TipoId = tareas.TareaId, TipoTarea = tareas.TipoTarea, Requerimiento = RequerimientotextBox.Text, Tiempo = Convert.ToInt32(TiempotextBox.Text) }); int total = Convert.ToInt32(TotaltextBox.Text); int tiempo = Convert.ToInt32(TiempotextBox.Text); total += tiempo; TotaltextBox.Text = Convert.ToString(total); CargarGrid(); TareacomboBox.Focus(); RequerimientotextBox.Clear(); TiempotextBox.Clear(); ErrorProvider.Clear(); }