private void btnAgregar_Click(object sender, EventArgs e) { if (txtIndicaciones.Text != "") { medicamento = administrador.buscarMedicamentoPorNombre(cbxMedicamentos.Text); indicacion = new Indicacion(id++, medicamento, txtIndicaciones.Text); indicaciones.Add(indicacion); cbxMedicamentos.SelectedIndex = 0; txtIndicaciones.Text = ""; llenarDataGridView(); } else { MessageBox.Show("Ingrese las indicaciones para el medicamento", "IESS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void dgvMedicamentos_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (dgvMedicamentos.SelectedRows.Count > 0) { indicacion = new Indicacion(); indicacion.NumeroIndicacion = Convert.ToInt32(dgvMedicamentos.Rows[e.RowIndex].Cells[0].Value.ToString()); indicacion = indicaciones.SingleOrDefault(aux => aux.NumeroIndicacion == indicacion.NumeroIndicacion); txtIndicaciones.Text = indicacion.Indicaciones; btnEliminar.Enabled = true; btnAgregar.Enabled = false; } else { MessageBox.Show("Por favor seleccione una fila", "IESS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch { MessageBox.Show("Seleccione una fila correcta", "IESS", MessageBoxButtons.OK, MessageBoxIcon.Error); } }