private void cboLisElim_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { Negocio.MedicamentoN mn = new Negocio.MedicamentoN(); Entidades.Medicamento m = new Entidades.Medicamento(); m = (Entidades.Medicamento)cboLisElim.SelectedItem; //Cargar datos txt m = mn.obtenerMedicamento(m.idMedicamento); txtNomCoElim.Text = m.nombreComercial; txtLabElim.Text = m.laboratorio; txtEANElim.Text = m.ean13; txtFFElim.Text = m.formaFarmaceutica; txtStockElim.Text = m.stock.ToString(); } catch (Exception) { } }
private void btnGuardarPres_Click(object sender, RoutedEventArgs e) { try { Entidades.PrescripcionPersonalizada pr = new Entidades.PrescripcionPersonalizada(); Negocio.PrescripcionN pn = new Negocio.PrescripcionN(); Entidades.Prescripcion p = new Entidades.Prescripcion(); Negocio.MedicamentoN mn = new Negocio.MedicamentoN(); Entidades.Medicamento m = new Entidades.Medicamento(); pr = (Entidades.PrescripcionPersonalizada)dgPrescrip.SelectedItem; p = pn.obtenerPres(pr.idPrescripcion); p.estado = valorDgCboEstado; if (p != null && p.estado != "Emitido" && valorDgCboEstado.Trim() != string.Empty) { if (p.estado == "Completado") { m = mn.obtenerMedicamento(p.idMedicamento); if (m.stock >= p.cantidad) { if (pn.modificarPres(p)) { decimal cantidad = m.stock - pr.cantidad; m.stock = cantidad; if (mn.modificarMedicamento(m) == true) { MessageBox.Show("Exito al Completar"); valorDgCboEstado = ""; llenarGrid(); } } } else { MessageBox.Show("No se puede completar porque el medicamento no tiene la cantidad requerida, recomiende reservar"); valorDgCboEstado = ""; llenarGrid(); } } else if (p.estado == "Reservar") { if (pn.modificarPres(p)) { MessageBox.Show("Exito al reservar"); valorDgCboEstado = ""; llenarGrid(); } } else if (p.estado == "Cancelar") { if (pn.modificarPres(p)) { MessageBox.Show("Exito al Cancelar"); valorDgCboEstado = ""; llenarGrid(); } } } } catch (Exception) { } }