public bool insertarLote(Lote_Medicamentos p) { try { Model model = new Model(); model.Entidades.Lote_Medicamentos.Add(p); model.Entidades.SaveChanges(); model.cerrarConexion(); } catch (Exception ex) { return(false); } return(true); }
public bool eliminarLote(int id) { try { Model model = new Model(); Lote_Medicamentos original = model.Entidades.Lote_Medicamentos.Find(id); model.Entidades.Lote_Medicamentos.Remove(original); model.Entidades.SaveChanges(); model.cerrarConexion(); } catch (Exception ex) { return(false); } return(true); }
public bool modificarLote(int id, Lote_Medicamentos lm) { try { Model model = new Model(); Lote_Medicamentos original = model.Entidades.Lote_Medicamentos.Find(id); original.codigoLote = lm.codigoLote; original.fecha_vencimiento = lm.fecha_vencimiento; model.Entidades.SaveChanges(); model.cerrarConexion(); } catch (Exception ex) { return(false); } return(true); }
private void btnGuardar_Click(object sender, EventArgs e) { if (validar()) { if (operacion == 0) { Model model = new Model(); Lote_Medicamentos lm = new Lote_Medicamentos(); lm.codigoLote = txtCodigo.Text; lm.fecha_vencimiento = dtfecha.Value.Date; if (controladorlotes.insertarLote(lm)) { MessageBox.Show("Correcto"); crearLista(); deshabilitar(); } } else { Model model = new Model(); Lote_Medicamentos lm = new Lote_Medicamentos(); lm.codigoLote = txtCodigo.Text; lm.fecha_vencimiento = dtfecha.Value.Date; if (controladorlotes.modificarLote(id, lm)) { MessageBox.Show("Actualizacion correcta"); } crearLista(); deshabilitar(); } } else { } }