private void Agregarbutton_Click(object sender, EventArgs e) { if (DetalledataGridView.DataSource != null) { this.Detalle = (List <ProyectoDetalle>)DetalledataGridView.DataSource; } if (RequerimentotextBox.Text == string.Empty) { ErroreserrorProvider.SetError(RequerimentotextBox, "Este campo no puede quedar vacio"); RequerimentotextBox.Focus(); return; } if (TiempotextBox.Text == string.Empty) { ErroreserrorProvider.SetError(TiempotextBox, "Este campo no puede quedar vacio"); TiempotextBox.Focus(); return; } if (string.IsNullOrWhiteSpace(TipoTareacomboBox.Text)) { ErroreserrorProvider.SetError(TipoTareacomboBox, "Debe agregar un tipo de tarea especifico"); TipoTareacomboBox.Focus(); return; } Tareas tareas = TareasBLL.Buscar(Convert.ToInt32(TipoTareacomboBox.SelectedValue)); this.Detalle.Add( new ProyectoDetalle ( TipoId: tareas.TareaId, TipoTarea: tareas.TipoTarea, Requerimentos: RequerimentotextBox.Text, Tiempo: Convert.ToInt32(TiempotextBox.Text) ) ); CargarGrid(); int totalTiempo = Convert.ToInt32(TiempototaltextBox.Text); int tiempo = Convert.ToInt32(TiempotextBox.Text); totalTiempo += tiempo; TiempototaltextBox.Text = totalTiempo.ToString(); }
private bool Validar() { bool validado = true; string obligatorio = "Campo obligatorio"; if (string.IsNullOrWhiteSpace(IDnumericUpDown.Text)) { errorProvider.SetError(IDnumericUpDown, obligatorio); IDnumericUpDown.Focus(); validado = false; } if (string.IsNullOrWhiteSpace(MontotextBox.Text)) { errorProvider.SetError(MontotextBox, obligatorio); MontotextBox.Focus(); validado = false; } if (ToDecimal(MontotextBox.Text) < 1) { errorProvider.SetError(MontotextBox, "El monto debe ser mayor a 0"); MontotextBox.Focus(); validado = false; } if (string.IsNullOrWhiteSpace(TiempotextBox.Text)) { errorProvider.SetError(TiempotextBox, obligatorio); TiempotextBox.Focus(); validado = false; } if (ToInt(TiempotextBox.Text) < 1) { errorProvider.SetError(TiempotextBox, "El tiempo debe ser mayor a un mes"); TiempotextBox.Focus(); validado = false; } if (string.IsNullOrWhiteSpace(FechadateTimePicker.Value.ToString())) { errorProvider.SetError(FechadateTimePicker, obligatorio); FechadateTimePicker.Focus(); validado = false; } return(validado); }
private bool ValidarDetalle() { bool paso = true; if (string.IsNullOrWhiteSpace(RequerimientotextBox.Text)) { ErrorProvider.SetError(RequerimientotextBox, "Este campo no puede estar vacío"); RequerimientotextBox.Focus(); paso = false; } if (string.IsNullOrWhiteSpace(TiempotextBox.Text)) { ErrorProvider.SetError(TiempotextBox, "Este campo no puede estar vacío"); TiempotextBox.Focus(); paso = false; } return(paso); }