Пример #1
0
 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);
 }
Пример #2
0
 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);
 }
Пример #3
0
        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);
        }
Пример #4
0
        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
            {
            }
        }